add deps on header files & stubs
This commit is contained in:
parent
11c61b3234
commit
875df08235
|
@ -466,6 +466,8 @@ module Gen(P : Params) = struct
|
|||
in
|
||||
add_rule
|
||||
(libs
|
||||
>>>
|
||||
Build.dyn_paths (Build.arr (Lib.archive_files ~mode ~ext_lib:ctx.ext_lib))
|
||||
>>>
|
||||
Build.run (Dep compiler)
|
||||
[ A "-o"; Target target
|
||||
|
@ -753,8 +755,8 @@ module Gen(P : Params) = struct
|
|||
|
||||
let lib_archive (lib : Library.t) ~dir ~ext = Path.relative dir (lib.name ^ ext)
|
||||
|
||||
let stubs_archive (lib : Library.t) ~dir =
|
||||
Path.relative dir (sprintf "lib%s_stubs%s" lib.name ctx.ext_lib)
|
||||
let stubs_archive lib ~dir =
|
||||
Library.stubs_archive lib ~dir ~ext_lib:ctx.ext_lib
|
||||
|
||||
let dll (lib : Library.t) ~dir =
|
||||
Path.relative dir (sprintf "dll%s_stubs%s" lib.name ctx.ext_dll)
|
||||
|
@ -820,7 +822,9 @@ module Gen(P : Params) = struct
|
|||
>>>
|
||||
Build.fanout
|
||||
(expand_and_eval_set ~dir lib.c_flags ~standard:default_c_flags)
|
||||
requires
|
||||
(requires
|
||||
>>>
|
||||
Build.dyn_paths (Build.arr Lib.header_files))
|
||||
>>>
|
||||
Build.run
|
||||
(* We have to execute the rule in the library directory as the .o is produced in
|
||||
|
@ -1039,7 +1043,7 @@ module Gen(P : Params) = struct
|
|||
add_rule
|
||||
(Build.fanout
|
||||
(requires
|
||||
>>> Build.dyn_paths (Build.arr (Lib.archive_files ~mode)))
|
||||
>>> Build.dyn_paths (Build.arr (Lib.archive_files ~mode ~ext_lib:ctx.ext_lib)))
|
||||
(dep_graph
|
||||
>>> Build.arr (fun dep_graph ->
|
||||
names_to_top_closed_cm_files
|
||||
|
|
|
@ -409,6 +409,9 @@ module Library = struct
|
|||
match t.c_names, t.cxx_names, t.self_build_stubs_archive with
|
||||
| [], [], None -> false
|
||||
| _ -> true
|
||||
|
||||
let stubs_archive t ~dir ~ext_lib =
|
||||
Path.relative dir (sprintf "lib%s_stubs%s" t.name ext_lib)
|
||||
end
|
||||
|
||||
module Executables = struct
|
||||
|
|
21
src/lib.ml
21
src/lib.ml
|
@ -27,6 +27,17 @@ let dir = function
|
|||
| Internal (dir, _) -> dir
|
||||
| External pkg -> pkg.dir
|
||||
|
||||
let header_files ts =
|
||||
List.fold_left ts ~init:[] ~f:(fun acc t ->
|
||||
match t with
|
||||
| External _ -> []
|
||||
| Internal (dir, lib) ->
|
||||
match lib.public_headers with
|
||||
| [] -> acc
|
||||
| l ->
|
||||
List.fold_left l ~init:acc ~f:(fun acc fn ->
|
||||
Path.relative dir (fn ^ ".h") :: acc))
|
||||
|
||||
let include_flags ts =
|
||||
let dirs =
|
||||
List.fold_left ts ~init:Path.Set.empty ~f:(fun acc t ->
|
||||
|
@ -66,12 +77,18 @@ let link_flags ts ~mode =
|
|||
| Internal (dir, lib) ->
|
||||
Dep_rel (dir, lib.name ^ Mode.compiled_lib_ext mode)))
|
||||
|
||||
let archive_files ts ~mode =
|
||||
let archive_files ts ~mode ~ext_lib =
|
||||
List.concat_map ts ~f:(function
|
||||
| External pkg ->
|
||||
List.map (Mode.Dict.get pkg.archives mode) ~f:(Path.relative pkg.dir)
|
||||
| Internal (dir, lib) ->
|
||||
[Path.relative dir (lib.name ^ Mode.compiled_lib_ext mode)])
|
||||
let l =
|
||||
[Path.relative dir (lib.name ^ Mode.compiled_lib_ext mode)]
|
||||
in
|
||||
if Jbuild_types.Library.has_stubs lib then
|
||||
Jbuild_types.Library.stubs_archive lib ~dir ~ext_lib :: l
|
||||
else
|
||||
l)
|
||||
(*
|
||||
let ppx_runtime_libraries ts =
|
||||
List.fold_left ts ~init:String_set.empty ~f:(fun acc t ->
|
||||
|
|
|
@ -12,13 +12,15 @@ module Set : Set.S with type elt := t
|
|||
|
||||
(*val deps : t -> string list*)
|
||||
|
||||
val header_files : t list -> Path.t list
|
||||
|
||||
val include_flags : t list -> _ Arg_spec.t
|
||||
|
||||
val c_include_flags : t list -> _ Arg_spec.t
|
||||
|
||||
val link_flags : t list -> mode:Mode.t -> _ Arg_spec.t
|
||||
|
||||
val archive_files : t list -> mode:Mode.t -> Path.t list
|
||||
val archive_files : t list -> mode:Mode.t -> ext_lib:string -> Path.t list
|
||||
|
||||
(** [public_name] if present, [name] if not *)
|
||||
val best_name : t -> string
|
||||
|
|
Loading…
Reference in New Issue