shellfiles/build_stx_libjava.sh
author Claus Gittinger <cg@exept.de>
Thu, 28 Mar 2019 13:54:38 +0100
changeset 542 aa25a71be62a
parent 227 8f0a7e9bddfb
permissions -rw-r--r--
#DOCUMENTATION by cg
class: stx_goodies_builder_quickSelfTest
class definition

class: stx_goodies_builder_quickSelfTest class
added:18 methods
     1 #!/bin/bash
     2 
     3 # Simple Unix shell script to build STX:LIBJAVA using Jenkins CI
     4 # Actually, it is used on Windows (with UnxUtils) as well.
     5 
     6 PROJECT="STX_LIBJAVA"
     7 
     8 # Determine operating system, bit simple but works
     9 if [ "$OS" == "Windows_NT" ]; then
    10     WIN32=1
    11     UNIX=0
    12 else
    13     WIN32=0
    14     UNIX=1
    15 fi
    16 
    17 # Setup...
    18 if [ "$WIN32" == "1" ]; then
    19     # WINDOWS
    20     # MUST export this, otherwise libjpeg fails to build!!!"
    21     export BCB="C:\Borland\BCC55"
    22     # To make cvs/ssh happy
    23     export CVS_RSH=plink
    24     # Set home
    25     export HOME=$USERPROFILE
    26     # Defaults
    27     export CVSROOT=":pserver:jenkinsBuild:blablu@cvs.bh.exept.de:/cvs/stx"
    28     # Make using bmake here..."
    29     MAKE="cmd /C bmake.bat"
    30 else
    31     # LINUX
    32     # to get Mercurial
    33     export PATH=$PATH:/home/vrany/bin
    34     if [ $(uname -n) == 'exeptn' ]; then
    35     	# On exeptn, default Java is 1.4, sigh
    36     	export PATH=/usr/java/jdk1.7.0_13/bin:$PATH
    37     fi
    38 
    39     # Make using regular make here..."
    40     MAKE=make
    41     # Defaults
    42     export CVSROOT="/cvs/stx"
    43 fi
    44 
    45 
    46 
    47 # Sorry, it's lot easier for JV to have all the messages in EN :-)
    48 export LANG=en_GB.UTF-8
    49 
    50 
    51 # When run interactively, Jenkins env variables
    52 # may not be set...
    53 if [ -z "$WORKSPACE" ]; then
    54   WORKSPACE="$PWD"
    55     INTERACTIVE=1
    56 else
    57     INTERACTIVE=0
    58 fi
    59 
    60 if [ "$INTERACTIVE" == "0" ]; then
    61   if [ "$WIN32" == "1" ]; then
    62     WORKSPACE="$PWD"
    63   fi
    64 fi
    65 
    66 if [ -z "$BUILD_NUMBER" ]; then
    67     BUILD_NUMBER=$(date +%Y_%m_%d_interactive)
    68 fi
    69 
    70 #BUILD="$WORKSPACE/${PROJECT}_${BUILD_NUMBER}_linux_build"
    71 BUILD="build"
    72 
    73 
    74 echo "INFO: BUILD=\"$BUILD\""
    75 
    76 if [ -d "$BUILD" ]; then
    77   echo "WARN: Build directory already exists!"
    78 else
    79     mkdir -p "$BUILD"
    80 fi
    81 
    82 pushd "$BUILD"
    83 
    84 function checkout_hg {
    85 	local directory=$1
    86 	local repository=$2
    87 	local branch=$3
    88 
    89 	if [ -z "$branch" ]; then
    90 		branch=default
    91 	fi
    92 
    93     if [ -d "$directory/CVS" ]; then
    94       rm -rf "$directory"
    95     fi
    96 
    97     if [ ! -d "$directory" ]; then
    98       if ! hg clone "$repository" "$directory" -b "$branch";  then
    99         echo "ERROR: HG: Cannot clone $directory";
   100         exit;
   101       fi
   102     else
   103       if ! hg --cwd "$directory" pull;  then
   104         echo "ERROR: HG: Cannot pull $directory";
   105         exit;
   106       fi
   107       if ! hg --cwd "$directory" update;  then
   108         echo "ERROR: HG: Cannot update $directory";
   109         exit;
   110       fi
   111     fi
   112 
   113 }
   114 
   115 
   116 if [ -z "$SKIP_CHECKOUT" ]; then
   117 
   118     echo "INFO: Checking out source code"
   119 
   120     # Checkout stx
   121     if [ ! -d stx ]; then
   122       if ! cvs co stx; then
   123         echo "ERROR: CVS: Cannot checkout stx";
   124         exit;
   125       fi
   126     else
   127       (cd stx && cvs update -d)
   128     fi
   129 
   130     checkout_hg stx/stc /home/vrany/repositories/hg/stx.stc jv
   131     checkout_hg stx/librun /home/vrany/repositories/hg/stx.librun jv
   132 
   133     # stx:libjava repo is huge, so first update from local cache
   134     # and then fetch updates from BitBucket.  
   135     if [ $(uname -n) == 'exeptn' ]; then
   136        checkout_hg stx/libjava /home/vrany/repositories/hg/stx.libjava development
   137     fi
   138     checkout_hg stx/libjava https://janvrany@bitbucket.org/janvrany/stx-libjava development
   139 
   140 else
   141     echo "INFO: Checkout skipped (SKIP_CHECKOUT=$SKIP_CHECKOUT)"
   142 fi
   143 
   144 # Compile
   145 
   146 if [ -z "$SKIP_COMPILE" ]; then
   147 
   148     if [ "$UNIX" == "1" ]; then
   149 	if [ ! -f stx/configurations/myConf ]; then
   150 	    (cd stx && ./CONFIG)
   151 	fi
   152 	# Hack...
   153         if [ ! -f stx/stc/makefile ]; then
   154             (cd stx/stc && ../rules/stmkmf)
   155         fi
   156         if [ ! -f stx/librun/makefile ]; then
   157             (cd stx/librun && ../rules/stmkmf)
   158         fi
   159     fi
   160 
   161     echo "INFO: Compiling"
   162     TARGETS1="stx stx/libjava stx/goodies/petitparser stx/libjava/tools stx/libjava/experiments stx/projects/smalltalk stx/librun"
   163     for target in $TARGETS1; do
   164       if ! (cd "$target" && $MAKE); then
   165         echo "ERROR:  cannot $MAKE in $target"
   166         exit 3
   167       fi
   168     done
   169 
   170 else
   171     echo "INFO: Compilation skipped (SKIP_COMPILE=$SKIP_COMPILE)"
   172 fi
   173 
   174 popd
   175 
   176 echo "INFO: $PROJECT SUCCESSFULLY BUILT"