#!/bin/sh
#**************************************************************************
#*                                                                        *
#*                                 OCaml                                  *
#*                                                                        *
#*            Sebastien Hinderer, projet Gallium, INRIA Paris             *
#*                                                                        *
#*   Copyright 2017 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.          *
#*                                                                        *
#**************************************************************************

# Commands to run for the 'other-configs' job on Inria's CI

mainjob=./tools/ci/inria/main

build() {
  name="$1"
  shift
  echo "==== $name ==== (`date`)"
  t=$(mktemp)
  if $mainjob -j8 $* >"$t" 2>&1
  then :
  else
    cat "$t"
    echo "==== Failure: $name"
    echo "==== Configuration: $*"
    exit 2
  fi
  rm -f "$t"
}

# The "MIN_BUILD" (formerly on Travis) builds with everything disabled (apart
# from ocamltest). Its goals:
#  - Ensure that the system builds correctly without native compilation
#  - Ensure ocamltest builds correctly without Unix
#  - Ensure the testsuite runs correctly with everything switched off
build "minimal build" \
        -conf --disable-native-compiler \
        -conf --disable-native-toplevel \
        -conf --disable-shared \
        -conf --disable-debug-runtime \
        -conf --disable-instrumented-runtime \
        -conf --disable-systhreads \
        -conf --disable-str-lib \
        -conf --disable-unix-lib \
        -conf --disable-ocamldoc \
        -conf --disable-dependency-generation \
        -no-native

build "no flat float arrays, clang, C23" \
        -conf --disable-flat-float-array \
        -conf CC=clang-18 \
        -conf CFLAGS=-std=gnu2x

build "flambda" \
        -conf --enable-flambda

build "frame pointers, reserved header bits" \
        -conf --enable-frame-pointers \
        -conf --enable-reserved-header-bits=27

build "bootstrap, pic" \
        -with-bootstrap -conf --with-pic

OCAMLRUNPARAM="c=1" \
build "cleanup at exit, clang" \
        -conf CC=clang-18

echo "==== done (`date`)"
