Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1372 #1373

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ next

- Pass `--set-switch` to opam (#1341, fix #1337, @diml)

- Fix bad interaction between multi-directory libraries the `menhir`
stanza (#1373, fix #1372, @diml)

1.3.0 (23/09/2018)
------------------

Expand Down
22 changes: 12 additions & 10 deletions src/gen_rules.ml
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ module Gen(P : Install_rules.Params) = struct
| Stanza |
+-----------------------------------------------------------------+ *)

let gen_rules dir_contents
let gen_rules dir_contents cctxs
{ SC.Dir_with_dune. src_dir; ctx_dir; stanzas; scope; kind } =
let merlins, cctxs =
let rec loop stanzas merlins cctxs =
Expand Down Expand Up @@ -260,7 +260,7 @@ module Gen(P : Install_rules.Params) = struct
| _ ->
loop stanzas merlins cctxs
in
loop stanzas [] []
loop stanzas [] cctxs
in
Option.iter (Merlin.merge_all merlins) ~f:(fun m ->
let more_src_dirs =
Expand Down Expand Up @@ -298,14 +298,15 @@ module Gen(P : Install_rules.Params) = struct
produced by this stanza are part of."
})
| Some cctx ->
Menhir_rules.gen_rules cctx m
Menhir_rules.gen_rules cctx m ~dir:ctx_dir
end
| _ -> ())
| _ -> ());
cctxs

let gen_rules dir_contents ~dir =
let gen_rules dir_contents cctxs ~dir : (Loc.t * Compilation_context.t) list =
match SC.stanzas_in sctx ~dir with
| None -> ()
| Some d -> gen_rules dir_contents d
| None -> []
| Some d -> gen_rules dir_contents cctxs d

let gen_rules ~dir components : Build_system.extra_sub_directories_to_keep =
(match components with
Expand All @@ -327,13 +328,14 @@ module Gen(P : Install_rules.Params) = struct
let dir_contents = Dir_contents.get sctx ~dir in
match Dir_contents.kind dir_contents with
| Standalone ->
gen_rules dir_contents ~dir
ignore (gen_rules dir_contents [] ~dir : _ list)
| Group_part root ->
SC.load_dir sctx ~dir:(Dir_contents.dir root)
| Group_root (lazy subs) ->
gen_rules dir_contents ~dir;
let cctxs = gen_rules dir_contents [] ~dir in
List.iter subs ~f:(fun dc ->
gen_rules dir_contents ~dir:(Dir_contents.dir dc)));
ignore (gen_rules dir_contents cctxs ~dir:(Dir_contents.dir dc)
: _ list)));
match components with
| [] -> These (String.Set.of_list [".js"; "_doc"; ".ppx"])
| [(".js"|"_doc"|".ppx")] -> All
Expand Down
4 changes: 2 additions & 2 deletions src/menhir.ml
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,10 @@ let module_names (stanza : Dune_file.Menhir.t) =
| Some m -> [Module.Name.of_string m]
| None -> List.map stanza.modules ~f:Module.Name.of_string

let gen_rules cctx stanza =
let gen_rules cctx stanza ~dir =
let module R = Run(struct
let sctx = Compilation_context.super_context cctx
let dir = Compilation_context.dir cctx
let dir = dir
let scope = Compilation_context.scope cctx
let stanza = stanza
end) in
Expand Down
3 changes: 3 additions & 0 deletions src/menhir.mli
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
(** Menhir rules *)

open Stdune

(** Return the list of targets that are generated by this stanza. This
list of targets is used by the code that computes the list of
modules in the directory. *)
Expand All @@ -12,4 +14,5 @@ val module_names : Dune_file.Menhir.t -> Module.Name.t list
val gen_rules
: Compilation_context.t
-> Dune_file.Menhir.t
-> dir:Path.t
-> unit
10 changes: 10 additions & 0 deletions test/blackbox-tests/dune.inc
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,14 @@
test-cases/github1342
(progn (run %{exe:cram.exe} -test run.t) (diff? run.t run.t.corrected)))))

(alias
(name github1372)
(deps (package dune) (source_tree test-cases/github1372))
(action
(chdir
test-cases/github1372
(progn (run %{exe:cram.exe} -test run.t) (diff? run.t run.t.corrected)))))

(alias
(name github20)
(deps (package dune) (source_tree test-cases/github20))
Expand Down Expand Up @@ -986,6 +994,7 @@
(alias github1099)
(alias github1231)
(alias github1342)
(alias github1372)
(alias github20)
(alias github24)
(alias github25)
Expand Down Expand Up @@ -1102,6 +1111,7 @@
(alias github1099)
(alias github1231)
(alias github1342)
(alias github1372)
(alias github20)
(alias github24)
(alias github25)
Expand Down
1 change: 1 addition & 0 deletions test/blackbox-tests/test-cases/github1372/dir/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(menhir (modules parser))
9 changes: 9 additions & 0 deletions test/blackbox-tests/test-cases/github1372/dir/parser.mly
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
%start <char list> main
%token <char> TOKEN
%token EOF

%%

main:
| c = TOKEN EOF { [c] }
| c = TOKEN xs = main { c :: xs }
3 changes: 3 additions & 0 deletions test/blackbox-tests/test-cases/github1372/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(include_subdirs unqualified)

(library (name foo))
2 changes: 2 additions & 0 deletions test/blackbox-tests/test-cases/github1372/dune-project
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(lang dune 1.3)
(using menhir 1.0)
3 changes: 3 additions & 0 deletions test/blackbox-tests/test-cases/github1372/run.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Reproduction case for #1372

$ dune build foo.cma