From 147008d3bc6fb68c759c84dc5b414ec0f959ce41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Bobot?= <francois.bobot@cea.fr> Date: Sat, 26 Sep 2020 11:48:07 +0200 Subject: [PATCH] Use load_script facilities of dune - remove the last use of ocamlfind --- Makefile | 2 +- share/Makefile.common | 4 +- .../plugin_entry_points/dynamic.ml | 41 +++++-------------- 3 files changed, 14 insertions(+), 33 deletions(-) diff --git a/Makefile b/Makefile index 310df6be813..7ad4104645e 100644 --- a/Makefile +++ b/Makefile @@ -87,7 +87,7 @@ MAJOR_VERSION=$(shell $(SED) -E 's/^([0-9]+)\..*/\1/' VERSION) MINOR_VERSION=$(shell $(SED) -E 's/^[0-9]+\.([0-9]+).*/\1/' VERSION) VERSION_CODENAME=$(shell $(CAT) VERSION_CODENAME) -config.sed: VERSION share/Makefile.config Makefile configure.in +config.sed: VERSION share/Makefile.config share/Makefile.common Makefile configure.in @echo "# generated file" > $@ @echo "s|@VERSION_CODENAME@|$(VERSION_CODENAME)|" >> $@ @echo "s|@VERSION@|$(VERSION)|" >> $@ diff --git a/share/Makefile.common b/share/Makefile.common index affc7756361..d62520b26de 100644 --- a/share/Makefile.common +++ b/share/Makefile.common @@ -87,7 +87,7 @@ ifeq ($(DEVELOPMENT),yes) # - 67 (unused module parameter in functor signature): naming all parameters # in functor signatures is a common practice that seems harmless. Warning 60 # ensures that named functor parameters are indeed used in the implementation. -WARNINGS ?= -w +a-4-6-9-40-41-42-44-45-48-50-67 +WARNINGS ?= +a-4-6-9-40-41-42-44-45-48-50-67 # - 3 (deprecated feature) cannot always be avoided for OCaml stdlib when # supporting several OCaml versions @@ -105,7 +105,7 @@ WARN_ERROR ?= -warn-error +a-3-4-32-33-34-35-36-37-38-39-58 else -WARNINGS ?= -w -a +WARNINGS ?= -a endif #DEVELOPMENT diff --git a/src/kernel_services/plugin_entry_points/dynamic.ml b/src/kernel_services/plugin_entry_points/dynamic.ml index 24b0a8fd546..f80c8c44d9f 100644 --- a/src/kernel_services/plugin_entry_points/dynamic.ml +++ b/src/kernel_services/plugin_entry_points/dynamic.ml @@ -131,36 +131,17 @@ let load_packages pkgs = let load_script base = Klog.feedback ~dkey "compiling script '%s.ml'" base ; - let cmd = Buffer.create 80 in - let fmt = Format.formatter_of_buffer cmd in - begin - if Dynlink.is_native then - Format.fprintf fmt "ocamlfind ocamlopt -shared -o %S.cmxs" base - else - Format.fprintf fmt "ocamlfind ocamlc -c"; - Format.fprintf fmt " -package frama-c.kernel -open Frama_c_kernel -g %s -warn-error a" Fc_config.ocaml_wflags ; - if Fc_config.is_gui then Format.pp_print_string fmt " -package lablgtk2" ; - Format.fprintf fmt " %s.ml" base ; - Format.pp_print_flush fmt () ; - let cmd = Buffer.contents cmd in - Klog.feedback ~dkey "running '%s'" cmd ; - begin - let res = Sys.command cmd in - if res <> 0 - then Klog.error "compilation of '%s.ml' failed" base - else - let pkg = Filename.basename base in - if Dynlink.is_native then - dynlib_module pkg (base ^ ".cmxs") - else - dynlib_module pkg (base ^ ".cmo") ; - end ; - let erase = Printf.sprintf "rm -f %s.cm* %s.o" base base in - Klog.feedback ~dkey "running '%s'" erase ; - let st = Sys.command erase in - if st <> 0 then - Klog.warning "Error when cleaning '%s.[o|cm*]' files" base ; - end + let result, stdout, stderr = + Dune_site_plugins.V1.load_script + ~open_:["Frama_c_kernel"] + ~warnings:Fc_config.ocaml_wflags + (base^".ml") + in + List.iter (Format.printf "%s") stdout; + List.iter (Format.eprintf "%s") stderr; + match result with + | `Ok -> () + | `Compilation_failed -> Klog.error "compilation of '%s.ml' failed" base (* -------------------------------------------------------------------------- *) (* --- Command-Line Entry Points --- *) -- GitLab