Fix Windows compilation of Verilator with spaces in the path (#6477)

This commit is contained in:
Fabian Keßler-Schulz 2025-09-23 20:25:25 +02:00 committed by GitHub
parent 6f250b3f8d
commit df187c4406
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 27 additions and 21 deletions

View File

@ -49,8 +49,13 @@ if(WIN32)
if(DEFINED ENV{WIN_FLEX_BISON})
set(WIN_FLEX_BISON "$ENV{WIN_FLEX_BISON}")
endif()
if(EXISTS ${WIN_FLEX_BISON})
if(IS_DIRECTORY ${WIN_FLEX_BISON})
list(APPEND CMAKE_PREFIX_PATH ${WIN_FLEX_BISON})
else()
message(
FATAL_ERROR
"The path specified by WIN_FLEX_BISON environment variable is not an existing folder: ${WIN_FLEX_BISON}"
)
endif()
if(NOT WIN_FLEX_BISON)
message(

View File

@ -58,7 +58,7 @@ Eric Müller
Eric Rippey
Ethan Sifferman
Eyck Jentzsch
Fabian Keßler
Fabian Keßler-Schulz
Fan Shupei
Felix Neumärker
Felix Yan

View File

@ -23,25 +23,26 @@ def process():
clean_input(Args.input, tmp_prefix() + ".y")
# Run bison
command = (
Args.yacc #
+ (" -t" if Args.debug else "") #
+ (" -d" if Args.definitions else "") #
+ (" -k" if Args.token_table else "") #
+ (" -v" if Args.verbose else "") #
+ (" -Wcounterexamples" if Args.Wcounterexamples else "") #
+ (" --report=itemset --report=lookahead" if (Args.verbose and supports_report) else "")
# Useful but slow:
# (" -Wcounterexamples" if
# (Args.verbose and supports_counter_examples) else "")
#
# -p required for GLR parsers; they write to -p basename, not -o
+ ((" -p " + Args.name_prefix) if Args.name_prefix else "") + " -b " + tmp_prefix() #
+ " -o " + tmp_prefix() + ".c" #
+ " " + tmp_prefix() + ".y")
prefix = tmp_prefix()
command = [
Args.yacc,
*(["-t"] if Args.debug else []),
*(["-d"] if Args.definitions else []),
*(["-k"] if Args.token_table else []),
*(["-v"] if Args.verbose else []),
*(["-Wcounterexamples"] if Args.Wcounterexamples else []),
*(["--report=itemset", "--report=lookahead"] if
(Args.verbose and supports_report) else []),
*(["-p", Args.name_prefix] if Args.name_prefix else []),
"-b",
prefix,
"-o",
f"{prefix}.c",
f"{prefix}.y",
]
print(" " + command)
status = subprocess.call(command, shell=True)
print(f"Executing: {subprocess.list2cmdline(command)}", flush=True)
status = subprocess.call(command)
if status != 0:
unlink_outputs()
sys.exit("bisonpre: %Error: " + Args.yacc + " version " + str(Bison_Version) +
@ -87,7 +88,7 @@ def unlink_outputs():
def bison_version_check():
with subprocess.Popen(Args.yacc + " --version", shell=True, stdout=subprocess.PIPE) as sp:
with subprocess.Popen([Args.yacc, "--version"], stdout=subprocess.PIPE) as sp:
out = str(sp.stdout.read())
match = re.search(r'([0-9]+\.[0-9]+)', out)
if match: