parent
1215fe2f8a
commit
22b024a977
|
@ -72,12 +72,12 @@ let restore_cwd_and_execve common prog argv env =
|
||||||
module Main = struct
|
module Main = struct
|
||||||
include Jbuilder.Main
|
include Jbuilder.Main
|
||||||
|
|
||||||
let setup ~log ?filter_out_optional_stanzas_with_missing_deps common =
|
let setup ~log ?external_lib_deps_mode common =
|
||||||
setup
|
setup
|
||||||
~log
|
~log
|
||||||
?workspace_file:common.workspace_file
|
?workspace_file:common.workspace_file
|
||||||
?only_packages:common.only_packages
|
?only_packages:common.only_packages
|
||||||
?filter_out_optional_stanzas_with_missing_deps
|
?external_lib_deps_mode
|
||||||
?x:common.x
|
?x:common.x
|
||||||
~ignore_promoted_rules:common.ignore_promoted_rules
|
~ignore_promoted_rules:common.ignore_promoted_rules
|
||||||
~capture_outputs:common.capture_outputs
|
~capture_outputs:common.capture_outputs
|
||||||
|
@ -752,7 +752,7 @@ let external_lib_deps =
|
||||||
set_common common ~targets:[];
|
set_common common ~targets:[];
|
||||||
let log = Log.create common in
|
let log = Log.create common in
|
||||||
Scheduler.go ~log ~common
|
Scheduler.go ~log ~common
|
||||||
(Main.setup ~log common ~filter_out_optional_stanzas_with_missing_deps:false
|
(Main.setup ~log common ~external_lib_deps_mode:true
|
||||||
>>= fun setup ->
|
>>= fun setup ->
|
||||||
let targets = resolve_targets_exn ~log common setup targets in
|
let targets = resolve_targets_exn ~log common setup targets in
|
||||||
let request = request_of_targets setup targets in
|
let request = request_of_targets setup targets in
|
||||||
|
@ -858,7 +858,7 @@ let rules =
|
||||||
set_common common ~targets;
|
set_common common ~targets;
|
||||||
let log = Log.create common in
|
let log = Log.create common in
|
||||||
Scheduler.go ~log ~common
|
Scheduler.go ~log ~common
|
||||||
(Main.setup ~log common ~filter_out_optional_stanzas_with_missing_deps:false
|
(Main.setup ~log common ~external_lib_deps_mode:true
|
||||||
>>= fun setup ->
|
>>= fun setup ->
|
||||||
let request =
|
let request =
|
||||||
match targets with
|
match targets with
|
||||||
|
|
|
@ -174,6 +174,19 @@ let root_package_name s =
|
||||||
| None -> s
|
| None -> s
|
||||||
| Some i -> String.sub s ~pos:0 ~len:i
|
| Some i -> String.sub s ~pos:0 ~len:i
|
||||||
|
|
||||||
|
let dummy_package t ~name =
|
||||||
|
let dir =
|
||||||
|
match t.path with
|
||||||
|
| [] -> t.stdlib_dir
|
||||||
|
| dir :: _ -> Path.relative dir (root_package_name name)
|
||||||
|
in
|
||||||
|
{ Package.
|
||||||
|
meta_file = Path.relative dir "META"
|
||||||
|
; name = name
|
||||||
|
; dir = dir
|
||||||
|
; vars = String_map.empty
|
||||||
|
}
|
||||||
|
|
||||||
(* Parse a single package from a META file *)
|
(* Parse a single package from a META file *)
|
||||||
let parse_package t ~meta_file ~name ~parent_dir ~vars =
|
let parse_package t ~meta_file ~name ~parent_dir ~vars =
|
||||||
let pkg_dir = Vars.get vars "directory" Ps.empty in
|
let pkg_dir = Vars.get vars "directory" Ps.empty in
|
||||||
|
|
|
@ -55,6 +55,9 @@ val all_packages : t -> Package.t list
|
||||||
(** List all the packages that are not available in this database *)
|
(** List all the packages that are not available in this database *)
|
||||||
val all_unavailable_packages : t -> (string * Unavailable_reason.t) list
|
val all_unavailable_packages : t -> (string * Unavailable_reason.t) list
|
||||||
|
|
||||||
|
(** A dummy package. This is used to implement [external-lib-deps] *)
|
||||||
|
val dummy_package : t -> name:string -> Package.t
|
||||||
|
|
||||||
module Config : sig
|
module Config : sig
|
||||||
type t
|
type t
|
||||||
val load : Path.t -> toolchain:string -> context:string -> t
|
val load : Path.t -> toolchain:string -> context:string -> t
|
||||||
|
|
|
@ -1027,7 +1027,7 @@ module type Gen = sig
|
||||||
end
|
end
|
||||||
|
|
||||||
let gen ~contexts ~build_system
|
let gen ~contexts ~build_system
|
||||||
?(filter_out_optional_stanzas_with_missing_deps=true)
|
?(external_lib_deps_mode=false)
|
||||||
?only_packages conf =
|
?only_packages conf =
|
||||||
let open Fiber.O in
|
let open Fiber.O in
|
||||||
let { Jbuild_load. file_tree; jbuilds; packages; scopes } = conf in
|
let { Jbuild_load. file_tree; jbuilds; packages; scopes } = conf in
|
||||||
|
@ -1075,7 +1075,7 @@ let gen ~contexts ~build_system
|
||||||
~scopes
|
~scopes
|
||||||
~file_tree
|
~file_tree
|
||||||
~packages
|
~packages
|
||||||
~filter_out_optional_stanzas_with_missing_deps
|
~external_lib_deps_mode
|
||||||
~stanzas
|
~stanzas
|
||||||
in
|
in
|
||||||
let module M = Gen(struct let sctx = sctx end) in
|
let module M = Gen(struct let sctx = sctx end) in
|
||||||
|
|
|
@ -5,7 +5,7 @@ open Jbuild
|
||||||
val gen
|
val gen
|
||||||
: contexts:Context.t list
|
: contexts:Context.t list
|
||||||
-> build_system:Build_system.t
|
-> build_system:Build_system.t
|
||||||
-> ?filter_out_optional_stanzas_with_missing_deps:bool (* default: true *)
|
-> ?external_lib_deps_mode:bool (* default: false *)
|
||||||
-> ?only_packages:Package.Name.Set.t
|
-> ?only_packages:Package.Name.Set.t
|
||||||
-> Jbuild_load.conf
|
-> Jbuild_load.conf
|
||||||
-> (Path.t * Scope_info.t * Stanzas.t) list String_map.t Fiber.t
|
-> (Path.t * Scope_info.t * Stanzas.t) list String_map.t Fiber.t
|
||||||
|
|
10
src/lib.ml
10
src/lib.ml
|
@ -1013,14 +1013,20 @@ module DB = struct
|
||||||
| Some x -> x)
|
| Some x -> x)
|
||||||
~all:(fun () -> String_map.keys map)
|
~all:(fun () -> String_map.keys map)
|
||||||
|
|
||||||
let create_from_findlib findlib =
|
let create_from_findlib ?(external_lib_deps_mode=false) findlib =
|
||||||
create ()
|
create ()
|
||||||
~resolve:(fun name ->
|
~resolve:(fun name ->
|
||||||
match Findlib.find findlib name with
|
match Findlib.find findlib name with
|
||||||
| Ok pkg -> Found (Info.of_findlib_package pkg)
|
| Ok pkg -> Found (Info.of_findlib_package pkg)
|
||||||
| Error e ->
|
| Error e ->
|
||||||
match e with
|
match e with
|
||||||
| Not_found -> Not_found
|
| Not_found ->
|
||||||
|
if external_lib_deps_mode then
|
||||||
|
Found
|
||||||
|
(Info.of_findlib_package
|
||||||
|
(Findlib.dummy_package findlib ~name))
|
||||||
|
else
|
||||||
|
Not_found
|
||||||
| Hidden pkg ->
|
| Hidden pkg ->
|
||||||
Hidden (Info.of_findlib_package pkg,
|
Hidden (Info.of_findlib_package pkg,
|
||||||
"unsatisfied 'exist_if'"))
|
"unsatisfied 'exist_if'"))
|
||||||
|
|
|
@ -257,7 +257,10 @@ module DB : sig
|
||||||
-> (Path.t * Jbuild.Library.t) list
|
-> (Path.t * Jbuild.Library.t) list
|
||||||
-> t
|
-> t
|
||||||
|
|
||||||
val create_from_findlib : Findlib.t -> t
|
val create_from_findlib
|
||||||
|
: ?external_lib_deps_mode:bool
|
||||||
|
-> Findlib.t
|
||||||
|
-> t
|
||||||
|
|
||||||
val find : t -> string -> (lib, Error.Library_not_available.Reason.t) result
|
val find : t -> string -> (lib, Error.Library_not_available.Reason.t) result
|
||||||
val find_many
|
val find_many
|
||||||
|
|
|
@ -29,7 +29,7 @@ let setup_env ~capture_outputs =
|
||||||
Env.add env ~var:"INSIDE_DUNE" ~value:"1"
|
Env.add env ~var:"INSIDE_DUNE" ~value:"1"
|
||||||
|
|
||||||
let setup ?(log=Log.no_log)
|
let setup ?(log=Log.no_log)
|
||||||
?filter_out_optional_stanzas_with_missing_deps
|
?external_lib_deps_mode
|
||||||
?workspace ?(workspace_file="jbuild-workspace")
|
?workspace ?(workspace_file="jbuild-workspace")
|
||||||
?only_packages
|
?only_packages
|
||||||
?extra_ignored_subtrees
|
?extra_ignored_subtrees
|
||||||
|
@ -92,7 +92,7 @@ let setup ?(log=Log.no_log)
|
||||||
~build_system
|
~build_system
|
||||||
~contexts
|
~contexts
|
||||||
?only_packages
|
?only_packages
|
||||||
?filter_out_optional_stanzas_with_missing_deps
|
?external_lib_deps_mode
|
||||||
>>= fun stanzas ->
|
>>= fun stanzas ->
|
||||||
Scheduler.set_status_line_generator gen_status_line
|
Scheduler.set_status_line_generator gen_status_line
|
||||||
>>>
|
>>>
|
||||||
|
@ -113,7 +113,7 @@ let find_context_exn t ~name =
|
||||||
|
|
||||||
let external_lib_deps ?log ~packages () =
|
let external_lib_deps ?log ~packages () =
|
||||||
Scheduler.go ?log
|
Scheduler.go ?log
|
||||||
(setup () ~filter_out_optional_stanzas_with_missing_deps:false
|
(setup () ~external_lib_deps_mode:true
|
||||||
>>| fun setup ->
|
>>| fun setup ->
|
||||||
let context = find_context_exn setup ~name:"default" in
|
let context = find_context_exn setup ~name:"default" in
|
||||||
let install_files =
|
let install_files =
|
||||||
|
|
|
@ -18,7 +18,7 @@ val package_install_file : setup -> Package.Name.t -> (Path.t, unit) result
|
||||||
it. *)
|
it. *)
|
||||||
val setup
|
val setup
|
||||||
: ?log:Log.t
|
: ?log:Log.t
|
||||||
-> ?filter_out_optional_stanzas_with_missing_deps:bool
|
-> ?external_lib_deps_mode:bool
|
||||||
-> ?workspace:Workspace.t
|
-> ?workspace:Workspace.t
|
||||||
-> ?workspace_file:string
|
-> ?workspace_file:string
|
||||||
-> ?only_packages:Package.Name.Set.t
|
-> ?only_packages:Package.Name.Set.t
|
||||||
|
|
|
@ -74,10 +74,12 @@ let create
|
||||||
~file_tree
|
~file_tree
|
||||||
~packages
|
~packages
|
||||||
~stanzas
|
~stanzas
|
||||||
~filter_out_optional_stanzas_with_missing_deps
|
~external_lib_deps_mode
|
||||||
~build_system
|
~build_system
|
||||||
=
|
=
|
||||||
let installed_libs = Lib.DB.create_from_findlib context.findlib in
|
let installed_libs =
|
||||||
|
Lib.DB.create_from_findlib context.findlib ~external_lib_deps_mode
|
||||||
|
in
|
||||||
let internal_libs =
|
let internal_libs =
|
||||||
List.concat_map stanzas ~f:(fun (dir, _, stanzas) ->
|
List.concat_map stanzas ~f:(fun (dir, _, stanzas) ->
|
||||||
let ctx_dir = Path.append context.build_dir dir in
|
let ctx_dir = Path.append context.build_dir dir in
|
||||||
|
@ -109,7 +111,7 @@ let create
|
||||||
})
|
})
|
||||||
in
|
in
|
||||||
let stanzas_to_consider_for_install =
|
let stanzas_to_consider_for_install =
|
||||||
if filter_out_optional_stanzas_with_missing_deps then
|
if not external_lib_deps_mode then
|
||||||
List.concat_map stanzas ~f:(fun { ctx_dir; stanzas; scope; _ } ->
|
List.concat_map stanzas ~f:(fun { ctx_dir; stanzas; scope; _ } ->
|
||||||
List.filter_map stanzas ~f:(fun stanza ->
|
List.filter_map stanzas ~f:(fun stanza ->
|
||||||
let keep =
|
let keep =
|
||||||
|
|
|
@ -27,7 +27,7 @@ val create
|
||||||
-> file_tree:File_tree.t
|
-> file_tree:File_tree.t
|
||||||
-> packages:Package.t Package.Name.Map.t
|
-> packages:Package.t Package.Name.Map.t
|
||||||
-> stanzas:(Path.t * Scope_info.t * Stanzas.t) list
|
-> stanzas:(Path.t * Scope_info.t * Stanzas.t) list
|
||||||
-> filter_out_optional_stanzas_with_missing_deps:bool
|
-> external_lib_deps_mode:bool
|
||||||
-> build_system:Build_system.t
|
-> build_system:Build_system.t
|
||||||
-> t
|
-> t
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,13 @@
|
||||||
|
|
||||||
These should print something:
|
These should print something:
|
||||||
|
|
||||||
$ jbuilder external-lib-deps @runtest
|
$ jbuilder external-lib-deps --display quiet @runtest
|
||||||
|
These are the external library dependencies in the default context:
|
||||||
|
- ocaml-migrate-parsetree.driver-main
|
||||||
|
- ppx_that_doesn't_exist
|
||||||
|
|
||||||
$ jbuilder external-lib-deps --missing @runtest
|
$ jbuilder external-lib-deps --display quiet --missing @runtest
|
||||||
|
Error: The following libraries are missing in the default context:
|
||||||
|
- ppx_that_doesn't_exist
|
||||||
|
Hint: try: opam install ppx_that_doesn't_exist
|
||||||
|
[1]
|
||||||
|
|
Loading…
Reference in New Issue