Merge pull request #551 from rgrinberg/revert-utop-gen
Revert "Use _utop.ml to avoid creating a separate dir for utop rules"
This commit is contained in:
commit
5017ac2a2a
15
src/exe.ml
15
src/exe.ml
|
@ -112,6 +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
|
||||||
~loc ~dir ~programs ~modules
|
~loc ~dir ~programs ~modules
|
||||||
~scope
|
~scope
|
||||||
~linkages
|
~linkages
|
||||||
|
@ -127,9 +128,13 @@ let build_and_link_many
|
||||||
sctx
|
sctx
|
||||||
=
|
=
|
||||||
let item = (List.hd programs).Program.name in
|
let item = (List.hd programs).Program.name in
|
||||||
(* Use "eobjs" rather than "objs" to avoid a potential conflict with a library of the
|
let obj_dir =
|
||||||
same name *)
|
match obj_dir with
|
||||||
let obj_dir = Path.relative dir ("." ^ item ^ ".eobjs") in
|
(* 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 dep_kind = Build.Required in
|
let dep_kind = Build.Required 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)
|
||||||
|
@ -193,5 +198,5 @@ let build_and_link_many
|
||||||
|
|
||||||
(obj_dir, real_requires)
|
(obj_dir, real_requires)
|
||||||
|
|
||||||
let build_and_link ~loc ~dir ~program =
|
let build_and_link ?obj_dir ~loc ~dir ~program =
|
||||||
build_and_link_many ~loc ~dir ~programs:[program]
|
build_and_link_many ?obj_dir ~loc ~dir ~programs:[program]
|
||||||
|
|
|
@ -38,7 +38,8 @@ end
|
||||||
directory and the resolved list of library dependencies. *)
|
directory and the resolved list of library dependencies. *)
|
||||||
|
|
||||||
val build_and_link
|
val build_and_link
|
||||||
: loc:Loc.t
|
: ?obj_dir:Path.t
|
||||||
|
-> loc:Loc.t
|
||||||
-> dir:Path.t
|
-> dir:Path.t
|
||||||
-> program:Program.t
|
-> program:Program.t
|
||||||
-> modules:Module.t String_map.t
|
-> modules:Module.t String_map.t
|
||||||
|
@ -57,7 +58,8 @@ val build_and_link
|
||||||
-> Path.t * (unit, Lib.t list) Build.t
|
-> Path.t * (unit, Lib.t list) Build.t
|
||||||
|
|
||||||
val build_and_link_many
|
val build_and_link_many
|
||||||
: loc:Loc.t
|
: ?obj_dir:Path.t
|
||||||
|
-> loc:Loc.t
|
||||||
-> dir:Path.t
|
-> dir:Path.t
|
||||||
-> programs:Program.t list
|
-> programs:Program.t list
|
||||||
-> modules:Module.t String_map.t
|
-> modules:Module.t String_map.t
|
||||||
|
|
15
src/utop.ml
15
src/utop.ml
|
@ -3,8 +3,8 @@ open Jbuild
|
||||||
open Build.O
|
open Build.O
|
||||||
open! No_io
|
open! No_io
|
||||||
|
|
||||||
let exe_name = "_utop"
|
let exe_name = "utop"
|
||||||
let main_module_name = "Utop"
|
let main_module_name = String.capitalize_ascii exe_name
|
||||||
let main_module_filename = exe_name ^ ".ml"
|
let main_module_filename = exe_name ^ ".ml"
|
||||||
|
|
||||||
let pp_ml fmt include_dirs =
|
let pp_ml fmt include_dirs =
|
||||||
|
@ -36,8 +36,10 @@ let add_module_rules sctx ~dir lib_requires =
|
||||||
>>> Build.write_file_dyn path in
|
>>> Build.write_file_dyn path in
|
||||||
Super_context.add_rule sctx utop_ml
|
Super_context.add_rule sctx utop_ml
|
||||||
|
|
||||||
|
let utop_exe_dir ~dir = Path.relative dir ".utop"
|
||||||
|
|
||||||
let utop_exe dir =
|
let utop_exe dir =
|
||||||
Path.relative dir exe_name
|
Path.relative (utop_exe_dir ~dir) exe_name
|
||||||
(* Use the [.exe] version. As the utop executable is declared with
|
(* Use the [.exe] version. As the utop executable is declared with
|
||||||
[(modes (byte))], the [.exe] correspond the bytecode linked in
|
[(modes (byte))], the [.exe] correspond the bytecode linked in
|
||||||
custom mode. We do that so that it works without hassle when
|
custom mode. We do that so that it works without hassle when
|
||||||
|
@ -60,10 +62,12 @@ let setup sctx ~dir ~(libs : Library.t list) ~scope =
|
||||||
}
|
}
|
||||||
; intf = None
|
; intf = None
|
||||||
; obj_name = "" } in
|
; obj_name = "" } in
|
||||||
|
let utop_exe_dir = utop_exe_dir ~dir in
|
||||||
let _obj_dir, libs =
|
let _obj_dir, libs =
|
||||||
Exe.build_and_link sctx
|
Exe.build_and_link sctx
|
||||||
~loc
|
~loc
|
||||||
~dir
|
~obj_dir:utop_exe_dir
|
||||||
|
~dir:utop_exe_dir
|
||||||
~program:{ name = exe_name ; main_module_name }
|
~program:{ name = exe_name ; main_module_name }
|
||||||
~modules
|
~modules
|
||||||
~scope
|
~scope
|
||||||
|
@ -73,7 +77,6 @@ let setup sctx ~dir ~(libs : Library.t list) ~scope =
|
||||||
(List.map ~f:(fun (lib : Library.t) ->
|
(List.map ~f:(fun (lib : Library.t) ->
|
||||||
Lib_dep.direct lib.name) libs)
|
Lib_dep.direct lib.name) libs)
|
||||||
)
|
)
|
||||||
~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
|
in
|
||||||
add_module_rules sctx ~dir libs
|
add_module_rules sctx ~dir:utop_exe_dir libs
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
$ $JBUILDER utop -j1 --display short --root . forutop -- init_forutop.ml
|
$ $JBUILDER utop -j1 --display short --root . forutop -- init_forutop.ml
|
||||||
ocamldep forutop/_utop.ml.d
|
ocamldep forutop/.utop/utop.ml.d
|
||||||
ocamldep forutop/forutop.ml.d
|
ocamldep forutop/forutop.ml.d
|
||||||
ocamlc forutop/.forutop.objs/forutop.{cmi,cmo,cmt}
|
ocamlc forutop/.forutop.objs/forutop.{cmi,cmo,cmt}
|
||||||
ocamlc forutop/._utop.eobjs/_utop.{cmi,cmo,cmt}
|
ocamlc forutop/.utop/utop.{cmi,cmo,cmt}
|
||||||
ocamlc forutop/forutop.cma
|
ocamlc forutop/forutop.cma
|
||||||
ocamlc forutop/_utop.exe
|
ocamlc forutop/.utop/utop.exe
|
||||||
hello in utop
|
hello in utop
|
||||||
|
|
Loading…
Reference in New Issue