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}) if(DEFINED ENV{WIN_FLEX_BISON})
set(WIN_FLEX_BISON "$ENV{WIN_FLEX_BISON}") set(WIN_FLEX_BISON "$ENV{WIN_FLEX_BISON}")
endif() endif()
if(EXISTS ${WIN_FLEX_BISON}) if(IS_DIRECTORY ${WIN_FLEX_BISON})
list(APPEND CMAKE_PREFIX_PATH ${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() endif()
if(NOT WIN_FLEX_BISON) if(NOT WIN_FLEX_BISON)
message( message(

View File

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

View File

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