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