Skip to content

Commit

Permalink
[coq] Generate flags correctly for use_stdlib
Browse files Browse the repository at this point in the history
  • Loading branch information
ejgallego committed Sep 27, 2022
1 parent 54f3d2c commit b4b9e32
Show file tree
Hide file tree
Showing 4 changed files with 16 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
5 changes: 4 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 All @@ -50,6 +51,8 @@ module Buildable = struct
]

let decode =
(* XXX fixme *)
let use_stdlib = true in
let* coq_lang_version = Dune_lang.Syntax.get_exn coq_syntax in
let+ loc = loc
and+ flags = Ordered_set_lang.Unexpanded.field "flags"
Expand All @@ -73,7 +76,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 b4b9e32

Please sign in to comment.