diff --git a/Makefile b/Makefile index af128130d..c2db71170 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ endif current_ocaml_version := $(shell opam exec -- ocamlc -version) -all: +all: generate_dune ifneq (${current_ocaml_version},${ocaml_version}) $(error Unexpected ocaml version (found: ${current_ocaml_version}, expected: ${ocaml_version})) endif @@ -37,7 +37,17 @@ endif cp _build/default/src/proto_$$p/bin_accuser/main_accuser_$$p.exe tezos-accuser-`echo $$p | tr -- _ -` ; \ done -all.pkg: +PROTOCOLS := genesis alpha demo +DUNE_INCS=$(patsubst %,src/proto_%/lib_protocol/src/dune.inc, ${PROTOCOLS}) + +generate_dune: ${DUNE_INCS} + +${DUNE_INCS}:: src/proto_%/lib_protocol/src/dune.inc: \ + src/proto_%/lib_protocol/src/TEZOS_PROTOCOL + dune build @$(dir $@)/runtest_dune_template --auto-promote + touch $@ + +all.pkg: generate_dune @dune build \ $(patsubst %.opam,%.install, $(shell find src vendors -name \*.opam -print)) diff --git a/src/lib_protocol_compiler/dune b/src/lib_protocol_compiler/dune index 4efdf54ea..182cb4038 100644 --- a/src/lib_protocol_compiler/dune +++ b/src/lib_protocol_compiler/dune @@ -99,11 +99,24 @@ -open Tezos_stdlib_unix)) (modules Main_embedded_packer)) +(executable + (name replace) + (libraries tezos-base tezos-stdlib-unix str) + (flags (:standard -open Tezos_base__TzPervasives + -open Tezos_stdlib_unix)) + (modules Replace)) + (install (section share) (files jbuild_protocol_template jbuild_embedded_protocol_template)) +(install + (section libexec) + (files (replace.exe as replace) + dune_protocol + dune_protocol.template)) + (alias (name runtest_indent) ;; we would like (deps ((glob_files *.ml \ embedded_cmis.ml))) diff --git a/src/lib_protocol_compiler/dune_protocol b/src/lib_protocol_compiler/dune_protocol new file mode 100644 index 000000000..8d24dd8cb --- /dev/null +++ b/src/lib_protocol_compiler/dune_protocol @@ -0,0 +1,19 @@ + +(include dune.inc) + +(rule + (targets "dune.inc.gen") + (deps TEZOS_PROTOCOL (glob_files *.ml) (glob_files *.mli)) + (action + (run + %{libexec:tezos-protocol-compiler:replace} + %{libexec:tezos-protocol-compiler:dune_protocol.template} + "dune.inc.gen"))) + +(alias + (name runtest_dune_template) + (action (diff dune.inc dune.inc.gen))) + +(alias + (name runtest) + (deps (alias runtest_dune_template))) diff --git a/src/lib_protocol_compiler/dune_protocol.template b/src/lib_protocol_compiler/dune_protocol.template new file mode 100644 index 000000000..7e7d5e8e5 --- /dev/null +++ b/src/lib_protocol_compiler/dune_protocol.template @@ -0,0 +1,70 @@ + +(rule + (targets environment.ml) + (action + (write-file %{targets} + "include Tezos_protocol_environment_shell.MakeV1(struct let name = \"%%VERSION%%\" end)() + module CamlinternalFormatBasics = struct include CamlinternalFormatBasics end +"))) + +(rule + (targets registerer.ml) + (deps tezos_embedded_protocol_environment_%%LIB_VERSION%%.cmxa + (:src_dir TEZOS_PROTOCOL)) + (action + (with-stdout-to %{targets} + (chdir %{workspace_root} (run %{bin:tezos-embedded-protocol-packer} "%{src_dir}" "%%LIB_VERSION%%"))))) + + +(rule + (targets functor.ml) + (deps %%SOURCES%% + (:src_dir TEZOS_PROTOCOL)) + (action (with-stdout-to %{targets} + (chdir %{workspace_root} + (run %{bin:tezos-protocol-compiler.tezos-protocol-packer} %{src_dir}))))) + +(library + (name tezos_protocol_%%LIB_VERSION%%) + (public_name tezos-protocol-%%VERSION%%) + (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)) + +(library + (name tezos_embedded_protocol_environment_%%LIB_VERSION%%) + (public_name tezos-embedded-protocol-%%VERSION%%.environment) + (library_flags (:standard -linkall)) + (libraries tezos-protocol-environment-shell) + (modules Environment)) + +(library + (name tezos_embedded_raw_protocol_%%LIB_VERSION%%) + (public_name tezos-embedded-protocol-%%VERSION%%.raw) + (libraries tezos_embedded_protocol_environment_%%LIB_VERSION%%) + (library_flags (:standard -linkall)) + (flags (:standard -nopervasives -nostdlib -safe-string + -w +a-4-6-7-9-29-32-40..42-44-45-48 + -warn-error -a+8 + -open Tezos_embedded_protocol_environment_%%LIB_VERSION%%__Environment + -open Pervasives + -open Error_monad)) + (modules %%MODULES%%)) + +(library + (name tezos_embedded_protocol_%%LIB_VERSION%%) + (public_name tezos-embedded-protocol-%%VERSION%%) + (library_flags (:standard -linkall)) + (libraries tezos_embedded_raw_protocol_%%LIB_VERSION%% + tezos-protocol-updater + tezos-protocol-environment-shell) + (flags (:standard -w +a-4-6-7-9-29-32-40..42-44-45-48 + -warn-error -a+8)) + (modules Registerer)) + +(alias + (name runtest_sandbox) + (deps .tezos_protocol_%%LIB_VERSION%%.objs/tezos_protocol_%%LIB_VERSION%%.cmx)) + diff --git a/src/lib_protocol_compiler/replace.ml b/src/lib_protocol_compiler/replace.ml new file mode 100644 index 000000000..b6a5b8ce6 --- /dev/null +++ b/src/lib_protocol_compiler/replace.ml @@ -0,0 +1,136 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2019 Nomadic Labs, *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +module StringMap = Map.Make(String) + +let regexp = Str.regexp "%%[^%]*%%" + +let current_dir = Sys.getcwd () + +let guess_version () = + let prefix = "proto_" in + let rec loop dir = + let dirname = Filename.basename dir in + let x = String.length prefix in + let n = String.length dirname in + if n >= x && String.sub dirname 0 x = prefix then + String.sub dirname x (n - x) + else + let updir = Filename.dirname dir in + if updir = dir then begin + Format.eprintf + "Cannot guess protocol version in path!@.Looking for `%s*` in `%s`@." + prefix current_dir ; + exit 1 + end; + loop updir in + loop (Sys.getcwd ()) + +let warning_message = {| + +; +; /!\ /!\ Do not modify this file /!\ /!\ +; +; but the original template in `tezos-protocol-compiler` +; + +|} + +let replace ~template ~destination vars = + let inch = open_in template in + let outch = open_out destination in + output_string outch warning_message ; + try + while true do + let line = input_line inch in + let line = + Str.global_substitute regexp begin fun s -> + let matched = Str.matched_string s in + let var = String.sub matched 2 (String.length matched - 4) in + match StringMap.find_opt var vars with + | Some value -> value + | None -> + prerr_endline ("Unknown variable: " ^ var) ; + exit 1 + end line in + output_string outch line ; + output_string outch "\n" ; + done ; + with End_of_file -> + flush outch ; + close_out outch ; + () + +let module_name (c : Protocol.component) = + String.capitalize_ascii c.name +let sources_name (c : Protocol.component) = + let name = String.lowercase_ascii c.name in + match c.interface with + | None -> + Printf.sprintf "%s.ml" name + | Some _ -> + Printf.sprintf "%s.mli %s.ml" name name + +let process ~template ~destination (protocol : Protocol.t) lib_version = + let version = String.concat "-" (String.split_on_char '_' lib_version) in + let vars = + StringMap.empty |> + StringMap.add "VERSION" version |> + StringMap.add "LIB_VERSION" lib_version |> + StringMap.add "MODULES" + (String.concat " " (List.map module_name protocol.components)) |> + StringMap.add "SOURCES" + (String.concat " " (List.map sources_name protocol.components)) in + replace ~template ~destination vars + +let read_proto destination = + let source_dir = + if Filename.is_relative destination then + Filename.concat + current_dir (Filename.dirname destination) + else + Filename.dirname destination in + match Lwt_main.run (Lwt_utils_unix.Protocol.read_dir source_dir) with + | Ok (None, proto) -> + (Protocol.hash proto, proto) + | Ok (Some hash, proto) -> + (hash, proto) + | Error err -> + Format.kasprintf Pervasives.failwith + "Failed to read TEZOS_PROTOCOL in %s:@ %a" + source_dir + pp_print_error err + +let main () = + let template = Sys.argv.(1) in + let destination = Sys.argv.(2) in + let version = + try Sys.argv.(3) + with _ -> guess_version () in + let _hash, proto = read_proto destination in + process ~template ~destination proto version + +let () = + main () diff --git a/src/proto_alpha/lib_protocol/dune b/src/proto_alpha/lib_protocol/dune deleted file mode 120000 index 3dc6e1fbd..000000000 --- a/src/proto_alpha/lib_protocol/dune +++ /dev/null @@ -1 +0,0 @@ -../../lib_protocol_compiler/jbuild_protocol_template \ No newline at end of file diff --git a/src/proto_alpha/lib_protocol/src/dune b/src/proto_alpha/lib_protocol/src/dune index acda1b059..3f5647096 120000 --- a/src/proto_alpha/lib_protocol/src/dune +++ b/src/proto_alpha/lib_protocol/src/dune @@ -1 +1 @@ -../../../lib_protocol_compiler/jbuild_embedded_protocol_template \ No newline at end of file +../../../lib_protocol_compiler/dune_protocol \ No newline at end of file diff --git a/src/proto_alpha/lib_protocol/src/dune.inc b/src/proto_alpha/lib_protocol/src/dune.inc new file mode 100644 index 000000000..635268b87 --- /dev/null +++ b/src/proto_alpha/lib_protocol/src/dune.inc @@ -0,0 +1,78 @@ + + +; +; /!\ /!\ Do not modify this file /!\ /!\ +; +; but the original template in `tezos-protocol-compiler` +; + + +(rule + (targets environment.ml) + (action + (write-file %{targets} + "include Tezos_protocol_environment_shell.MakeV1(struct let name = \"alpha\" end)() + module CamlinternalFormatBasics = struct include CamlinternalFormatBasics end +"))) + +(rule + (targets registerer.ml) + (deps tezos_embedded_protocol_environment_alpha.cmxa + (:src_dir TEZOS_PROTOCOL)) + (action + (with-stdout-to %{targets} + (chdir %{workspace_root} (run %{bin:tezos-embedded-protocol-packer} "%{src_dir}" "alpha"))))) + + +(rule + (targets functor.ml) + (deps misc.mli misc.ml storage_description.mli storage_description.ml state_hash.ml nonce_hash.ml script_expr_hash.ml contract_hash.ml blinded_public_key_hash.mli blinded_public_key_hash.ml qty_repr.ml tez_repr.mli tez_repr.ml period_repr.mli period_repr.ml time_repr.mli time_repr.ml constants_repr.ml fitness_repr.ml raw_level_repr.mli raw_level_repr.ml voting_period_repr.mli voting_period_repr.ml cycle_repr.mli cycle_repr.ml level_repr.mli level_repr.ml seed_repr.mli seed_repr.ml gas_limit_repr.mli gas_limit_repr.ml script_int_repr.mli script_int_repr.ml script_timestamp_repr.mli script_timestamp_repr.ml michelson_v1_primitives.mli michelson_v1_primitives.ml script_repr.mli script_repr.ml contract_repr.mli contract_repr.ml roll_repr.mli roll_repr.ml vote_repr.mli vote_repr.ml block_header_repr.mli block_header_repr.ml operation_repr.mli operation_repr.ml manager_repr.mli manager_repr.ml commitment_repr.mli commitment_repr.ml parameters_repr.mli parameters_repr.ml raw_context.mli raw_context.ml storage_sigs.ml storage_functors.mli storage_functors.ml storage.mli storage.ml constants_storage.ml level_storage.mli level_storage.ml nonce_storage.mli nonce_storage.ml seed_storage.mli seed_storage.ml roll_storage.mli roll_storage.ml delegate_storage.mli delegate_storage.ml contract_storage.mli contract_storage.ml bootstrap_storage.mli bootstrap_storage.ml fitness_storage.ml vote_storage.mli vote_storage.ml commitment_storage.mli commitment_storage.ml init_storage.ml fees_storage.mli fees_storage.ml alpha_context.mli alpha_context.ml script_typed_ir.ml script_tc_errors.ml michelson_v1_gas.mli michelson_v1_gas.ml script_ir_annot.mli script_ir_annot.ml script_ir_translator.mli script_ir_translator.ml script_tc_errors_registration.ml script_interpreter.mli script_interpreter.ml baking.mli baking.ml amendment.mli amendment.ml apply_results.mli apply_results.ml apply.ml services_registration.ml constants_services.mli constants_services.ml contract_services.mli contract_services.ml delegate_services.mli delegate_services.ml helpers_services.mli helpers_services.ml voting_services.mli voting_services.ml alpha_services.mli alpha_services.ml main.mli main.ml + (:src_dir TEZOS_PROTOCOL)) + (action (with-stdout-to %{targets} + (chdir %{workspace_root} + (run %{bin:tezos-protocol-compiler.tezos-protocol-packer} %{src_dir}))))) + +(library + (name tezos_protocol_alpha) + (public_name tezos-protocol-alpha) + (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)) + +(library + (name tezos_embedded_protocol_environment_alpha) + (public_name tezos-embedded-protocol-alpha.environment) + (library_flags (:standard -linkall)) + (libraries tezos-protocol-environment-shell) + (modules Environment)) + +(library + (name tezos_embedded_raw_protocol_alpha) + (public_name tezos-embedded-protocol-alpha.raw) + (libraries tezos_embedded_protocol_environment_alpha) + (library_flags (:standard -linkall)) + (flags (:standard -nopervasives -nostdlib -safe-string + -w +a-4-6-7-9-29-32-40..42-44-45-48 + -warn-error -a+8 + -open Tezos_embedded_protocol_environment_alpha__Environment + -open Pervasives + -open Error_monad)) + (modules Misc Storage_description State_hash Nonce_hash Script_expr_hash Contract_hash Blinded_public_key_hash Qty_repr Tez_repr Period_repr Time_repr Constants_repr Fitness_repr Raw_level_repr Voting_period_repr Cycle_repr Level_repr Seed_repr Gas_limit_repr Script_int_repr Script_timestamp_repr Michelson_v1_primitives Script_repr Contract_repr Roll_repr Vote_repr Block_header_repr Operation_repr Manager_repr Commitment_repr Parameters_repr Raw_context Storage_sigs Storage_functors Storage Constants_storage Level_storage Nonce_storage Seed_storage Roll_storage Delegate_storage Contract_storage Bootstrap_storage Fitness_storage Vote_storage Commitment_storage Init_storage Fees_storage Alpha_context Script_typed_ir Script_tc_errors Michelson_v1_gas Script_ir_annot Script_ir_translator Script_tc_errors_registration Script_interpreter Baking Amendment Apply_results Apply Services_registration Constants_services Contract_services Delegate_services Helpers_services Voting_services Alpha_services Main)) + +(library + (name tezos_embedded_protocol_alpha) + (public_name tezos-embedded-protocol-alpha) + (library_flags (:standard -linkall)) + (libraries tezos_embedded_raw_protocol_alpha + tezos-protocol-updater + tezos-protocol-environment-shell) + (flags (:standard -w +a-4-6-7-9-29-32-40..42-44-45-48 + -warn-error -a+8)) + (modules Registerer)) + +(alias + (name runtest_sandbox) + (deps .tezos_protocol_alpha.objs/tezos_protocol_alpha.cmx)) + diff --git a/src/proto_alpha/lib_protocol/tezos-embedded-protocol-alpha.opam b/src/proto_alpha/lib_protocol/tezos-embedded-protocol-alpha.opam index 55f4c1ffd..beade11d5 100644 --- a/src/proto_alpha/lib_protocol/tezos-embedded-protocol-alpha.opam +++ b/src/proto_alpha/lib_protocol/tezos-embedded-protocol-alpha.opam @@ -13,9 +13,9 @@ depends: [ "tezos-protocol-updater" ] build: [ - [ "rm" "dune" "src/dune" ] - [ "cp" "%{tezos-protocol-compiler:share}%/jbuild_embedded_protocol_template" "src/dune" ] - [ "sed" "-i" "s/let predefined_version = None/let predefined_version = Some \"alpha\"/" "src/dune" ] + [ "%{tezos-protocol-compiler:lib}%/replace" + "%{tezos-protocol-compiler:lib}%/dune_protocol.template" + "src/dune" "alpha" ] [ "dune" "build" "-p" name "-j" jobs ] ] run-test: [ diff --git a/src/proto_alpha/lib_protocol/tezos-protocol-alpha.opam b/src/proto_alpha/lib_protocol/tezos-protocol-alpha.opam index b9ea2c80f..c651b91ff 100644 --- a/src/proto_alpha/lib_protocol/tezos-protocol-alpha.opam +++ b/src/proto_alpha/lib_protocol/tezos-protocol-alpha.opam @@ -17,9 +17,9 @@ depends: [ "bip39" { with-test } ] build: [ - [ "rm" "dune" "src/dune" ] - [ "cp" "%{tezos-protocol-compiler:share}%/jbuild_protocol_template" "dune" ] - [ "sed" "-i" "s/let predefined_version = None/let predefined_version = Some \"alpha\"/" "dune" ] + [ "%{tezos-protocol-compiler:lib}%/replace" + "%{tezos-protocol-compiler:lib}%/dune_protocol.template" + "src/dune" "alpha" ] [ "dune" "build" "-p" name "-j" jobs ] ] run-test: [ diff --git a/src/proto_demo/lib_protocol/dune b/src/proto_demo/lib_protocol/dune deleted file mode 120000 index 3dc6e1fbd..000000000 --- a/src/proto_demo/lib_protocol/dune +++ /dev/null @@ -1 +0,0 @@ -../../lib_protocol_compiler/jbuild_protocol_template \ No newline at end of file diff --git a/src/proto_demo/lib_protocol/src/dune b/src/proto_demo/lib_protocol/src/dune index acda1b059..3f5647096 120000 --- a/src/proto_demo/lib_protocol/src/dune +++ b/src/proto_demo/lib_protocol/src/dune @@ -1 +1 @@ -../../../lib_protocol_compiler/jbuild_embedded_protocol_template \ No newline at end of file +../../../lib_protocol_compiler/dune_protocol \ No newline at end of file diff --git a/src/proto_demo/lib_protocol/src/dune.inc b/src/proto_demo/lib_protocol/src/dune.inc new file mode 100644 index 000000000..3d9aa9755 --- /dev/null +++ b/src/proto_demo/lib_protocol/src/dune.inc @@ -0,0 +1,78 @@ + + +; +; /!\ /!\ Do not modify this file /!\ /!\ +; +; but the original template in `tezos-protocol-compiler` +; + + +(rule + (targets environment.ml) + (action + (write-file %{targets} + "include Tezos_protocol_environment_shell.MakeV1(struct let name = \"demo\" end)() + module CamlinternalFormatBasics = struct include CamlinternalFormatBasics end +"))) + +(rule + (targets registerer.ml) + (deps tezos_embedded_protocol_environment_demo.cmxa + (:src_dir TEZOS_PROTOCOL)) + (action + (with-stdout-to %{targets} + (chdir %{workspace_root} (run %{bin:tezos-embedded-protocol-packer} "%{src_dir}" "demo"))))) + + +(rule + (targets functor.ml) + (deps error.ml services.ml main.mli main.ml + (:src_dir TEZOS_PROTOCOL)) + (action (with-stdout-to %{targets} + (chdir %{workspace_root} + (run %{bin:tezos-protocol-compiler.tezos-protocol-packer} %{src_dir}))))) + +(library + (name tezos_protocol_demo) + (public_name tezos-protocol-demo) + (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)) + +(library + (name tezos_embedded_protocol_environment_demo) + (public_name tezos-embedded-protocol-demo.environment) + (library_flags (:standard -linkall)) + (libraries tezos-protocol-environment-shell) + (modules Environment)) + +(library + (name tezos_embedded_raw_protocol_demo) + (public_name tezos-embedded-protocol-demo.raw) + (libraries tezos_embedded_protocol_environment_demo) + (library_flags (:standard -linkall)) + (flags (:standard -nopervasives -nostdlib -safe-string + -w +a-4-6-7-9-29-32-40..42-44-45-48 + -warn-error -a+8 + -open Tezos_embedded_protocol_environment_demo__Environment + -open Pervasives + -open Error_monad)) + (modules Error Services Main)) + +(library + (name tezos_embedded_protocol_demo) + (public_name tezos-embedded-protocol-demo) + (library_flags (:standard -linkall)) + (libraries tezos_embedded_raw_protocol_demo + tezos-protocol-updater + tezos-protocol-environment-shell) + (flags (:standard -w +a-4-6-7-9-29-32-40..42-44-45-48 + -warn-error -a+8)) + (modules Registerer)) + +(alias + (name runtest_sandbox) + (deps .tezos_protocol_demo.objs/tezos_protocol_demo.cmx)) + diff --git a/src/proto_demo/lib_protocol/tezos-embedded-protocol-demo.opam b/src/proto_demo/lib_protocol/tezos-embedded-protocol-demo.opam index e8dafcbdb..1b64f451f 100644 --- a/src/proto_demo/lib_protocol/tezos-embedded-protocol-demo.opam +++ b/src/proto_demo/lib_protocol/tezos-embedded-protocol-demo.opam @@ -12,9 +12,9 @@ depends: [ "tezos-protocol-updater" ] build: [ - [ "rm" "dune" "src/dune" ] - [ "cp" "%{tezos-protocol-compiler:share}%/jbuild_embedded_protocol_template" "src/dune" ] - [ "sed" "-i" "s/let predefined_version = None/let predefined_version = Some \"demo\"/" "src/dune" ] + [ "%{tezos-protocol-compiler:lib}%/replace" + "%{tezos-protocol-compiler:lib}%/dune_protocol.template" + "src/dune" "demo" ] [ "dune" "build" "-p" name "-j" jobs ] ] run-test: [ diff --git a/src/proto_demo/lib_protocol/tezos-protocol-demo.opam b/src/proto_demo/lib_protocol/tezos-protocol-demo.opam index ffed72264..234dd48ec 100644 --- a/src/proto_demo/lib_protocol/tezos-protocol-demo.opam +++ b/src/proto_demo/lib_protocol/tezos-protocol-demo.opam @@ -11,9 +11,9 @@ depends: [ "tezos-protocol-compiler" ] build: [ - [ "rm" "dune" "src/dune" ] - [ "cp" "%{tezos-protocol-compiler:share}%/jbuild_protocol_template" "dune" ] - [ "sed" "-i" "s/let predefined_version = None/let predefined_version = Some \"demo\"/" "dune" ] + [ "%{tezos-protocol-compiler:lib}%/replace" + "%{tezos-protocol-compiler:lib}%/dune_protocol.template" + "src/dune" "demo" ] [ "dune" "build" "-p" name "-j" jobs ] ] run-test: [ diff --git a/src/proto_genesis/lib_protocol/dune b/src/proto_genesis/lib_protocol/dune deleted file mode 120000 index 3dc6e1fbd..000000000 --- a/src/proto_genesis/lib_protocol/dune +++ /dev/null @@ -1 +0,0 @@ -../../lib_protocol_compiler/jbuild_protocol_template \ No newline at end of file diff --git a/src/proto_genesis/lib_protocol/dune.inc b/src/proto_genesis/lib_protocol/dune.inc new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/src/proto_genesis/lib_protocol/dune.inc @@ -0,0 +1 @@ + diff --git a/src/proto_genesis/lib_protocol/src/dune b/src/proto_genesis/lib_protocol/src/dune index acda1b059..3f5647096 120000 --- a/src/proto_genesis/lib_protocol/src/dune +++ b/src/proto_genesis/lib_protocol/src/dune @@ -1 +1 @@ -../../../lib_protocol_compiler/jbuild_embedded_protocol_template \ No newline at end of file +../../../lib_protocol_compiler/dune_protocol \ No newline at end of file diff --git a/src/proto_genesis/lib_protocol/src/dune.inc b/src/proto_genesis/lib_protocol/src/dune.inc new file mode 100644 index 000000000..3b1045f41 --- /dev/null +++ b/src/proto_genesis/lib_protocol/src/dune.inc @@ -0,0 +1,78 @@ + + +; +; /!\ /!\ Do not modify this file /!\ /!\ +; +; but the original template in `tezos-protocol-compiler` +; + + +(rule + (targets environment.ml) + (action + (write-file %{targets} + "include Tezos_protocol_environment_shell.MakeV1(struct let name = \"genesis\" end)() + module CamlinternalFormatBasics = struct include CamlinternalFormatBasics end +"))) + +(rule + (targets registerer.ml) + (deps tezos_embedded_protocol_environment_genesis.cmxa + (:src_dir TEZOS_PROTOCOL)) + (action + (with-stdout-to %{targets} + (chdir %{workspace_root} (run %{bin:tezos-embedded-protocol-packer} "%{src_dir}" "genesis"))))) + + +(rule + (targets functor.ml) + (deps data.ml services.ml main.mli main.ml + (:src_dir TEZOS_PROTOCOL)) + (action (with-stdout-to %{targets} + (chdir %{workspace_root} + (run %{bin:tezos-protocol-compiler.tezos-protocol-packer} %{src_dir}))))) + +(library + (name tezos_protocol_genesis) + (public_name tezos-protocol-genesis) + (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)) + +(library + (name tezos_embedded_protocol_environment_genesis) + (public_name tezos-embedded-protocol-genesis.environment) + (library_flags (:standard -linkall)) + (libraries tezos-protocol-environment-shell) + (modules Environment)) + +(library + (name tezos_embedded_raw_protocol_genesis) + (public_name tezos-embedded-protocol-genesis.raw) + (libraries tezos_embedded_protocol_environment_genesis) + (library_flags (:standard -linkall)) + (flags (:standard -nopervasives -nostdlib -safe-string + -w +a-4-6-7-9-29-32-40..42-44-45-48 + -warn-error -a+8 + -open Tezos_embedded_protocol_environment_genesis__Environment + -open Pervasives + -open Error_monad)) + (modules Data Services Main)) + +(library + (name tezos_embedded_protocol_genesis) + (public_name tezos-embedded-protocol-genesis) + (library_flags (:standard -linkall)) + (libraries tezos_embedded_raw_protocol_genesis + tezos-protocol-updater + tezos-protocol-environment-shell) + (flags (:standard -w +a-4-6-7-9-29-32-40..42-44-45-48 + -warn-error -a+8)) + (modules Registerer)) + +(alias + (name runtest_sandbox) + (deps .tezos_protocol_genesis.objs/tezos_protocol_genesis.cmx)) + diff --git a/src/proto_genesis/lib_protocol/tezos-embedded-protocol-genesis.opam b/src/proto_genesis/lib_protocol/tezos-embedded-protocol-genesis.opam index de3328cd4..c67f3e7f3 100644 --- a/src/proto_genesis/lib_protocol/tezos-embedded-protocol-genesis.opam +++ b/src/proto_genesis/lib_protocol/tezos-embedded-protocol-genesis.opam @@ -12,9 +12,9 @@ depends: [ "tezos-protocol-updater" ] build: [ - [ "rm" "dune" "src/dune" ] - [ "cp" "%{tezos-protocol-compiler:share}%/jbuild_embedded_protocol_template" "src/dune" ] - [ "sed" "-i" "s/let predefined_version = None/let predefined_version = Some \"genesis\"/" "src/dune" ] + [ "%{tezos-protocol-compiler:lib}%/replace" + "%{tezos-protocol-compiler:lib}%/dune_protocol.template" + "src/dune" "genesis" ] [ "dune" "build" "-p" name "-j" jobs ] ] run-test: [ diff --git a/src/proto_genesis/lib_protocol/tezos-protocol-genesis.opam b/src/proto_genesis/lib_protocol/tezos-protocol-genesis.opam index 8d888e94f..aa4d51677 100644 --- a/src/proto_genesis/lib_protocol/tezos-protocol-genesis.opam +++ b/src/proto_genesis/lib_protocol/tezos-protocol-genesis.opam @@ -11,9 +11,9 @@ depends: [ "tezos-protocol-compiler" ] build: [ - [ "rm" "dune" "src/dune" ] - [ "cp" "%{tezos-protocol-compiler:share}%/jbuild_protocol_template" "dune" ] - [ "sed" "-i" "s/let predefined_version = None/let predefined_version = Some \"genesis\"/" "dune" ] + [ "%{tezos-protocol-compiler:lib}%/replace" + "%{tezos-protocol-compiler:lib}%/dune_protocol.template" + "src/dune" "genesis" ] [ "dune" "build" "-p" name "-j" jobs ] ] run-test: [