Skip to content

Commit

Permalink
Clean up archive naming functions
Browse files Browse the repository at this point in the history
Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
  • Loading branch information
rgrinberg committed Dec 16, 2020
1 parent 75f32e2 commit 3e9e9f3
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions src/dune_rules/dune_file.ml
Original file line number Diff line number Diff line change
Expand Up @@ -809,22 +809,18 @@ module Library = struct
~lib_config:
( { Lib_config.has_native; ext_lib; ext_dll; natdynlink_supported; _ }
as lib_config ) =
let _loc, lib_name = conf.name in
let obj_dir = obj_dir ~dir conf in
let gen_archive_file ~dir ext =
Path.Build.relative dir (Lib_name.Local.to_string lib_name ^ ext)
in
let archive_file = gen_archive_file ~dir in
let archive ?(dir = dir) ext = archive conf ~dir ~ext in
let modes = Mode_conf.Set.eval ~has_native conf.modes in
let archive_file ~f_ext ~mode =
let archive_for_mode ~f_ext ~mode =
if Mode.Dict.get modes mode then
Some (archive_file (f_ext mode))
Some (archive (f_ext mode))
else
None
in
let archive_files ~f_ext =
let archives_for_mode ~f_ext =
Mode.Dict.of_func (fun ~mode ->
archive_file ~f_ext ~mode |> Option.to_list)
archive_for_mode ~f_ext ~mode |> Option.to_list)
in
let jsoo_runtime =
List.map conf.buildable.js_of_ocaml.javascript_files
Expand All @@ -839,8 +835,7 @@ module Library = struct
let foreign_archives = foreign_lib_files conf ~dir ~ext_lib in
let native_archives =
if modes.native then
[ Path.Build.relative dir (Lib_name.Local.to_string lib_name ^ ext_lib)
]
[ archive ext_lib ]
else
[]
in
Expand All @@ -850,7 +845,7 @@ module Library = struct
(* XXX we shouldn't access the directory of the obj_dir directly. We
should use something like [Obj_dir.Archive.obj] instead *)
if modes.byte then
Some (gen_archive_file ~dir:(Obj_dir.obj_dir obj_dir) ".cma.js")
Some (archive ~dir:(Obj_dir.obj_dir obj_dir) ".cma.js")
else
None
in
Expand All @@ -864,7 +859,7 @@ module Library = struct
else
let plugins =
let archive_file ~mode =
archive_file ~f_ext:Mode.plugin_ext ~mode |> Option.to_list
archive_for_mode ~f_ext:Mode.plugin_ext ~mode |> Option.to_list
in
{ Mode.Dict.native =
( if Dynlink_supported.get conf.dynlink natdynlink_supported then
Expand All @@ -874,7 +869,7 @@ module Library = struct
; byte = archive_file ~mode:Byte
}
in
(archive_files ~f_ext:Mode.compiled_lib_ext, plugins)
(archives_for_mode ~f_ext:Mode.compiled_lib_ext, plugins)
in
let main_module_name = main_module_name conf in
let name = best_name conf in
Expand Down

0 comments on commit 3e9e9f3

Please sign in to comment.