shellfiles/build_mercurial.sh
author Claus Gittinger <cg@exept.de>
Thu, 28 Mar 2019 13:54:38 +0100
changeset 542 aa25a71be62a
parent 159 40cdb9aa191d
permissions -rw-r--r--
#DOCUMENTATION by cg class: stx_goodies_builder_quickSelfTest class definition class: stx_goodies_builder_quickSelfTest class added:18 methods
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
159
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
     1
#!/bin/bash 
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
     2
# Simple Unix shell script to build Mercurial using Jenkins CI
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
     3
# Designed to run under Cygwin as well. 
158
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     4
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     5
PROJECT="Mercurial Support"
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     6
159
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
     7
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
     8
# ### START OF common.sh.in ##########################################
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
     9
#
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
    10
# Common set of function to build a project. 
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
    11
# 
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
    12
 
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
    13
158
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    14
# Determine operating system, bit simple but works
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    15
if [ "$OS" == "Windows_NT" ]; then
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    16
    WIN32=1
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    17
    UNIX=0
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    18
else
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    19
    WIN32=0
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    20
    UNIX=1
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    21
fi
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    22
159
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
    23
# =====================================================
158
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    24
# Utility functions
159
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
    25
# =====================================================
158
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    26
159
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
    27
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
    28
# Simple logging functions
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
    29
function info {
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
    30
    echo "[INF] $1"
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
    31
    if [ ! -z "$2" ]; then
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
    32
        echo "      $2"
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
    33
    fi
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
    34
}
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
    35
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
    36
function error {
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
    37
    echo     "[ERR] $1"
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
    38
    if [ ! -z "$2" ]; then
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
    39
        echo "      $2"
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
    40
    fi
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
    41
    exit 1
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
    42
}
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
    43
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
    44
# Run make in current directory. Caller should cd to target 
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
    45
# directory before calling this method.
158
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    46
function mk {
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    47
    if [ "$WIN32" == "1" ]; then
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    48
    	cmd /C bmake.bat $1 $2
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    49
    else
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    50
    	if [ ! -f makefile ]; then
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    51
    	   if [ -f Makefile ]; then
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    52
    	   	make mf || error "Failed to generate makefile (make mf)"
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    53
    	   else
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    54
    	   	make -f Makefile.init mf || error "Failed to generate makefile (make -f Makefile.init mf)"
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    55
    	   fi
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    56
    	fi
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    57
    	make $1 $2 || error "Make failed"
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    58
    fi
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    59
}
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    60
159
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
    61
# Run tests for package specified in first argument. 
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
    62
function sunit {    
158
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    63
    pushd stx/goodies/builder/reports
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    64
    info "Running tests for $1"
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    65
    if [ "$WIN32" == "1" ]; then
159
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
    66
        cmd /C report-runner.bat -D ../../../.. -r Builder::TestReport -p "$1" || error "Failed to run reports"
158
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    67
    else
159
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
    68
        (echo "" | ./report-runner.sh -D ../../../.. -r Builder::TestReport -p "$1") || error "Failed to run reports"
158
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    69
    fi
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    70
    popd
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    71
}
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    72
159
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
    73
# Main function. Performs complete build or given task
158
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    74
function main {
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    75
    pushd "$BUILD"
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    76
    if [ -z "$1" ]; then
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    77
    	info "Checking out..."
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    78
    	checkout
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    79
    	info "Compiling..."
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    80
    	compile
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    81
    	info "Running tests..."
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    82
    	runtests
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    83
    else
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    84
        case "$1" in
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    85
            checkout)
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    86
    	        info "Checking out..."
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    87
    	        checkout;;
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    88
            compile)
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    89
                info "Compiling..."
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    90
    	        compile;;
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    91
            tests)
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    92
    	        info "Running tests..."
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    93
    	        runtests;;
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    94
            test)
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    95
    	        info "Running tests..."
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    96
    	        runtests;;
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    97
            *)
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    98
                error "Invalid command ($1)"
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    99
        esac
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   100
    fi
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   101
    popd
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   102
    exit 0
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   103
}
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   104
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   105
# Setup...
159
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
   106
158
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   107
if [ "$WIN32" == "1" ]; then
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   108
    # WINDOWS
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   109
    # MUST export this, otherwise libjpeg fails to build!!!"
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   110
    if [ -z "$BCB"]; then
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   111
        export BCB="C:\Borland\BCC55"
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   112
    fi
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   113
    # To make cvs/ssh happy
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   114
    if [ -z "$CVS_RSH" ]; then
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   115
        export CVS_RSH=plink
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   116
    fi
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   117
    # Set home
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   118
    export HOME=$USERPROFILE
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   119
else
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   120
    # LINUX
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   121
    # to get Mercurial on build slave
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   122
    export PATH=$PATH:/home/vrany/bin
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   123
fi
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   124
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   125
if [ -z "$CVSROOT" ]; then
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   126
    error "CVSROOT not set!"
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   127
fi
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   128
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   129
# Sorry, it's lot easier for all to have all the messages in EN :-)
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   130
export LANG=en_GB.UTF-8
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   131
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   132
# When run interactively, Jenkins env variables
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   133
# may not be set...
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   134
if [ -z "$WORKSPACE" ]; then
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   135
  WORKSPACE="$PWD"
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   136
    INTERACTIVE=1
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   137
else
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   138
    INTERACTIVE=0
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   139
fi
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   140
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   141
if [ "$INTERACTIVE" == "0" ]; then
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   142
  if [ "$WIN32" == "1" ]; then
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   143
    WORKSPACE="$PWD"
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   144
  fi
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   145
fi
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   146
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   147
if [ -z "$BUILD_NUMBER" ]; then
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   148
    BUILD_NUMBER=$(date +%Y_%m_%d_interactive)
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   149
fi
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   150
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   151
BUILD="."
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   152
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   153
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   154
echo "INFO: BUILD=\"$BUILD\""
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   155
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   156
if [ -d "$BUILD" ]; then
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   157
    if [ "$BUILD" != "." ]; then
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   158
        info "Build directory already exists!"
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   159
    fi
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   160
else
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   161
    mkdir -p "$BUILD"
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   162
fi
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   163
159
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
   164
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
   165
# ===================================================================
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
   166
# Actual build functions. 
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
   167
# ===================================================================
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
   168
#
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
   169
# User scripts should override following functions to define a build
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
   170
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
   171
function checkout {
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
   172
    error "You have to override function 'checkout'"
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
   173
}
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
   174
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
   175
function compile {
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
   176
    error "You have to override function 'compile'"
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
   177
}
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
   178
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
   179
function runtests {
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
   180
    info "No tests specified" "To do so, override function runtests"
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
   181
}
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
   182
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
   183
# ### END OF common.sh.in ############################################
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
   184
158
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   185
# Checkout
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   186
function checkout {
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   187
    # Checkout stx
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   188
    if [ ! -d stx ]; then
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   189
      if ! cvs co stx; then
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   190
        error "CVS: Cannot checkout stx";
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   191
      fi
159
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
   192
    #else
40cdb9aa191d Add support for generating build scripts using M4 preprocessor
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 158
diff changeset
   193
    #  (cd stx && cvs update -d)
158
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   194
    fi
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   195
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   196
    # Checkout stx:libscm
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   197
    repo="https://bitbucket.org/janvrany/stx-libscm"
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   198
    if [ ! -d stx/libscm ]; then
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   199
        hg clone "$repo" stx/libscm || error "HG: cannot clone stx:libscm"
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   200
    else
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   201
        hg --cwd stx/libscm pull "$repo" || error "HG: cannot pull stx:libscm"
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   202
        hg --cwd stx/libscm update || error "HG: cannot update stx:libscm"
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   203
    fi
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   204
}
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   205
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   206
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   207
# Compile
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   208
function compile {
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   209
    TARGETS1="stx stx/libscm/common stx/libscm/mercurial stx/librun"
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   210
    for target in $TARGETS1; do
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   211
      if ! (cd "$target" && mk); then
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   212
        echo "ERROR:  cannot $MAKE in $target"
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   213
        exit 3
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   214
      fi
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   215
    done
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   216
}
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   217
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   218
function runtests {
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   219
    sunit "stx:libscm/mercurial"
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   220
}
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   221
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   222
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   223
# Now, call main
93cbdd865850 Initial version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   224
main $1 $2 $3