From ba530c73b96861fb8f9b3b7b9e7bda98212aa9ce Mon Sep 17 00:00:00 2001 From: Jeremie Dimino Date: Tue, 26 Apr 2016 17:03:48 +0100 Subject: [PATCH] 113.33.03 --- META.ab | 9 ++-- Makefile | 4 +- _oasis | 37 +++++++------- _tags | 2 +- install.ml | 10 ++++ js-utils/gen_install.ml | 102 --------------------------------------- js-utils/install_tags.ml | 13 ----- myocamlbuild.ml | 25 ++-------- opam | 7 +-- 9 files changed, 47 insertions(+), 162 deletions(-) create mode 100644 install.ml delete mode 100644 js-utils/gen_install.ml delete mode 100644 js-utils/install_tags.ml diff --git a/META.ab b/META.ab index 8dc31d222..1597907eb 100644 --- a/META.ab +++ b/META.ab @@ -1,8 +1,9 @@ version = "$(pkg_version)" description = "Monadic let-bindings" requires = "ppx_core ppx_driver" -archive(ppx_driver, byte ) = "ppx_let.cma" -archive(ppx_driver, native ) = "ppx_let.cmxa" -archive(ppx_driver, native, plugin) = "ppx_let.cmxs" +archive(ppx_driver, byte ) = "ppx_let.cma" +archive(ppx_driver, native) = "ppx_let.cmxa" +plugin(ppx_driver, byte ) = "ppx_let.cma" +plugin(ppx_driver, native) = "ppx_let.cmxs" exists_if = "ppx_let.cma" -ppx(-ppx_driver) = "./ppx" +ppx(-ppx_driver,-custom_ppx) = "./ppx" diff --git a/Makefile b/Makefile index d97d2e123..07639e816 100644 --- a/Makefile +++ b/Makefile @@ -26,8 +26,8 @@ all: $(SETUP) ./$(SETUP) -all $(ALLFLAGS) $(MAKE) $(NAME).install -$(NAME).install: js-utils/gen_install.ml setup.log setup.data - ocaml -I js-utils js-utils/gen_install.ml +$(NAME).install: install.ml setup.log setup.data + ocaml install.ml install: $(NAME).install opam-installer -i --prefix $(PREFIX) $(NAME).install diff --git a/_oasis b/_oasis index 0e8538ec4..0ce6f20d9 100644 --- a/_oasis +++ b/_oasis @@ -1,20 +1,23 @@ -OASISFormat: 0.4 -OCamlVersion: >= 4.02.3 -FindlibVersion: >= 1.3.2 -Name: ppx_let -Version: 113.33.00 -Synopsis: Monadic let-bindings -Authors: Jane Street Group, LLC -Copyrights: (C) 2015-2016 Jane Street Group LLC -Maintainers: Jane Street Group, LLC -License: Apache-2.0 -LicenseFile: LICENSE.txt -Homepage: https://github.com/janestreet/ppx_let -Plugins: StdFiles (0.3), DevFiles (0.3), META (0.3) -XStdFilesAUTHORS: false -XStdFilesREADME: false -BuildTools: ocamlbuild -FilesAB: META.ab +OASISFormat: 0.4 +OCamlVersion: >= 4.02.3 +FindlibVersion: >= 1.3.2 +Name: ppx_let +Version: 113.33.03 +Synopsis: Monadic let-bindings +Authors: Jane Street Group, LLC +Copyrights: (C) 2015-2016 Jane Street Group LLC +Maintainers: Jane Street Group, LLC +License: Apache-2.0 +LicenseFile: LICENSE.txt +Homepage: https://github.com/janestreet/ppx_let +Plugins: StdFiles (0.3), DevFiles (0.3) +XStdFilesAUTHORS: false +XStdFilesREADME: false +BuildTools: ocamlbuild +BetaFeatures: section_object +AlphaFeatures: ocamlbuild_more_args +XOCamlbuildPluginTags: package(js-build-tools.ocamlbuild_goodies) +FilesAB: META.ab Description: Part of the Jane Street's PPX rewriters collection. diff --git a/_tags b/_tags index 48f85ad4b..eed4cdef9 100644 --- a/_tags +++ b/_tags @@ -1,7 +1,7 @@ <**/*.ml{,i}>: warn(-40), no_alias_deps <**/*>: thread # This prevents the implicit addition of -ppx options by ocamlfind -<**/*.ml{,i}>: predicate(ppx_driver) +<**/*>: predicate(custom_ppx) : predicate(ppx_driver) : linkall # OASIS_START diff --git a/install.ml b/install.ml new file mode 100644 index 000000000..86d1afc2b --- /dev/null +++ b/install.ml @@ -0,0 +1,10 @@ +#use "topfind";; +#require "js-build-tools.oasis2opam_install";; + +open Oasis2opam_install;; + +generate ~package:"ppx_let" + [ oasis_lib "ppx_let" + ; file "META" ~section:"lib" + ; oasis_exe "ppx" ~dest:"../lib/ppx_let/ppx" + ] diff --git a/js-utils/gen_install.ml b/js-utils/gen_install.ml deleted file mode 100644 index 39db64239..000000000 --- a/js-utils/gen_install.ml +++ /dev/null @@ -1,102 +0,0 @@ -(* Generate .install from setup.log *) - -#use "install_tags.ml" - -module String_map = Map.Make(String) -let string_map_of_list = - List.fold_left - (fun acc (k, v) -> - assert (not (String_map.mem k acc)); - String_map.add k v acc) - String_map.empty - -let lines_of_file fn = - let ic = open_in fn in - let rec loop acc = - match input_line ic with - | exception End_of_file -> - close_in ic; - List.rev acc - | line -> - loop (line :: acc) - in - loop [] - -let read_setup_log () = - lines_of_file "setup.log" - |> List.map (fun line -> Scanf.sscanf line "%S %S" (fun tag arg -> (tag, arg))) - -let read_setup_data () = - lines_of_file "setup.data" - |> List.map (fun line -> Scanf.sscanf line "%[^=]=%S" (fun k v -> (k, v))) - -let remove_cwd = - let prefix = Sys.getcwd () ^ "/" in - let len_prefix = String.length prefix in - fun fn -> - let len = String.length fn in - if len >= len_prefix && String.sub fn 0 len_prefix = prefix then - String.sub fn len_prefix (len - len_prefix) - else - fn - -let gen_section oc name files = - let pr fmt = Printf.fprintf oc (fmt ^^ "\n") in - pr "%s: [" name; - List.iter - (fun (src, dst) -> - let src = remove_cwd src in - let dst = - match dst with - | None -> Filename.basename src - | Some fn -> fn - in - if src = dst then - pr " %S" src - else - pr " %S {%S}" src dst) - files; - pr "]" - -let rec filter_log tags log acc = - match log with - | [] -> acc - | (tag, fname) :: rest -> - match String_map.find tag tags with - | exception Not_found -> filter_log tags rest acc - | dst -> filter_log tags rest ((fname, dst) :: acc) - -let () = - let log = read_setup_log () in - let setup_data = read_setup_data () in - let ext_dll = - match List.assoc "ext_dll" setup_data with - | ext -> ext - | exception Not_found -> ".so" - in - let merge name files map = - match String_map.find name map with - | files' -> String_map.add name (files @ files') map - | exception Not_found -> String_map.add name files map - in - let sections = - List.fold_left - (fun acc (name, tags, extra_files) -> - let tags = string_map_of_list tags in - let files = filter_log tags log [] @ extra_files in - if name = "lib" then - let stubs, others = - List.partition - (fun (fn, _) -> Filename.check_suffix fn ext_dll) - files - in - merge "lib" others (merge "stublibs" stubs acc) - else - merge name files acc) - String_map.empty sections - |> String_map.bindings - |> List.filter (fun (_, l) -> l <> []) - in - let oc = open_out (package_name ^ ".install") in - List.iter (fun (name, files) -> gen_section oc name files) sections; - close_out oc diff --git a/js-utils/install_tags.ml b/js-utils/install_tags.ml deleted file mode 100644 index 6f8f3879c..000000000 --- a/js-utils/install_tags.ml +++ /dev/null @@ -1,13 +0,0 @@ -let package_name = "ppx_let" - -let sections = - [ ("lib", - [ ("built_lib_ppx_let", None) - ], - [ ("META", None) - ]) - ; ("bin", - [ ("built_exec_ppx", Some "../lib/ppx_let/ppx") - ], - []) - ] diff --git a/myocamlbuild.ml b/myocamlbuild.ml index 46889547f..326d29383 100644 --- a/myocamlbuild.ml +++ b/myocamlbuild.ml @@ -2,28 +2,13 @@ (* OASIS_STOP *) # 3 "myocamlbuild.ml" -(* Temporary hacks *) -let js_hacks = function - | After_rules -> - rule "Generate a cmxs from a cmxa" - ~dep:"%.cmxa" - ~prod:"%.cmxs" - ~insert:`top - (fun env _ -> - Cmd (S [ !Options.ocamlopt - ; A "-shared" - ; A "-linkall" - ; A "-I"; A (Pathname.dirname (env "%")) - ; A (env "%.cmxa") - ; A "-o" - ; A (env "%.cmxs") - ])); +module JS = Jane_street_ocamlbuild_goodies - (* Pass -predicates to ocamldep *) - pflag ["ocaml"; "ocamldep"] "predicate" (fun s -> S [A "-predicates"; A s]) - | _ -> () +let dev_mode = true let () = Ocamlbuild_plugin.dispatch (fun hook -> - js_hacks hook; + JS.alt_cmxs_of_cmxa_rule hook; + JS.pass_predicates_to_ocamldep hook; + if dev_mode && not Sys.win32 then JS.track_external_deps hook; dispatch_default hook) diff --git a/opam b/opam index ce1c4a254..3e8ed8000 100644 --- a/opam +++ b/opam @@ -10,9 +10,10 @@ build: [ [make] ] depends: [ - "ocamlbuild" {build} - "oasis" {build & >= "0.4"} - "ocamlfind" {build & >= "1.3.2"} + "ocamlbuild" {build} + "oasis" {build & >= "0.4"} + "ocamlfind" {build & >= "1.3.2"} + "js-build-tools" {build} "ppx_core" "ppx_driver" ]