Generate all the .pp files in the object directory
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
This commit is contained in:
parent
4d4eb5919e
commit
c0f9c32475
|
@ -548,7 +548,7 @@ module Gen(P : Install_rules.Params) = struct
|
||||||
(* Preprocess before adding the alias module as it doesn't need
|
(* Preprocess before adding the alias module as it doesn't need
|
||||||
preprocessing *)
|
preprocessing *)
|
||||||
let pp =
|
let pp =
|
||||||
Preprocessing.make sctx ~dir ~dep_kind ~scope
|
Preprocessing.make sctx ~dir ~obj_dir ~dep_kind ~scope
|
||||||
~preprocess:lib.buildable.preprocess
|
~preprocess:lib.buildable.preprocess
|
||||||
~preprocessor_deps:
|
~preprocessor_deps:
|
||||||
(SC.Deps.interpret sctx ~scope ~dir
|
(SC.Deps.interpret sctx ~scope ~dir
|
||||||
|
@ -805,6 +805,11 @@ module Gen(P : Install_rules.Params) = struct
|
||||||
let executables_rules ~dir ~all_modules ~dir_kind
|
let executables_rules ~dir ~all_modules ~dir_kind
|
||||||
~modules_partitioner ~scope ~compile_info
|
~modules_partitioner ~scope ~compile_info
|
||||||
(exes : Executables.t) =
|
(exes : Executables.t) =
|
||||||
|
(* Use "eobjs" rather than "objs" to avoid a potential conflict
|
||||||
|
with a library of the same name *)
|
||||||
|
let obj_dir =
|
||||||
|
Utils.executable_object_directory ~dir (List.hd exes.names |> snd)
|
||||||
|
in
|
||||||
let requires = Lib.Compile.requires compile_info in
|
let requires = Lib.Compile.requires compile_info in
|
||||||
let modules =
|
let modules =
|
||||||
parse_modules ~all_modules ~buildable:exes.buildable
|
parse_modules ~all_modules ~buildable:exes.buildable
|
||||||
|
@ -815,7 +820,7 @@ module Gen(P : Install_rules.Params) = struct
|
||||||
~scope ~dir
|
~scope ~dir
|
||||||
in
|
in
|
||||||
let pp =
|
let pp =
|
||||||
Preprocessing.make sctx ~dir ~dep_kind:Required
|
Preprocessing.make sctx ~dir ~obj_dir ~dep_kind:Required
|
||||||
~scope
|
~scope
|
||||||
~preprocess:exes.buildable.preprocess
|
~preprocess:exes.buildable.preprocess
|
||||||
~preprocessor_deps
|
~preprocessor_deps
|
||||||
|
@ -874,12 +879,6 @@ module Gen(P : Install_rules.Params) = struct
|
||||||
~standard:(Build.return [])
|
~standard:(Build.return [])
|
||||||
in
|
in
|
||||||
|
|
||||||
(* Use "eobjs" rather than "objs" to avoid a potential conflict
|
|
||||||
with a library of the same name *)
|
|
||||||
let obj_dir =
|
|
||||||
Utils.executable_object_directory ~dir (List.hd programs).name
|
|
||||||
in
|
|
||||||
|
|
||||||
let cctx =
|
let cctx =
|
||||||
Compilation_context.create ()
|
Compilation_context.create ()
|
||||||
~super_context:sctx
|
~super_context:sctx
|
||||||
|
|
|
@ -4,9 +4,11 @@ open Jbuild
|
||||||
|
|
||||||
module SC = Super_context
|
module SC = Super_context
|
||||||
|
|
||||||
let pped_module m ~f =
|
let pped_module m ~obj_dir ~f =
|
||||||
Module.map_files m ~f:(fun kind file ->
|
Module.map_files m ~f:(fun kind file ->
|
||||||
let pp_fname = Path.extend_basename file.path ~suffix:".pp" in
|
let pp_fname =
|
||||||
|
Path.relative obj_dir (Path.basename file.path ^ ".pp")
|
||||||
|
in
|
||||||
f kind file.path pp_fname;
|
f kind file.path pp_fname;
|
||||||
{ file with path = pp_fname })
|
{ file with path = pp_fname })
|
||||||
|
|
||||||
|
@ -401,7 +403,7 @@ let cookie_library_name lib_name =
|
||||||
|
|
||||||
(* Generate rules for the reason modules in [modules] and return a
|
(* Generate rules for the reason modules in [modules] and return a
|
||||||
a new module with only OCaml sources *)
|
a new module with only OCaml sources *)
|
||||||
let setup_reason_rules sctx (m : Module.t) =
|
let setup_reason_rules sctx ~obj_dir (m : Module.t) =
|
||||||
let ctx = SC.context sctx in
|
let ctx = SC.context sctx in
|
||||||
let refmt =
|
let refmt =
|
||||||
Artifacts.binary (SC.artifacts sctx) "refmt" ~hint:"opam install reason" in
|
Artifacts.binary (SC.artifacts sctx) "refmt" ~hint:"opam install reason" in
|
||||||
|
@ -420,7 +422,7 @@ let setup_reason_rules sctx (m : Module.t) =
|
||||||
let ml =
|
let ml =
|
||||||
{ Module.File.
|
{ Module.File.
|
||||||
syntax = OCaml
|
syntax = OCaml
|
||||||
; path = Path.extend_basename f.path ~suffix:".ast"
|
; path = Path.relative obj_dir (Path.basename f.path ^ ".ast")
|
||||||
}
|
}
|
||||||
in
|
in
|
||||||
SC.add_rule sctx (rule f.path ml.path);
|
SC.add_rule sctx (rule f.path ml.path);
|
||||||
|
@ -510,7 +512,7 @@ type t = (Module.t -> lint:bool -> Module.t) Per_module.t
|
||||||
|
|
||||||
let dummy = Per_module.for_all (fun m ~lint:_ -> m)
|
let dummy = Per_module.for_all (fun m ~lint:_ -> m)
|
||||||
|
|
||||||
let make sctx ~dir ~dep_kind ~lint ~preprocess
|
let make sctx ~dir ~obj_dir ~dep_kind ~lint ~preprocess
|
||||||
~preprocessor_deps ~lib_name ~scope ~dir_kind =
|
~preprocessor_deps ~lib_name ~scope ~dir_kind =
|
||||||
let preprocessor_deps =
|
let preprocessor_deps =
|
||||||
Build.memoize "preprocessor deps" preprocessor_deps
|
Build.memoize "preprocessor deps" preprocessor_deps
|
||||||
|
@ -522,13 +524,13 @@ let make sctx ~dir ~dep_kind ~lint ~preprocess
|
||||||
Per_module.map preprocess ~f:(function
|
Per_module.map preprocess ~f:(function
|
||||||
| Preprocess.No_preprocessing ->
|
| Preprocess.No_preprocessing ->
|
||||||
(fun m ~lint ->
|
(fun m ~lint ->
|
||||||
let ast = setup_reason_rules sctx m in
|
let ast = setup_reason_rules sctx m ~obj_dir in
|
||||||
if lint then lint_module ~ast ~source:m;
|
if lint then lint_module ~ast ~source:m;
|
||||||
ast)
|
ast)
|
||||||
| Action (loc, action) ->
|
| Action (loc, action) ->
|
||||||
(fun m ~lint ->
|
(fun m ~lint ->
|
||||||
let ast =
|
let ast =
|
||||||
pped_module m ~f:(fun _kind src dst ->
|
pped_module m ~obj_dir ~f:(fun _kind src dst ->
|
||||||
let bindings = Pform.Map.input_file src in
|
let bindings = Pform.Map.input_file src in
|
||||||
SC.add_rule sctx
|
SC.add_rule sctx
|
||||||
(preprocessor_deps
|
(preprocessor_deps
|
||||||
|
@ -547,8 +549,9 @@ let make sctx ~dir ~dep_kind ~lint ~preprocess
|
||||||
~dep_kind
|
~dep_kind
|
||||||
~bindings
|
~bindings
|
||||||
~targets:(Static [dst])
|
~targets:(Static [dst])
|
||||||
|
~targets_dir:obj_dir
|
||||||
~scope))
|
~scope))
|
||||||
|> setup_reason_rules sctx in
|
|> setup_reason_rules sctx ~obj_dir in
|
||||||
if lint then lint_module ~ast ~source:m;
|
if lint then lint_module ~ast ~source:m;
|
||||||
ast)
|
ast)
|
||||||
| Pps { loc; pps; flags } ->
|
| Pps { loc; pps; flags } ->
|
||||||
|
@ -574,9 +577,9 @@ let make sctx ~dir ~dep_kind ~lint ~preprocess
|
||||||
~standard:(Build.return [])))
|
~standard:(Build.return [])))
|
||||||
in
|
in
|
||||||
(fun m ~lint ->
|
(fun m ~lint ->
|
||||||
let ast = setup_reason_rules sctx m in
|
let ast = setup_reason_rules sctx m ~obj_dir in
|
||||||
if lint then lint_module ~ast ~source:m;
|
if lint then lint_module ~ast ~source:m;
|
||||||
pped_module ast ~f:(fun kind src dst ->
|
pped_module ast ~obj_dir ~f:(fun kind src dst ->
|
||||||
SC.add_rule sctx
|
SC.add_rule sctx
|
||||||
(promote_correction ~suffix:corrected_suffix
|
(promote_correction ~suffix:corrected_suffix
|
||||||
(Option.value_exn (Module.file m kind))
|
(Option.value_exn (Module.file m kind))
|
||||||
|
|
|
@ -10,6 +10,7 @@ val dummy : t
|
||||||
val make
|
val make
|
||||||
: Super_context.t
|
: Super_context.t
|
||||||
-> dir:Path.t
|
-> dir:Path.t
|
||||||
|
-> obj_dir:Path.t
|
||||||
-> dep_kind:Build.lib_dep_kind
|
-> dep_kind:Build.lib_dep_kind
|
||||||
-> lint:Jbuild.Preprocess_map.t
|
-> lint:Jbuild.Preprocess_map.t
|
||||||
-> preprocess:Jbuild.Preprocess_map.t
|
-> preprocess:Jbuild.Preprocess_map.t
|
||||||
|
|
|
@ -772,8 +772,8 @@ module Action = struct
|
||||||
Exn.code_error "Unexpected variable in step2"
|
Exn.code_error "Unexpected variable in step2"
|
||||||
["var", String_with_vars.Var.sexp_of_t pform]))
|
["var", String_with_vars.Var.sexp_of_t pform]))
|
||||||
|
|
||||||
let run sctx ~loc ~bindings t ~dir ~dep_kind
|
let run sctx ~loc ~bindings ~dir ~dep_kind
|
||||||
~targets:targets_written_by_user ~scope
|
~targets:targets_written_by_user ~scope ?(targets_dir=dir) t
|
||||||
: (Path.t Bindings.t, Action.t) Build.t =
|
: (Path.t Bindings.t, Action.t) Build.t =
|
||||||
let bindings = Pform.Map.superpose sctx.pforms bindings in
|
let bindings = Pform.Map.superpose sctx.pforms bindings in
|
||||||
let map_exe = map_exe sctx in
|
let map_exe = map_exe sctx in
|
||||||
|
@ -824,7 +824,7 @@ module Action = struct
|
||||||
in
|
in
|
||||||
let targets = Path.Set.to_list targets in
|
let targets = Path.Set.to_list targets in
|
||||||
List.iter targets ~f:(fun target ->
|
List.iter targets ~f:(fun target ->
|
||||||
if Path.parent_exn target <> dir then
|
if Path.parent_exn target <> targets_dir then
|
||||||
Loc.fail loc
|
Loc.fail loc
|
||||||
"This action has targets in a different directory than the current \
|
"This action has targets in a different directory than the current \
|
||||||
one, this is not allowed by dune at the moment:\n%s"
|
one, this is not allowed by dune at the moment:\n%s"
|
||||||
|
|
|
@ -240,11 +240,12 @@ module Action : sig
|
||||||
: t
|
: t
|
||||||
-> loc:Loc.t
|
-> loc:Loc.t
|
||||||
-> bindings:Pform.Map.t
|
-> bindings:Pform.Map.t
|
||||||
-> Action.Unexpanded.t
|
|
||||||
-> dir:Path.t
|
-> dir:Path.t
|
||||||
-> dep_kind:Build.lib_dep_kind
|
-> dep_kind:Build.lib_dep_kind
|
||||||
-> targets:targets
|
-> targets:targets
|
||||||
-> scope:Scope.t
|
-> scope:Scope.t
|
||||||
|
-> ?targets_dir:Path.t (* default: dir *)
|
||||||
|
-> Action.Unexpanded.t
|
||||||
-> (Path.t Bindings.t, Action.t) Build.t
|
-> (Path.t Bindings.t, Action.t) Build.t
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ Same, but with error pointing to .ppx
|
||||||
Test the argument syntax
|
Test the argument syntax
|
||||||
|
|
||||||
$ dune build test_ppx_args.cma
|
$ dune build test_ppx_args.cma
|
||||||
ppx test_ppx_args.ml.pp
|
ppx .test_ppx_args.objs/test_ppx_args.ml.pp
|
||||||
.ppx/driver_print_args@foo/ppx.exe
|
.ppx/driver_print_args@foo/ppx.exe
|
||||||
-arg1
|
-arg1
|
||||||
-arg2
|
-arg2
|
||||||
|
@ -50,9 +50,9 @@ Test the argument syntax
|
||||||
--cookie
|
--cookie
|
||||||
library-name="test_ppx_args"
|
library-name="test_ppx_args"
|
||||||
-o
|
-o
|
||||||
test_ppx_args.ml.pp
|
.test_ppx_args.objs/test_ppx_args.ml.pp
|
||||||
--impl
|
--impl
|
||||||
test_ppx_args.ml
|
test_ppx_args.ml
|
||||||
Error: Rule failed to generate the following targets:
|
Error: Rule failed to generate the following targets:
|
||||||
- test_ppx_args.ml.pp
|
- .test_ppx_args.objs/test_ppx_args.ml.pp
|
||||||
[1]
|
[1]
|
||||||
|
|
|
@ -2,17 +2,17 @@
|
||||||
ocamlc lib/stubs$ext_obj
|
ocamlc lib/stubs$ext_obj
|
||||||
ocamlmklib lib/dllx_stubs$ext_dll,lib/libx_stubs$ext_lib
|
ocamlmklib lib/dllx_stubs$ext_dll,lib/libx_stubs$ext_lib
|
||||||
ocamlopt .ppx/js_of_ocaml-ppx/ppx.exe
|
ocamlopt .ppx/js_of_ocaml-ppx/ppx.exe
|
||||||
ppx lib/x.ml.pp
|
ppx lib/.x.objs/x.ml.pp
|
||||||
ocamldep lib/.x.objs/x.ml.pp.d
|
ocamldep lib/.x.objs/x.ml.pp.d
|
||||||
ocamlc lib/.x.objs/x__.{cmi,cmo,cmt}
|
ocamlc lib/.x.objs/x__.{cmi,cmo,cmt}
|
||||||
ocamlopt lib/.x.objs/x__.{cmx,o}
|
ocamlopt lib/.x.objs/x__.{cmx,o}
|
||||||
ppx lib/y.ml.pp
|
ppx lib/.x.objs/y.ml.pp
|
||||||
ocamldep lib/.x.objs/y.ml.pp.d
|
ocamldep lib/.x.objs/y.ml.pp.d
|
||||||
ocamlc lib/.x.objs/x__Y.{cmi,cmo,cmt}
|
ocamlc lib/.x.objs/x__Y.{cmi,cmo,cmt}
|
||||||
ocamlopt lib/.x.objs/x__Y.{cmx,o}
|
ocamlopt lib/.x.objs/x__Y.{cmx,o}
|
||||||
ppx bin/technologic.ml.pp
|
ppx bin/.technologic.eobjs/technologic.ml.pp
|
||||||
ocamldep bin/.technologic.eobjs/technologic.ml.pp.d
|
ocamldep bin/.technologic.eobjs/technologic.ml.pp.d
|
||||||
ppx bin/z.ml.pp
|
ppx bin/.technologic.eobjs/z.ml.pp
|
||||||
ocamldep bin/.technologic.eobjs/z.ml.pp.d
|
ocamldep bin/.technologic.eobjs/z.ml.pp.d
|
||||||
js_of_ocaml .js/js_of_ocaml/js_of_ocaml.cma.js
|
js_of_ocaml .js/js_of_ocaml/js_of_ocaml.cma.js
|
||||||
js_of_ocaml lib/.x.objs/x__Y.cmo.js
|
js_of_ocaml lib/.x.objs/x__Y.cmo.js
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
ocamlopt ppx/.fooppx.objs/fooppx.{cmx,o}
|
ocamlopt ppx/.fooppx.objs/fooppx.{cmx,o}
|
||||||
ocamlopt ppx/fooppx.{a,cmxa}
|
ocamlopt ppx/fooppx.{a,cmxa}
|
||||||
ocamlopt .ppx/jbuild/fooppx/ppx.exe
|
ocamlopt .ppx/jbuild/fooppx/ppx.exe
|
||||||
ppx w_omp_driver.ml.pp
|
ppx .w_omp_driver.eobjs/w_omp_driver.ml.pp
|
||||||
ocamldep .w_omp_driver.eobjs/w_omp_driver.ml.pp.d
|
ocamldep .w_omp_driver.eobjs/w_omp_driver.ml.pp.d
|
||||||
ocamlc .w_omp_driver.eobjs/w_omp_driver.{cmi,cmo,cmt}
|
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.eobjs/w_omp_driver.{cmx,o}
|
||||||
|
|
|
@ -15,7 +15,7 @@ On the other hand, public libraries may have private preprocessors
|
||||||
ocamlopt .ppx_internal.objs/ppx_internal.{cmx,o}
|
ocamlopt .ppx_internal.objs/ppx_internal.{cmx,o}
|
||||||
ocamlopt ppx_internal.{a,cmxa}
|
ocamlopt ppx_internal.{a,cmxa}
|
||||||
ocamlopt .ppx/jbuild/ppx_internal@mylib/ppx.exe
|
ocamlopt .ppx/jbuild/ppx_internal@mylib/ppx.exe
|
||||||
ppx mylib.ml.pp
|
ppx .mylib.objs/mylib.ml.pp
|
||||||
ocamldep .mylib.objs/mylib.ml.pp.d
|
ocamldep .mylib.objs/mylib.ml.pp.d
|
||||||
ocamlc .mylib.objs/mylib.{cmi,cmo,cmt}
|
ocamlc .mylib.objs/mylib.{cmi,cmo,cmt}
|
||||||
ocamlopt .mylib.objs/mylib.{cmx,o}
|
ocamlopt .mylib.objs/mylib.{cmx,o}
|
||||||
|
@ -33,7 +33,7 @@ Unless they introduce private runtime dependencies:
|
||||||
ocamlopt .private_ppx.objs/private_ppx.{cmx,o}
|
ocamlopt .private_ppx.objs/private_ppx.{cmx,o}
|
||||||
ocamlopt private_ppx.{a,cmxa}
|
ocamlopt private_ppx.{a,cmxa}
|
||||||
ocamlopt .ppx/jbuild/private_ppx@mylib/ppx.exe
|
ocamlopt .ppx/jbuild/private_ppx@mylib/ppx.exe
|
||||||
ppx mylib.ml.pp
|
ppx .mylib.objs/mylib.ml.pp
|
||||||
ocamldep .mylib.objs/mylib.ml.pp.d
|
ocamldep .mylib.objs/mylib.ml.pp.d
|
||||||
[1]
|
[1]
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
ocamlc a/kernel/a_kernel.cma
|
ocamlc a/kernel/a_kernel.cma
|
||||||
ocamlopt .ppx/jbuild/a.kernel/ppx.exe
|
ocamlopt .ppx/jbuild/a.kernel/ppx.exe
|
||||||
ocamlopt .ppx/jbuild/a/ppx.exe
|
ocamlopt .ppx/jbuild/a/ppx.exe
|
||||||
ppx b/b.ml.pp
|
ppx b/.b.objs/b.ml.pp
|
||||||
ocamldep b/.b.objs/b.ml.pp.d
|
ocamldep b/.b.objs/b.ml.pp.d
|
||||||
ocamlc b/.b.objs/b.{cmi,cmo,cmt}
|
ocamlc b/.b.objs/b.{cmi,cmo,cmt}
|
||||||
ocamlopt b/.b.objs/b.{cmx,o}
|
ocamlopt b/.b.objs/b.{cmx,o}
|
||||||
|
|
Loading…
Reference in New Issue