diff --git a/src/exe.ml b/src/exe.ml index 3a4aa7e9..5fa3ede2 100644 --- a/src/exe.ml +++ b/src/exe.ml @@ -145,7 +145,7 @@ let link_exe link_flags >>> Build.of_result_map requires ~f:(fun libs -> - Build.paths (Lib.L.archive_files libs ~mode ~ext_lib:ctx.ext_lib)) + Build.paths (Lib.L.archive_files libs ~mode)) >>> Build.run ~context:ctx (Ok compiler) diff --git a/src/lib.ml b/src/lib.ml index f15a49dd..e9f8d794 100644 --- a/src/lib.ml +++ b/src/lib.ml @@ -72,17 +72,11 @@ module Info = struct ~init:(Deps.to_lib_deps t.requires) ~f:(fun acc s -> Dune_file.Lib_dep.Direct s :: acc) - let of_library_stanza ~dir (conf : Dune_file.Library.t) = + let of_library_stanza ~dir ~ext_lib (conf : Dune_file.Library.t) = let archive_file ext = Path.relative dir (conf.name ^ ext) in let archive_files ~f_ext = Mode.Dict.of_func (fun ~mode -> [archive_file (f_ext mode)]) in - let stubs = - if Dune_file.Library.has_stubs conf then - [Dune_file.Library.stubs_archive conf ~dir ~ext_lib:""] - else - [] - in let jsoo_runtime = List.map conf.buildable.js_of_ocaml.javascript_files ~f:(Path.relative dir) @@ -93,9 +87,15 @@ module Info = struct | Some p -> Public p.package in let foreign_archives = + let stubs = + if Dune_file.Library.has_stubs conf then + [Dune_file.Library.stubs_archive conf ~dir ~ext_lib] + else + [] + in { Mode.Dict. byte = stubs - ; native = Path.relative dir conf.name :: stubs + ; native = Path.relative dir (conf.name ^ ext_lib) :: stubs } in { loc = conf.buildable.loc @@ -420,11 +420,10 @@ module L = struct let jsoo_runtime_files ts = List.concat_map ts ~f:(fun t -> t.info.jsoo_runtime) - let archive_files ts ~mode ~ext_lib = + let archive_files ts ~mode = List.concat_map ts ~f:(fun t -> Mode.Dict.get t.info.archives mode @ - List.map (Mode.Dict.get t.info.foreign_archives mode) - ~f:(Path.extend_basename ~suffix:ext_lib)) + Mode.Dict.get t.info.foreign_archives mode) let remove_dups l = let rec loop acc l seen = @@ -946,10 +945,10 @@ module DB = struct ; all = Lazy.from_fun all } - let create_from_library_stanzas ?parent stanzas = + let create_from_library_stanzas ?parent ~ext_lib stanzas = let map = List.concat_map stanzas ~f:(fun (dir, (conf : Dune_file.Library.t)) -> - let info = Info.of_library_stanza ~dir conf in + let info = Info.of_library_stanza ~dir ~ext_lib conf in match conf.public with | None -> [(conf.name, Resolve_result.Found info)] diff --git a/src/lib.mli b/src/lib.mli index 312f3e24..f4748754 100644 --- a/src/lib.mli +++ b/src/lib.mli @@ -69,7 +69,7 @@ module L : sig (** All the library archive files (.a, .cmxa, _stubs.a, ...) that should be linked in when linking an executable. *) - val archive_files : t -> mode:Mode.t -> ext_lib:string -> Path.t list + val archive_files : t -> mode:Mode.t -> Path.t list val jsoo_runtime_files : t -> Path.t list @@ -109,7 +109,12 @@ module Info : sig ; sub_systems : Dune_file.Sub_system_info.t Sub_system_name.Map.t } - val of_library_stanza : dir:Path.t -> Dune_file.Library.t -> t + val of_library_stanza + : dir:Path.t + -> ext_lib:string + -> Dune_file.Library.t + -> t + val of_findlib_package : Findlib.Package.t -> t end @@ -257,6 +262,7 @@ module DB : sig (** Create a database from a list of library stanzas *) val create_from_library_stanzas : ?parent:t + -> ext_lib:string -> (Path.t * Dune_file.Library.t) list -> t diff --git a/src/preprocessing.ml b/src/preprocessing.ml index afe6499a..81f2c7b0 100644 --- a/src/preprocessing.ml +++ b/src/preprocessing.ml @@ -295,7 +295,7 @@ let build_ppx_driver sctx ~lib_db ~dep_kind ~target ~dir_kind pps = (Lib_deps.info ~kind:dep_kind (Lib_deps.of_pps pps)) >>> Build.of_result_map driver_and_libs ~f:(fun (_, libs) -> - Build.paths (Lib.L.archive_files libs ~mode ~ext_lib:ctx.ext_lib)) + Build.paths (Lib.L.archive_files libs ~mode)) >>> Build.run ~context:ctx (Ok compiler) [ A "-o" ; Target target diff --git a/src/scope.ml b/src/scope.ml index 72602a45..685bf425 100644 --- a/src/scope.ml +++ b/src/scope.ml @@ -50,7 +50,7 @@ module DB = struct (Project_name_map.keys t.by_name) ] - let create ~projects ~context ~installed_libs internal_libs = + let create ~projects ~context ~installed_libs ~ext_lib internal_libs = let projects_by_name = List.map projects ~f:(fun (project : Dune_project.t) -> (project.name, project)) @@ -119,7 +119,7 @@ module DB = struct let project = Option.value_exn project in let libs = Option.value libs ~default:[] in let db = - Lib.DB.create_from_library_stanzas libs ~parent:public_libs + Lib.DB.create_from_library_stanzas libs ~parent:public_libs ~ext_lib in let root = Path.append_local build_context_dir project.root in Some { project; db; root }) diff --git a/src/scope.mli b/src/scope.mli index 9bb2cfac..20e5e8c4 100644 --- a/src/scope.mli +++ b/src/scope.mli @@ -25,6 +25,7 @@ module DB : sig : projects:Dune_project.t list -> context:string -> installed_libs:Lib.DB.t + -> ext_lib:string -> (Path.t * Dune_file.Library.t) list -> t * Lib.DB.t diff --git a/src/super_context.ml b/src/super_context.ml index ef924de9..ebbaafdb 100644 --- a/src/super_context.ml +++ b/src/super_context.ml @@ -512,6 +512,7 @@ let create ~projects ~context:context.name ~installed_libs + ~ext_lib:context.ext_lib internal_libs in let stanzas =