Skip to content

Commit

Permalink
[coq_lib] Enforce that boot libraries depend on no theories
Browse files Browse the repository at this point in the history
Signed-off-by: Emilio Jesus Gallego Arias <[email protected]>
  • Loading branch information
ejgallego committed Jun 11, 2022
1 parent f2f42dd commit 5e243ec
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/dune_rules/coq_stanza.ml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,16 @@ module Theory = struct
1.0 version of the Coq language"
]

let boot_has_deps loc =
User_error.raise ~loc
[ Pp.textf "(boot) libraries cannot have dependencies" ]

let check_boot_has_no_deps boot { Buildable.theories; _ } =
if boot then
match theories with
| [] -> ()
| t :: _ -> boot_has_deps (fst t)

let decode =
fields
(let+ loc, name = field "name" Coq_lib_name.decode
Expand All @@ -145,6 +155,8 @@ module Theory = struct
and+ modules = Stanza_common.modules_field "modules"
and+ enabled_if = Enabled_if.decode ~allowed_vars:Any ~since:None ()
and+ buildable = Buildable.decode in
(* boot libraries cannot depend on other theories *)
check_boot_has_no_deps boot buildable;
let package = select_deprecation ~package ~public in
{ loc
; name
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Inductive AnotherBegining := Of | The | Universe.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(coq.theory
(name A)
(package A)
(theories B)
(boot))
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(lang dune 2.5)

(using coq 0.2)
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Inductive Begining := Of | The | Universe.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(coq.theory
(name B)
(package B))


Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(lang dune 2.5)

(using coq 0.2)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(lang dune 3.2)
11 changes: 11 additions & 0 deletions test/blackbox-tests/test-cases/coq/compose-boot-nodeps.t/run.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Testing composition with two boot libraries

$ dune build
File "A/dune", line 1, characters 0-57:
1 | (coq.theory
2 | (name A)
3 | (package A)
4 | (theories B)
5 | (boot))
Error: (boot) libraries cannot have dependencies
[1]

0 comments on commit 5e243ec

Please sign in to comment.