From f3b7299662c10e0a4ed9f542de438289d39e74b9 Mon Sep 17 00:00:00 2001 From: Vincent Bernardoff Date: Mon, 24 Oct 2016 15:39:53 +0200 Subject: [PATCH] tezos-compiler: better arguments, add doc --- src/Makefile | 4 ++-- src/compiler/tezos_compiler.ml | 23 ++++++++++------------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/Makefile b/src/Makefile index 5425b524f..b9254edb7 100644 --- a/src/Makefile +++ b/src/Makefile @@ -315,7 +315,7 @@ proto/embedded_proto_%.cmxa: \ proto/%/TEZOS_PROTOCOL \ $$(wildcard proto/%/*.ml) \ $$(wildcard proto/%/*.mli) - @${TZCOMPILER} --build-dir proto/$*/_tzbuild $@ proto/$*/ + @${TZCOMPILER} -static -build-dir proto/$*/_tzbuild $@ proto/$*/ CLIENT_PROTO_INCLUDES := \ utils node/updater node/db node/net node/shell client \ @@ -328,7 +328,7 @@ proto/client_embedded_proto_%.cmxa: \ proto/%/TEZOS_PROTOCOL \ $$(wildcard proto/%/*.ml) \ $$(wildcard proto/%/*.mli) - @./${TZCOMPILER} --client --build-dir client/embedded/$*/_tzbuild \ + @./${TZCOMPILER} -static -client -build-dir client/embedded/$*/_tzbuild \ $(addprefix -I , ${CLIENT_PROTO_INCLUDES}) \ $@ proto/$* diff --git a/src/compiler/tezos_compiler.ml b/src/compiler/tezos_compiler.ml index 5ea8eb1ff..4b533f6e0 100644 --- a/src/compiler/tezos_compiler.ml +++ b/src/compiler/tezos_compiler.ml @@ -36,11 +36,6 @@ module Backend = struct end let backend = (module Backend : Backend_intf.S) -let usage () = - Printf.eprintf - "Usage: %s output.cmxs source_dir [--in-place]\n%!" - Sys.argv.(0) - let warnings = "+a-4-6-7-9-29-40..42-44-45-48" let warn_error = "-a" @@ -215,11 +210,11 @@ let pack_objects ?(ctxt = "") ?(keep_object = false) output objects = if not keep_object then at_exit (fun () -> unlink_object output) ; Warnings.check_fatal () -let link_shared output objects = +let link_shared ?(static=false) output objects = Printf.printf "LINK %s\n%!" (Filename.basename output); Compenv.(readenv Format.err_formatter Before_link); Compmisc.init_path true; - if Filename.check_suffix output ".cmxa" then + if static then Asmlibrarian.create_archive objects output else Asmlink.link_shared Format.err_formatter objects output; @@ -283,12 +278,14 @@ let main () = and client = ref false and build_dir = ref None and include_dirs = ref [] in + let static = ref false in let args_spec = [ - "--client", Arg.Set client, "TODO" ; - "-I", Arg.String (fun s -> include_dirs := s :: !include_dirs), "TODO" ; - "--build-dir", Arg.String (fun s -> build_dir := Some s), "TODO"] in - let usage_msg = "TODO" in - Arg.parse args_spec (fun s -> anonymous := s :: !anonymous) "TODO" ; + "-static", Arg.Set static, " Build a library (.cmxa)"; + "-client", Arg.Set client, " Preserve type equality with concrete node environment (used to embed protocol into the client)" ; + "-I", Arg.String (fun s -> include_dirs := s :: !include_dirs), "path Path for concrete node signatures (used to embed protocol into the client)" ; + "-build-dir", Arg.String (fun s -> build_dir := Some s), "path Reuse build dir (incremental compilation)"] in + let usage_msg = Printf.sprintf "Usage: %s \nOptions are:" Sys.argv.(0) in + Arg.parse args_spec (fun s -> anonymous := s :: !anonymous) usage_msg ; let client = !client and include_dirs = !include_dirs in let output, source_dir = @@ -439,4 +436,4 @@ let main () = (* Create the final [cmxs] *) Clflags.link_everything := true ; - link_shared output [packed_objects; register_object] + link_shared ~static:!static output [packed_objects; register_object]