From 6252cc6e34678f54917d03b68887f98c6c50b8b0 Mon Sep 17 00:00:00 2001 From: Jeremie Dimino Date: Fri, 11 May 2018 15:44:47 +0200 Subject: [PATCH] Auto-detect ppx_sexp_conv runtime library --- myocamlbuild.ml | 25 ++++++++++++++++++++++--- pkg/{META => META.in} | 2 +- 2 files changed, 23 insertions(+), 4 deletions(-) rename pkg/{META => META.in} (95%) diff --git a/myocamlbuild.ml b/myocamlbuild.ml index 8fcbe33..95f4051 100644 --- a/myocamlbuild.ml +++ b/myocamlbuild.ml @@ -1,5 +1,24 @@ open Ocamlbuild_plugin -let () = dispatch Ocb_stubblr.( - init & ccopt ~tags:["accelerate"] "-DACCELERATE -mssse3 -maes -mpclmul" -) +let runtime_deps_of_ppx ppx = + (Findlib.query "ppx_sexp_conv").dependencies + |> List.filter_opt (fun { Findlib.name; _ } -> + if name = ppx || name = "ppx_deriving" then + None + else + Some name) + +let () = dispatch (fun hook -> + Ocb_stubblr.( + init & ccopt ~tags:["accelerate"] "-DACCELERATE -mssse3 -maes -mpclmul" + ) hook; + match hook with + | After_rules -> + let meta = "pkg/META" in + let meta_in = meta ^ ".in" in + rule meta ~dep:meta_in ~prod:meta (fun _ _ -> + let deps = String.concat " " (runtime_deps_of_ppx "ppx_sexp_conv") in + Echo([String.subst "PPX_SEXP_CONV_RUNTIME" deps + (Pathname.read meta_in)], + meta)) + | _ -> ()) diff --git a/pkg/META b/pkg/META.in similarity index 95% rename from pkg/META rename to pkg/META.in index 64a1dbf..c633212 100644 --- a/pkg/META +++ b/pkg/META.in @@ -1,6 +1,6 @@ version = "%%VERSION_NUM%%" description = "Simple crypto for the modern age" -requires = "cstruct zarith sexplib" +requires = "cstruct zarith sexplib PPX_SEXP_CONV_RUNTIME" archive(byte) = "nocrypto.cma" archive(native) = "nocrypto.cmxa" plugin(byte) = "nocrypto.cma"