Add Lib.Compile.compile_and_link_flags
This commit is contained in:
parent
945583ff43
commit
bdb03925d1
30
src/lib.ml
30
src/lib.ml
|
@ -383,6 +383,12 @@ end)
|
||||||
module L = struct
|
module L = struct
|
||||||
type nonrec t = t list
|
type nonrec t = t list
|
||||||
|
|
||||||
|
let to_iflags dirs =
|
||||||
|
Arg_spec.S
|
||||||
|
(Path.Set.fold dirs ~init:[] ~f:(fun dir acc ->
|
||||||
|
Arg_spec.Path dir :: A "-I" :: acc)
|
||||||
|
|> List.rev)
|
||||||
|
|
||||||
let include_paths ts ~stdlib_dir =
|
let include_paths ts ~stdlib_dir =
|
||||||
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 ->
|
||||||
|
@ -391,24 +397,34 @@ module L = struct
|
||||||
Path.Set.remove dirs stdlib_dir
|
Path.Set.remove dirs stdlib_dir
|
||||||
|
|
||||||
let include_flags ts ~stdlib_dir =
|
let include_flags ts ~stdlib_dir =
|
||||||
let dirs = include_paths ts ~stdlib_dir in
|
to_iflags (include_paths ts ~stdlib_dir)
|
||||||
Arg_spec.S (List.concat_map (Path.Set.to_list dirs) ~f:(fun dir ->
|
|
||||||
[Arg_spec.A "-I"; Path dir]))
|
|
||||||
|
|
||||||
let c_include_flags ts ~stdlib_dir =
|
let c_include_paths ts ~stdlib_dir =
|
||||||
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 ->
|
||||||
Path.Set.add acc t.src_dir)
|
Path.Set.add acc t.src_dir)
|
||||||
in
|
in
|
||||||
let dirs = Path.Set.remove dirs stdlib_dir in
|
Path.Set.remove dirs stdlib_dir
|
||||||
Arg_spec.S (List.concat_map (Path.Set.to_list dirs) ~f:(fun dir ->
|
|
||||||
[Arg_spec.A "-I"; Path dir]))
|
let c_include_flags ts ~stdlib_dir =
|
||||||
|
to_iflags (c_include_paths ts ~stdlib_dir)
|
||||||
|
|
||||||
let link_flags ts ~mode ~stdlib_dir =
|
let link_flags ts ~mode ~stdlib_dir =
|
||||||
Arg_spec.S
|
Arg_spec.S
|
||||||
(c_include_flags ts ~stdlib_dir ::
|
(c_include_flags ts ~stdlib_dir ::
|
||||||
List.map ts ~f:(fun t -> Arg_spec.Deps (Mode.Dict.get t.archives mode)))
|
List.map ts ~f:(fun t -> Arg_spec.Deps (Mode.Dict.get t.archives mode)))
|
||||||
|
|
||||||
|
let compile_and_link_flags ~compile ~link ~mode ~stdlib_dir =
|
||||||
|
let dirs =
|
||||||
|
Path.Set.union
|
||||||
|
( include_paths compile ~stdlib_dir)
|
||||||
|
(c_include_paths link ~stdlib_dir)
|
||||||
|
in
|
||||||
|
Arg_spec.S
|
||||||
|
(to_iflags dirs ::
|
||||||
|
List.map link ~f:(fun t ->
|
||||||
|
Arg_spec.Deps (Mode.Dict.get t.archives mode)))
|
||||||
|
|
||||||
let jsoo_runtime_files ts =
|
let jsoo_runtime_files ts =
|
||||||
List.concat_map ts ~f:(fun t -> t.jsoo_runtime)
|
List.concat_map ts ~f:(fun t -> t.jsoo_runtime)
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,13 @@ module L : sig
|
||||||
|
|
||||||
val link_flags : t -> mode:Mode.t -> stdlib_dir:Path.t -> _ Arg_spec.t
|
val link_flags : t -> mode:Mode.t -> stdlib_dir:Path.t -> _ Arg_spec.t
|
||||||
|
|
||||||
|
val compile_and_link_flags
|
||||||
|
: compile:t
|
||||||
|
-> link:t
|
||||||
|
-> mode:Mode.t
|
||||||
|
-> stdlib_dir:Path.t
|
||||||
|
-> _ Arg_spec.t
|
||||||
|
|
||||||
(** All the library archive files (.a, .cmxa, _stubs.a, ...) that
|
(** All the library archive files (.a, .cmxa, _stubs.a, ...) that
|
||||||
should be linked in when linking an executable. *)
|
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 -> ext_lib:string -> Path.t list
|
||||||
|
|
Loading…
Reference in New Issue