pax_global_header00006660000000000000000000000064134662154320014520gustar00rootroot0000000000000052 comment=6c73974ec50a91265c1d411e461f9de82a3cbd5f ppxfind-1.3/000077500000000000000000000000001346621543200130335ustar00rootroot00000000000000ppxfind-1.3/.gitignore000066400000000000000000000000311346621543200150150ustar00rootroot00000000000000_build *.merlin *.installppxfind-1.3/.ocp-indent000066400000000000000000000000131346621543200150660ustar00rootroot00000000000000JaneStreet ppxfind-1.3/CHANGES.md000066400000000000000000000003721346621543200144270ustar00rootroot00000000000000# 1.3 - Fix compilation warnings under 4.02 (#5, @ELLIOTTCABLE) - Switch to dune and opam 2.0 (@diml) # 1.2 - Fix compatibility with OCaml 4.02 (#1, ZAN DoYe) # 1.1 - Fix compatibility with OCaml 4.04 (#1, Marcello Seri) # 1.0 Initial import ppxfind-1.3/LICENSE.md000066400000000000000000000027561346621543200144510ustar00rootroot00000000000000Copyright (c) 2011, Jeremie Dimino All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Jeremie Dimino nor the names of his contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ppxfind-1.3/Makefile000066400000000000000000000007101346621543200144710ustar00rootroot00000000000000INSTALL_ARGS := $(if $(PREFIX),--prefix $(PREFIX),) .PHONY: all all: dune build @install .PHONY: install install: dune install $(INSTALL_ARGS) .PHONY: uninstall uninstall: dune uninstall $(INSTALL_ARGS) .PHONY: reinstall reinstall: $(MAKE) uninstall $(MAKE) install .PHONY: test test: dune runtest .PHONY: clean clean: dune clean .PHONY: all-supported-ocaml-versions all-supported-ocaml-versions: dune build --workspace jbuild-workspace.dev ppxfind-1.3/README.md000066400000000000000000000017311346621543200143140ustar00rootroot00000000000000ppxfind - ocamlfind ppx tool ============================ Ppxfind is a small command line tool that allow to apply ppx rewriters installed on the system on a file. It supports both new style ppx rewriters (driverised) and old styles ones. At the moment new styles ppx rewriters are executed in byte-code mode as Ppxfind relies on dynamic loading and the packaging of a lot of ppx rewriters is incomplete, i.e. the cmxs files are missing. Using old styles ppx rewriters with jbuilder -------------------------------------------- Ppxfind allows to use old style ppx rewriters with jbuilder. This is not the recommended way of using ppx rewriters with jbuilder and in particular it is slower and breaks composability. However, if you need to use a ppx rewriter that is not compatible with the new style with jbuilder, you can use Ppxfind as a workaround. Simply write this in your `jbuild` file: ```scheme (preprocess (action (run ppxfind -legacy ppx1,ppx2,... --as-pp ${<}))) ``` ppxfind-1.3/dune-project000066400000000000000000000000371346621543200153550ustar00rootroot00000000000000(lang dune 1.0) (name ppxfind) ppxfind-1.3/dune-workspace.dev000066400000000000000000000003621346621543200164630ustar00rootroot00000000000000(lang dune 1.0) ;; This file is used by `make all-supported-ocaml-versions` (context (opam (switch 4.02.3))) (context (opam (switch 4.03.0))) (context (opam (switch 4.04.2))) (context (opam (switch 4.05.0))) (context (opam (switch 4.06.0))) ppxfind-1.3/pkg/000077500000000000000000000000001346621543200136145ustar00rootroot00000000000000ppxfind-1.3/pkg/pkg.ml000066400000000000000000000000561346621543200147300ustar00rootroot00000000000000#use "topfind" #require "topkg-jbuilder.auto" ppxfind-1.3/ppxfind.opam000066400000000000000000000012371346621543200153640ustar00rootroot00000000000000opam-version: "2.0" maintainer: "jeremie@dimino.org" authors: ["Jérémie Dimino"] license: "BSD3" homepage: "https://github.com/diml/ppxfind" bug-reports: "https://github.com/diml/ppxfind/issues" dev-repo: "git+https://github.com/diml/ppxfind.git" doc: "https://diml.github.io/ppxfind/" build: [ ["dune" "build" "-p" name "-j" jobs] ] depends: [ "dune" {build & >= "1.0"} "ocaml-migrate-parsetree" "ocamlfind" "ocaml" {>= "4.02.3"} ] conflicts: [ "dune" {= "1.2.0" | = "1.2.1"} ] synopsis: "Tool combining ocamlfind and ppx" description: """ Ppxfind is a small command line tool that among other things allows to use old style ppx rewriters with jbuilder. """ ppxfind-1.3/src/000077500000000000000000000000001346621543200136225ustar00rootroot00000000000000ppxfind-1.3/src/dune000066400000000000000000000002621346621543200145000ustar00rootroot00000000000000(executable (name ppxfind) (public_name ppxfind) (libraries dynlink findlib.dynload ocaml-migrate-parsetree compiler-libs.common str) (link_flags -linkall) (modes byte)) ppxfind-1.3/src/ppxfind.ml000066400000000000000000000065161346621543200156340ustar00rootroot00000000000000open StdLabels let split_on_char ~sep s = let open String in let r = ref [] in let j = ref (length s) in for i = length s - 1 downto 0 do if unsafe_get s i = sep then begin r := sub s ~pos:(i + 1) ~len:(!j - i - 1) :: !r; j := i end done; sub s ~pos:0 ~len:!j :: !r let linked_in = ["findlib.dynload"; "dynlink"; "ocaml-migrate-parsetree"; "compiler-libs.common"; "str"] module List = struct include List let concat_map l ~f = List.concat (List.map l ~f) end let init_findlib preds = Findlib.init (); (* Record linked in packages *) List.iter (Findlib.package_deep_ancestors [] linked_in) ~f:(Findlib.record_package Record_core); Findlib.record_package_predicates ((if Dynlink.is_native then "native" else "byte") :: preds) let package_property preds pkg var = match Findlib.package_property preds pkg var with | x -> Some x | exception Not_found -> None let split_words = Str.split (Str.regexp "[ \t\n\r]+") let setup_external_ppxs pkgs = let preds = [] in let pkgs = List.map (Findlib.package_deep_ancestors preds pkgs) ~f:(fun pkg -> (pkg, Findlib.package_directory pkg, package_property preds pkg "ppx", package_property preds pkg "ppxopt")) in let ppxopts = List.concat_map pkgs ~f:(fun (_pkg, dir, _ppx, ppxopt) -> match ppxopt with | None -> [] | Some ppxopt -> List.concat_map (split_words ppxopt) ~f:(fun opt -> match split_on_char ~sep:',' opt with | pkg' :: (_ :: _ as opts) -> List.map opts ~f:(fun opt -> (pkg', Findlib.resolve_path opt ~base:dir ~explicit:true)) | _ -> [])) in let ppxs = List.concat_map pkgs ~f:(fun (pkg, dir, ppx, _ppxopt) -> match ppx with | None -> [] | Some ppx -> let ppx = Findlib.resolve_path ~base:dir ~explicit:true ppx in let opts = List.filter ppxopts ~f:(fun (p, _) -> p = pkg) |> List.map ~f:snd in [ String.concat ~sep:" " (ppx :: opts) ]) in Clflags.all_ppx := ppxs; let tool = "ppxfind" in Migrate_parsetree.Driver.register ~name:tool (module Migrate_parsetree.OCaml_current) (fun _ _ -> { Ast_mapper.default_mapper with structure = (fun _ x -> Pparse.apply_rewriters_str ~tool_name:tool x) ; signature = (fun _ x -> Pparse.apply_rewriters_sig ~tool_name:tool x) }) let main () = let legacy = ref false in let debug = ref false in let args = Arg.align [ "-legacy", Set legacy, " Use the legacy ppx system" ; "-debug", Set debug, " Enable debug messages" ] in let usage = "ppxfind [options] ppx1,ppx2,... [ppx-options] [file]" in let anon pkgs = let pkgs = split_on_char ~sep:',' pkgs in if not !legacy then begin init_findlib ["ppx_driver"]; Dynlink.allow_unsafe_modules true; Fl_dynload.load_packages ~debug:!debug pkgs end else begin init_findlib []; Clflags.verbose := !debug; setup_external_ppxs pkgs end; (* Chain to omp *) Sys.argv.(!Arg.current) <- Sys.argv.(0); Migrate_parsetree.Driver.run_main () in Arg.parse args anon usage; prerr_endline "ppxfind: no packages given"; exit 2 let () = try main () with | Dynlink.Error error -> Printf.eprintf "ppxfoo: %s\n%!" (Dynlink.error_message error); exit 1