Skip to content

Commit

Permalink
[Windows] Support spaces in $python_path (#829)
Browse files Browse the repository at this point in the history
Wraps `$python_path` usages in quotes to support python installations in
directories with spaces.

Fixes: flutter/flutter#143740

Reported and identified by @CodeVisio.

## Pre-launch Checklist

- [X] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [X] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [X] I read the [Flutter Style Guide] _recently_, and have followed its
advice.
- [X] I signed the [CLA].
- [X] I listed at least one issue that this PR fixes in the description
above.
- [X] Caution: Laser radiation. Do not stare into beam or view directly
with optical instruments.
- [X] I updated/added relevant documentation (doc comments with `///`).
- [X] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [X] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
  • Loading branch information
cbracken authored Feb 28, 2024
1 parent 2f684ab commit 7b537de
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build/toolchain/nacl/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ toolchain("x86_newlib") {

if (is_win) {
tool("stamp") {
command = "$python_path gyp-win-tool stamp \$out"
command = "\"$python_path\" gyp-win-tool stamp \$out"
description = "STAMP \$out"
}
} else {
Expand Down
16 changes: 8 additions & 8 deletions build/toolchain/win/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ template("msvc_toolchain") {
}

tool("rc") {
command = "$python_path $tool_wrapper_path rc-wrapper $env rc.exe /nologo {{defines}} {{include_dirs}} /fo{{output}} {{source}}"
command = "\"$python_path\" $tool_wrapper_path rc-wrapper $env rc.exe /nologo {{defines}} {{include_dirs}} /fo{{output}} {{source}}"
depsformat = "msvc"
outputs = [
"{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.res",
Expand All @@ -170,7 +170,7 @@ template("msvc_toolchain") {
ml = "ml.exe"
x64 = ""
}
command = "$python_path $tool_wrapper_path asm-wrapper $env $ml $x64 {{defines}} {{include_dirs}} {{asmflags}} "
command = "\"$python_path\" $tool_wrapper_path asm-wrapper $env $ml $x64 {{defines}} {{include_dirs}} {{asmflags}} "
if (is_msvc_assembler) {
command += "-c -o{{output}} {{source}}"
} else {
Expand All @@ -183,7 +183,7 @@ template("msvc_toolchain") {

tool("alink") {
rspfile = "{{output}}.rsp"
command = "$python_path $tool_wrapper_path link-wrapper $env False lib.exe /nologo /ignore:4221 /OUT:{{output}} @$rspfile"
command = "\"$python_path\" $tool_wrapper_path link-wrapper $env False lib.exe /nologo /ignore:4221 /OUT:{{output}} @$rspfile"
description = "LIB {{output}}"
outputs = [
# Ignore {{output_extension}} and always use .lib, there's no reason to
Expand All @@ -205,10 +205,10 @@ template("msvc_toolchain") {
pdbname = "${dllname}.pdb"
rspfile = "${dllname}.rsp"

link_command = "$python_path $tool_wrapper_path link-wrapper $env False link.exe /nologo /IMPLIB:$libname /DLL /OUT:$dllname /PDB:${dllname}.pdb @$rspfile"
link_command = "\"$python_path\" $tool_wrapper_path link-wrapper $env False link.exe /nologo /IMPLIB:$libname /DLL /OUT:$dllname /PDB:${dllname}.pdb @$rspfile"

# TODO(brettw) support manifests
#manifest_command = "$python_path $tool_wrapper_path manifest-wrapper $env mt.exe -nologo -manifest $manifests -out:${dllname}.manifest"
#manifest_command = "\"$python_path\" $tool_wrapper_path manifest-wrapper $env mt.exe -nologo -manifest $manifests -out:${dllname}.manifest"
#command = "cmd /c $link_command && $manifest_command"
command = link_command

Expand Down Expand Up @@ -236,10 +236,10 @@ template("msvc_toolchain") {
rspfile = "$binary_output.rsp"
pdbfile = "$binary_output.pdb"

link_command = "$python_path $tool_wrapper_path link-wrapper $env False link.exe /nologo /OUT:$binary_output /PDB:$pdbfile @$rspfile"
link_command = "\"$python_path\" $tool_wrapper_path link-wrapper $env False link.exe /nologo /OUT:$binary_output /PDB:$pdbfile @$rspfile"

# TODO(brettw) support manifests
#manifest_command = "$python_path $tool_wrapper_path manifest-wrapper $env mt.exe -nologo -manifest $manifests -out:{{output}}.manifest"
#manifest_command = "\"$python_path\" $tool_wrapper_path manifest-wrapper $env mt.exe -nologo -manifest $manifests -out:{{output}}.manifest"
#command = "cmd /c $link_command && $manifest_command"
command = link_command

Expand All @@ -263,7 +263,7 @@ template("msvc_toolchain") {
}

tool("copy") {
command = "$python_path $tool_wrapper_path recursive-mirror {{source}} {{output}}"
command = "\"$python_path\" $tool_wrapper_path recursive-mirror {{source}} {{output}}"
description = "COPY {{source}} {{output}}"
}
}
Expand Down

0 comments on commit 7b537de

Please sign in to comment.