Libraries and executables can allow overlapping dependencies

This commit is contained in:
Jeremie Dimino 2018-03-05 16:33:03 +00:00 committed by Jérémie Dimino
parent a5f9a9e063
commit 232acdd92f
4 changed files with 20 additions and 5 deletions

View File

@ -177,6 +177,9 @@ modules you want.
such modules to avoid surprises. ``<modules>`` must be a subset of
the modules listed in the ``(modules ...)`` field.
- ``(allow_overlapping_dependencies)`` allows external dependencies to
overlap with libraries that are present in the workspace
Note that when binding C libraries, Jbuilder doesn't provide special support for
tools such as ``pkg-config``, however it integrates easily with `configurator
<https://github.com/janestreet/configurator>`__ by using ``(c_flags (:include
@ -263,6 +266,9 @@ binary at the same place as where ``ocamlc`` was found, or when there is a
- ``(modules_without_implementation <modules>)`` is the same as the
corresponding field of `library`_
- ``(allow_overlapping_dependencies)`` is the same as the
corresponding field of `library`_
executables
-----------

View File

@ -559,7 +559,10 @@ module Gen(P : Install_rules.Params) = struct
|> String.concat ~sep:"\n")
>>> Build.write_file_dyn (Path.relative dir file.name)));
let compile_info = Lib.DB.get_compile_info (Scope.libs scope) lib.name in
let compile_info =
Lib.DB.get_compile_info (Scope.libs scope) lib.name
~allow_overlaps:lib.buildable.allow_overlapping_dependencies
in
let requires, real_requires =
SC.Libs.requires sctx compile_info
~dir ~has_dot_merlin:true
@ -810,6 +813,7 @@ module Gen(P : Install_rules.Params) = struct
Lib.DB.resolve_user_written_deps (Scope.libs scope)
exes.buildable.libraries
~pps:(Jbuild.Preprocess_map.pps exes.buildable.preprocess)
~allow_overlaps:exes.buildable.allow_overlapping_dependencies
in
let requires, real_requires =
SC.Libs.requires sctx ~dir

View File

@ -476,6 +476,7 @@ module Buildable = struct
; ocamlc_flags : Ordered_set_lang.Unexpanded.t
; ocamlopt_flags : Ordered_set_lang.Unexpanded.t
; js_of_ocaml : Js_of_ocaml.t
; allow_overlapping_dependencies : bool
}
let modules_field name =
@ -487,8 +488,6 @@ module Buildable = struct
>>= fun preprocess ->
field "preprocessor_deps" (list Dep_conf.t) ~default:[]
>>= fun preprocessor_deps ->
(* CR-someday jdimino: remove this. There are still a few Jane Street packages using
this *)
field "lint" Lint.t ~default:Lint.default
>>= fun lint ->
modules_field "modules"
@ -500,7 +499,10 @@ module Buildable = struct
field_oslu "flags" >>= fun flags ->
field_oslu "ocamlc_flags" >>= fun ocamlc_flags ->
field_oslu "ocamlopt_flags" >>= fun ocamlopt_flags ->
field "js_of_ocaml" (Js_of_ocaml.t) ~default:Js_of_ocaml.default >>= fun js_of_ocaml ->
field "js_of_ocaml" (Js_of_ocaml.t) ~default:Js_of_ocaml.default
>>= fun js_of_ocaml ->
field_b "allow_overlapping_dependencies"
>>= fun allow_overlapping_dependencies ->
return
{ loc
; preprocess
@ -513,6 +515,7 @@ module Buildable = struct
; ocamlc_flags
; ocamlopt_flags
; js_of_ocaml
; allow_overlapping_dependencies
}
let single_preprocess t =
@ -867,7 +870,8 @@ module Rule = struct
return (fallback, mode))
~f:(function
| true, Some _ ->
Error "Cannot use both (fallback) and (mode ...) at the same time.\n\
Error "Cannot use both (fallback) and (mode ...) at the \
same time.\n\
(fallback) is the same as (mode fallback), \
please use the latter in new code."
| false, Some mode -> Ok mode

View File

@ -143,6 +143,7 @@ module Buildable : sig
; ocamlc_flags : Ordered_set_lang.Unexpanded.t
; ocamlopt_flags : Ordered_set_lang.Unexpanded.t
; js_of_ocaml : Js_of_ocaml.t
; allow_overlapping_dependencies : bool
}
(** Preprocessing specification used by all modules or [No_preprocessing] *)