ligo/src/lib_protocol_compiler/jbuild_protocol_template
2018-08-01 10:52:24 +02:00

62 lines
1.7 KiB
Plaintext

(* -*- tuareg -*- *)
let prefix = "proto_"
let dirname = Filename.basename @@ Filename.dirname @@ Sys.getcwd ()
let predefined_version = None (* to be substituted in opam packages *)
let lib_version =
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 version = String.concat "-" (String.split_on_char '_' lib_version)
let path =
match predefined_version with
| None -> "src/proto_" ^ version ^ "/lib_protocol"
| Some _ -> "."
let sources =
Format.kasprintf
Jbuild_plugin.V1.run_and_read_lines
"find src -name \\*.ml -or -name \\*.mli"
let () = Format.kasprintf Jbuild_plugin.V1.send {|
(rule
(targets functor.ml)
(deps (glob_files src/*.ml{,i})
(:src_dir src/TEZOS_PROTOCOL))
(action (with-stdout-to %%{targets}
(chdir %%{workspace_root}
(run %%{bin:tezos-protocol-compiler.tezos-protocol-packer} %%{src_dir})))))
(library
(name tezos_protocol_%s)
(public_name tezos-protocol-%s)
(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))
(alias
(name runtest_sandbox)
(deps .tezos_protocol_%s.objs/tezos_protocol_%s.cmx))
(alias
(name runtest_indent)
(deps @[<v>%a@])
(action (run bash %%{libexec:tezos-stdlib:test-ocp-indent.sh} %%{deps})))
|}
lib_version version lib_version lib_version
Format.(pp_print_list (fun ppf -> Format.fprintf ppf "%S"))
sources