Skip to content

Commit

Permalink
Create (stdlib) syntax for Coq stanza
Browse files Browse the repository at this point in the history
  • Loading branch information
LasseBlaauwbroek committed Sep 27, 2022
1 parent 2531e72 commit b56b0e7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/dune_rules/coq_rules.ml
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ let setup_coqdep_rule ~sctx ~loc (cctx : _ Context.t) ~source_rule coq_module =
let source = Coq_module.source coq_module in
let file_flags =
let file_flags = Context.coqc_file_flags cctx in
(if cctx.buildable.stdlib then [] else [Command.Args.A "-boot"]) @
[ Command.Args.S file_flags
; As [ "-dyndep"; "opt" ]
; Dep (Path.build source)
Expand All @@ -399,6 +400,8 @@ let coqc_rule (cctx : _ Context.t) ~file_flags coq_module =
|> List.map ~f:fst
in
let native_flags = Context.coqc_native_flags cctx in
(if cctx.buildable.stdlib then [] else
[Command.Args.A "-boot"; A "-noinit"]) @
[ Command.Args.Hidden_targets objects_to
; native_flags
; S file_flags
Expand Down
8 changes: 7 additions & 1 deletion src/dune_rules/coq_stanza.ml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ let coq_syntax =
; ((0, 3), `Since (2, 8))
; ((0, 4), `Since (3, 3))
; ((0, 5), `Since (3, 4))
; ((0, 6), `Since (3, 5))
]

module Buildable = struct
Expand All @@ -34,6 +35,7 @@ module Buildable = struct
; mode : Loc.t * Coq_mode.t
; plugins : (Loc.t * Lib_name.t) list (** ocaml libraries *)
; theories : (Loc.t * Coq_lib_name.t) list (** coq libraries *)
; stdlib : bool
; loc : Loc.t
}

Expand Down Expand Up @@ -71,9 +73,13 @@ module Buildable = struct
field "theories"
(Dune_lang.Syntax.since coq_syntax (0, 2) >>> repeat Coq_lib_name.decode)
~default:[]
and+ stdlib =
field "stdlib"
(Dune_lang.Syntax.since coq_syntax (0, 6) >>> enum ["yes", true; "no", false])
~default:true
in
let plugins = merge_plugins_libraries ~plugins ~libraries in
{ flags; mode; coq_lang_version; plugins; theories; loc }
{ flags; mode; coq_lang_version; plugins; theories; stdlib; loc }
end

module Extraction = struct
Expand Down
1 change: 1 addition & 0 deletions src/dune_rules/coq_stanza.mli
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module Buildable : sig
; mode : Loc.t * Coq_mode.t
; plugins : (Loc.t * Lib_name.t) list (** ocaml plugins *)
; theories : (Loc.t * Coq_lib_name.t) list (** coq libraries *)
; stdlib : bool
; loc : Loc.t
}
end
Expand Down

0 comments on commit b56b0e7

Please sign in to comment.