Merge pull request #373 from rgrinberg/reason-preprocess-fix

Reason preprocess fix
This commit is contained in:
Rudi Grinberg 2017-12-18 23:25:10 +08:00 committed by GitHub
commit 2f8d95cdeb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 43 additions and 4 deletions

View File

@ -874,9 +874,8 @@ module PP = struct
(Deps.interpret sctx ~scope ~dir preprocessor_deps)
in
String_map.map modules ~f:(fun (m : Module.t) ->
let m = setup_reason_rules sctx ~dir m in
match Preprocess_map.find m.name preprocess with
| No_preprocessing -> m
| No_preprocessing -> setup_reason_rules sctx ~dir m
| Action action ->
pped_module m ~dir ~f:(fun _kind src dst ->
add_rule sctx
@ -895,8 +894,10 @@ module PP = struct
~dep_kind
~targets:(Static [dst])
~scope))
|> setup_reason_rules sctx ~dir
| Pps { pps; flags } ->
let ppx_exe = get_ppx_driver sctx pps ~dir ~dep_kind in
let m = setup_reason_rules sctx ~dir m in
pped_module m ~dir ~f:(fun kind src dst ->
add_rule sctx
(preprocessor_deps

View File

@ -5,7 +5,9 @@
(library
((name rlib)
(public_name rlib)))
(public_name rlib)
(preprocess
(per_module ((action (run ./pp/reasononlypp.exe ${<})) (cppome))))))
;; we want to make sure that .rei files are present
(alias

View File

@ -0,0 +1,4 @@
(jbuild_version 1)
(executable
((name reasononlypp)))

View File

@ -0,0 +1,16 @@
let () =
let fname = Sys.argv.(1) in
if Filename.check_suffix fname ".re"
|| Filename.check_suffix fname ".rei" then (
let ch = open_in fname in
let rec loop () =
match input_line ch with
| exception End_of_file -> ()
| line -> print_endline line; loop () in
loop ();
close_in ch
) else (
Format.eprintf "%s is not a reason source@.%!" fname;
exit 1
)

View File

@ -1,20 +1,31 @@
$ $JBUILDER runtest -j1 --root .
refmt bar.re.ml
ocamldep pp/reasononlypp.depends.ocamldep-output
refmt hello.re.ml
refmt pped.re.ml
ocamlc rlib.{cmi,cmo,cmt}
refmt foo.re.mli
refmt hello.re.mli
refmt pped.re.mli
ocamldep rlib.depends.ocamldep-output
ocamlc pp/reasononlypp.{cmi,cmo,cmt}
ocamlopt rlib.{cmx,o}
ocamlopt pp/reasononlypp.{cmx,o}
ocamlopt pp/reasononlypp.exe
reasononlypp cppome.pp.re
reasononlypp cppome.pp.rei
refmt cppome.pp.re.ml
refmt cppome.pp.re.mli
ocamldep rlib.depends.ocamldep-output
ocamldep rlib.dependsi.ocamldep-output
ocamlc rlib__Bar.{cmi,cmti}
ocamlc rlib__Cppome.{cmi,cmti}
ocamlc rlib__Foo.{cmi,cmti}
ocamlc rlib__Hello.{cmi,cmti}
ocamlc rlib__Pped.{cmi,cmti}
ocamlc rlib__Bar.{cmo,cmt}
ocamlopt rlib__Bar.{cmx,o}
ocamlc rlib__Cppome.{cmo,cmt}
ocamlopt rlib__Cppome.{cmx,o}
ocamlc rlib__Foo.{cmo,cmt}
ocamlopt rlib__Foo.{cmx,o}
ocamlc rlib__Hello.{cmo,cmt}
@ -32,6 +43,11 @@
"_build/install/default/lib/rlib/rlib__Bar.cmt"
"_build/install/default/lib/rlib/rlib__Bar.cmti"
"_build/install/default/lib/rlib/bar.mli"
"_build/install/default/lib/rlib/rlib__Cppome.cmi"
"_build/install/default/lib/rlib/rlib__Cppome.cmx"
"_build/install/default/lib/rlib/rlib__Cppome.cmt"
"_build/install/default/lib/rlib/rlib__Cppome.cmti"
"_build/install/default/lib/rlib/cppome.rei"
"_build/install/default/lib/rlib/rlib__Foo.cmi"
"_build/install/default/lib/rlib/rlib__Foo.cmx"
"_build/install/default/lib/rlib/rlib__Foo.cmt"