Skip to content

Commit b383828

Browse files
Better support for mli/rei only modules (#489)
1 parent f083b6a commit b383828

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+582
-291
lines changed

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ next
2626
directory can't see each other unless one of them depend on the
2727
other (#472)
2828

29+
- Better support for mli/rei only modules (#490)
30+
2931
1.0+beta17 (01/02/2018)
3032
-----------------------
3133

doc/jbuild.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,16 @@ modules you want.
167167
build system. It is not for casual uses, see the `re2 library
168168
<https://github.com/janestreet/re2>`__ for an example of use
169169

170+
- ``(modules_without_implementation <modules>)`` specifies a list of
171+
modules that have only a ``.mli`` or ``.rei`` but no ``.ml`` or
172+
``.re`` file. Such modules are usually referred as *mli only
173+
modules*. They are not officially supported by the OCaml compiler,
174+
however they are commonly used. Such modules must only define
175+
types. Since it is not reasonably possible for Jbuilder to check
176+
that this is the case, Jbuilder requires the user to explicitly list
177+
such modules to avoid surprises. ``<modules>`` must be a subset of
178+
the modules listed in the ``(modules ...)`` field.
179+
170180
Note that when binding C libraries, Jbuilder doesn't provide special support for
171181
tools such as ``pkg-config``, however it integrates easily with `configurator
172182
<https://github.com/janestreet/configurator>`__ by using ``(c_flags (:include
@@ -250,6 +260,9 @@ binary at the same place as where ``ocamlc`` was found, or when there is a
250260
- ``flags``, ``ocamlc_flags`` and ``ocamlopt_flags``. See the section about
251261
specifying `OCaml flags`_
252262

263+
- ``(modules_without_implementation <modules>)`` is the same as the
264+
corresponding field of `library`_
265+
253266
executables
254267
-----------
255268

src/context.ml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ type t =
5252
; opam_var_cache : (string, string) Hashtbl.t
5353
; natdynlink_supported : bool
5454
; ocamlc_config : (string * string) list
55-
; version : string
55+
; version_string : string
56+
; version : int * int * int
5657
; stdlib_dir : Path.t
5758
; ccomp_type : string
5859
; c_compiler : string
@@ -318,16 +319,16 @@ let create ~(kind : Kind.t) ~path ~base_env ~env_extra ~name ~merlin
318319
let get_path var = Path.absolute (get var) in
319320
let stdlib_dir = get_path "standard_library" in
320321
let natdynlink_supported = Path.exists (Path.relative stdlib_dir "dynlink.cmxa") in
321-
let version = get "version" in
322+
let version_string = get "version" in
323+
let version = Scanf.sscanf version_string "%u.%u.%u" (fun a b c -> a, b, c) in
322324
let env, env_extra =
323325
(* See comment in ansi_color.ml for setup_env_for_colors. For OCaml < 4.05,
324326
OCAML_COLOR is not supported so we use OCAMLPARAM. OCaml 4.02 doesn't support
325327
'color' in OCAMLPARAM, so we just don't force colors with 4.02. *)
326-
let ocaml_version = Scanf.sscanf version "%u.%u" (fun a b -> a, b) in
327328
if !Clflags.capture_outputs
328329
&& Lazy.force Ansi_color.stderr_supports_colors
329-
&& ocaml_version > (4, 02)
330-
&& ocaml_version < (4, 05) then
330+
&& version >= (4, 03, 0)
331+
&& version < (4, 05, 0) then
331332
let value =
332333
match get_env env "OCAMLPARAM" with
333334
| None -> "color=always,_"
@@ -401,6 +402,7 @@ let create ~(kind : Kind.t) ~path ~base_env ~env_extra ~name ~merlin
401402

402403
; stdlib_dir
403404
; ocamlc_config = String_map.bindings ocamlc_config
405+
; version_string
404406
; version
405407
; ccomp_type = get "ccomp_type"
406408
; c_compiler

src/context.mli

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ type t =
8888

8989
; (** Output of [ocamlc -config] *)
9090
ocamlc_config : (string * string) list
91-
; version : string
91+
; version_string : string
92+
; version : int * int * int
9293
; stdlib_dir : Path.t
9394
; ccomp_type : string
9495
; c_compiler : string

0 commit comments

Comments
 (0)