Skip to content

Commit

Permalink
[coq] Generate flags correctly for use_stdlib
Browse files Browse the repository at this point in the history
Signed-off-by: Emilio Jesus Gallego Arias <e+git@x80.org>
  • Loading branch information
ejgallego committed Sep 28, 2022
1 parent 3582ba2 commit 4e6d57f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/dune_rules/coq_lib.ml
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ module DB = struct
let open Memo.O in
let* boot = if s.boot then Resolve.Memo.return None else boot coq_db in
let allow_private_deps = Option.is_none s.package in
let use_stdlib = true in
let use_stdlib = s.buildable.use_stdlib in
let+ libraries =
Resolve.Memo.List.map s.buildable.plugins ~f:(fun (loc, lib) ->
let open Resolve.Memo.O in
Expand Down
12 changes: 10 additions & 2 deletions src/dune_rules/coq_rules.ml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ module Bootstrap = struct
(** We are compiling the prelude itself
[should be replaced with (per_file ...) flags] *)

let get ~boot_lib ~wrapper_name coq_module =
let get_for_module ~boot_lib ~wrapper_name coq_module =
match boot_lib with
| None -> No_boot
| Some (_loc, lib) -> (
Expand All @@ -127,6 +127,10 @@ module Bootstrap = struct
| false -> Bootstrap lib
| true -> Bootstrap_prelude)

let get ~use_stdlib ~boot_lib ~wrapper_name coq_module =
if not use_stdlib then Bootstrap_prelude
else get_for_module ~boot_lib ~wrapper_name coq_module

let boot_lib_flags ~coqdoc lib : _ Command.Args.t =
let dir = Coq_lib.src_root lib in
S
Expand Down Expand Up @@ -171,6 +175,7 @@ module Context = struct
; ml_flags : 'a Command.Args.t Resolve.Memo.t
; scope : Scope.t
; boot_type : Bootstrap.t Resolve.Memo.t
; use_stdlib : bool
; profile_flags : string list Action_builder.t
; mode : Coq_mode.t
; native_includes : Path.Set.t Resolve.t
Expand Down Expand Up @@ -283,6 +288,7 @@ module Context = struct
let create ~coqc_dir sctx ~dir ~wrapper_name ~theories_deps ~theory_dirs
(buildable : Buildable.t) =
let loc = buildable.loc in
let use_stdlib = buildable.use_stdlib in
let rr = resolve_program sctx ~dir ~loc in
let* expander = Super_context.expander sctx ~dir in
let* scope = Scope.DB.find_by_dir dir in
Expand Down Expand Up @@ -315,6 +321,7 @@ module Context = struct
; ml_flags
; scope
; boot_type = Resolve.Memo.return Bootstrap.No_boot
; use_stdlib
; profile_flags
; mode
; native_includes
Expand All @@ -325,7 +332,8 @@ module Context = struct
let boot_type =
let open Resolve.Memo.O in
let+ boot_lib = t.scope |> Scope.coq_libs |> Coq_lib.DB.boot_library in
Bootstrap.get ~boot_lib ~wrapper_name:t.wrapper_name coq_module
Bootstrap.get ~use_stdlib:t.use_stdlib ~boot_lib
~wrapper_name:t.wrapper_name coq_module
in
{ t with boot_type }
end
Expand Down
6 changes: 5 additions & 1 deletion src/dune_rules/coq_stanza.ml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ module Buildable = struct
{ flags : Ordered_set_lang.Unexpanded.t
; coq_lang_version : Dune_sexp.Syntax.Version.t
; mode : Loc.t * Coq_mode.t
; use_stdlib : bool
; plugins : (Loc.t * Lib_name.t) list (** ocaml libraries *)
; theories : (Loc.t * Coq_lib_name.t) list (** coq libraries *)
; loc : Loc.t
Expand Down Expand Up @@ -60,6 +61,9 @@ module Buildable = struct
located
(field "mode" ~default
(Dune_lang.Syntax.since coq_syntax (0, 3) >>> Coq_mode.decode))
and+ use_stdlib =
field ~default:true "stdlib"
Dune_lang.Decoder.(enum [ ("yes", true); ("no", false) ])
and+ libraries =
field "libraries" ~default:[]
(Dune_sexp.Syntax.deprecated_in coq_syntax (0, 5)
Expand All @@ -73,7 +77,7 @@ module Buildable = struct
~default:[]
in
let plugins = merge_plugins_libraries ~plugins ~libraries in
{ flags; mode; coq_lang_version; plugins; theories; loc }
{ flags; mode; use_stdlib; coq_lang_version; plugins; theories; 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 @@ -5,6 +5,7 @@ module Buildable : sig
{ flags : Ordered_set_lang.Unexpanded.t
; coq_lang_version : Dune_sexp.Syntax.Version.t
; mode : Loc.t * Coq_mode.t
; use_stdlib : bool
; plugins : (Loc.t * Lib_name.t) list (** ocaml plugins *)
; theories : (Loc.t * Coq_lib_name.t) list (** coq libraries *)
; loc : Loc.t
Expand Down

0 comments on commit 4e6d57f

Please sign in to comment.