Add a new simpler CI build script

This script is used on Inria's infrastructure

Once all Inria CI jobs will use this script, it will replace the
legacy one.
master
Sébastien Hinderer 2017-04-03 11:05:06 +02:00
parent d96f81177d
commit d847e077e8
1 changed files with 193 additions and 0 deletions

193
tools/ci-build-new Executable file
View File

@ -0,0 +1,193 @@
#!/bin/sh
#**************************************************************************
#* *
#* OCaml *
#* *
#* Damien Doligez, projet Gallium, INRIA Rocquencourt *
#* *
#* Copyright 2014 Institut National de Recherche en Informatique et *
#* en Automatique. *
#* *
#* All rights reserved. This file is distributed under the terms of *
#* the GNU Lesser General Public License version 2.1, with the *
#* special exception on linking described in the file LICENSE. *
#* *
#**************************************************************************
# This script is run on our continuous-integration servers to recompile
# from scratch and run the test suite.
# To know the slave's architecture, this script looks at the OCAML_ARCH
# environment variable. For a given node NODe, this variable can be defined
# in Jenkins at the following address:
# https://ci.inria.fr/ocaml/computer/NODE/configure
# arguments:
# -conf configure-option add configure-option to configure cmd line
# -patch1 file-name apply patch with -p1
# -no-native do not build "opt" and "opt.opt"
error () {
echo "$1" >&2
exit 3
}
arch_error() {
configure_url = "https://ci.inria.fr/ocaml/computer/${NODE_NAME}/configure"
msg = "Unknown architecture. Make sure the OCAML_ARCH environemnt"
msg = "$msg variable has been defined."
msg = "$msg\nSee ${configure_url}"
error "$msg"
}
# Kill a task on Windows
# Errors are ignored
kill_task()
{
task=$1
taskkill /f /im ${task} || true
}
quote1 () {
printf "'%s'" "`printf %s "$1" | sed -e "s/'/'\\\\\\\\''/g"`";
}
#########################################################################
# be verbose
set -x
#########################################################################
# Save the current directory (on cygwin, /etc/profile changes it)
jenkinsdir="$(pwd)"
echo jenkinsdir=${jenkinsdir}
#########################################################################
# If we are called from a Windows batch script, we must set up the
# Unix environment variables (e.g. PATH).
case "${OCAML_ARCH}" in
bsd|macos|linux) ;;
cygwin|mingw|mingw64)
. /etc/profile
. "$HOME/.profile"
;;
msvc)
. /etc/profile
. "$HOME/.profile"
. "$HOME/.msenv32"
;;
msvc64)
. /etc/profile
. "$HOME/.profile"
. "$HOME/.msenv64"
;;
*) arch_error;;
esac
#########################################################################
# be verbose and stop on error
set -ex
#########################################################################
# set up variables
# default values
make=make
instdir="$HOME/ocaml-tmp-install"
configure=unix
cleanup=false
case "${OCAML_ARCH}" in
bsd) make=gmake ;;
macos) ;;
linux) ;;
cygwin)
cleanup=true;;
mingw)
instdir=/cygdrive/c/ocamlmgw
configure=nt
cleanup=true
;;
mingw64)
instdir=/cygdrive/c/ocamlmgw64
configure=nt
cleanup=true
;;
msvc)
instdir=/cygdrive/c/ocamlms
configure=nt
cleanup=true
;;
msvc64)
instdir=/cygdrive/c/ocamlms64
configure=nt
cleanup=true
;;
*) arch_error;;
esac
#########################################################################
# On Windows, cleanup processes that may remain from previous run
if $cleanup; then
tasks="tee ocamlrun program"
for task in ${tasks}; do kill_task ${task}.exe; done
fi
#########################################################################
# Go to the right directory
pwd
cd "$jenkinsdir"
#########################################################################
# parse optional command-line arguments (has to be done after the "cd")
confoptions="${OCAML_CONFIGURE_OPTIONS}"
make_native=true
while [ $# -gt 0 ]; do
case $1 in
-conf) confoptions="$confoptions `quote1 "$2"`"; shift;;
-patch1) patch -f -p1 <"$2"; shift;;
-no-native) make_native=false;;
*) error "unknown option $1";;
esac
shift
done
#########################################################################
# Do the work
# Tell gcc to use only ASCII in its diagnostic outputs.
export LC_ALL=C
$make distclean || :
# `make distclean` does not clean the files from previous versions that
# are not produced by the current version, so use `git clean` in addition.
git clean -f -d -x
case $configure in
unix) eval "./configure -prefix '$instdir' $confoptions";;
nt)
cp config/m-nt.h config/m.h
cp config/s-nt.h config/s.h
cp config/Makefile.${OCAML_ARCH} config/Makefile
;;
*) error "internal error";;
esac
$make coldstart
$make core
$make coreboot
$make world
if $make_native; then
$make opt
$make opt.opt
fi
$make install
rm -rf "$instdir"
cd testsuite
$make all