Dune: don't use the 'tezos-protocol-compiler' in the build system

This commit is contained in:
Grégoire Henry 2018-03-08 09:11:58 +01:00 committed by Benjamin Canou
parent a405eb2d0e
commit 801bdf3d4c
3 changed files with 59 additions and 46 deletions

View File

@ -77,6 +77,19 @@
(flags (:standard -linkall))
(modules (Main_native))))
(executable
((name main_packer)
(public_name tezos-protocol-compiler.tezos-protocol-packer)
(libraries (tezos-base
tezos-protocol-compiler
tezos-stdlib-unix))
(flags (:standard -w -9+27-30-32-40@8
-safe-string
-open Tezos_base__TzPervasives
-open Tezos_stdlib_unix
-open Tezos_protocol_compiler))
(modules (Main_packer))))
(executable
((name main_embedded_packer)
(public_name tezos-embedded-protocol-packer)

View File

@ -54,47 +54,20 @@ let () = Format.kasprintf Jbuild_plugin.V1.send {|
(jbuild_version 1)
(rule
((targets (tezos_protocol_%s.cmo
tezos_protocol_%s_dummy_byte.ml))
(deps ((glob_files src/*.ml*)
src/TEZOS_PROTOCOL))
(action (with-stdout-to ${path-no-dep:tezos_protocol_%s_dummy_byte.ml}
(progn
(chdir ${ROOT}
(run ${bin:tezos-protocol-compiler-byte} -static -output-dep ${path-no-dep:.tezos_protocol_%s_byte.objs/tezos_protocol_%s} ${path-no-dep:src}))
(run ln -s .tezos_protocol_%s_byte.objs/tezos_protocol_%s.cmo tezos_protocol_%s.cmo))))))
(rule
((targets (tezos_protocol_%s.o
tezos_protocol_%s.cmx
tezos_protocol_%s_dummy.ml))
(deps ((glob_files src/*.ml)
(glob_files src/*.mli)
src/TEZOS_PROTOCOL))
(action (with-stdout-to ${path-no-dep:tezos_protocol_%s_dummy.ml}
(progn
(chdir ${ROOT}
(run ${bin:tezos-protocol-compiler} -static -output-dep ${path-no-dep:.tezos_protocol_%s.objs/tezos_protocol_%s} ${path-no-dep:src}))
(run ln -s .tezos_protocol_%s.objs/tezos_protocol_%s.o tezos_protocol_%s.o)
(run ln -s .tezos_protocol_%s.objs/tezos_protocol_%s.cmx tezos_protocol_%s.cmx))))))
((targets (functor.ml))
(deps ((glob_files src/*.ml*)
src/TEZOS_PROTOCOL))
(action (with-stdout-to ${path-no-dep:functor.ml}
(run ${bin:tezos-protocol-compiler.tezos-protocol-packer} ${path-no-dep:src})))))
(library
((name tezos_protocol_%s)
(public_name tezos-protocol-%s)
(library_flags (:standard -linkall %s/tezos_protocol_%s.cmx))
(flags (:standard -safe-string))
(wrapped false)
(modes (native))
(modules (Tezos_protocol_%s_dummy))))
(library
((name tezos_protocol_%s_byte)
(public_name tezos-protocol-%s.byte)
(library_flags (:standard -linkall %s/tezos_protocol_%s.cmo))
(flags (:standard -safe-string))
(wrapped false)
(modes (byte))
(modules (Tezos_protocol_%s_dummy_byte))))
(libraries (tezos-protocol-environment-sigs))
(flags (-w "+a-4-6-7-9-29-40..42-44-45-48"
-warn-error "-a+8"
-safe-string -nopervasives))
(modules (Functor))))
(install
((section lib)
@ -111,15 +84,6 @@ let () = Format.kasprintf Jbuild_plugin.V1.send {|
(action (run bash ${libexec:tezos-stdlib:test-ocp-indent.sh} ${^}))))
|}
version version version version
version version version version
version version version version
version version version version
version version version version
version version version version
path
version version version version
path
version version version version
version version
Format.(pp_print_list (fun ppf -> Format.fprintf ppf "%S"))

View File

@ -0,0 +1,36 @@
(**************************************************************************)
(* *)
(* Copyright (c) 2014 - 2018. *)
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
(* *)
(* All rights reserved. No warranty, explicit or implicit, provided. *)
(* *)
(**************************************************************************)
let (//) = Filename.concat
let () =
Random.self_init () ;
let anonymous = ref [] in
let args_spec = [ ] in
let usage_msg =
Printf.sprintf "Usage: %s [options] <srcdir>" Sys.argv.(0) in
Arg.parse args_spec (fun s -> anonymous := s :: !anonymous) usage_msg ;
let source_dir =
match List.rev !anonymous with
| [ source_dir ] -> source_dir
| _ -> Arg.usage args_spec usage_msg ; Pervasives.exit 1 in
let _hash, protocol =
match Lwt_main.run (Lwt_utils_unix.Protocol.read_dir source_dir) with
| Ok v -> v
| Error err ->
Format.kasprintf Pervasives.failwith
"Failed to read TEZOS_PROTOCOL: %a" pp_print_error err in
(* Generate the 'functor' *)
Packer.dump stdout
(Array.map
begin fun { Protocol.name ; _ } ->
let name_lowercase = String.uncapitalize_ascii name in
source_dir // name_lowercase ^ ".ml"
end
(Array.of_list protocol.components))