Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: failed to detect flavor if compiler path include white spaces #240

Merged
merged 12 commits into from
Apr 23, 2024
Prev Previous commit
Next Next commit
os.sep
  • Loading branch information
toyobayashi committed Apr 2, 2024
commit 3945b0da3fbc11d1feea4913f4651febcc3fa6c3
2 changes: 1 addition & 1 deletion pylib/gyp/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ def GetCrossCompilerPredefines(): # -> dict
# setting posix=False will preserve extra '"' cause CreateProcess fail on Windows
# this makes '\' in %CC_target% and %CFLAGS% work
def replace_sep(s):
return s.replace("\\", "/") if sys.platform == "win32" else s
return s.replace(os.sep, "/") if os.sep != "/" else s

if CC := os.environ.get("CC_target") or os.environ.get("CC"):
cmd += shlex.split(replace_sep(CC))
Expand Down
6 changes: 3 additions & 3 deletions pylib/gyp/common_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,14 @@ def mock_run(env, defines_stdout, expected_cmd):
}, defines5)
self.assertEqual("wasi", flavor5)

original_platform = sys.platform
sys.platform = "win32"
original_platform = os.sep
os.sep = "\\"
[defines6, flavor6] = mock_run(
{ "CC_target": "\"C:\\Program Files\\wasi-sdk\\clang.exe\"" },
"#define __wasm__ 1\n#define __wasi__ 1\n",
["C:/Program Files/wasi-sdk/clang.exe"]
)
sys.platform = original_platform
os.sep = original_platform
self.assertDictEqual({ "__wasm__": "1", "__wasi__": "1" }, defines6)
self.assertEqual("wasi", flavor6)

Expand Down