Merge pull request #1136 from rgrinberg/simplify-stub-handling
Remove extension argument for Lib.L.archive_files
This commit is contained in:
commit
ef46a443b2
|
@ -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)
|
||||
|
|
25
src/lib.ml
25
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)]
|
||||
|
|
10
src/lib.mli
10
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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 })
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -512,6 +512,7 @@ let create
|
|||
~projects
|
||||
~context:context.name
|
||||
~installed_libs
|
||||
~ext_lib:context.ext_lib
|
||||
internal_libs
|
||||
in
|
||||
let stanzas =
|
||||
|
|
Loading…
Reference in New Issue