| 1 |
#!/bin/sh |
| 2 |
#************************************************************************** |
| 3 |
#* * |
| 4 |
#* OCaml * |
| 5 |
#* * |
| 6 |
#* Damien Doligez, projet Gallium, INRIA Rocquencourt * |
| 7 |
#* * |
| 8 |
#* Copyright 2014 Institut National de Recherche en Informatique et * |
| 9 |
#* en Automatique. * |
| 10 |
#* * |
| 11 |
#* All rights reserved. This file is distributed under the terms of * |
| 12 |
#* the GNU Lesser General Public License version 2.1, with the * |
| 13 |
#* special exception on linking described in the file LICENSE. * |
| 14 |
#* * |
| 15 |
#************************************************************************** |
| 16 |
|
| 17 |
# This script is run on Inria's continuous-integration servers to make sure |
| 18 |
# it is possible to bootstrap the compiler. |
| 19 |
|
| 20 |
# To know the slave's architecture, this script looks at the OCAML_ARCH |
| 21 |
# environment variable. For a given node NODE, this variable can be defined |
| 22 |
# in Jenkins at the following address: |
| 23 |
# https://ci.inria.fr/ocaml/computer/NODE/configure |
| 24 |
|
| 25 |
# Other environments variables that are honored: |
| 26 |
# OCAML_CONFIGURE_OPTIONS additional options for configure |
| 27 |
# OCAML_JOBS number of jobs to run in parallel (make -j) |
| 28 |
|
| 29 |
# Command-line arguments: |
| 30 |
# -conf configure-option add configure-option to configure cmd line |
| 31 |
# -patch1 file-name apply patch with -p1 |
| 32 |
# -no-native do not build "opt" and "opt.opt" |
| 33 |
# -jNN pass "-jNN" option to make for parallel builds |
| 34 |
|
| 35 |
error () { |
| 36 |
echo "$1" >&2 |
| 37 |
exit 3 |
| 38 |
} |
| 39 |
|
| 40 |
arch_error() { |
| 41 |
configure_url="https://ci.inria.fr/ocaml/computer/${NODE_NAME}/configure" |
| 42 |
msg="Unknown architecture. Make sure the OCAML_ARCH environment" |
| 43 |
msg="$msg variable has been defined." |
| 44 |
msg="$msg\nSee ${configure_url}" |
| 45 |
error "$msg" |
| 46 |
} |
| 47 |
|
| 48 |
# Kill a task on Windows |
| 49 |
# Errors are ignored |
| 50 |
kill_task() |
| 51 |
{ |
| 52 |
task=$1 |
| 53 |
taskkill /f /im ${task} /t || true |
| 54 |
} |
| 55 |
|
| 56 |
quote1 () { |
| 57 |
printf "'%s'" "`printf %s "$1" | sed -e "s/'/'\\\\\\\\''/g"`"; |
| 58 |
} |
| 59 |
|
| 60 |
remove_primitive() |
| 61 |
{ |
| 62 |
echo Removing the \'sinh\' primitive |
| 63 |
patch -p1 < tools/ci/inria/bootstrap/remove-sinh-primitive.patch |
| 64 |
} |
| 65 |
|
| 66 |
######################################################################### |
| 67 |
# be verbose |
| 68 |
set -x |
| 69 |
|
| 70 |
######################################################################### |
| 71 |
# Save the current directory (on cygwin, /etc/profile changes it) |
| 72 |
jenkinsdir="$(pwd)" |
| 73 |
echo jenkinsdir=${jenkinsdir} |
| 74 |
|
| 75 |
######################################################################### |
| 76 |
# If we are called from a Windows batch script, we must set up the |
| 77 |
# Unix environment variables (e.g. PATH). |
| 78 |
|
| 79 |
case "${OCAML_ARCH}" in |
| 80 |
bsd|macos|linux|solaris) ;; |
| 81 |
cygwin|cygwin64|mingw|mingw64) |
| 82 |
. /etc/profile |
| 83 |
. "$HOME/.profile" |
| 84 |
;; |
| 85 |
msvc) |
| 86 |
. /etc/profile |
| 87 |
. "$HOME/.profile" |
| 88 |
. "$HOME/.msenv32" |
| 89 |
;; |
| 90 |
msvc64) |
| 91 |
. /etc/profile |
| 92 |
. "$HOME/.profile" |
| 93 |
. "$HOME/.msenv64" |
| 94 |
;; |
| 95 |
*) arch_error;; |
| 96 |
esac |
| 97 |
|
| 98 |
######################################################################### |
| 99 |
|
| 100 |
# be considerate towards other potential users of the test machine |
| 101 |
case "${OCAML_ARCH}" in |
| 102 |
bsd|macos|linux) renice 10 $$ ;; |
| 103 |
esac |
| 104 |
|
| 105 |
# be verbose and stop on error |
| 106 |
set -ex |
| 107 |
|
| 108 |
######################################################################### |
| 109 |
# set up variables |
| 110 |
|
| 111 |
# default values |
| 112 |
make=make |
| 113 |
instdir="$HOME/ocaml-tmp-install" |
| 114 |
confoptions="--enable-ocamltest --enable-dependency-generation \ |
| 115 |
${OCAML_CONFIGURE_OPTIONS}" |
| 116 |
make_native=true |
| 117 |
cleanup=false |
| 118 |
check_make_alldepend=false |
| 119 |
dorebase=false |
| 120 |
jobs='' |
| 121 |
build='' |
| 122 |
host='' |
| 123 |
|
| 124 |
case "${OCAML_ARCH}" in |
| 125 |
bsd|solaris) make=gmake ;; |
| 126 |
macos) ;; |
| 127 |
linux) |
| 128 |
check_make_alldepend=true |
| 129 |
;; |
| 130 |
cygwin) |
| 131 |
cleanup=true |
| 132 |
check_make_alldepend=true |
| 133 |
;; |
| 134 |
cygwin64) |
| 135 |
cleanup=true |
| 136 |
check_make_alldepend=true |
| 137 |
dorebase=true |
| 138 |
;; |
| 139 |
mingw) |
| 140 |
build='--build=i686-pc-cygwin' |
| 141 |
host='--host=i686-w64-mingw32' |
| 142 |
instdir='C:/ocamlmgw' |
| 143 |
cleanup=true |
| 144 |
check_make_alldepend=true |
| 145 |
;; |
| 146 |
mingw64) |
| 147 |
build='--build=x86_64-pc-cygwin' |
| 148 |
host='--host=x86_64-w64-mingw32' |
| 149 |
instdir='C:/ocamlmgw64' |
| 150 |
cleanup=true |
| 151 |
check_make_alldepend=true |
| 152 |
;; |
| 153 |
msvc) |
| 154 |
build='--build=i686-pc-cygwin' |
| 155 |
host='--host=i686-pc-windows' |
| 156 |
instdir='C:/ocamlms' |
| 157 |
configure=nt |
| 158 |
cleanup=true |
| 159 |
;; |
| 160 |
msvc64) |
| 161 |
build='--build=x86_64-pc-cygwin' |
| 162 |
host='--host=x86_64-pc-windows' |
| 163 |
instdir='C:/ocamlms64' |
| 164 |
configure=nt |
| 165 |
cleanup=true |
| 166 |
;; |
| 167 |
*) arch_error;; |
| 168 |
esac |
| 169 |
|
| 170 |
# Make sure two builds won't use the same install directory |
| 171 |
instdir="$instdir-$$" |
| 172 |
|
| 173 |
case "${OCAML_JOBS}" in |
| 174 |
[1-9]|[1-9][0-9]) jobs="-j${OCAML_JOBS}" ;; |
| 175 |
esac |
| 176 |
|
| 177 |
######################################################################### |
| 178 |
# On Windows, cleanup processes that may remain from previous run |
| 179 |
|
| 180 |
if $cleanup; then |
| 181 |
tasks="tee ocamlrun program ocamltest ocamltest.opt" |
| 182 |
for task in ${tasks}; do kill_task ${task}.exe; done |
| 183 |
fi |
| 184 |
|
| 185 |
######################################################################### |
| 186 |
# Go to the right directory |
| 187 |
|
| 188 |
pwd |
| 189 |
cd "$jenkinsdir" |
| 190 |
|
| 191 |
######################################################################### |
| 192 |
# parse optional command-line arguments (has to be done after the "cd") |
| 193 |
|
| 194 |
while [ $# -gt 0 ]; do |
| 195 |
case $1 in |
| 196 |
-conf) confoptions="$confoptions `quote1 "$2"`"; shift;; |
| 197 |
-patch1) patch -f -p1 <"$2"; shift;; |
| 198 |
-no-native) make_native=false;; |
| 199 |
-j[1-9]|-j[1-9][0-9]) jobs="$1";; |
| 200 |
*) error "unknown option $1";; |
| 201 |
esac |
| 202 |
shift |
| 203 |
done |
| 204 |
|
| 205 |
######################################################################### |
| 206 |
# Do the work |
| 207 |
|
| 208 |
# Tell gcc to use only ASCII in its diagnostic outputs. |
| 209 |
export LC_ALL=C |
| 210 |
|
| 211 |
$make -s distclean || : |
| 212 |
|
| 213 |
# `make distclean` does not clean the files from previous versions that |
| 214 |
# are not produced by the current version, so use `git clean` in addition. |
| 215 |
git clean -f -d -x |
| 216 |
|
| 217 |
# Also make a hard reset |
| 218 |
git reset --hard HEAD |
| 219 |
|
| 220 |
if $flambda; then |
| 221 |
confoptions="$confoptions -enable-flambda --enable-flambda-invariants" |
| 222 |
fi |
| 223 |
eval "./configure $build $host --prefix='$instdir' $confoptions" |
| 224 |
|
| 225 |
$make world |
| 226 |
|
| 227 |
tools/bump-magic-numbers ZZZ |
| 228 |
|
| 229 |
remove_primitive |
| 230 |
|
| 231 |
$make coreall |
| 232 |
$make bootstrap |