ligo/lib_protocol_compiler/jbuild_protocol_template

59 lines
1.8 KiB
Plaintext
Raw Normal View History

(* -*- 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... *)
let prefix = "lib_embedded_protocol_"
let dirname = Filename.basename @@ Sys.getcwd ()
let version =
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 () = Format.kasprintf Jbuild_plugin.V1.send {|
(jbuild_version 1)
(rule
((targets (tezos_protocol_%s.o
tezos_protocol_%s.cmx
tezos_protocol_%s.cmi
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}
(chdir ${ROOT}
(run ${bin:tezos-protocol-compiler} -static ${path-no-dep:tezos_protocol_%s} ${path-no-dep:src}))))))
(library
((name tezos_protocol_%s)
(public_name tezos-protocol-%s)
(library_flags (:standard -linkall
lib_embedded_protocol_%s/tezos_protocol_%s.cmx))
(wrapped false)
(modes (native))
(modules (Tezos_protocol_%s_dummy))))
(alias
((name runtest_sandbox)
(deps (tezos_protocol_%s.cmx))))
(alias
((name runtest_indent)
(deps ((glob_files src/*.ml) (glob_files src/*.mli)))
(action (run bash ${libexec:tezos-stdlib:test-ocp-indent.sh} ${<}))))
|}
version version version version version version version version
version version version version