Menu

[r1093]: / trunk / build  Maximize  Restore  History

Download this file

206 lines (183 with data), 5.9 kB

#!/usr/bin/env bash
# 
#      Copyright Texas Instruments 2003.  All Rights Reserved.
#  
#  This program is free software; you can redistribute it and/or
#  modify it under the terms of the GNU Lesser General Public
#  License as published by the Free Software Foundation; either
#  version 2 of the License, or (at your option) any later version.
#  
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#  Lesser General Public License for more details.
#  
#  You should have received a copy of the GNU Lesser General Public
#  License along with this library; if not, write to the Free Software
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#  
#  $ProjectHeader: OSCRIPT 0.155 Fri, 20 Dec 2002 18:34:22 -0800 rclark $
#


cd `dirname $0`;    # do everything relative to the directory this build file is in



default_targets="oscript chimera ode oscom osxmlrpc osregexp osbsf";
default_ant_targets="compile docs jar";
targets="";
ant_args="";
ant_targets="";
mode="build";
overwrite="false";
nodeps="false";
signed="false";


# 
# Print usage msg
# 
usage() {
  echo -n "$0 [-v] [--help] [--release [--signed] | [--no-deps | --no-docs | --no-test | -compile | -docs | -jar | -test]*] [";
  first="true";
  for file in `ls */build.properties`; do
    if [ $first = "false" ]; then
      echo -n " | ";
    else
      first="false";
    fi;
    echo -n `dirname $file`;
  done
  echo "]";
  echo "   --help      print this usage message";
  echo "   --release   use 'svn export' to export a src tree from version control";
  echo "               system, build, and generate release files";
  echo "   --signed    when combined with --release, also build signed binaries";
  echo "   --no-deps   do not also build dependent trees";
  echo "   --no-docs   do not build javadocs";
  echo "   --no-test   do not run unit test";
  echo "   -compile    run 'compile' build target";
  echo "   -docs       run 'docs' build target";
  echo "   -jar        run 'jar' build target";
  echo "   -test       run 'test' build target";
  echo "   -clean      delete intermediate files";
  echo "   -distclean  clean up all generated files";
}

# 
# Wrapper for invoking ant
# 
runant() {
  ant_targets=$*;
  for target in $targets; do
    cmd="ant $ant_args $props -Dtarget=$target -Dproject.version.name=$project_short_version_name -Dproject.version.number=$project_version_number -Dcopy.overwrite=$overwrite $ant_targets"
    echo "$cmd";
    $cmd;
    if [ $? != "0" ]; then
      echo "doh!";
      exit -1;
    fi
  done
}


# 
# Parse Command Line args:
#
for arg in $*; do
  if [ "x$arg" = "x-v" ]; then
    ant_args="$ant_args $arg";
  elif [ "x$arg" = "x--help" ]; then
    usage;
    exit 0;
  elif [ "x$arg" = "x--no-deps" ]; then
    nodeps="true";
  elif [ "x$arg" = "x--no-test" ]; then
    props="$props -Dnotest=true";
  elif [ "x$arg" = "x--no-docs" ]; then
    props="$props -Dnodocs=true";
  elif [ "x$arg" = "x--release" ]; then
    mode="release";
  elif [ "x$arg" = "x--signed" ]; then
    signed="true";
  elif [ "$arg" != "${arg#-}" ]; then
    ant_targets="$ant_targets ${arg#-}";
  else
    targets="$targets $arg";
  fi
done

if [ "x$ant_targets" = "x" ]; then
  ant_targets=$default_ant_targets;
fi

if [ "x$targets" = "x" ]; then
  targets=$default_targets;
fi


# 
# Add any dependent targets:
#
if [ $nodeps = "false" ]; then
  while [ "true" ]; do
    added_target="false";
    
    for target in $targets; do
      classpathlist=`grep "classpathlist=" $target/build.properties`;
      classpathlist=${classpathlist#classpathlist=};
      for dependent in `echo $classpathlist | awk '{ n=split( $1, a, "," ); for(i=1;i<=n;i++) printf("%s\n",a[i]); }'`; do
        new_target=${dependent#dest/};
        if [ "x$new_target" != "x$dependent" ]; then
          new_target=${new_target%.jar};
          in_current_targets="false";
          for t in $targets; do
            if [ $t = $new_target ]; then
              in_current_targets="true";
              break;
            fi;
          done;
          if [ $in_current_targets = "false" ]; then
            targets="$new_target $targets";
            added_target="true";
          fi;
        fi;
      done;
    done;
    
    if [ $added_target = "false" ]; then
      break;
    fi;
  done;
fi

echo "targets: $targets";


. project-version.sh;

# 
# Invoke ant for each target (.jar) to build
# 
if [ $mode = "build" ]; then
  runant $ant_targets;
elif [ $mode = "release" ]; then
  tmppath="/tmp/$USER-$RANDOM/$project_version_name";
  curpath=`pwd`;
  mkdir -p `dirname $tmppath`;
  svn export . $tmppath;
  cd $tmppath;
  runant $default_ant_targets tarballclean;
  rm -rf dest/classes;
  ./macosx/make-app;
  mv unknown.dmg $curpath/$project_version_name.dmg;
  ./win/make-app;
  if [ -r unknown.zip ]; then
    mv unknown.zip $curpath/$project_version_name.zip;
  fi;
  keystore="$HOME/.keystore";
  if [ $signed = "true" ] && [ -r $keystore ]; then
    mkdir dest/signed;
    cp dest/*.jar dest/signed;
    for file in dest/*.dll; do
      jar cf dest/signed/`basename $file`.jar $file;
    done
    echo -n "enter password for existing keystore: $keystore";
    read passwd rest;
    for file in dest/signed/*.jar; do
      echo "sign: $file";
      jarsigner -keystore $keystore -storepass $passwd $file oscript
    done
    cd ..;
    rm -f $curpath/$project_version_name-signed.tar.gz;
    tar -cf - $project_version_name/dest/signed | gzip -c > $curpath/$project_version_name-signed.tar.gz;
    rm -rf $project_version_name/dest/signed;
  else
    cd ..;
  fi;
  rm -f $curpath/$project_version_name.tar.gz;
  tar cf - $project_version_name | gzip -c > $curpath/$project_version_name.tar.gz;
  cd $curpath;
  rm -rf `dirname $tmppath`;
fi


Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.