Skip to content

Instantly share code, notes, and snippets.

@ulrikstrid
Created June 3, 2021 10:14
Show Gist options
  • Save ulrikstrid/f9458ae08791cf2748b681638ea2e00f to your computer and use it in GitHub Desktop.
Save ulrikstrid/f9458ae08791cf2748b681638ea2e00f to your computer and use it in GitHub Desktop.
Update tezos-benchmark to ppxlib
diff --git a/src/lib_benchmark/codegen.ml b/src/lib_benchmark/codegen.ml
index 17fdfe9eb..1dcf5e9bf 100644
--- a/src/lib_benchmark/codegen.ml
+++ b/src/lib_benchmark/codegen.ml
@@ -26,31 +26,30 @@
(* ------------------------------------------------------------------------- *)
(* OCaml codegen *)
-open Migrate_parsetree.Ast_408
-module Codegen_helpers = struct
- open Ast_helper
+open Ppxlib
- let loc txt = {Asttypes.txt; loc = Location.none}
+module Codegen_helpers = struct
+ let loc txt = {Ppxlib.Asttypes.txt; loc = Location.none}
- let loc_ident x = {Asttypes.txt = Longident.Lident x; loc = Location.none}
+ let loc_ident x = {Ppxlib.Asttypes.txt = Ocaml_common.Longident.Lident x; loc = Location.none}
let loc_str (x : string) = {Asttypes.txt = x; loc = Location.none}
- let ident x = Exp.ident (loc_ident x)
+ let ident x = Ast_helper.Exp.ident (loc_ident x)
- let pvar x = Pat.var (loc_str x)
+ let pvar x = Ast_helper.Pat.var (loc_str x)
let call f args =
- let f = WithExceptions.Option.get ~loc:__LOC__ @@ Longident.unflatten f in
+ let f = WithExceptions.Option.get ~loc:__LOC__ @@ Ocaml_common.Longident.unflatten f in
let args = List.map (fun x -> (Asttypes.Nolabel, x)) args in
- Exp.(apply (ident (loc f)) args)
+ Ast_helper.Exp.(apply (ident (loc f)) args)
let string_of_fv fv = Format.asprintf "%a" Free_variable.pp fv
end
-module Codegen : Costlang.S with type 'a repr = Parsetree.expr = struct
- type 'a repr = Parsetree.expr
+module Codegen : Costlang.S with type 'a repr = Parsetree.expression = struct
+ type 'a repr = Parsetree.expression
type size = int
@@ -106,29 +105,28 @@ module Codegen : Costlang.S with type 'a repr = Parsetree.expr = struct
end
let make_module bindings =
- let open Migrate_parsetree.Ast_408.Ast_helper in
+ let open Ast_helper in
let structure_items =
List.map
(fun (name, expr) ->
let name = Printf.sprintf "cost_%s" name in
Str.value
- Migrate_parsetree.Ast_408.Asttypes.Nonrecursive
+ Asttypes.Nonrecursive
[Vb.mk (Codegen_helpers.pvar name) expr])
bindings
in
Str.module_
- (Mb.mk (Codegen_helpers.loc "Generated") @@ Mod.structure structure_items)
+ (Mb.mk (Codegen_helpers.loc (Some "Generated")) @@ Mod.structure structure_items)
+
-module Convert_to_current =
- Migrate_parsetree.Convert
- (Migrate_parsetree.OCaml_408)
- (Migrate_parsetree.OCaml_current)
+module Conv = Ppxlib_ast.Select_ast (Ppxlib_ast__.Versions.OCaml_408) (* https://github.com/ocaml-ppx/ppxlib/issues/185 *)
+module To_ppxlib = Conv.Of_ocaml
let pp_expr fmtr expr =
- Pprintast.expression fmtr (Convert_to_current.copy_expression expr)
+ Ppxlib.Pprintast.expression fmtr expr
let pp_structure_item fmtr generated =
- Pprintast.structure fmtr (Convert_to_current.copy_structure [generated])
+ Ppxlib.Pprintast.structure fmtr [generated]
(* ------------------------------------------------------------------------- *)
diff --git a/src/lib_benchmark/dune b/src/lib_benchmark/dune
index f584a8c8f..4ce9eb916 100644
--- a/src/lib_benchmark/dune
+++ b/src/lib_benchmark/dune
@@ -1,22 +1,29 @@
(library
(name tezos_benchmark)
(public_name tezos-benchmark)
- (libraries tezos-base
- tezos-stdlib-unix
- tezos-micheline
- tezos-clic
- data-encoding
- staTz
- benchmark-utils
- pyml-plot ;; because of Matrix module... pyml-plot should be split further
- ocaml-migrate-parsetree
- )
- (flags (:standard
- -open Tezos_base__TzPervasives
- -open StaTz
- -open Tezos_stdlib_unix)))
+ (libraries
+ tezos-base
+ tezos-stdlib-unix
+ tezos-micheline
+ tezos-clic
+ data-encoding
+ staTz
+ benchmark-utils
+ pyml-plot ;; because of Matrix module... pyml-plot should be split further
+ ppxlib
+ ocaml-migrate-parsetree)
+ (flags
+ (:standard
+ -open
+ Tezos_base__TzPervasives
+ -open
+ StaTz
+ -open
+ Tezos_stdlib_unix)))
(rule
(alias runtest_lint)
- (deps (glob_files *.ml{,i}))
- (action (run %{lib:tezos-tooling:lint.sh} %{deps})))
+ (deps
+ (glob_files *.ml{,i}))
+ (action
+ (run %{lib:tezos-tooling:lint.sh} %{deps})))
diff --git a/src/lib_benchmark/lib_micheline_rewriting/test/dune b/src/lib_benchmark/lib_micheline_rewriting/test/dune
index 5715d3dc3..289295241 100644
--- a/src/lib_benchmark/lib_micheline_rewriting/test/dune
+++ b/src/lib_benchmark/lib_micheline_rewriting/test/dune
@@ -1,12 +1,16 @@
(executables
(names test_rewriting)
- (libraries tezos-micheline
- tezos-micheline-rewriting
- tezos-protocol-alpha
- tezos-error-monad
- tezos-client-alpha
- alcotest-lwt)
- (flags (:standard -open Tezos_micheline)))
+ (libraries
+ tezos-micheline
+ tezos-micheline-rewriting
+ tezos-protocol-alpha
+ tezos-error-monad
+ tezos-client-alpha
+ alcotest-lwt
+ tezos-hacl-glue-unix
+ bls12-381-unix)
+ (flags
+ (:standard -open Tezos_micheline)))
(rule
(alias buildtest)
@@ -15,15 +19,19 @@
(rule
(alias runtest_test_rewriting)
- (action (run %{exe:test_rewriting.exe})))
+ (action
+ (run %{exe:test_rewriting.exe})))
(rule
(alias runtest)
(package tezos-micheline-rewriting)
- (deps (alias runtest_test_rewriting))
+ (deps
+ (alias runtest_test_rewriting))
(action (progn)))
(rule
(alias runtest_lint)
- (deps (glob_files *.ml{,i}))
- (action (run %{lib:tezos-tooling:lint.sh} %{deps})))
+ (deps
+ (glob_files *.ml{,i}))
+ (action
+ (run %{lib:tezos-tooling:lint.sh} %{deps})))
diff --git a/src/lib_benchmark/test/dune b/src/lib_benchmark/test/dune
index 1d7648d21..669877db1 100644
--- a/src/lib_benchmark/test/dune
+++ b/src/lib_benchmark/test/dune
@@ -1,14 +1,18 @@
(executables
(names main main_ci)
- (libraries alcotest-lwt
- tezos-base
- tezos-base.unix
- tezos-stdlib-unix
- tezos-micheline
- tezos-crypto
- tezos-benchmark
- tezos-benchmark-examples)
- (flags (:standard -open Tezos_base__TzPervasives)))
+ (libraries
+ alcotest-lwt
+ tezos-base
+ tezos-base.unix
+ tezos-stdlib-unix
+ tezos-micheline
+ tezos-crypto
+ tezos-benchmark
+ tezos-benchmark-examples
+ tezos-hacl-glue-unix
+ bls12-381-unix)
+ (flags
+ (:standard -open Tezos_base__TzPervasives)))
(rule
(alias buildtest)
@@ -17,15 +21,19 @@
(rule
(alias runtest_lib_bench)
- (action (run %{exe:main_ci.exe})))
+ (action
+ (run %{exe:main_ci.exe})))
(rule
(alias runtest)
(package tezos-benchmark-tests)
- (deps (alias runtest_lib_bench))
+ (deps
+ (alias runtest_lib_bench))
(action (progn)))
(rule
(alias runtest_lint)
- (deps (glob_files *.ml{,i}))
- (action (run %{lib:tezos-tooling:lint.sh} %{deps})))
+ (deps
+ (glob_files *.ml{,i}))
+ (action
+ (run %{lib:tezos-tooling:lint.sh} %{deps})))
diff --git a/src/lib_benchmark/tezos-benchmark.opam b/src/lib_benchmark/tezos-benchmark.opam
index f515e2b29..dd58edc38 100644
--- a/src/lib_benchmark/tezos-benchmark.opam
+++ b/src/lib_benchmark/tezos-benchmark.opam
@@ -18,7 +18,7 @@ depends: [
"pyml-plot"
"conf-autoconf"
"hashcons"
- "ocaml-migrate-parsetree"
+ "ppxlib"
]
build: [
["dune" "build" "-p" name "-j" jobs]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment