diff --git a/src/dune_rules/dune_file.ml b/src/dune_rules/dune_file.ml index 724033e7f14..52afd195d57 100644 --- a/src/dune_rules/dune_file.ml +++ b/src/dune_rules/dune_file.ml @@ -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 @@ -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 @@ -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 @@ -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 @@ -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