Commit ef723f6d authored by Simon Braß's avatar Simon Braß
Browse files

Add ROOT and Delphes / Add CMAKE workflow

parent 4fbc8611
Pipeline #7973 failed with stage
in 4 minutes and 56 seconds
......@@ -28,9 +28,14 @@ bootstrap.ocaml:
BUILD_OPTION: "ocaml"
<<: *bootstrap
bootstrap.hepmc:
bootstrap.hepmc2:
variables:
BUILD_OPTION: "hepmc"
BUILD_OPTION: "hepmc2"
<<: *bootstrap
bootstrap.hepmc3:
variables:
BUILD_OPTION: "hepmc3"
<<: *bootstrap
bootstrap.lhapdf:
......@@ -48,6 +53,11 @@ bootstrap.openloops:
BUILD_OPTION: "openloops"
<<: *bootstrap
bootstrap.delphes:
variables:
BUILD_OPTION: "delphes"
<<: *bootstrap
bootstrap.pythia8:
variables:
BUILD_OPTION: "pythia8"
......@@ -62,7 +72,7 @@ bootstrap.rivet:
bootstrap.default:
variables:
BUILD_OPTION: ""
BUILD_OPTION: "whizard"
<<: *bootstrap
allow_failure: true
#!/usr/bin/env bash
## Author: Simon Braß <simon.brass@desy.de>
## Last modified: 2. Juni 2020
##
## CAUTION: We take no garantue for correct useage or indentation of this script.
## USE AT YOUR OWN RISK! → READ AND UNDERSTAND the following lines of bash code.
##
## Requirements: Bash (>5), Unix-System
## Unsupported: Mac OS - I do not care enough to provide such support.
##
## Description: Bundle all external dependencies of the Monte Carlo event generator WHIZARD.
## The bootstrap script downloads, builds and installs all external tools in a consistent way in one (discardable) user place.
## The script is not meant for global installation, i.e. directly in {/usr,/usr/local}, neither to be run as root or with superuser/sudo permissions.
## We try our best to veto those cases, but beware of the unconventional user.
##
## External tools:
## - Autotools
## - m4
## - Make
## - Autoconf
## - Automake
## - Libtool
## - OCaml
## - Root (as mandatory dependency of Delphes)
## - HepMC2
## - HepMC3
## - LHAPDF6
## - FastJet
## - Pythia8
## - Delphes
## - Rivet (convenience for the author of this script)
##
## We configure the external tools for *our* toolchain.
##
## TODO:
## - CMake
## - WHIZARD/make check
## - Compiler FLAGS (FC, CC, CXX) and CFLAGS, CXXFLAGS, FCFLAGS (at least)
test -z "${FORCE}" && FORCE=False
test -z "${BUILD}" && BUILD="$(pwd)"
test -z "${PREFIX}" && PREFIX="${HOME}/local"
LOG=${BUILD}/log
LOG="${BUILD}"/log
test -z "${NPROC}" && NPROC="$(expr `nproc` - 1)"
test -z "${NPROC}" && NPROC="$(($(nproc) - 1))"
test -n "${DEBUG}" && set -x
if test -z "${CMAKE_GENERATOR}"; then
command -v ninja 1>/dev/null 2>&1
if test $? -eq 0; then
CMAKE_GENERATOR="Ninja"
else
CMAKE_GENERATOR="Makefile"
fi
fi
# ROOT_DIR must point to a directory containing cmake/RootConfig.cmake
test -z "${ROOT_DIR}" && ROOT_DIR="${PREFIX}"
export PATH="${PREFIX}/bin:${PATH}"
export LD_LIBRARY_PATH="${PREFIX}/lib:${PREFIX}/OpenLoops/lib:$LD_LIBRARY_PATH"
......@@ -16,6 +64,9 @@ export LD_LIBRARY_PATH="${PREFIX}/lib:${PREFIX}/OpenLoops/lib:$LD_LIBRARY_PATH"
# The locations of the sofware packages
########################################################################
# 1. Verify packages (checksum, GPG signature,...)
# 2. Switch to secure HTTP
# Autotools
url_make="http://ftp.gnu.org/gnu/make/make-4.2.1.tar.gz"
url_m4="http://ftp.gnu.org/gnu/m4/m4-1.4.18.tar.gz"
......@@ -23,23 +74,30 @@ url_autoconf="http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz"
url_automake="http://ftp.gnu.org/gnu/automake/automake-1.16.1.tar.gz"
url_libtool="http://ftp.gnu.org/gnu/libtool/libtool-2.4.6.tar.gz"
# CMake
# url_cmake="https://github.com/Kitware/CMake/releases/download/v3.17.3/cmake-3.17.3.tar.gz"
# O'Caml
url_ocaml="http://caml.inria.fr/pub/distrib/ocaml-4.09/ocaml-4.09.0.tar.gz"
# External tool dependencies
url_root="https://github.com/root-project/root/archive/v6-23-01.tar.gz"
# Whizard External Dependencies
url_hepmc="https://hepmc.web.cern.ch/hepmc/releases/hepmc2.06.10.tgz"
dir_hepmc="HepMC-2.06.10" # The HepMC packages comes with an enstranged nomenclature.
url_hepmc3="https://hepmc.web.cern.ch/hepmc/releases/HepMC3-3.2.1.tar.gz"
url_lhapdf="https://lhapdf.hepforge.org/downloads/?f=LHAPDF-6.2.3.tar.gz"
url_fastjet="http://fastjet.fr/repo/fastjet-3.3.3.tar.gz"
url_fastjet="http://fastjet.fr/repo/fastjet-3.3.4.tar.gz"
url_openloops="https://openloops.hepforge.org/downloads?f=OpenLoops-2.1.1.tar.gz"
url_pythia8="http://home.thep.lu.se/~torbjorn/pythia8/pythia8244.tgz"
url_delphes="https://github.com/delphes/delphes/archive/3.4.2.tar.gz"
# WHIZARD
url_whizard_git="git@gitlab.tp.nt.uni-siegen.de:whizard/development.git"
url_whizard="http://www.hepforge.org/archive/whizard/whizard-2.6.4.tar.gz"
url_whizard="http://whizard.hepforge.org/whizard-2.8.2.tar.gz"
# Analysis Tools
url_rivet="https://gitlab.com/hepcedar/rivetbootstrap/raw/3.1.0/rivet-bootstrap"
url_rivet="https://gitlab.com/hepcedar/rivetbootstrap/raw/3.1.1/rivet-bootstrap"
########################################################################
......@@ -47,8 +105,13 @@ function fetch_pkg_filename () {
local url="${1}"
# --spider: test whether file exists (do not download)
# -S: print response header
# We expect an content-description with the field fielname (HepForge).
wget -S --spider "${url}" 2>&1 | grep -e 'filename' | cut -d'=' -f2
# We expect a content-disposition header with the field 'filename'.
filename="$(wget -S --spider ${url} 2>&1 | grep -e 'filename' | cut -d'=' -f2)"
if test -z "${filename}"; then
basename "${url}"
else
echo "${filename}"
fi
}
# The actual basename of package is quite cumbersome:
......@@ -59,11 +122,11 @@ function fetch_pkg_filename () {
function basename_pkg () {
local url="${1}"
local suffix="${2:-.tar.gz}"
# \todo{sbrass: Implement this.}
if ! grep -q "hepforge" <<< "${url}"; then
basename "${url}" "${suffix}"
# We except Hepforge and Github URLs where we can spider the header with a corresponding filename field.
if grep -q "hepforge" <<< "${url}" || grep -q "github" <<< "${url}"; then
fetch_pkg_filename "${url}" | xargs basename -s "${suffix}"
else
fetch_pkg_filename "${url}" | xargs basename -s .tar.gz
basename "${url}" "${suffix}"
fi
}
......@@ -81,6 +144,27 @@ function make_make_install () {
make install -s V=0
}
function cmake_make_install () {
local config="${1}"
local cmake_path="${2}"
# Do not place variable config in quotes as it needs expansion.
cmake ${config} -G "${CMAKE_GENERATOR}" "${cmake_path}" || return
case "${CMAKE_GENERATOR}" in
"Makefile")
make -j"${NPROC}" -s V=0 &&
make install -s V=0
;;
"Ninja")
ninja -j"${NPROC}" &&
ninja -j"${NPROC}" install
;;
*)
echo "Unknown CMAKE generator type: ${CMAKE_GENERATOR} [Ninja, Makefile]."
exit 1
;;
esac
}
# $1 : Download-URL
# $2 : Configure options
build_generic () {
......@@ -88,9 +172,22 @@ build_generic () {
local config="${2:-}"
local name="$(basename_pkg ${url} .tar.gz)"
test -d "${name}" || download_untar_pkg "${url}"
cd "${name}" && \
pushd "${name}" && \
make_make_install "${config}" && \
cd "${BUILD}"
popd
}
# $1 : Download-URL
# $2 : Configure options
build_cmake_generic () {
local url="${1}"
local config="${2:-}"
local name="$(basename_pkg ${url} .tar.gz)"
test -d "${name}" || download_untar_pkg "${url}"
mkdir -p "${name}-build" &&
pushd "${name}-build" && \
cmake_make_install "${config}" "../${name}" && \
popd
}
build_hepmc () {
......@@ -99,25 +196,23 @@ build_hepmc () {
local name="${dir_hepmc}"
test -d "${name}" || download_untar_pkg "${url}"
test ! -d "${name}-build" || rm -rf "${name}-build"
mkdir -p "${name}-build" && \
cd "${name}-build" && \
mkdir -p "${name}-build" || return
pushd "${name}-build" && \
cmake ${config} "../${name}" && \
make && \
# \todo{sbrass: The tests are not working.}
# make test && \
make install && \
cd "${BUILD}"
popd
}
build_ocaml () {
local url="${1}"
local name="$(basename ${url} .tar.gz)"
test -d "${name}" || download_untar_pkg "${url}"
cd "${name}" && \
pushd "${name}" && \
./configure -prefix ${PREFIX} && \
make world.opt && \
make install && \
cd "${BUILD}"
popd
}
build_openloops () {
......@@ -125,13 +220,13 @@ build_openloops () {
local name="$(basename_pkg ${url} .tar.gz)"
local dirname="OpenLoops"
test -d "${PREFIX}" || mkdir -p "${PREFIX}"
cd ${PREFIX} && \
pushd "${PREFIX}" && \
test -d "${dirname}" || (download_untar_pkg "${url}" && mv "${name}" "${dirname}") && \
cd "${dirname}" && \
cat openloops.cfg.tmpl | sed 's/^#compile_extra.*/compile_extra = 1/' > openloops.cfg && \
./scons && \
./openloops libinstall -j${NPROC} ppzj ppzjj ppll eett eehtt tbw eevvjj && \
cd "${BUILD}"
./openloops libinstall -j"${NPROC}" ppzj ppzjj ppllj eett eehtt tbw eevvjj && \
popd
}
build_pythia8 () {
......@@ -139,9 +234,9 @@ build_pythia8 () {
local config="${2:-}"
name="$(basename ${url} .tgz)"
test -d "${name}" || download_untar_pkg "${url}"
cd "${name}" && \
pushd "${name}" && \
make_make_install "${config}" && \
cd "${BUILD}"
popd
}
build_rivet () {
......@@ -154,22 +249,36 @@ build_rivet () {
(wget --no-check-certificate --no-verbose "${url}" -O "${name}" && \
chmod u+x "${name}" && \
mkdir -p "${dirname}")
cd "${dirname}" && \
pushd "${dirname}" && \
# Wrap rivet-bootstrap and ENV variables into an eval statement.
eval "${config} ../rivet-bootstrap" && \
mv "${PREFIX}/rivetenv.csh" "${PREFIX}/bin" && \
mv "${PREFIX}/rivetenv.sh" "${PREFIX}/bin" && \
mv "${PREFIX}/yodaenv.sh" "${PREFIX}/bin" && \
cd "${BUILD}"
popd
}
# Download and build package with NAME from URL, log the progress to LOGDIR/NAME.log.
build_and_log () {
make_and_log () {
local name="${1}"
local url="${2}"
local config="${3:-}"
echo "Build ${name} ... " && \
build_generic "${url}" "${config}" 1>"${LOG}/${name}.log" 2>&1
if test $? -eq 0; then
echo "... finished."
else
echo "... failed. See ${LOG}/${name}.log."
exit 2
fi
}
cmake_and_log () {
local name="${1}"
local url="${2}"
local config="${3:-}"
echo "Build ${name} ... " && \
build_generic "${url}" "${config}" 2>&1 1>"${LOG}/${name}.log"
build_cmake_generic "${url}" "${config}" 1>"${LOG}/${name}.log" 2>&1
if test $? -eq 0; then
echo "... finished."
else
......@@ -183,7 +292,7 @@ build_and_log_hepmc () {
local url="${2}"
local config="${3:-}"
echo "Build ${name} ... " && \
build_hepmc "${url}" "${config}" 2>&1 1>"${LOG}/${name}.log"
build_hepmc "${url}" "${config}" 1>"${LOG}/${name}.log" 2>&1
if test $? -eq 0; then
echo "... finished."
else
......@@ -197,7 +306,7 @@ build_and_log_ocaml () {
local name="OCaml"
local config="${2:-}"
echo "Build ${name} ... " && \
build_ocaml "${url}" "${config}" 2>&1 1>"${LOG}/${name}.log"
build_ocaml "${url}" "${config}" 1>"${LOG}/${name}.log" 2>&1
if test $? -eq 0; then
echo "... finished."
else
......@@ -211,7 +320,7 @@ build_and_log_openloops () {
local name="OpenLoops"
local config="${2:-}"
echo "Build ${name} ... " && \
build_openloops "${url}" "${config}" 2>&1 1>"${LOG}/${name}.log"
build_openloops "${url}" "${config}" 1>"${LOG}/${name}.log" 2>&1
if test $? -eq 0; then
echo "... finished."
else
......@@ -225,7 +334,7 @@ build_and_log_pythia8 () {
local name="Pythia8"
local config="${2:-}"
echo "Build ${name} ... " && \
build_pythia8 "${url}" "${config}" 2>&1 1>"${LOG}/${name}.log"
build_pythia8 "${url}" "${config}" 1>"${LOG}/${name}.log" 2>&1
if test $? -eq 0; then
echo "... finished."
else
......@@ -239,7 +348,7 @@ build_and_log_rivet () {
local name="Rivet"
local config="${2:-}"
echo "Build ${name} ... " && \
build_rivet "${url}" "${config}" 2>&1 1>"${LOG}/${name}.log"
build_rivet "${url}" "${config}" 1>"${LOG}/${name}.log" 2>&1
if test $? -eq 0; then
echo "... finished."
else
......@@ -253,10 +362,10 @@ build_and_log_rivet () {
write_script () {
name=$1
date="`date`"
date="$(date)"
myself="$0"
rm -f "${name}" && touch "${name}"
cat <<EOF >$name
cat <<EOF > "${name}"
#!/bin/bash
########################################################################
# WHIZARD build environment
......@@ -296,7 +405,7 @@ function help() {
########################################################################
HEPMC_CONFIG=(
HEPMC2_CONFIG=(
-DCMAKE_INSTALL_PREFIX="${PREFIX}"
-DCMAKE_CXX_FLAGS="--std=c++11"
-Dmomentum:STRING=GEV
......@@ -318,19 +427,59 @@ FASTJET_CONFIG=(
PYTHIA8_CONFIG=(
--enable-64bit
--enable-shared
--with-fastjet3="${PREFIX}"
--with-lhapdf6="${PREFIX}"
--with-hepmc2="${PREFIX}"
)
# PYTHIA8_DATA:PATH=PYTHIA8_DATA-NOTFOUND
# PYTHIA8_INCLUDE_DIR:PATH=PYTHIA8_INCLUDE_DIR-NOTFOUND
# PYTHIA8_LIBRARY:FILEPATH=PYTHIA8_LIBRARY-NOTFOUND
# PYTHIA8_hepmcinterface_LIBRARY:FILEPATH=PYTHIA8_hepmcinterface_LIBRARY-NOTFOUND
# PYTHIA8_lhapdfdummy_LIBRARY:FILEPATH=PYTHIA8_lhapdfdummy_LIBRARY-NOTFOUND
## Build chain: FastJet, HepMC and LHAPDF6 → Pythia8 → ROOT → Delphes, HepMC3
# CMAKE_INSTALL_PREFIX PATH Path where ROOT will be installed if make install is invoked or the “INSTALL” target is built.
# CMAKE_C_FLAGS STRING Extra flags to use when compiling C source files.
# CMAKE_CXX_FLAGS STRING Extra flags to use when compiling C++ source files.
# BUILD_SHARED_LIBS BOOL Flag indicating if shared libraries will be built. Its default value is ON.
# CMAKE_Fortran_COMPILER PATH Full path to the Fortran compiler. Alternatively you can specify the environment variable FC before invoking cmake
# CMAKE_C_COMPILER PATH Full path to the C compiler. Alternatively you can specify the environment variable CC before invoking cmake
# CMAKE_CXX_COMPILER PATH Full path to the C++ compiler. Alternatively you can specify the environment variable CXX before invoking cmake
# Use: FC, CC, CXX for Fortran, C and C++ Compiler
## We handle ROOT "just" a dependency of Delphes and HepMC3.
## Therefore, we do not configure ROOT with any additional external tool, i.e. Pythia8.
## We will only include mandatory dependencies, when needed.
## Note: Per default, we do not include the ROOT build.
## However, the user must set an exisiting ROOT_DIR, where test only the existence of =thisroot.sh= (we are really lazy).
ROOT_CONFIG=(
-DCMAKE_INSTALL_PREFIX="${PREFIX}"
)
# HepMC3 include ROOTIO
# Delphes comes with its own FastJet build chain.
DELPHES_CONFIG=(
-DROOT_DIR="${ROOT_DIR}/cmake"
)
# https://hepmc.web.cern.ch/hepmc/building.html
# Note: We drop the Python support (as we do not want to mess with any (custom or system) Python setup).
HEPMC3_CONFIG=(
-DCMAKE_INSTALL_PREFIX="${PREFIX}"
-DHEPMC3_ENABLE_PYTHON="OFF"
-DHEPMC3_ENABLE_ROOTIO="OFF"
)
WHIZARD_CONFIG=(
--enable-lhapdf
--enable-lhapdf LHAPDF_DIR="${PREFIX}"
--enable-hepmc HEPMC_DIR="${PREFIX}"
--enable-pythia8 --with-pythia8="${PREFIX}"
--enable-fastjet --with-fastjet="${PREFIX}"
--enable-openloops --with-openloops="${PREFIX}/OpenLoops"
--disable-static
FCFLAGS="\"-O2 -g -fbacktrace\""
)
RIVET_CONFIG=(
......@@ -347,47 +496,57 @@ function main() {
mkdir -p "${BUILD}"
cd ${BUILD} || (echo "cd: failed to go to ${BUILD}" && exit 2)
if test $# -eq 0 || test "$@" == ""; then
local modes=(autotools hepmc lhapdf fastjet pythia8 openloops bin)
local modes=(autotools hepmc3 lhapdf fastjet pythia8 openloops whizard bin)
else
local modes=$@
local modes=${@}
fi
for mode in ${modes[@]}; do
for mode in "${modes[@]}"; do
case $mode in
autotools)
(command -v make >/dev/null 2>&1 && test "${FORCE}" != "True") || build_and_log "make" "${url_make}"
(command -v m4 >/dev/null 2>&1 && test "${FORCE}" != "True") || build_and_log "m4" "${url_m4}"
(command -v autoconf >/dev/null 2>&1 && test "${FORCE}" != "True") || build_and_log "autoconf" "${url_autoconf}"
(command -v automake >/dev/null 2>&1 && test "${FORCE}" != "True") || build_and_log "automake" "${url_automake}"
(command -v libtool >/dev/null 2>&1 && test "${FORCE}" != "True") || build_and_log "libtool" "${url_libtool}"
(command -v make >/dev/null 2>&1 && test "${FORCE}" != "True") || make_and_log "make" "${url_make}"
(command -v m4 >/dev/null 2>&1 && test "${FORCE}" != "True") || make_and_log "m4" "${url_m4}"
(command -v autoconf >/dev/null 2>&1 && test "${FORCE}" != "True") || make_and_log "autoconf" "${url_autoconf}"
(command -v automake >/dev/null 2>&1 && test "${FORCE}" != "True") || make_and_log "automake" "${url_automake}"
(command -v libtool >/dev/null 2>&1 && test "${FORCE}" != "True") || make_and_log "libtool" "${url_libtool}"
;;
ocaml)
build_and_log_ocaml "${url_ocaml}"
;;
hepmc)
CONFIG="${HEPMC_CONFIG[@]}"
build_and_log_hepmc "HepMC2" "${url_hepmc}" "${CONFIG}"
hepmc2)
build_and_log_hepmc "HepMC2" "${url_hepmc}" "${HEPMC2_CONFIG[*]}"
;;
lhapdf)
CONFIG="${LHAPDF_CONFIG[@]}"
build_and_log "LHAPDF6" "${url_lhapdf}" "${CONFIG}" && \
wget https://lhapdf.hepforge.org/downloads?f=pdfsets/6.2/CT10.tar.gz -O- | tar xz -C ${PREFIX}/share/LHAPDF && \
wget https://lhapdf.hepforge.org/downloads?f=pdfsets/6.2/cteq6l1.tar.gz -O- | tar xz -C ${PREFIX}/share/LHAPDF
make_and_log "LHAPDF6" "${url_lhapdf}" "${LHAPDF_CONFIG[*]}" && \
wget https://lhapdfsets.web.cern.ch/lhapdfsets/current/CT10.tar.gz -O- | tar xz -C ${PREFIX}/share/LHAPDF && \
wget https://lhapdfsets.web.cern.ch/lhapdfsets/current/cteq6l1.tar.gz -O- | tar xz -C ${PREFIX}/share/LHAPDF
# lhapdf install cteq6 cteq6l1 cteq66 CT10
;;
fastjet)
CONFIG="${FASTJET_CONFIG[@]}"
build_and_log "FastJet" "${url_fastjet}" "${CONFIG}"
make_and_log "FastJet" "${url_fastjet}" "${FASTJET_CONFIG[*]}"
;;
openloops)
build_and_log_openloops "${url_openloops}"
;;
root)
cmake_and_log "ROOT" "${url_root}" "${ROOT_CONFIG[*]}"
;;
hepmc3)
cmake_and_log "HepMC3" "${url_hepmc3}" "${HEPMC3_CONFIG[*]}"
;;
delphes)
if test -z "${ROOT_DIR}" && ! test -f "${ROOT_DIR}/cmake/ROOTConfig.cmake"; then
cmake_and_log "ROOT" "${url_root}" "${ROOT_CONFIG[*]}"
fi
cmake_and_log "Delphes" "${url_delphes}" "${DELPHES_CONFIG[*]}"
;;
pythia8)
CONFIG="${PYTHIA8_CONFIG[@]}"
build_and_log_pythia8 "${url_pythia8}" "${CONFIG}"
build_and_log_pythia8 "${url_pythia8}" "${PYTHIA8_CONFIG[*]}"
;;
rivet)
CONFIG="${RIVET_CONFIG[@]}"
build_and_log_rivet "${url_rivet}" "${CONFIG}"
build_and_log_rivet "${url_rivet}" "${RIVET_CONFIG[*]}"
;;
whizard)
make_and_log "WHIZARD" "${url_whizard}" "${WHIZARD_CONFIG[*]}"
;;
whizard-config)
echo "${WHIZARD_CONFIG[@]}"
......@@ -409,3 +568,4 @@ function main() {
}
main "$@"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment