1#!bin/bash
2
3# --- Script used in continuous integration to configure, build and test siconos software ---
4#
5# Usage :
6# > export CI_PROJECT_DIR=<path-to-siconos-repository>
7# > export ctest_build_model=Experimental or Continuous or Nightly
8# > export cdash_submit=1 or 0
9# > export allow_parallel_build=1 or 0. Set to 1 to allow -jN, 0 to restrict to -j1.
10#
11# > sh ctest_siconos.sh <ctest_mode> user_option_filename
12#
13# - ctest_mode : choose among 'Configure', 'Build', 'Test' or 'all'
14# - user_option_filename is optional. If not set, siconos build will use <siconos repository>/cmake/default_options.cmake file.
15#
16# - Will execute :
17#    - ctest_configure (cmake) if ctest_mode=Configure
18#    - ctest_build (make) if ctest_mode=Build
19#    - ctest_test (test) if ctest_mode=Test
20#    - ctest... all steps if ctest_mode=all
21#  Results will be submitted to cdash if cdash_submit=1.
22#
23#
24#  Use absolute path or path relative to $CI_PROJECT_DIR/build
25#
26# The default installation path for siconos is /home/install-siconos.
27# Use -DSICONOS_INSTALL_DIR=<something else> as ctest option to change this location.
28
29: ${CI_PROJECT_DIR:?"Please set environment variable CI_PROJECT_DIR with 'siconos' repository (absolute) path."}
30: ${ctest_build_model:?"Please set Dashboard client mode. Choose among Experimental, Continuous or Nightly."}
31: ${cdash_submit:?"Please set environment variable cdash_submit to TRUE or FALSE. If true, ctests results will be submitted to cdash server."}
32: ${allow_parallel_build:?"Please set environment variable allow_parallel_build to TRUE or FALSE. If true, ctests will use paralle build option (-jN)".}
33
34ctest_mode=$1
35user_file=$2
36
37echo "${ctest_mode} and ${user_file}"
38if [ $1 = "Configure" ] || [ $1 = "all" ]
39then
40    rm -rf $CI_PROJECT_DIR/build
41    mkdir -p $CI_PROJECT_DIR/build
42    #python3 -m pip  install packaging
43fi
44
45# --- Run ctest for Siconos ---
46cd $CI_PROJECT_DIR/build
47
48ctest -S ${CI_PROJECT_DIR}/ci_gitlab/ctest_driver_install_siconos.cmake -Dmodel=$ctest_build_model -DUSER_FILE=$user_file -DALLOW_PARALLEL_BUILD=$allow_parallel_build -DCDASH_SUBMIT=$cdash_submit -V -DCTEST_MODE=${ctest_mode}
49