Pass obj_dir explicitely to Exe.build_and_link and don't return it
The only place where we used the default value was gen_rules
This commit is contained in:
parent
138c920069
commit
4dc8d2456f
18
src/exe.ml
18
src/exe.ml
|
@ -112,7 +112,7 @@ let link_exe
|
||||||
SC.add_rules sctx (List.map rules ~f:(fun r -> libs_and_cm_and_flags >>> r))
|
SC.add_rules sctx (List.map rules ~f:(fun r -> libs_and_cm_and_flags >>> r))
|
||||||
|
|
||||||
let build_and_link_many
|
let build_and_link_many
|
||||||
?obj_dir ~dir ~programs ~modules
|
~dir ~obj_dir ~programs ~modules
|
||||||
~scope
|
~scope
|
||||||
~linkages
|
~linkages
|
||||||
?(requires=Build.return [])
|
?(requires=Build.return [])
|
||||||
|
@ -122,14 +122,6 @@ let build_and_link_many
|
||||||
?(js_of_ocaml=Jbuild.Js_of_ocaml.default)
|
?(js_of_ocaml=Jbuild.Js_of_ocaml.default)
|
||||||
sctx
|
sctx
|
||||||
=
|
=
|
||||||
let item = (List.hd programs).Program.name in
|
|
||||||
let obj_dir =
|
|
||||||
match obj_dir with
|
|
||||||
(* Use "eobjs" rather than "objs" to avoid a potential conflict with a
|
|
||||||
library of the same name *)
|
|
||||||
| None -> Path.relative dir ("." ^ item ^ ".eobjs")
|
|
||||||
| Some d -> d
|
|
||||||
in
|
|
||||||
let modules =
|
let modules =
|
||||||
String_map.map modules ~f:(Module.set_obj_name ~wrapper:None)
|
String_map.map modules ~f:(Module.set_obj_name ~wrapper:None)
|
||||||
in
|
in
|
||||||
|
@ -162,9 +154,7 @@ let build_and_link_many
|
||||||
~top_sorted_modules
|
~top_sorted_modules
|
||||||
~js_of_ocaml
|
~js_of_ocaml
|
||||||
~flags
|
~flags
|
||||||
?link_flags));
|
?link_flags))
|
||||||
|
|
||||||
obj_dir
|
let build_and_link ~dir ~obj_dir ~program =
|
||||||
|
build_and_link_many ~dir ~obj_dir ~programs:[program]
|
||||||
let build_and_link ?obj_dir ~dir ~program =
|
|
||||||
build_and_link_many ?obj_dir ~dir ~programs:[program]
|
|
||||||
|
|
14
src/exe.mli
14
src/exe.mli
|
@ -34,11 +34,11 @@ end
|
||||||
|
|
||||||
(** {1 High-level functions} *)
|
(** {1 High-level functions} *)
|
||||||
|
|
||||||
(** Build and link one or more executables. Return the object directory. *)
|
(** Build and link one or more executables *)
|
||||||
|
|
||||||
val build_and_link
|
val build_and_link
|
||||||
: ?obj_dir:Path.t
|
: dir:Path.t
|
||||||
-> dir:Path.t
|
-> obj_dir:Path.t
|
||||||
-> program:Program.t
|
-> program:Program.t
|
||||||
-> modules:Module.t String_map.t
|
-> modules:Module.t String_map.t
|
||||||
-> scope:Scope.t
|
-> scope:Scope.t
|
||||||
|
@ -49,11 +49,11 @@ val build_and_link
|
||||||
-> ?link_flags:(unit, string list) Build.t
|
-> ?link_flags:(unit, string list) Build.t
|
||||||
-> ?js_of_ocaml:Jbuild.Js_of_ocaml.t
|
-> ?js_of_ocaml:Jbuild.Js_of_ocaml.t
|
||||||
-> Super_context.t
|
-> Super_context.t
|
||||||
-> Path.t
|
-> unit
|
||||||
|
|
||||||
val build_and_link_many
|
val build_and_link_many
|
||||||
: ?obj_dir:Path.t
|
: dir:Path.t
|
||||||
-> dir:Path.t
|
-> obj_dir:Path.t
|
||||||
-> programs:Program.t list
|
-> programs:Program.t list
|
||||||
-> modules:Module.t String_map.t
|
-> modules:Module.t String_map.t
|
||||||
-> scope:Scope.t
|
-> scope:Scope.t
|
||||||
|
@ -64,7 +64,7 @@ val build_and_link_many
|
||||||
-> ?link_flags:(unit, string list) Build.t
|
-> ?link_flags:(unit, string list) Build.t
|
||||||
-> ?js_of_ocaml:Jbuild.Js_of_ocaml.t
|
-> ?js_of_ocaml:Jbuild.Js_of_ocaml.t
|
||||||
-> Super_context.t
|
-> Super_context.t
|
||||||
-> Path.t
|
-> unit
|
||||||
|
|
||||||
(** {1 Low-level functions} *)
|
(** {1 Low-level functions} *)
|
||||||
|
|
||||||
|
|
|
@ -813,19 +813,23 @@ module Gen(P : Params) = struct
|
||||||
compile_info
|
compile_info
|
||||||
in
|
in
|
||||||
|
|
||||||
|
(* Use "eobjs" rather than "objs" to avoid a potential conflict
|
||||||
|
with a library of the same name *)
|
||||||
let obj_dir =
|
let obj_dir =
|
||||||
Exe.build_and_link_many sctx
|
Path.relative dir ("." ^ (List.hd programs).name ^ ".eobjs")
|
||||||
~dir
|
|
||||||
~programs
|
|
||||||
~modules
|
|
||||||
~already_used
|
|
||||||
~scope
|
|
||||||
~linkages
|
|
||||||
~requires
|
|
||||||
~flags
|
|
||||||
~link_flags
|
|
||||||
~js_of_ocaml:exes.buildable.js_of_ocaml
|
|
||||||
in
|
in
|
||||||
|
Exe.build_and_link_many sctx
|
||||||
|
~dir
|
||||||
|
~obj_dir
|
||||||
|
~programs
|
||||||
|
~modules
|
||||||
|
~already_used
|
||||||
|
~scope
|
||||||
|
~linkages
|
||||||
|
~requires
|
||||||
|
~flags
|
||||||
|
~link_flags
|
||||||
|
~js_of_ocaml:exes.buildable.js_of_ocaml;
|
||||||
|
|
||||||
{ Merlin.
|
{ Merlin.
|
||||||
requires = real_requires
|
requires = real_requires
|
||||||
|
|
22
src/utop.ml
22
src/utop.ml
|
@ -68,16 +68,14 @@ let setup sctx ~dir ~(libs : Library.t list) ~scope =
|
||||||
|> Lib.Compile.make
|
|> Lib.Compile.make
|
||||||
|> Super_context.Libs.requires sctx ~dir ~has_dot_merlin:false
|
|> Super_context.Libs.requires sctx ~dir ~has_dot_merlin:false
|
||||||
in
|
in
|
||||||
let (_obj_dir : Path.t) =
|
Exe.build_and_link sctx
|
||||||
Exe.build_and_link sctx
|
~dir:utop_exe_dir
|
||||||
~dir:utop_exe_dir
|
~obj_dir:utop_exe_dir
|
||||||
~obj_dir:utop_exe_dir
|
~program:{ name = exe_name ; main_module_name }
|
||||||
~program:{ name = exe_name ; main_module_name }
|
~modules
|
||||||
~modules
|
~scope
|
||||||
~scope
|
~linkages:[Exe.Linkage.custom]
|
||||||
~linkages:[Exe.Linkage.custom]
|
~requires
|
||||||
~requires
|
~flags:(Ocaml_flags.append_common (Ocaml_flags.default ()) ["-w"; "-24"])
|
||||||
~flags:(Ocaml_flags.append_common (Ocaml_flags.default ()) ["-w"; "-24"])
|
~link_flags:(Build.return ["-linkall"; "-warn-error"; "-31"]);
|
||||||
~link_flags:(Build.return ["-linkall"; "-warn-error"; "-31"])
|
|
||||||
in
|
|
||||||
add_module_rules sctx ~dir:utop_exe_dir requires
|
add_module_rules sctx ~dir:utop_exe_dir requires
|
||||||
|
|
Loading…
Reference in New Issue