From 5a60dff9179b556fee3a58a84b6c793f45dd484d Mon Sep 17 00:00:00 2001 From: Pierre Chambart Date: Thu, 19 Jul 2018 17:46:18 +0200 Subject: [PATCH] Protocol_compiler: Add an option to avoid compiling --- scripts/archive_protocol.sh | 2 +- scripts/update_hashes.sh | 4 ++-- src/lib_protocol_compiler/compiler.ml | 12 +++++++++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/scripts/archive_protocol.sh b/scripts/archive_protocol.sh index 5fcc61d62..14c7d6639 100755 --- a/scripts/archive_protocol.sh +++ b/scripts/archive_protocol.sh @@ -36,7 +36,7 @@ echo "Computing the protocol hash..." cp src/proto_${name}/lib_protocol/src/*.ml src/proto_${name}/lib_protocol/src/*.mli "$alpha_tmpdir"/src/ grep -v '"hash"' < src/proto_${name}/lib_protocol/src/TEZOS_PROTOCOL > "$alpha_tmpdir"/src/TEZOS_PROTOCOL -long_hash=`./tezos-protocol-compiler $alpha_tmpdir/tmp $alpha_tmpdir/src | cut -d' ' -f2` +long_hash=`./tezos-protocol-compiler -hash-only $alpha_tmpdir/tmp $alpha_tmpdir/src` short_hash=$(echo $long_hash | head -c 8) if [ -d "src/proto_${version}_${short_hash}" ] ; then diff --git a/scripts/update_hashes.sh b/scripts/update_hashes.sh index bb4a732da..42f2f7da9 100755 --- a/scripts/update_hashes.sh +++ b/scripts/update_hashes.sh @@ -22,7 +22,7 @@ genesis_tmpdir=`mktemp -d` mkdir $genesis_tmpdir/src cp src/proto_genesis/lib_protocol/src/*.ml src/proto_genesis/lib_protocol/src/*.mli $genesis_tmpdir/src/ grep -v '"hash"' < src/proto_genesis/lib_protocol/src/TEZOS_PROTOCOL > $genesis_tmpdir/src/TEZOS_PROTOCOL -new_hash_genesis=`./tezos-protocol-compiler $genesis_tmpdir/tmp $genesis_tmpdir/src | cut -d' ' -f2` +new_hash_genesis=`./tezos-protocol-compiler -hash-only $genesis_tmpdir/tmp $genesis_tmpdir/src` echo "Genesis's new hash: $new_hash_genesis" if [ "$current_hash_genesis" != "$new_hash_genesis" ] then @@ -38,7 +38,7 @@ alpha_tmpdir=`mktemp -d` mkdir $alpha_tmpdir/src cp src/proto_alpha/lib_protocol/src/*.ml src/proto_alpha/lib_protocol/src/*.mli $alpha_tmpdir/src/ grep -v '"hash"' < src/proto_alpha/lib_protocol/src/TEZOS_PROTOCOL > $alpha_tmpdir/src/TEZOS_PROTOCOL -new_hash_alpha=`./tezos-protocol-compiler $alpha_tmpdir/tmp $alpha_tmpdir/src | cut -d' ' -f2` +new_hash_alpha=`./tezos-protocol-compiler -hash-only $alpha_tmpdir/tmp $alpha_tmpdir/src` echo "Alpha's new hash: $new_hash_alpha" if [ "$current_hash_alpha" != "$new_hash_alpha" ] then diff --git a/src/lib_protocol_compiler/compiler.ml b/src/lib_protocol_compiler/compiler.ml index cc847745c..c98c7a90a 100644 --- a/src/lib_protocol_compiler/compiler.ml +++ b/src/lib_protocol_compiler/compiler.ml @@ -150,10 +150,12 @@ let main { compile_ml ; pack_objects ; link_shared } = and static = ref false and register = ref false and build_dir = ref None - and output_dep = ref false in + and output_dep = ref false + and hash_only = 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"; + "-hash-only", Arg.Set hash_only, " Don't compile" ; + "-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, " ..." ; @@ -182,6 +184,10 @@ let main { compile_ml ; pack_objects ; link_shared } = | Error err -> Format.kasprintf Pervasives.failwith "Failed to read TEZOS_PROTOCOL: %a" pp_print_error err in + if !hash_only then begin + Format.printf "%a@." Protocol_hash.pp hash ; + exit 0 + end ; Lwt_main.run (Lwt_utils_unix.create_dir ~perm:0o755 build_dir) ; Lwt_main.run (Lwt_utils_unix.create_dir ~perm:0o755 (Filename.dirname output)) ; (* Generate the 'functor' *)