Jbuilder: Wrap the Tezos_protocol_compiler

This commit is contained in:
Grégoire Henry 2017-10-28 23:14:00 +02:00 committed by Benjamin Canou
parent 0a7f9a39a9
commit 05da5a73b8
8 changed files with 13 additions and 14 deletions

View File

@ -39,7 +39,7 @@ let commands () =
(fun () dirname cctxt -> (fun () dirname cctxt ->
Lwt.catch Lwt.catch
(fun () -> (fun () ->
let _hash, proto = Native.read_dir dirname in let _hash, proto = Tezos_protocol_compiler.Native.read_dir dirname in
Client_node_rpcs.inject_protocol cctxt.rpc_config proto >>= function Client_node_rpcs.inject_protocol cctxt.rpc_config proto >>= function
| Ok hash -> | Ok hash ->
cctxt.message "Injected protocol %a successfully" Protocol_hash.pp_short hash >>= fun () -> cctxt.message "Injected protocol %a successfully" Protocol_hash.pp_short hash >>= fun () ->

View File

@ -9,4 +9,4 @@
val camlinternalFormatBasics_cmi: string val camlinternalFormatBasics_cmi: string
val tezos_protocol_environment_sigs_v1_cmi: string val tezos_protocol_environment_sigs_v1_cmi: string
val registerer_cmi: string val tezos_protocol_compiler__Registerer_cmi: string

View File

@ -5,7 +5,7 @@
(action (action
(run ${bin:ocp-ocamlres} -format ocaml -o ${@} (run ${bin:ocp-ocamlres} -format ocaml -o ${@}
${lib:stdlib:camlinternalFormatBasics.cmi} ${lib:stdlib:camlinternalFormatBasics.cmi}
${path:registerer.cmi} ${path:tezos_protocol_compiler__Registerer.cmi}
${path:../environment/tezos_protocol_environment_sigs_v1.cmi})))) ${path:../environment/tezos_protocol_environment_sigs_v1.cmi}))))
(library (library
@ -19,7 +19,6 @@
ocplib-endian ocplib-endian
ocplib-ocamlres ocplib-ocamlres
unix)) unix))
(wrapped false)
(flags (:standard -w +27-30-40@8 (flags (:standard -w +27-30-40@8
-opaque -opaque
-open Error_monad -open Error_monad

View File

@ -115,7 +115,7 @@ let tezos_protocol_env =
let register_env = let register_env =
let open Embedded_cmis in let open Embedded_cmis in
[ [
"registerer", registerer_cmi ; "tezos_protocol_compiler__Registerer", tezos_protocol_compiler__Registerer_cmi ;
] ]
@ -319,7 +319,7 @@ let main () =
create_file register_file create_file register_file
(Printf.sprintf (Printf.sprintf
"module Name = struct let name = %S end\n\ "module Name = struct let name = %S end\n\
\ let () = Registerer.register Name.name (module %s.Make)" \ let () = Tezos_protocol_compiler__Registerer.register Name.name (module %s.Make)"
(Protocol_hash.to_b58check hash) (Protocol_hash.to_b58check hash)
functor_unit) ; functor_unit) ;
let register_object = compile_ml ~for_pack register_file in let register_object = compile_ml ~for_pack register_file in

View File

@ -9,7 +9,7 @@
let () = let () =
try try
Native.main (); Tezos_protocol_compiler.Native.main ();
Pervasives.exit 0 Pervasives.exit 0
with exn -> with exn ->
Format.eprintf "%a\n%!" Opterrors.report_error exn; Format.eprintf "%a\n%!" Opterrors.report_error exn;

View File

@ -586,7 +586,7 @@ module Registred_protocol = struct
end end
let build_v1 hash = let build_v1 hash =
let (module F) = Registerer.get_exn hash in let (module F) = Tezos_protocol_compiler.Registerer.get_exn hash in
let module Name = struct let module Name = struct
let name = Protocol_hash.to_b58check hash let name = Protocol_hash.to_b58check hash
end in end in
@ -605,7 +605,7 @@ module Registred_protocol = struct
VersionTable.create 20 VersionTable.create 20
let mem hash = let mem hash =
VersionTable.mem versions hash || Registerer.mem hash VersionTable.mem versions hash || Tezos_protocol_compiler.Registerer.mem hash
let get_exn hash = let get_exn hash =
try VersionTable.find versions hash try VersionTable.find versions hash

View File

@ -60,7 +60,7 @@ let create_files dir units =
let extract dir ?hash (p: Protocol.t) = let extract dir ?hash (p: Protocol.t) =
create_files dir p.components >>= fun _files -> create_files dir p.components >>= fun _files ->
Native.Meta.to_file dir Tezos_protocol_compiler.Native.Meta.to_file dir
?hash ?hash
~env_version:p.expected_env ~env_version:p.expected_env
(List.map (fun {Protocol.name} -> String.capitalize_ascii name) p.components) ; (List.map (fun {Protocol.name} -> String.capitalize_ascii name) p.components) ;
@ -78,7 +78,7 @@ let do_compile hash p =
Format.asprintf "protocol_%a.cmxs" Protocol_hash.pp hash Format.asprintf "protocol_%a.cmxs" Protocol_hash.pp hash
in in
create_files source_dir units >>= fun _files -> create_files source_dir units >>= fun _files ->
Native.Meta.to_file source_dir ~hash Tezos_protocol_compiler.Native.Meta.to_file source_dir ~hash
(List.map (fun {Protocol.name} -> String.capitalize_ascii name) units); (List.map (fun {Protocol.name} -> String.capitalize_ascii name) units);
let compiler_command = let compiler_command =
(Sys.executable_name, (Sys.executable_name,
@ -103,11 +103,11 @@ let do_compile hash p =
Lwt.return false Lwt.return false
let compile hash p = let compile hash p =
if Registerer.mem hash then if Tezos_protocol_compiler.Registerer.mem hash then
Lwt.return true Lwt.return true
else begin else begin
do_compile hash p >>= fun success -> do_compile hash p >>= fun success ->
let loaded = Registerer.mem hash in let loaded = Tezos_protocol_compiler.Registerer.mem hash in
if success && not loaded then if success && not loaded then
log_error "Internal error while compiling %a" Protocol_hash.pp hash; log_error "Internal error while compiling %a" Protocol_hash.pp hash;
Lwt.return loaded Lwt.return loaded

View File

@ -10,7 +10,7 @@
let () = let () =
if Filename.basename Sys.argv.(0) = Updater.compiler_name then begin if Filename.basename Sys.argv.(0) = Updater.compiler_name then begin
try try
Native.main (); Tezos_protocol_compiler.Native.main ();
Pervasives.exit 0 Pervasives.exit 0
with exn -> with exn ->
Format.eprintf "%a\n%!" Opterrors.report_error exn; Format.eprintf "%a\n%!" Opterrors.report_error exn;