From df187c44065fbd36b151424abcaf15ddc2e24266 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ke=C3=9Fler-Schulz?= Date: Tue, 23 Sep 2025 20:25:25 +0200 Subject: [PATCH] Fix Windows compilation of Verilator with spaces in the path (#6477) --- CMakeLists.txt | 7 ++++++- docs/CONTRIBUTORS | 2 +- src/bisonpre | 39 ++++++++++++++++++++------------------- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 596401d29..0269ca85b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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( diff --git a/docs/CONTRIBUTORS b/docs/CONTRIBUTORS index 4a0851e62..3450e2e21 100644 --- a/docs/CONTRIBUTORS +++ b/docs/CONTRIBUTORS @@ -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 diff --git a/src/bisonpre b/src/bisonpre index 3830c972d..e14b8170b 100755 --- a/src/bisonpre +++ b/src/bisonpre @@ -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: