Skip to content

Commit 5ba818c

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 69c65a0 commit 5ba818c

File tree

57 files changed

+368
-313
lines changed

Some content is hidden

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

57 files changed

+368
-313
lines changed
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/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
@@ -130,14 +130,15 @@ let link_exe
130130
let mode = linkage.mode in
131131
let exe = Path.relative dir (name ^ linkage.ext) in
132132
let compiler = Option.value_exn (Context.compiler ctx mode) in
133+
let kind = Mode.cm_kind mode in
133134
let artifacts ~ext modules =
134-
List.map modules ~f:(Module.obj_file ~obj_dir ~ext)
135+
List.map modules ~f:(Module.obj_file ~mode ~obj_dir ~ext)
135136
in
136137
let modules_and_cm_files =
137138
Build.memoize "cm files"
138139
(top_sorted_modules >>^ fun modules ->
139140
(modules,
140-
artifacts modules ~ext:(Cm_kind.ext (Mode.cm_kind mode))))
141+
artifacts modules ~ext:(Cm_kind.ext kind)))
141142
in
142143
let register_native_objs_deps build =
143144
match mode with

src/exe_rules.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ let executables_rules ~sctx ~dir ~dir_kind ~expander
1111
let obj_dir =
1212
Utils.executable_object_directory ~dir (List.hd exes.names |> snd)
1313
in
14-
Check_rules.add_obj_dir sctx ~dir ~obj_dir;
14+
Check_rules.add_obj_dir sctx ~dir ~obj_dir:(Utils.library_byte_dir ~obj_dir);
1515
let requires = Lib.Compile.requires compile_info in
1616
let modules =
1717
Dir_contents.modules_of_executables dir_contents

src/install_rules.ml

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

src/lib.ml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,18 @@ let virtual_ t = t.info.virtual_
188188

189189
let src_dir t = t.info.src_dir
190190
let obj_dir t = t.info.obj_dir
191-
let private_obj_dir t = t.info.private_obj_dir
192-
193191
let is_local t = Path.is_managed t.info.obj_dir
194192

193+
let public_cmi_dir t =
194+
if is_local t then
195+
Utils.library_public_cmi_dir ~obj_dir:t.info.obj_dir
196+
else obj_dir t
197+
198+
let native_dir t =
199+
if is_local t then
200+
Utils.library_native_dir ~obj_dir:t.info.obj_dir
201+
else obj_dir t
202+
195203
let status t = t.info.status
196204

197205
let foreign_objects t = t.info.foreign_objects
@@ -242,7 +250,8 @@ module L = struct
242250
let include_paths ts ~stdlib_dir =
243251
let dirs =
244252
List.fold_left ts ~init:Path.Set.empty ~f:(fun acc t ->
245-
Path.Set.add acc (obj_dir t))
253+
List.fold_left ~f:Path.Set.add ~init:acc
254+
[public_cmi_dir t; native_dir t])
246255
in
247256
Path.Set.remove dirs stdlib_dir
248257

src/lib.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ val src_dir : t -> Path.t
1818
(** Directory where the object files for the library are located. *)
1919
val obj_dir : t -> Path.t
2020

21-
val private_obj_dir : t -> Path.t option
21+
val public_cmi_dir : t -> Path.t
2222

2323
(** Same as [Path.is_managed (obj_dir t)] *)
2424
val is_local : t -> bool

src/lib_info.ml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ type t =
5454
; status : Status.t
5555
; src_dir : Path.t
5656
; obj_dir : Path.t
57-
; private_obj_dir : Path.t option
5857
; version : string option
5958
; synopsis : string option
6059
; archives : Path.t list Mode.Dict.t
@@ -101,10 +100,6 @@ let of_library_stanza ~dir ~has_native ~ext_lib ~ext_obj
101100
| Some p -> Public p.package
102101
in
103102
let virtual_library = Dune_file.Library.is_virtual conf in
104-
let private_obj_dir =
105-
Option.map conf.private_modules ~f:(fun _ ->
106-
Utils.library_private_obj_dir ~obj_dir)
107-
in
108103
let (foreign_archives, foreign_objects) =
109104
let stubs =
110105
if Dune_file.Library.has_stubs conf then
@@ -176,7 +171,6 @@ let of_library_stanza ~dir ~has_native ~ext_lib ~ext_obj
176171
; virtual_
177172
; implements = conf.implements
178173
; main_module_name
179-
; private_obj_dir
180174
; modes
181175
}
182176

@@ -192,7 +186,6 @@ let of_dune_lib dp =
192186
{ loc = Lib.loc dp
193187
; name = Lib.name dp
194188
; kind = Lib.kind dp
195-
; private_obj_dir = None
196189
; status = Installed
197190
; src_dir
198191
; obj_dir = src_dir

0 commit comments

Comments
 (0)