2017-12-05 18:16:34 +04:00
|
|
|
(* -*- tuareg -*- *)
|
|
|
|
|
|
|
|
(* Build a functorized version of the protocol with the
|
|
|
|
`tezos-protocol-compiler` This is bit hackish...
|
|
|
|
|
|
|
|
AFAIK the current version of jbuilder (1.0+beta16) does not allow
|
|
|
|
to compile with a custom `rule` the `(modules)` of a library.
|
|
|
|
|
|
|
|
A trick is to provide the `.cmx` through the `(library_flags)` and
|
|
|
|
to generate a empty `.ml` to correctly handle the dependencies... *)
|
|
|
|
|
2018-01-27 14:21:41 +04:00
|
|
|
#require "unix"
|
|
|
|
|
2018-01-29 04:16:58 +04:00
|
|
|
let prefix = "proto_"
|
|
|
|
let dirname = Filename.basename @@ Filename.dirname @@ Sys.getcwd ()
|
2017-12-05 18:16:34 +04:00
|
|
|
|
2017-12-06 22:51:49 +04:00
|
|
|
let predefined_version = None (* to be substituted in opam packages *)
|
|
|
|
|
2017-12-05 18:16:34 +04:00
|
|
|
let version =
|
2017-12-06 22:51:49 +04:00
|
|
|
match predefined_version with
|
|
|
|
| Some version -> version
|
|
|
|
| None ->
|
|
|
|
let x = String.length prefix in
|
|
|
|
let n = String.length dirname in
|
|
|
|
if not (n >= x && String.sub dirname 0 x = prefix) then
|
|
|
|
failwith "unexpected directory name" ;
|
|
|
|
String.sub dirname x (n - x)
|
|
|
|
|
|
|
|
let path =
|
|
|
|
match predefined_version with
|
2018-01-29 04:16:58 +04:00
|
|
|
| None -> "src/proto_" ^ version ^ "/lib_protocol"
|
2017-12-06 22:51:49 +04:00
|
|
|
| Some _ -> "."
|
2017-12-05 18:16:34 +04:00
|
|
|
|
2018-01-27 14:21:41 +04:00
|
|
|
let sources =
|
|
|
|
let d = Unix.opendir "src" in
|
|
|
|
let rec loop acc =
|
|
|
|
match Unix.readdir d with
|
|
|
|
| exception End_of_file ->
|
|
|
|
Unix.closedir d ;
|
|
|
|
acc
|
|
|
|
| file ->
|
|
|
|
let acc =
|
|
|
|
if Filename.check_suffix file ".mli"
|
|
|
|
|| Filename.check_suffix file ".ml" then
|
|
|
|
("src/" ^ file) :: acc
|
|
|
|
else
|
|
|
|
acc
|
|
|
|
in
|
|
|
|
loop acc in
|
|
|
|
loop []
|
|
|
|
|
2017-12-05 18:16:34 +04:00
|
|
|
let () = Format.kasprintf Jbuild_plugin.V1.send {|
|
|
|
|
|
|
|
|
(jbuild_version 1)
|
|
|
|
|
2018-01-30 19:30:22 +04:00
|
|
|
(rule
|
2018-03-08 12:11:58 +04:00
|
|
|
((targets (functor.ml))
|
2018-05-26 22:06:05 +04:00
|
|
|
(deps ((glob_files src/*.ml{,i})
|
2018-03-08 12:11:58 +04:00
|
|
|
src/TEZOS_PROTOCOL))
|
|
|
|
(action (with-stdout-to ${path-no-dep:functor.ml}
|
2018-03-13 16:18:29 +04:00
|
|
|
(chdir ${ROOT}
|
|
|
|
(run ${bin:tezos-protocol-compiler.tezos-protocol-packer} ${path-no-dep:src}))))))
|
2017-12-05 18:16:34 +04:00
|
|
|
|
|
|
|
(library
|
|
|
|
((name tezos_protocol_%s)
|
|
|
|
(public_name tezos-protocol-%s)
|
2018-03-08 12:11:58 +04:00
|
|
|
(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))))
|
2018-01-30 19:30:22 +04:00
|
|
|
|
2017-12-05 18:16:34 +04:00
|
|
|
(alias
|
|
|
|
((name runtest_sandbox)
|
|
|
|
(deps (tezos_protocol_%s.cmx))))
|
|
|
|
|
|
|
|
(alias
|
|
|
|
((name runtest_indent)
|
2018-01-27 14:21:41 +04:00
|
|
|
(deps (@[<v>%a@]))
|
|
|
|
(action (run bash ${libexec:tezos-stdlib:test-ocp-indent.sh} ${^}))))
|
2017-12-05 18:16:34 +04:00
|
|
|
|
|
|
|
|}
|
2018-03-08 18:42:53 +04:00
|
|
|
version version version
|
2018-01-27 14:21:41 +04:00
|
|
|
Format.(pp_print_list (fun ppf -> Format.fprintf ppf "%S"))
|
|
|
|
sources
|