From 32750ac6c9d1fb1a698976108e23556fc94aee9f Mon Sep 17 00:00:00 2001
From: Bouillaguet Quentin <quentin.bouillaguet@cea.fr>
Date: Fri, 1 Dec 2017 18:44:16 +0100
Subject: [PATCH] [Dynamic] No longer warn-errors on script loading

Use of Frama-C's Makefile WARNINGS variable through Config and hardcoded
disable of warning-errors.

Changes on Kernel:
[Config]: - 'ocaml_wflags' exposes warning flags used by ocamlc and
ocamlopt when compiling Frama-C.
---
 Makefile.generating                                | 1 +
 src/kernel_internals/runtime/config.ml.in          | 1 +
 src/kernel_internals/runtime/config.mli            | 4 ++++
 src/kernel_services/plugin_entry_points/dynamic.ml | 2 +-
 4 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/Makefile.generating b/Makefile.generating
index 576ed8f1f3e..47aab1767ad 100644
--- a/Makefile.generating
+++ b/Makefile.generating
@@ -48,6 +48,7 @@ $(CONFIG_FILE): $(CONFIG_FILE).in VERSION share/Makefile.config Makefile.generat
           -e "s|@CURR_DATE@|$$(LC_ALL=C date)|" \
 	  -e "s|@OCAMLC@|$(OCAMLC)|" \
           -e "s|@OCAMLOPT@|$(OCAMLOPT)|" \
+	  -e "s|@WARNINGS@|$(WARNINGS)|" \
           -e "s|@FRAMAC_DATADIR@|$(FRAMAC_DATADIR)|" \
 	  -e "s|@FRAMAC_LIBDIR@|$(FRAMAC_LIBDIR)|" \
 	  -e "s|@FRAMAC_ROOT_SRCDIR@|$(FRAMAC_ROOT_SRCDIR)|" \
diff --git a/src/kernel_internals/runtime/config.ml.in b/src/kernel_internals/runtime/config.ml.in
index 8e48cc5c2d5..865bb2a1a3c 100644
--- a/src/kernel_internals/runtime/config.ml.in
+++ b/src/kernel_internals/runtime/config.ml.in
@@ -28,6 +28,7 @@ let is_gui = ref false
 
 let ocamlc = "@OCAMLC@"
 let ocamlopt = "@OCAMLOPT@"
+let ocaml_wflags = "@WARNINGS@"
 
 let datadir = try Sys.getenv "FRAMAC_SHARE" with Not_found -> "@FRAMAC_DATADIR@"
 let () = Filepath.add_symbolic_dir "FRAMAC_SHARE" datadir
diff --git a/src/kernel_internals/runtime/config.mli b/src/kernel_internals/runtime/config.mli
index fdde4685021..167eaa3ab62 100644
--- a/src/kernel_internals/runtime/config.mli
+++ b/src/kernel_internals/runtime/config.mli
@@ -38,6 +38,10 @@ val ocamlopt: string
   (** Name of the native compiler.
       @since Boron-20100401 *)
 
+val ocaml_wflags: string
+  (** Warning flags used when compiling Frama-C.
+      @since Sulfur-20171101-dev *)
+
 val datadir: string
   (** Directory where architecture independent files are. *)
 
diff --git a/src/kernel_services/plugin_entry_points/dynamic.ml b/src/kernel_services/plugin_entry_points/dynamic.ml
index dcdfee6f7b0..066bd480591 100644
--- a/src/kernel_services/plugin_entry_points/dynamic.ml
+++ b/src/kernel_services/plugin_entry_points/dynamic.ml
@@ -232,7 +232,7 @@ let load_script base =
       Format.fprintf fmt "%s -shared -o %s.cmxs" Config.ocamlopt base
     else
       Format.fprintf fmt "%s -c" Config.ocamlc ;
-    Format.fprintf fmt " -w Ly -warn-error A -I %s" Config.libdir ;
+    Format.fprintf fmt " %s -warn-error a -I %s" Config.ocaml_wflags Config.libdir ;
     if !Config.is_gui then Format.pp_print_string fmt " -package lablgtk2" ;
     List.iter (fun p -> Format.fprintf fmt " -I %s" p) !load_path ;
     Format.fprintf fmt " %s.ml" base ;
-- 
GitLab