Protocol_compiler: Add an option to avoid compiling

This commit is contained in:
Pierre Chambart 2018-07-19 17:46:18 +02:00 committed by Grégoire Henry
parent 077b3cd964
commit 5a60dff917
3 changed files with 12 additions and 6 deletions

View File

@ -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/ 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 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) short_hash=$(echo $long_hash | head -c 8)
if [ -d "src/proto_${version}_${short_hash}" ] ; then if [ -d "src/proto_${version}_${short_hash}" ] ; then

View File

@ -22,7 +22,7 @@ genesis_tmpdir=`mktemp -d`
mkdir $genesis_tmpdir/src mkdir $genesis_tmpdir/src
cp src/proto_genesis/lib_protocol/src/*.ml src/proto_genesis/lib_protocol/src/*.mli $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 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" echo "Genesis's new hash: $new_hash_genesis"
if [ "$current_hash_genesis" != "$new_hash_genesis" ] if [ "$current_hash_genesis" != "$new_hash_genesis" ]
then then
@ -38,7 +38,7 @@ alpha_tmpdir=`mktemp -d`
mkdir $alpha_tmpdir/src mkdir $alpha_tmpdir/src
cp src/proto_alpha/lib_protocol/src/*.ml src/proto_alpha/lib_protocol/src/*.mli $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 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" echo "Alpha's new hash: $new_hash_alpha"
if [ "$current_hash_alpha" != "$new_hash_alpha" ] if [ "$current_hash_alpha" != "$new_hash_alpha" ]
then then

View File

@ -150,8 +150,10 @@ let main { compile_ml ; pack_objects ; link_shared } =
and static = ref false and static = ref false
and register = ref false and register = ref false
and build_dir = ref None 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 = [ let args_spec = [
"-hash-only", Arg.Set hash_only, " Don't compile" ;
"-static", Arg.Set static, " Only build the static library (no .cmxs)" ; "-static", Arg.Set static, " Only build the static library (no .cmxs)" ;
"-register", Arg.Set register, " Generete the `Registerer` module" ; "-register", Arg.Set register, " Generete the `Registerer` module" ;
"-bin-annot", Arg.Set Clflags.binary_annotations, " (see ocamlopt)" ; "-bin-annot", Arg.Set Clflags.binary_annotations, " (see ocamlopt)" ;
@ -182,6 +184,10 @@ let main { compile_ml ; pack_objects ; link_shared } =
| Error err -> | Error err ->
Format.kasprintf Pervasives.failwith Format.kasprintf Pervasives.failwith
"Failed to read TEZOS_PROTOCOL: %a" pp_print_error err in "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 build_dir) ;
Lwt_main.run (Lwt_utils_unix.create_dir ~perm:0o755 (Filename.dirname output)) ; Lwt_main.run (Lwt_utils_unix.create_dir ~perm:0o755 (Filename.dirname output)) ;
(* Generate the 'functor' *) (* Generate the 'functor' *)