Skip to content

Commit 826db51

Browse files
committed
Add --coqlib, --passing-coqlib
In preparation for threading them through more explicitly.
1 parent e13f58e commit 826db51

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

coq_tools/custom_arguments.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,13 @@ def add_libname_arguments_gen(parser, passing):
152152
help='Arguments to pass to coqc and coqtop; e.g., " -indices-matter" (leading and trailing spaces are stripped)'
153153
+ passing_for,
154154
)
155+
parser.add_argument(
156+
twodash_passing_dash + "coqlib",
157+
metavar="COQLIB",
158+
dest=passing_underscore + "coqlib",
159+
type=str,
160+
help="Coqlib argument to pass to Coq" + passing_for,
161+
)
155162
parser.add_argument(
156163
onedash_passing_dash + "f",
157164
metavar="FILE",
@@ -268,9 +275,13 @@ def argstring_to_iterable(arg):
268275
return arg.split(" ")
269276

270277

271-
def append_coq_arg(env, arg, passing=""):
278+
def append_coq_args_raw(env, *args, passing=""):
272279
for key in ("coqc_args", "coqtop_args"):
273-
env[passing + key] = tuple(list(env.get(passing + key, [])) + list(argstring_to_iterable(arg)))
280+
env[passing + key] = tuple(list(env.get(passing + key, [])) + list(args))
281+
282+
283+
def append_coq_arg(env, arg, passing=""):
284+
append_coq_args_raw(env, *argstring_to_iterable(arg), passing=passing)
274285

275286

276287
def process_CoqProject(env, contents, passing=""):
@@ -370,6 +381,11 @@ def do_with_path(path):
370381
do_with_path(coqpath if coqpath != "" else ".")
371382

372383

384+
def update_env_with_coqlib(passing_prefix, env):
385+
if env.get(passing_prefix + "coqlib"):
386+
append_coq_args_raw(env, "-coqlib", env[passing_prefix + "coqlib"], passing=passing_prefix)
387+
388+
373389
# http://stackoverflow.com/questions/5943249/python-argparse-and-controlling-overriding-the-exit-status-code
374390
class ArgumentParser(argparse.ArgumentParser):
375391
def _get_action_from_name(self, name):

coq_tools/find_bug.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
add_passing_libname_arguments,
4545
update_env_with_libnames,
4646
update_env_with_coqpath_folders,
47+
update_env_with_coqlib,
4748
add_logging_arguments,
4849
process_logging_arguments,
4950
get_parser_name_mapping,
@@ -2085,6 +2086,8 @@ def prepend_coqbin(prog):
20852086
"admit_obligations": args.admit_obligations and args.admit_any,
20862087
"aggressive": args.aggressive,
20872088
"admit_transparent": args.admit_transparent and args.admit_any,
2089+
"coqlib": args.coqlib,
2090+
"passing_coqlib": args.passing_coqlib,
20882091
"coqc_args": tuple(
20892092
i.strip()
20902093
for i in (
@@ -2189,6 +2192,9 @@ def prepend_coqbin(prog):
21892192
if env["temp_file_log_name"] == "":
21902193
env["temp_file_log_name"] = env["temp_file_name"] + ".log"
21912194

2195+
for passing_prefix in ("", "passing_"):
2196+
update_env_with_coqlib(env=env, passing_prefix=passing_prefix)
2197+
21922198
def make_make_coqc(coqc_prog, **kwargs):
21932199
if get_coq_accepts_compile(coqc_prog):
21942200
return f"{util.resource_path('coqtop-as-coqc.sh')} {coqc_prog}"

coq_tools/inline_imports.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
update_env_with_libnames,
88
update_env_with_coqpath_folders,
99
add_logging_arguments,
10+
update_env_with_coqlib,
1011
process_logging_arguments,
1112
get_parser_name_mapping,
1213
)
@@ -141,6 +142,7 @@ def main():
141142
"walk_tree": args.walk_tree,
142143
"cli_mapping": get_parser_name_mapping(parser),
143144
}
145+
update_env_with_coqlib("", env)
144146
update_env_with_libnames(env, args)
145147
if args.inline_user_contrib:
146148
update_env_with_coqpath_folders(

0 commit comments

Comments
 (0)