Skip to content

Commit 9814464

Browse files
committed
Change compilation layout
- all the cmx are all at the same place - all the cmi and cmo are in another directory - the public directory contains the public cmi Signed-off-by: François Bobot <[email protected]>
1 parent d594a49 commit 9814464

File tree

65 files changed

+422
-318
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+422
-318
lines changed

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
unreleased
22
----------
33

4+
- Change the layout of build artifacts inside _build (#1676 @bobot)
5+
46
- Fix merlin handling of private module visibility (#1653 @bobot)
57

68
- unstable-fmt: use boxes to wrap some lists (#1608, fix #1153, @emillon,
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
$ dune build @install @runtest --display short
22
ocamldep bin/.main.eobjs/main.ml.d
33
ocamldep lib/.hello_world.objs/hello_world.ml.d
4-
ocamlc lib/.hello_world.objs/hello_world.{cmi,cmo,cmt}
4+
ocamlc lib/.hello_world.objs/.byte_objs/hello_world.{cmi,cmo,cmt}
55
ocamlc lib/hello_world.cma
66
ocamldep test/.test.eobjs/test.ml.d
7-
ocamlopt lib/.hello_world.objs/hello_world.{cmx,o}
7+
ocamlopt lib/.hello_world.objs/.native_objs/hello_world.{cmx,o}
88
ocamlopt lib/hello_world.{a,cmxa}
9-
ocamlc test/.test.eobjs/test.{cmi,cmo,cmt}
10-
ocamlopt test/.test.eobjs/test.{cmx,o}
9+
ocamlc test/.test.eobjs/.byte_objs/test.{cmi,cmo,cmt}
10+
ocamlopt test/.test.eobjs/.native_objs/test.{cmx,o}
1111
ocamlopt test/test.exe
1212
test test/test.output
1313
ocamlopt lib/hello_world.cmxs
14-
ocamlc bin/.main.eobjs/main.{cmi,cmo,cmt}
15-
ocamlopt bin/.main.eobjs/main.{cmx,o}
14+
ocamlc bin/.main.eobjs/.byte_objs/main.{cmi,cmo,cmt}
15+
ocamlopt bin/.main.eobjs/.native_objs/main.{cmx,o}
1616
ocamlopt bin/main.exe

example/sample-projects/with-configure-step/run.t

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
ocaml config.full
33
ocamldep src/.plop.eobjs/config.ml.d
44
ocamldep src/.plop.eobjs/plop.ml.d
5-
ocamlc src/.plop.eobjs/config.{cmi,cmo,cmt}
6-
ocamlc src/.plop.eobjs/plop.{cmi,cmo,cmt}
7-
ocamlopt src/.plop.eobjs/plop.{cmx,o}
8-
ocamlopt src/.plop.eobjs/config.{cmx,o}
5+
ocamlc src/.plop.eobjs/.byte_objs/config.{cmi,cmo,cmt}
6+
ocamlc src/.plop.eobjs/.byte_objs/plop.{cmi,cmo,cmt}
7+
ocamlopt src/.plop.eobjs/.native_objs/plop.{cmx,o}
8+
ocamlopt src/.plop.eobjs/.native_objs/config.{cmx,o}
99
ocamlopt src/plop.exe

src/check_rules.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ let add_obj_dir sctx ~obj_dir =
1616
~dyn_deps:(Build.paths_matching ~loc:Loc.none ~dir dev_files)
1717
Path.Set.empty
1818
in
19-
List.iter ~f (Obj_dir.all_objs_dir obj_dir)
19+
List.iter ~f [obj_dir.byte_dir]

src/cm_kind.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ let choose cmi cmo cmx = function
1111

1212
let ext = choose ".cmi" ".cmo" ".cmx"
1313

14+
let pp fmt p = Format.pp_print_string fmt (ext p)
15+
1416
let source = choose Ml_kind.Intf Impl Impl
1517

1618
module Dict = struct

src/cm_kind.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ open Stdune
33
type t = Cmi | Cmo | Cmx
44

55
val all : t list
6-
6+
val pp : t Fmt.t
77
val ext : t -> string
88
val source : t -> Ml_kind.t
99

src/exe.ml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,15 @@ let link_exe
129129
let mode = linkage.mode in
130130
let exe = Path.relative dir (name ^ linkage.ext) in
131131
let compiler = Option.value_exn (Context.compiler ctx mode) in
132+
let kind = Mode.cm_kind mode in
132133
let artifacts ~ext modules =
133-
List.map modules ~f:(Module.obj_file ~ext)
134+
List.map modules ~f:(Module.obj_file ~mode ~ext)
134135
in
135136
let modules_and_cm_files =
136137
Build.memoize "cm files"
137138
(top_sorted_modules >>^ fun modules ->
138139
(modules,
139-
artifacts modules ~ext:(Cm_kind.ext (Mode.cm_kind mode))))
140+
artifacts modules ~ext:(Cm_kind.ext kind)))
140141
in
141142
let register_native_objs_deps build =
142143
match mode with

src/exe_rules.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ let executables_rules ~sctx ~dir ~dir_kind ~expander
107107
~flags:(Ocaml_flags.common flags)
108108
~preprocess:(Dune_file.Buildable.single_preprocess exes.buildable)
109109
(* only public_dir? *)
110-
~objs_dirs:(Path.Set.singleton obj_dir.Obj_dir.public_dir))
110+
~objs_dirs:(Path.Set.singleton (Obj_dir.public_cmi_dir obj_dir)))
111111

112112
let rules ~sctx ~dir ~dir_contents ~scope ~expander ~dir_kind
113113
(exes : Dune_file.Executables.t) =

src/install_rules.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,13 @@ module Gen(P : Params) = struct
226226
List.concat_map installable_modules ~f:(fun m ->
227227
List.concat
228228
[ if_ (Module.is_public m)
229-
[ Module.cm_file_unsafe m Cmi ]
229+
[ Module.cm_public_file_unsafe m Cmi ]
230230
; if_ (native && Module.has_impl m)
231231
[ Module.cm_file_unsafe m Cmx ]
232232
; if_ (byte && Module.has_impl m && virtual_library)
233233
[ Module.cm_file_unsafe m Cmo ]
234234
; if_ (native && Module.has_impl m && virtual_library)
235-
[ Module.obj_file m ~ext:ctx.ext_obj ]
235+
[ Module.obj_file m ~mode:Native ~ext:ctx.ext_obj ]
236236
; List.filter_map Ml_kind.all ~f:(Module.cmt_file m)
237237
])
238238
in

src/lib.ml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,12 @@ let virtual_ t = t.info.virtual_
190190
let src_dir t = t.info.src_dir
191191
let obj_dir t = t.info.obj_dir
192192

193-
let is_local t = Path.is_managed t.info.obj_dir.public_dir
193+
let is_local t = Path.is_managed t.info.obj_dir.byte_dir
194+
195+
let public_cmi_dir t = Obj_dir.public_cmi_dir t.info.obj_dir
196+
197+
198+
let native_dir t = t.info.obj_dir.native_dir
194199

195200
let status t = t.info.status
196201

@@ -253,7 +258,8 @@ module L = struct
253258
let include_paths ts ~stdlib_dir =
254259
let dirs =
255260
List.fold_left ts ~init:Path.Set.empty ~f:(fun acc t ->
256-
Path.Set.add acc (obj_dir t).public_dir)
261+
List.fold_left ~f:Path.Set.add ~init:acc
262+
[public_cmi_dir t ; native_dir t])
257263
in
258264
Path.Set.remove dirs stdlib_dir
259265

0 commit comments

Comments
 (0)