From fbb5b4fe6bbfab98fb79b7f1335c70575c1fcb1e Mon Sep 17 00:00:00 2001
From: Allan Blanchard <allan.blanchard@cea.fr>
Date: Wed, 1 Jun 2022 16:25:51 +0200
Subject: [PATCH] [ci] build distrib in release mode

---
 nix/frama-c.nix           | 14 ++++++++------
 nix/pkgs.nix              |  4 ++--
 nix/src-distrib-tests.nix |  4 ++--
 3 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/nix/frama-c.nix b/nix/frama-c.nix
index eae9bed8d6f..4703f6b739a 100644
--- a/nix/frama-c.nix
+++ b/nix/frama-c.nix
@@ -37,7 +37,7 @@
 , dos2unix
 , doxygen
 , python3
-, do_autoconf ? true
+, release_mode ? false
 }:
 
 # We do not use buildDunePackage because Frama-C still uses a Makefile to build
@@ -51,9 +51,9 @@ stdenvNoCC.mkDerivation rec {
   slang = lib.strings.removeSuffix "\n" (builtins.readFile ../VERSION_CODENAME);
 
   src =
-    if do_autoconf
-    then gitignoreSource ./..
-    else ./.. ;
+    if release_mode
+    then ./..
+    else gitignoreSource ./.. ;
 
   nativeBuildInputs = [
     autoconf
@@ -93,16 +93,18 @@ stdenvNoCC.mkDerivation rec {
 
   outputs = [ "out" "build_dir" ];
 
-  preConfigure = (if do_autoconf then "autoconf \n" else "") + ''
+  preConfigure = (if release_mode then "" else "autoconf \n") + ''
     patchShebangs src/plugins/value/gen-api.sh
     chmod +x src/plugins/value/gen-api.sh
   '';
 
   # Do not use default parallel building, but allow 2 cores for Frama-C build
   enableParallelBuilding = false;
+  dune_opt = if release_mode then "--release" else "" ;
+
   buildPhase = ''
     make config.sed
-    dune build -j2 --display short @install
+    dune build -j2 --display short $release_mode @install
     make ptests/ptests.exe
     make ptests/wtests.exe
   '';
diff --git a/nix/pkgs.nix b/nix/pkgs.nix
index 8efe95c14a8..e2204458103 100644
--- a/nix/pkgs.nix
+++ b/nix/pkgs.nix
@@ -48,8 +48,8 @@ let
       git = pkgs.git ;
     };
     src-distrib-tests = oself.callPackage ./src-distrib-tests.nix {
-      frama-c-no-configure = oself.frama-c.override {
-        do_autoconf = false ;
+      frama-c-release = oself.frama-c.override {
+        release_mode = true ;
       } ;
     };
   };
diff --git a/nix/src-distrib-tests.nix b/nix/src-distrib-tests.nix
index e365ec96434..c1a52472721 100644
--- a/nix/src-distrib-tests.nix
+++ b/nix/src-distrib-tests.nix
@@ -1,7 +1,7 @@
-{ mk_tests, frama-c-no-configure } :
+{ mk_tests, frama-c-release } :
 
 let mk_tests_distrib = mk_tests.override {
-  frama-c = frama-c-no-configure ;
+  frama-c = frama-c-release ;
 }; in
 mk_tests_distrib {
   tests-name = "src-distrib-tests";
-- 
GitLab