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:
Jeremie Dimino 2018-02-25 22:04:46 +00:00 committed by Jérémie Dimino
parent 138c920069
commit 4dc8d2456f
4 changed files with 36 additions and 44 deletions

View File

@ -112,7 +112,7 @@ let link_exe
SC.add_rules sctx (List.map rules ~f:(fun r -> libs_and_cm_and_flags >>> r))
let build_and_link_many
?obj_dir ~dir ~programs ~modules
~dir ~obj_dir ~programs ~modules
~scope
~linkages
?(requires=Build.return [])
@ -122,14 +122,6 @@ let build_and_link_many
?(js_of_ocaml=Jbuild.Js_of_ocaml.default)
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 =
String_map.map modules ~f:(Module.set_obj_name ~wrapper:None)
in
@ -162,9 +154,7 @@ let build_and_link_many
~top_sorted_modules
~js_of_ocaml
~flags
?link_flags));
?link_flags))
obj_dir
let build_and_link ?obj_dir ~dir ~program =
build_and_link_many ?obj_dir ~dir ~programs:[program]
let build_and_link ~dir ~obj_dir ~program =
build_and_link_many ~dir ~obj_dir ~programs:[program]

View File

@ -34,11 +34,11 @@ end
(** {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
: ?obj_dir:Path.t
-> dir:Path.t
: dir:Path.t
-> obj_dir:Path.t
-> program:Program.t
-> modules:Module.t String_map.t
-> scope:Scope.t
@ -49,11 +49,11 @@ val build_and_link
-> ?link_flags:(unit, string list) Build.t
-> ?js_of_ocaml:Jbuild.Js_of_ocaml.t
-> Super_context.t
-> Path.t
-> unit
val build_and_link_many
: ?obj_dir:Path.t
-> dir:Path.t
: dir:Path.t
-> obj_dir:Path.t
-> programs:Program.t list
-> modules:Module.t String_map.t
-> scope:Scope.t
@ -64,7 +64,7 @@ val build_and_link_many
-> ?link_flags:(unit, string list) Build.t
-> ?js_of_ocaml:Jbuild.Js_of_ocaml.t
-> Super_context.t
-> Path.t
-> unit
(** {1 Low-level functions} *)

View File

@ -813,19 +813,23 @@ module Gen(P : Params) = struct
compile_info
in
(* Use "eobjs" rather than "objs" to avoid a potential conflict
with a library of the same name *)
let obj_dir =
Exe.build_and_link_many sctx
~dir
~programs
~modules
~already_used
~scope
~linkages
~requires
~flags
~link_flags
~js_of_ocaml:exes.buildable.js_of_ocaml
Path.relative dir ("." ^ (List.hd programs).name ^ ".eobjs")
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.
requires = real_requires

View File

@ -68,16 +68,14 @@ let setup sctx ~dir ~(libs : Library.t list) ~scope =
|> Lib.Compile.make
|> Super_context.Libs.requires sctx ~dir ~has_dot_merlin:false
in
let (_obj_dir : Path.t) =
Exe.build_and_link sctx
~dir:utop_exe_dir
~obj_dir:utop_exe_dir
~program:{ name = exe_name ; main_module_name }
~modules
~scope
~linkages:[Exe.Linkage.custom]
~requires
~flags:(Ocaml_flags.append_common (Ocaml_flags.default ()) ["-w"; "-24"])
~link_flags:(Build.return ["-linkall"; "-warn-error"; "-31"])
in
Exe.build_and_link sctx
~dir:utop_exe_dir
~obj_dir:utop_exe_dir
~program:{ name = exe_name ; main_module_name }
~modules
~scope
~linkages:[Exe.Linkage.custom]
~requires
~flags:(Ocaml_flags.append_common (Ocaml_flags.default ()) ["-w"; "-24"])
~link_flags:(Build.return ["-linkall"; "-warn-error"; "-31"]);
add_module_rules sctx ~dir:utop_exe_dir requires