From c0a6438fcc05a2a2be16479c3e8314fb3c741d87 Mon Sep 17 00:00:00 2001 From: Jeremie Dimino Date: Thu, 12 Jul 2018 10:14:56 +0100 Subject: [PATCH] Fix reason support by keeping the original extension Signed-off-by: Jeremie Dimino --- src/preprocessing.ml | 16 +++--- .../test-cases/dune-ppx-driver-system/run.t | 6 +-- .../test-cases/js_of_ocaml/run.t | 16 +++--- .../test-cases/ppx-rewriter/run.t | 4 +- .../test-cases/private-public-overlap/run.t | 8 +-- test/blackbox-tests/test-cases/reason/run.t | 50 +++++++++---------- .../test-cases/scope-ppx-bug/run.t | 4 +- 7 files changed, 54 insertions(+), 50 deletions(-) diff --git a/src/preprocessing.ml b/src/preprocessing.ml index f01cd68c..8aeeae95 100644 --- a/src/preprocessing.ml +++ b/src/preprocessing.ml @@ -4,13 +4,17 @@ open Jbuild module SC = Super_context +let pped_path path ~obj_dir ~suffix = + (* We need to insert the suffix before the extension as some tools + inspect the extension *) + let base, ext = Filename.split_extension (Path.basename path) in + Path.relative obj_dir (base ^ suffix ^ ext) + let pped_module m ~obj_dir ~f = Module.map_files m ~f:(fun kind file -> - let pp_fname = - Path.relative obj_dir (Path.basename file.path ^ ".pp") - in - f kind file.path pp_fname; - { file with path = pp_fname }) + let pp_path = pped_path file.path ~obj_dir ~suffix:".pp" in + f kind file.path pp_path; + { file with path = pp_path }) module Driver = struct module M = struct @@ -422,7 +426,7 @@ let setup_reason_rules sctx ~obj_dir (m : Module.t) = let ml = { Module.File. syntax = OCaml - ; path = Path.relative obj_dir (Path.basename f.path ^ ".ast") + ; path = pped_path f.path ~obj_dir ~suffix:".ast" } in SC.add_rule sctx (rule f.path ml.path); diff --git a/test/blackbox-tests/test-cases/dune-ppx-driver-system/run.t b/test/blackbox-tests/test-cases/dune-ppx-driver-system/run.t index 67cca07e..a021d721 100644 --- a/test/blackbox-tests/test-cases/dune-ppx-driver-system/run.t +++ b/test/blackbox-tests/test-cases/dune-ppx-driver-system/run.t @@ -41,7 +41,7 @@ Same, but with error pointing to .ppx Test the argument syntax $ dune build test_ppx_args.cma - ppx .test_ppx_args.objs/test_ppx_args.ml.pp + ppx .test_ppx_args.objs/test_ppx_args.pp.ml .ppx/driver_print_args@foo/ppx.exe -arg1 -arg2 @@ -50,9 +50,9 @@ Test the argument syntax --cookie library-name="test_ppx_args" -o - .test_ppx_args.objs/test_ppx_args.ml.pp + .test_ppx_args.objs/test_ppx_args.pp.ml --impl test_ppx_args.ml Error: Rule failed to generate the following targets: - - .test_ppx_args.objs/test_ppx_args.ml.pp + - .test_ppx_args.objs/test_ppx_args.pp.ml [1] diff --git a/test/blackbox-tests/test-cases/js_of_ocaml/run.t b/test/blackbox-tests/test-cases/js_of_ocaml/run.t index 09260e82..d9581de4 100644 --- a/test/blackbox-tests/test-cases/js_of_ocaml/run.t +++ b/test/blackbox-tests/test-cases/js_of_ocaml/run.t @@ -2,18 +2,18 @@ ocamlc lib/stubs$ext_obj ocamlmklib lib/dllx_stubs$ext_dll,lib/libx_stubs$ext_lib ocamlopt .ppx/js_of_ocaml-ppx/ppx.exe - ppx lib/.x.objs/x.ml.pp - ocamldep lib/.x.objs/x.ml.pp.d + ppx lib/.x.objs/x.pp.ml + ocamldep lib/.x.objs/x.pp.ml.d ocamlc lib/.x.objs/x__.{cmi,cmo,cmt} ocamlopt lib/.x.objs/x__.{cmx,o} - ppx lib/.x.objs/y.ml.pp - ocamldep lib/.x.objs/y.ml.pp.d + ppx lib/.x.objs/y.pp.ml + ocamldep lib/.x.objs/y.pp.ml.d ocamlc lib/.x.objs/x__Y.{cmi,cmo,cmt} ocamlopt lib/.x.objs/x__Y.{cmx,o} - ppx bin/.technologic.eobjs/technologic.ml.pp - ocamldep bin/.technologic.eobjs/technologic.ml.pp.d - ppx bin/.technologic.eobjs/z.ml.pp - ocamldep bin/.technologic.eobjs/z.ml.pp.d + ppx bin/.technologic.eobjs/technologic.pp.ml + ocamldep bin/.technologic.eobjs/technologic.pp.ml.d + ppx bin/.technologic.eobjs/z.pp.ml + ocamldep bin/.technologic.eobjs/z.pp.ml.d js_of_ocaml .js/js_of_ocaml/js_of_ocaml.cma.js js_of_ocaml lib/.x.objs/x__Y.cmo.js ocamlc lib/.x.objs/x.{cmi,cmo,cmt} diff --git a/test/blackbox-tests/test-cases/ppx-rewriter/run.t b/test/blackbox-tests/test-cases/ppx-rewriter/run.t index c1b34fbf..234bf5c4 100644 --- a/test/blackbox-tests/test-cases/ppx-rewriter/run.t +++ b/test/blackbox-tests/test-cases/ppx-rewriter/run.t @@ -4,8 +4,8 @@ ocamlopt ppx/.fooppx.objs/fooppx.{cmx,o} ocamlopt ppx/fooppx.{a,cmxa} ocamlopt .ppx/jbuild/fooppx/ppx.exe - ppx .w_omp_driver.eobjs/w_omp_driver.ml.pp - ocamldep .w_omp_driver.eobjs/w_omp_driver.ml.pp.d + ppx .w_omp_driver.eobjs/w_omp_driver.pp.ml + ocamldep .w_omp_driver.eobjs/w_omp_driver.pp.ml.d ocamlc .w_omp_driver.eobjs/w_omp_driver.{cmi,cmo,cmt} ocamlopt .w_omp_driver.eobjs/w_omp_driver.{cmx,o} ocamlopt w_omp_driver.exe diff --git a/test/blackbox-tests/test-cases/private-public-overlap/run.t b/test/blackbox-tests/test-cases/private-public-overlap/run.t index 6f1f6d07..7e99dba5 100644 --- a/test/blackbox-tests/test-cases/private-public-overlap/run.t +++ b/test/blackbox-tests/test-cases/private-public-overlap/run.t @@ -15,8 +15,8 @@ On the other hand, public libraries may have private preprocessors ocamlopt .ppx_internal.objs/ppx_internal.{cmx,o} ocamlopt ppx_internal.{a,cmxa} ocamlopt .ppx/jbuild/ppx_internal@mylib/ppx.exe - ppx .mylib.objs/mylib.ml.pp - ocamldep .mylib.objs/mylib.ml.pp.d + ppx .mylib.objs/mylib.pp.ml + ocamldep .mylib.objs/mylib.pp.ml.d ocamlc .mylib.objs/mylib.{cmi,cmo,cmt} ocamlopt .mylib.objs/mylib.{cmx,o} ocamlopt mylib.{a,cmxa} @@ -33,8 +33,8 @@ Unless they introduce private runtime dependencies: ocamlopt .private_ppx.objs/private_ppx.{cmx,o} ocamlopt private_ppx.{a,cmxa} ocamlopt .ppx/jbuild/private_ppx@mylib/ppx.exe - ppx .mylib.objs/mylib.ml.pp - ocamldep .mylib.objs/mylib.ml.pp.d + ppx .mylib.objs/mylib.pp.ml + ocamldep .mylib.objs/mylib.pp.ml.d [1] However, public binaries may accept private dependencies diff --git a/test/blackbox-tests/test-cases/reason/run.t b/test/blackbox-tests/test-cases/reason/run.t index 07d72163..d0fb85a5 100644 --- a/test/blackbox-tests/test-cases/reason/run.t +++ b/test/blackbox-tests/test-cases/reason/run.t @@ -1,54 +1,54 @@ $ dune build @runtest @install-file --display short - refmt bar.re.ml - ocamldep .rlib.objs/bar.re.ml.d + refmt .rlib.objs/bar.ast.re + ocamldep .rlib.objs/bar.ast.re.d ocamldep pp/.reasononlypp.eobjs/reasononlypp.ml.d ocamlc pp/.reasononlypp.eobjs/reasononlypp.{cmi,cmo,cmt} ocamlopt pp/.reasononlypp.eobjs/reasononlypp.{cmx,o} ocamlopt pp/reasononlypp.exe - reasononlypp cppome.pp.re - refmt cppome.pp.re.ml - ocamldep .rlib.objs/cppome.pp.re.ml.d + reasononlypp .rlib.objs/cppome.pp.re + refmt .rlib.objs/cppome.pp.ast.re + ocamldep .rlib.objs/cppome.pp.ast.re.d ocamldep ppx/.reasonppx.objs/reasonppx.ml.d ocamlc ppx/.reasonppx.objs/reasonppx.{cmi,cmo,cmt} ocamlopt ppx/.reasonppx.objs/reasonppx.{cmx,o} ocamlopt ppx/reasonppx.{a,cmxa} ocamlopt .ppx/jbuild/reasonppx@rlib/ppx.exe - ppx foo.pp.ml + ppx .rlib.objs/foo.pp.ml ocamldep .rlib.objs/foo.pp.ml.d - refmt hello.re.ml - ppx hello.re.pp.ml - ocamldep .rlib.objs/hello.re.pp.ml.d - refmt pped.re.ml - ocamldep .rlib.objs/pped.re.ml.d + refmt .rlib.objs/hello.ast.re + ppx .rlib.objs/hello.ast.pp.re + ocamldep .rlib.objs/hello.ast.pp.re.d + refmt .rlib.objs/pped.ast.re + ocamldep .rlib.objs/pped.ast.re.d ocamlc .rlib.objs/rlib.{cmi,cmo,cmt} ocamlopt .rlib.objs/rlib.{cmx,o} ocamldep .rlib.objs/bar.mli.d ocamlc .rlib.objs/rlib__Bar.{cmi,cmti} ocamlopt .rlib.objs/rlib__Bar.{cmx,o} - refmt foo.re.mli - ppx foo.re.pp.mli - ocamldep .rlib.objs/foo.re.pp.mli.d + refmt .rlib.objs/foo.ast.rei + ppx .rlib.objs/foo.ast.pp.rei + ocamldep .rlib.objs/foo.ast.pp.rei.d ocamlc .rlib.objs/rlib__Foo.{cmi,cmti} ocamlopt .rlib.objs/rlib__Foo.{cmx,o} - refmt hello.re.mli - ppx hello.re.pp.mli - ocamldep .rlib.objs/hello.re.pp.mli.d + refmt .rlib.objs/hello.ast.rei + ppx .rlib.objs/hello.ast.pp.rei + ocamldep .rlib.objs/hello.ast.pp.rei.d ocamlc .rlib.objs/rlib__Hello.{cmi,cmti} ocamlopt .rlib.objs/rlib__Hello.{cmx,o} - refmt pped.re.mli - ocamldep .rlib.objs/pped.re.mli.d + refmt .rlib.objs/pped.ast.rei + ocamldep .rlib.objs/pped.ast.rei.d ocamlc .rlib.objs/rlib__Pped.{cmi,cmti} ocamlopt .rlib.objs/rlib__Pped.{cmx,o} - reasononlypp cppome.pp.rei - refmt cppome.pp.re.mli - ocamldep .rlib.objs/cppome.pp.re.mli.d + reasononlypp .rlib.objs/cppome.pp.rei + refmt .rlib.objs/cppome.pp.ast.rei + ocamldep .rlib.objs/cppome.pp.ast.rei.d ocamlc .rlib.objs/rlib__Cppome.{cmi,cmti} ocamlopt .rlib.objs/rlib__Cppome.{cmx,o} ocamlopt rlib.{a,cmxa} ocamlopt rlib.cmxs - reasononlypp rbin.pp.re - refmt rbin.pp.re.ml - ocamldep .rbin.eobjs/rbin.pp.re.ml.d + reasononlypp .rbin.eobjs/rbin.pp.re + refmt .rbin.eobjs/rbin.pp.ast.re + ocamldep .rbin.eobjs/rbin.pp.ast.re.d ocamlc .rbin.eobjs/rbin.{cmi,cmo,cmt} ocamlopt .rbin.eobjs/rbin.{cmx,o} ocamlopt rbin.exe diff --git a/test/blackbox-tests/test-cases/scope-ppx-bug/run.t b/test/blackbox-tests/test-cases/scope-ppx-bug/run.t index 5b5b6819..ebc4b4a0 100644 --- a/test/blackbox-tests/test-cases/scope-ppx-bug/run.t +++ b/test/blackbox-tests/test-cases/scope-ppx-bug/run.t @@ -11,8 +11,8 @@ ocamlc a/kernel/a_kernel.cma ocamlopt .ppx/jbuild/a.kernel/ppx.exe ocamlopt .ppx/jbuild/a/ppx.exe - ppx b/.b.objs/b.ml.pp - ocamldep b/.b.objs/b.ml.pp.d + ppx b/.b.objs/b.pp.ml + ocamldep b/.b.objs/b.pp.ml.d ocamlc b/.b.objs/b.{cmi,cmo,cmt} ocamlopt b/.b.objs/b.{cmx,o} ocamlopt b/b.{a,cmxa}