From 0f0ec6ab7a726640624990c22682078d7fc5511a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Sun, 11 Feb 2018 19:17:39 +0100 Subject: [PATCH] Jbuilder: fix dependencies in the `tezos-compiler` hack --- src/lib_protocol_compiler/compiler.ml | 15 ++++++++++++++- .../jbuild_protocol_template | 4 ++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/lib_protocol_compiler/compiler.ml b/src/lib_protocol_compiler/compiler.ml index baf76e776..352860f88 100644 --- a/src/lib_protocol_compiler/compiler.ml +++ b/src/lib_protocol_compiler/compiler.ml @@ -152,12 +152,14 @@ let main { compile_ml ; pack_objects ; link_shared } = let anonymous = ref [] and static = ref false and register = ref false - and build_dir = ref None in + and build_dir = ref None + and output_dep = ref false in let args_spec = [ "-static", Arg.Set static, " Only build the static library (no .cmxs)"; "-register", Arg.Set register, " Generete the `Registerer` module"; "-bin-annot", Arg.Set Clflags.binary_annotations, " (see ocamlopt)" ; "-g", Arg.Set Clflags.debug, " (see ocamlopt)" ; + "-output-dep", Arg.Set output_dep, " ..." ; "-build-dir", Arg.String (fun s -> build_dir := Some s), "use custom build directory and preserve build artifacts" ] in @@ -239,4 +241,15 @@ let main { compile_ml ; pack_objects ; link_shared } = if not !static then begin Clflags.link_everything := true ; link_shared (output ^ ".cmxs") [resulting_object] ; + end ; + + if !output_dep then begin + let dsrc = Digest.file functor_file in + let dimpl = Digest.file resulting_object in + let dintf = Digest.file (Filename.chop_extension resulting_object ^ ".cmi") in + Format.printf "module Toto = struct include %s end ;; \n" for_pack ; + Format.printf "let src_digest = %S ;;\n" (Digest.to_hex dsrc) ; + Format.printf "let impl_digest = %S ;;\n" (Digest.to_hex dimpl) ; + Format.printf "let intf_digest = %S ;;\n" (Digest.to_hex dintf) end + diff --git a/src/lib_protocol_compiler/jbuild_protocol_template b/src/lib_protocol_compiler/jbuild_protocol_template index 1f603b93e..9d3cdfd99 100644 --- a/src/lib_protocol_compiler/jbuild_protocol_template +++ b/src/lib_protocol_compiler/jbuild_protocol_template @@ -60,7 +60,7 @@ let () = Format.kasprintf Jbuild_plugin.V1.send {| src/TEZOS_PROTOCOL)) (action (with-stdout-to ${path-no-dep:tezos_protocol_%s_dummy_byte.ml} (chdir ${ROOT} - (run ${bin:tezos-protocol-compiler-byte} -static ${path-no-dep:tezos_protocol_%s} ${path-no-dep:src})))))) + (run ${bin:tezos-protocol-compiler-byte} -static -output-dep ${path-no-dep:tezos_protocol_%s} ${path-no-dep:src})))))) (rule ((targets (tezos_protocol_%s.o @@ -72,7 +72,7 @@ let () = Format.kasprintf Jbuild_plugin.V1.send {| src/TEZOS_PROTOCOL)) (action (with-stdout-to ${path-no-dep:tezos_protocol_%s_dummy.ml} (chdir ${ROOT} - (run ${bin:tezos-protocol-compiler} -static ${path-no-dep:tezos_protocol_%s} ${path-no-dep:src})))))) + (run ${bin:tezos-protocol-compiler} -static -output-dep ${path-no-dep:tezos_protocol_%s} ${path-no-dep:src})))))) (library ((name tezos_protocol_%s)