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
|
in
|
||||||
add_rule
|
add_rule
|
||||||
(libs
|
(libs
|
||||||
|
>>>
|
||||||
|
Build.dyn_paths (Build.arr (Lib.archive_files ~mode ~ext_lib:ctx.ext_lib))
|
||||||
>>>
|
>>>
|
||||||
Build.run (Dep compiler)
|
Build.run (Dep compiler)
|
||||||
[ A "-o"; Target target
|
[ 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 lib_archive (lib : Library.t) ~dir ~ext = Path.relative dir (lib.name ^ ext)
|
||||||
|
|
||||||
let stubs_archive (lib : Library.t) ~dir =
|
let stubs_archive lib ~dir =
|
||||||
Path.relative dir (sprintf "lib%s_stubs%s" lib.name ctx.ext_lib)
|
Library.stubs_archive lib ~dir ~ext_lib:ctx.ext_lib
|
||||||
|
|
||||||
let dll (lib : Library.t) ~dir =
|
let dll (lib : Library.t) ~dir =
|
||||||
Path.relative dir (sprintf "dll%s_stubs%s" lib.name ctx.ext_dll)
|
Path.relative dir (sprintf "dll%s_stubs%s" lib.name ctx.ext_dll)
|
||||||
|
@ -820,7 +822,9 @@ module Gen(P : Params) = struct
|
||||||
>>>
|
>>>
|
||||||
Build.fanout
|
Build.fanout
|
||||||
(expand_and_eval_set ~dir lib.c_flags ~standard:default_c_flags)
|
(expand_and_eval_set ~dir lib.c_flags ~standard:default_c_flags)
|
||||||
requires
|
(requires
|
||||||
|
>>>
|
||||||
|
Build.dyn_paths (Build.arr Lib.header_files))
|
||||||
>>>
|
>>>
|
||||||
Build.run
|
Build.run
|
||||||
(* We have to execute the rule in the library directory as the .o is produced in
|
(* 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
|
add_rule
|
||||||
(Build.fanout
|
(Build.fanout
|
||||||
(requires
|
(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
|
(dep_graph
|
||||||
>>> Build.arr (fun dep_graph ->
|
>>> Build.arr (fun dep_graph ->
|
||||||
names_to_top_closed_cm_files
|
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
|
match t.c_names, t.cxx_names, t.self_build_stubs_archive with
|
||||||
| [], [], None -> false
|
| [], [], None -> false
|
||||||
| _ -> true
|
| _ -> true
|
||||||
|
|
||||||
|
let stubs_archive t ~dir ~ext_lib =
|
||||||
|
Path.relative dir (sprintf "lib%s_stubs%s" t.name ext_lib)
|
||||||
end
|
end
|
||||||
|
|
||||||
module Executables = struct
|
module Executables = struct
|
||||||
|
|
21
src/lib.ml
21
src/lib.ml
|
@ -27,6 +27,17 @@ let dir = function
|
||||||
| Internal (dir, _) -> dir
|
| Internal (dir, _) -> dir
|
||||||
| External pkg -> pkg.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 include_flags ts =
|
||||||
let dirs =
|
let dirs =
|
||||||
List.fold_left ts ~init:Path.Set.empty ~f:(fun acc t ->
|
List.fold_left ts ~init:Path.Set.empty ~f:(fun acc t ->
|
||||||
|
@ -66,12 +77,18 @@ let link_flags ts ~mode =
|
||||||
| Internal (dir, lib) ->
|
| Internal (dir, lib) ->
|
||||||
Dep_rel (dir, lib.name ^ Mode.compiled_lib_ext mode)))
|
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
|
List.concat_map ts ~f:(function
|
||||||
| External pkg ->
|
| External pkg ->
|
||||||
List.map (Mode.Dict.get pkg.archives mode) ~f:(Path.relative pkg.dir)
|
List.map (Mode.Dict.get pkg.archives mode) ~f:(Path.relative pkg.dir)
|
||||||
| Internal (dir, lib) ->
|
| 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 =
|
let ppx_runtime_libraries ts =
|
||||||
List.fold_left ts ~init:String_set.empty ~f:(fun acc t ->
|
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 deps : t -> string list*)
|
||||||
|
|
||||||
|
val header_files : t list -> Path.t list
|
||||||
|
|
||||||
val include_flags : t list -> _ Arg_spec.t
|
val include_flags : t list -> _ Arg_spec.t
|
||||||
|
|
||||||
val c_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 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 *)
|
(** [public_name] if present, [name] if not *)
|
||||||
val best_name : t -> string
|
val best_name : t -> string
|
||||||
|
|
Loading…
Reference in New Issue