|
44 | 44 | add_passing_libname_arguments, |
45 | 45 | update_env_with_libnames, |
46 | 46 | update_env_with_coqpath_folders, |
| 47 | + update_env_with_coqlib, |
47 | 48 | add_logging_arguments, |
48 | 49 | process_logging_arguments, |
49 | 50 | get_parser_name_mapping, |
@@ -2085,6 +2086,8 @@ def prepend_coqbin(prog): |
2085 | 2086 | "admit_obligations": args.admit_obligations and args.admit_any, |
2086 | 2087 | "aggressive": args.aggressive, |
2087 | 2088 | "admit_transparent": args.admit_transparent and args.admit_any, |
| 2089 | + "coqlib": args.coqlib, |
| 2090 | + "passing_coqlib": args.passing_coqlib, |
2088 | 2091 | "coqc_args": tuple( |
2089 | 2092 | i.strip() |
2090 | 2093 | for i in ( |
@@ -2151,145 +2154,142 @@ def prepend_coqbin(prog): |
2151 | 2154 | "cli_mapping": get_parser_name_mapping(parser), |
2152 | 2155 | } |
2153 | 2156 |
|
2154 | | - if bug_file_name[-2:] != ".v": |
2155 | | - env["log"]( |
2156 | | - "\nError: BUGGY_FILE must end in .v (value: %s)" % bug_file_name, force_stdout=True, level=LOG_ALWAYS |
2157 | | - ) |
2158 | | - sys.exit(1) |
2159 | | - if output_file_name[-2:] != ".v": |
2160 | | - env["log"]( |
2161 | | - "\nError: OUT_FILE must end in .v (value: %s)" % output_file_name, force_stdout=True, level=LOG_ALWAYS |
2162 | | - ) |
2163 | | - sys.exit(1) |
2164 | | - if os.path.exists(output_file_name): |
2165 | | - env["log"]( |
2166 | | - "\nWarning: OUT_FILE (%s) already exists. Would you like to overwrite?\n" % output_file_name, |
2167 | | - force_stdout=True, |
2168 | | - level=LOG_ALWAYS, |
2169 | | - ) |
2170 | | - if not yes_no_prompt(yes=env["yes"]): |
| 2157 | + try: |
| 2158 | + |
| 2159 | + if bug_file_name[-2:] != ".v": |
| 2160 | + env["log"]( |
| 2161 | + "\nError: BUGGY_FILE must end in .v (value: %s)" % bug_file_name, force_stdout=True, level=LOG_ALWAYS |
| 2162 | + ) |
| 2163 | + sys.exit(1) |
| 2164 | + if output_file_name[-2:] != ".v": |
| 2165 | + env["log"]( |
| 2166 | + "\nError: OUT_FILE must end in .v (value: %s)" % output_file_name, force_stdout=True, level=LOG_ALWAYS |
| 2167 | + ) |
2171 | 2168 | sys.exit(1) |
2172 | | - for k, arg in (("base_dir", "--base-dir"), ("passing_base_dir", "--passing-base-dir")): |
2173 | | - if env[k] is not None and not os.path.isdir(env[k]): |
| 2169 | + if os.path.exists(output_file_name): |
2174 | 2170 | env["log"]( |
2175 | | - "\nError: Argument to %s (%s) must exist and be a directory." % (arg, env[k]), |
| 2171 | + "\nWarning: OUT_FILE (%s) already exists. Would you like to overwrite?\n" % output_file_name, |
2176 | 2172 | force_stdout=True, |
2177 | 2173 | level=LOG_ALWAYS, |
2178 | 2174 | ) |
2179 | | - sys.exit(1) |
2180 | | - |
2181 | | - env["remove_temp_file"] = False |
2182 | | - if env["temp_file_name"] == "": |
2183 | | - temp_file = tempfile.NamedTemporaryFile(suffix=".v", dir=".", delete=False) |
2184 | | - env["temp_file_name"] = temp_file.name |
2185 | | - temp_file.close() |
2186 | | - env["remove_temp_file"] = True |
2187 | | - if env["temp_file_log_name"] == "": |
2188 | | - env["temp_file_log_name"] = env["temp_file_name"] + ".log" |
2189 | | - |
2190 | | - def make_make_coqc(coqc_prog, **kwargs): |
2191 | | - if get_coq_accepts_compile(coqc_prog): |
2192 | | - return f"{util.resource_path('coqtop-as-coqc.sh')} {coqc_prog}" |
2193 | | - if "coqtop" in coqc_prog: |
2194 | | - return coqc_prog.replace("coqtop", "coqc") |
2195 | | - return "coqc" |
2196 | | - |
2197 | | - if env["coqc_is_coqtop"]: |
2198 | | - if env["coqc"] == "coqc": |
2199 | | - env["coqc"] = env["coqtop"] |
2200 | | - env["make_coqc"] = make_make_coqc(env["coqc"], **env) |
2201 | | - if env["passing_coqc_is_coqtop"]: |
2202 | | - if env["passing_coqc"] == "coqc": |
2203 | | - if env["passing_coqtop"] is not None: |
2204 | | - env["passing_coqc"] = env["passing_coqtop"] |
2205 | | - else: |
2206 | | - env["passing_coqc"] = env["coqtop"] |
2207 | | - env["passing_make_coqc"] = make_make_coqc(env["passing_coqc"], **env) |
2208 | | - |
2209 | | - coqc_help = get_coqc_help(get_preferred_passing("coqc", **env), **env) |
2210 | | - coqc_version = get_coqc_version(env["coqc"], **env) |
| 2175 | + if not yes_no_prompt(yes=env["yes"]): |
| 2176 | + sys.exit(1) |
| 2177 | + for k, arg in (("base_dir", "--base-dir"), ("passing_base_dir", "--passing-base-dir")): |
| 2178 | + if env[k] is not None and not os.path.isdir(env[k]): |
| 2179 | + env["log"]( |
| 2180 | + "\nError: Argument to %s (%s) must exist and be a directory." % (arg, env[k]), |
| 2181 | + force_stdout=True, |
| 2182 | + level=LOG_ALWAYS, |
| 2183 | + ) |
| 2184 | + sys.exit(1) |
2211 | 2185 |
|
2212 | | - update_env_with_libnames( |
2213 | | - env, |
2214 | | - args, |
2215 | | - include_passing=env["passing_coqc"], |
2216 | | - use_default=not has_dir_binding(env["coqc_args"], coqc_help=coqc_help, file_name=bug_file_name), |
2217 | | - use_passing_default=not has_dir_binding(env["passing_coqc_args"], coqc_help=coqc_help, file_name=bug_file_name), |
2218 | | - ) |
| 2186 | + env["remove_temp_file"] = False |
| 2187 | + if env["temp_file_name"] == "": |
| 2188 | + temp_file = tempfile.NamedTemporaryFile(suffix=".v", dir=".", delete=False) |
| 2189 | + env["temp_file_name"] = temp_file.name |
| 2190 | + temp_file.close() |
| 2191 | + env["remove_temp_file"] = True |
| 2192 | + if env["temp_file_log_name"] == "": |
| 2193 | + env["temp_file_log_name"] = env["temp_file_name"] + ".log" |
2219 | 2194 |
|
2220 | | - if args.inline_user_contrib: |
2221 | 2195 | for passing_prefix in ("", "passing_"): |
2222 | | - if env[passing_prefix + "coqc"]: |
2223 | | - coq_user_contrib_path = os.path.join( |
2224 | | - get_coqc_coqlib( |
2225 | | - env[passing_prefix + "coqc"], coq_args=env[passing_prefix + "coqc_args"], **env |
2226 | | - ), |
2227 | | - "user-contrib", |
| 2196 | + update_env_with_coqlib(env, passing_prefix=passing_prefix) |
| 2197 | + |
| 2198 | + def make_make_coqc(coqc_prog, **kwargs): |
| 2199 | + if get_coq_accepts_compile(coqc_prog): |
| 2200 | + return f"{util.resource_path('coqtop-as-coqc.sh')} {coqc_prog}" |
| 2201 | + if "coqtop" in coqc_prog: |
| 2202 | + return coqc_prog.replace("coqtop", "coqc") |
| 2203 | + return "coqc" |
| 2204 | + |
| 2205 | + if env["coqc_is_coqtop"]: |
| 2206 | + if env["coqc"] == "coqc": |
| 2207 | + env["coqc"] = env["coqtop"] |
| 2208 | + env["make_coqc"] = make_make_coqc(env["coqc"], **env) |
| 2209 | + if env["passing_coqc_is_coqtop"]: |
| 2210 | + if env["passing_coqc"] == "coqc": |
| 2211 | + if env["passing_coqtop"] is not None: |
| 2212 | + env["passing_coqc"] = env["passing_coqtop"] |
| 2213 | + else: |
| 2214 | + env["passing_coqc"] = env["coqtop"] |
| 2215 | + env["passing_make_coqc"] = make_make_coqc(env["passing_coqc"], **env) |
| 2216 | + |
| 2217 | + coqc_help = get_coqc_help(get_preferred_passing("coqc", **env), **env) |
| 2218 | + coqc_version = get_coqc_version(env["coqc"], **env) |
| 2219 | + |
| 2220 | + update_env_with_libnames( |
| 2221 | + env, |
| 2222 | + args, |
| 2223 | + include_passing=env["passing_coqc"], |
| 2224 | + use_default=not has_dir_binding(env["coqc_args"], coqc_help=coqc_help, file_name=bug_file_name), |
| 2225 | + use_passing_default=not has_dir_binding(env["passing_coqc_args"], coqc_help=coqc_help, file_name=bug_file_name), |
| 2226 | + ) |
| 2227 | + |
| 2228 | + if args.inline_user_contrib: |
| 2229 | + for passing_prefix in ("", "passing_"): |
| 2230 | + if env[passing_prefix + "coqc"]: |
| 2231 | + coq_user_contrib_path = os.path.join( |
| 2232 | + get_coqc_coqlib( |
| 2233 | + env[passing_prefix + "coqc"], coq_args=env[passing_prefix + "coqc_args"], **env |
| 2234 | + ), |
| 2235 | + "user-contrib", |
| 2236 | + ) |
| 2237 | + update_env_with_coqpath_folders( |
| 2238 | + passing_prefix, |
| 2239 | + env, |
| 2240 | + coq_user_contrib_path, |
2228 | 2241 | ) |
2229 | | - update_env_with_coqpath_folders( |
2230 | | - passing_prefix, |
2231 | | - env, |
2232 | | - coq_user_contrib_path, |
2233 | | - ) |
2234 | | - env[passing_prefix + "coqpath_paths"].append(coq_user_contrib_path) |
| 2242 | + env[passing_prefix + "coqpath_paths"].append(coq_user_contrib_path) |
2235 | 2243 |
|
2236 | | - if args.inline_coqlib or args.inline_stdlib: |
2237 | | - for passing_prefix in ("", "passing_"): |
2238 | | - if env[passing_prefix + "coqc"]: |
2239 | | - coq_lib_path = get_coqc_coqlib( |
2240 | | - env[passing_prefix + "coqc"], coq_args=env[passing_prefix + "coqc_args"], **env |
2241 | | - ) |
2242 | | - coq_theories_path = os.path.join(coq_lib_path, "theories") |
2243 | | - coq_user_contrib_path = os.path.join(os.path.join(coq_lib_path, "user-contrib"), "Stdlib") |
2244 | | - coqpath_path = os.environ.get('COQPATH', '') |
2245 | | - coqpath_paths = coqpath_path.split(os.pathsep) if coqpath_path else [] |
2246 | | - if args.inline_coqlib: |
2247 | | - if coqc_version != "" and coqc_version[0] == '8': |
| 2244 | + if args.inline_coqlib or args.inline_stdlib: |
| 2245 | + for passing_prefix in ("", "passing_"): |
| 2246 | + if env[passing_prefix + "coqc"]: |
| 2247 | + coq_lib_path = get_coqc_coqlib( |
| 2248 | + env[passing_prefix + "coqc"], coq_args=env[passing_prefix + "coqc_args"], **env |
| 2249 | + ) |
| 2250 | + coq_theories_path = os.path.join(coq_lib_path, "theories") |
| 2251 | + coq_user_contrib_path = os.path.join(os.path.join(coq_lib_path, "user-contrib"), "Stdlib") |
| 2252 | + coqpath_paths = os.environ.get('COQPATH', '').split(os.pathsep) |
| 2253 | + if args.inline_coqlib: |
2248 | 2254 | env[passing_prefix + "libnames"] = tuple( |
2249 | 2255 | list(env[passing_prefix + "libnames"]) + [(coq_theories_path, "Coq")] |
2250 | 2256 | ) |
2251 | | - else: |
2252 | 2257 | env[passing_prefix + "libnames"] = tuple( |
2253 | | - list(env[passing_prefix + "libnames"]) + [(coq_theories_path, "Corelib")] |
| 2258 | + list(env[passing_prefix + "libnames"]) + [(coq_user_contrib_path, "Coq")] |
2254 | 2259 | ) |
2255 | | - env[passing_prefix + "libnames"] = tuple( |
2256 | | - list(env[passing_prefix + "libnames"]) + [(coq_user_contrib_path, "Stdlib")] |
2257 | | - ) |
2258 | | - for p in coqpath_paths: |
| 2260 | + for p in coqpath_paths: |
| 2261 | + env[passing_prefix + "libnames"] = tuple( |
| 2262 | + list(env[passing_prefix + "libnames"]) + [(os.path.join(p, "Stdlib"), "Coq")] |
| 2263 | + ) |
| 2264 | + if args.inline_stdlib: |
2259 | 2265 | env[passing_prefix + "libnames"] = tuple( |
2260 | | - list(env[passing_prefix + "libnames"]) + [(os.path.join(p, "Stdlib"), "Coq")] |
| 2266 | + list(env[passing_prefix + "libnames"]) + [(coq_theories_path, "Stdlib")] |
2261 | 2267 | ) |
2262 | | - if args.inline_stdlib: |
2263 | | - env[passing_prefix + "libnames"] = tuple( |
2264 | | - list(env[passing_prefix + "libnames"]) + [(coq_theories_path, "Stdlib")] |
2265 | | - ) |
2266 | | - env[passing_prefix + "libnames"] = tuple( |
2267 | | - list(env[passing_prefix + "libnames"]) + [(coq_user_contrib_path, "Stdlib")] |
2268 | | - ) |
2269 | | - for p in coqpath_paths: |
2270 | 2268 | env[passing_prefix + "libnames"] = tuple( |
2271 | | - list(env[passing_prefix + "libnames"]) + [(os.path.join(p, "Stdlib"), "Stdlib")] |
| 2269 | + list(env[passing_prefix + "libnames"]) + [(coq_user_contrib_path, "Stdlib")] |
2272 | 2270 | ) |
2273 | | - if args.inline_coqlib or args.inline_stdlib: |
2274 | | - env[passing_prefix + "coqpath_paths"].append(coq_theories_path) |
2275 | | - env[passing_prefix + "coqpath_paths"].append(coq_user_contrib_path) |
2276 | | - env[passing_prefix + "coqpath_paths"].extend(coqpath_paths) |
2277 | | - |
2278 | | - env["log"]("{", level=2) |
2279 | | - for k, v in sorted(list(env.items())): |
2280 | | - env["log"](" %s: %s" % (repr(k), repr(v)), level=2) |
2281 | | - env["log"]("}", level=2) |
2282 | | - |
2283 | | - for passing_prefix in ("", "passing_"): |
2284 | | - if env[passing_prefix + "coqc"]: |
2285 | | - args_key = passing_prefix + "coqc_args" |
2286 | | - if "-native-compiler" not in env[args_key]: |
2287 | | - env[args_key] = tuple( |
2288 | | - list(env[args_key]) |
2289 | | - + list(get_coq_native_compiler_ondemand_fragment(env[passing_prefix + "coqc"], **env)) |
2290 | | - ) |
| 2271 | + for p in coqpath_paths: |
| 2272 | + env[passing_prefix + "libnames"] = tuple( |
| 2273 | + list(env[passing_prefix + "libnames"]) + [(os.path.join(p, "Stdlib"), "Stdlib")] |
| 2274 | + ) |
| 2275 | + if args.inline_coqlib or args.inline_stdlib: |
| 2276 | + env[passing_prefix + "coqpath_paths"].append(coq_theories_path) |
| 2277 | + env[passing_prefix + "coqpath_paths"].append(coq_user_contrib_path) |
| 2278 | + env[passing_prefix + "coqpath_paths"].extend(coqpath_paths) |
2291 | 2279 |
|
2292 | | - try: |
| 2280 | + env["log"]("{", level=2) |
| 2281 | + for k, v in sorted(list(env.items())): |
| 2282 | + env["log"](" %s: %s" % (repr(k), repr(v)), level=2) |
| 2283 | + env["log"]("}", level=2) |
| 2284 | + |
| 2285 | + for passing_prefix in ("", "passing_"): |
| 2286 | + if env[passing_prefix + "coqc"]: |
| 2287 | + args_key = passing_prefix + "coqc_args" |
| 2288 | + if "-native-compiler" not in env[args_key]: |
| 2289 | + env[args_key] = tuple( |
| 2290 | + list(env[args_key]) |
| 2291 | + + list(get_coq_native_compiler_ondemand_fragment(env[passing_prefix + "coqc"], **env)) |
| 2292 | + ) |
2293 | 2293 |
|
2294 | 2294 | if env["temp_file_name"][-2:] != ".v": |
2295 | 2295 | env["log"]( |
@@ -2614,7 +2614,7 @@ def get_test_output( |
2614 | 2614 | env["log"](traceback.format_exc(), level=LOG_ALWAYS) |
2615 | 2615 | raise |
2616 | 2616 | finally: |
2617 | | - if env["remove_temp_file"]: |
| 2617 | + if env.get("remove_temp_file"): |
2618 | 2618 | clean_v_file(env["temp_file_name"]) |
2619 | 2619 | if os.path.exists(env["temp_file_log_name"]): |
2620 | 2620 | os.remove(env["temp_file_log_name"]) |
|
0 commit comments