Skip to content

Commit

Permalink
feat: allow multiple globs in library's (stdlib (internal_modules ...))
Browse files Browse the repository at this point in the history
Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>
  • Loading branch information
anmonteiro committed Jun 10, 2023
1 parent 1d9065c commit 73fcee6
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ Unreleased
- Fix scanning of Coq installed files (@ejgallego, reported by
@palmskog, #7895 , fixes #7893)

- Allow multiple globs in library's `(stdlib (internal_modules ..))`
(@anmonteiro, #7878)

3.8.1 (2023-06-05)
------------------

Expand Down
4 changes: 3 additions & 1 deletion src/dune_rules/modules.ml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ module Stdlib = struct
compilation unit name of such modules, so they cannot be wrapped. *)
let special_compiler_module (stdlib : Ocaml_stdlib.t) m =
let name = Module.name m in
Glob.test stdlib.internal_modules (Module_name.to_string name)
let name_str = Module_name.to_string name in
Predicate_lang.Glob.test stdlib.internal_modules
~standard:Predicate_lang.false_ name_str
||
match stdlib.exit_module with
| None -> false
Expand Down
5 changes: 3 additions & 2 deletions src/dune_rules/ocaml_stdlib.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ open! Import
type t =
{ modules_before_stdlib : Module_name.Set.t
; exit_module : Module_name.t option
; internal_modules : Glob.t
; internal_modules : Predicate_lang.Glob.t
; loc : Loc.t
}

Expand All @@ -24,7 +24,8 @@ let decode =
field "modules_before_stdlib" (repeat Module_name.decode) ~default:[]
and+ exit_module = field_o "exit_module" Module_name.decode
and+ internal_modules =
field "internal_modules" Glob.decode ~default:Dune_lang.Glob.empty
field "internal_modules" Predicate_lang.Glob.decode
~default:Predicate_lang.false_
and+ loc = loc in
{ modules_before_stdlib = Module_name.Set.of_list modules_before_stdlib
; exit_module
Expand Down
2 changes: 1 addition & 1 deletion src/dune_rules/ocaml_stdlib.mli
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type t = private
; exit_module : Module_name.t option
(** Modules that are implicitly added by the compiler at the end when
linking an executable *)
; internal_modules : Glob.t
; internal_modules : Predicate_lang.Glob.t
(** Module names that are hardcoded in the compiler and so cannot be
wrapped *)
; loc : Loc.t
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,18 @@ Compile a library with `(stdlib ..)` and multiple globs for internal_modules
> module Other = Other
> EOF

First we test wrapped:

$ cat >stdlib/dune <<EOF
> (library
> (name mystdlib)
> (stdlib
> (internal_modules one* other)))
> EOF

Works when setting the correct version

$ dune build
File "stdlib/dune", line 4, characters 25-30:
4 | (internal_modules one* other)))
^^^^^
Error: Too many arguments for internal_modules
[1]
$ find _build/default/stdlib -iname '*.cmi' | sort;
find: '_build/default/stdlib': No such file or directory
_build/default/stdlib/.mystdlib.objs/byte/mystdlib.cmi
_build/default/stdlib/.mystdlib.objs/byte/mystdlib__One_module.cmi
_build/default/stdlib/.mystdlib.objs/byte/mystdlib__Other.cmi

0 comments on commit 73fcee6

Please sign in to comment.