More hacks for external-lib-deps

Fix #644
This commit is contained in:
Jeremie Dimino 2018-03-30 21:52:18 -04:00 committed by Rudi Grinberg
parent 1215fe2f8a
commit 22b024a977
12 changed files with 54 additions and 20 deletions

View File

@ -72,12 +72,12 @@ let restore_cwd_and_execve common prog argv env =
module Main = struct
include Jbuilder.Main
let setup ~log ?filter_out_optional_stanzas_with_missing_deps common =
let setup ~log ?external_lib_deps_mode common =
setup
~log
?workspace_file:common.workspace_file
?only_packages:common.only_packages
?filter_out_optional_stanzas_with_missing_deps
?external_lib_deps_mode
?x:common.x
~ignore_promoted_rules:common.ignore_promoted_rules
~capture_outputs:common.capture_outputs
@ -752,7 +752,7 @@ let external_lib_deps =
set_common common ~targets:[];
let log = Log.create common in
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 ->
let targets = resolve_targets_exn ~log common setup targets in
let request = request_of_targets setup targets in
@ -858,7 +858,7 @@ let rules =
set_common common ~targets;
let log = Log.create common in
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 ->
let request =
match targets with

View File

@ -174,6 +174,19 @@ let root_package_name s =
| None -> s
| 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 *)
let parse_package t ~meta_file ~name ~parent_dir ~vars =
let pkg_dir = Vars.get vars "directory" Ps.empty in

View File

@ -55,6 +55,9 @@ val all_packages : t -> Package.t list
(** List all the packages that are not available in this database *)
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
type t
val load : Path.t -> toolchain:string -> context:string -> t

View File

@ -1027,7 +1027,7 @@ module type Gen = sig
end
let gen ~contexts ~build_system
?(filter_out_optional_stanzas_with_missing_deps=true)
?(external_lib_deps_mode=false)
?only_packages conf =
let open Fiber.O in
let { Jbuild_load. file_tree; jbuilds; packages; scopes } = conf in
@ -1075,7 +1075,7 @@ let gen ~contexts ~build_system
~scopes
~file_tree
~packages
~filter_out_optional_stanzas_with_missing_deps
~external_lib_deps_mode
~stanzas
in
let module M = Gen(struct let sctx = sctx end) in

View File

@ -5,7 +5,7 @@ open Jbuild
val gen
: contexts:Context.t list
-> 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
-> Jbuild_load.conf
-> (Path.t * Scope_info.t * Stanzas.t) list String_map.t Fiber.t

View File

@ -1013,14 +1013,20 @@ module DB = struct
| Some x -> x)
~all:(fun () -> String_map.keys map)
let create_from_findlib findlib =
let create_from_findlib ?(external_lib_deps_mode=false) findlib =
create ()
~resolve:(fun name ->
match Findlib.find findlib name with
| Ok pkg -> Found (Info.of_findlib_package pkg)
| Error e ->
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 (Info.of_findlib_package pkg,
"unsatisfied 'exist_if'"))

View File

@ -257,7 +257,10 @@ module DB : sig
-> (Path.t * Jbuild.Library.t) list
-> 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_many

View File

@ -29,7 +29,7 @@ let setup_env ~capture_outputs =
Env.add env ~var:"INSIDE_DUNE" ~value:"1"
let setup ?(log=Log.no_log)
?filter_out_optional_stanzas_with_missing_deps
?external_lib_deps_mode
?workspace ?(workspace_file="jbuild-workspace")
?only_packages
?extra_ignored_subtrees
@ -92,7 +92,7 @@ let setup ?(log=Log.no_log)
~build_system
~contexts
?only_packages
?filter_out_optional_stanzas_with_missing_deps
?external_lib_deps_mode
>>= fun stanzas ->
Scheduler.set_status_line_generator gen_status_line
>>>
@ -113,7 +113,7 @@ let find_context_exn t ~name =
let external_lib_deps ?log ~packages () =
Scheduler.go ?log
(setup () ~filter_out_optional_stanzas_with_missing_deps:false
(setup () ~external_lib_deps_mode:true
>>| fun setup ->
let context = find_context_exn setup ~name:"default" in
let install_files =

View File

@ -18,7 +18,7 @@ val package_install_file : setup -> Package.Name.t -> (Path.t, unit) result
it. *)
val setup
: ?log:Log.t
-> ?filter_out_optional_stanzas_with_missing_deps:bool
-> ?external_lib_deps_mode:bool
-> ?workspace:Workspace.t
-> ?workspace_file:string
-> ?only_packages:Package.Name.Set.t

View File

@ -74,10 +74,12 @@ let create
~file_tree
~packages
~stanzas
~filter_out_optional_stanzas_with_missing_deps
~external_lib_deps_mode
~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 =
List.concat_map stanzas ~f:(fun (dir, _, stanzas) ->
let ctx_dir = Path.append context.build_dir dir in
@ -109,7 +111,7 @@ let create
})
in
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.filter_map stanzas ~f:(fun stanza ->
let keep =

View File

@ -27,7 +27,7 @@ val create
-> file_tree:File_tree.t
-> packages:Package.t Package.Name.Map.t
-> 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
-> t

View File

@ -6,6 +6,13 @@
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]