Skip to content

Commit f6979fb

Browse files
mukilanGae24
authored andcommitted
mach: Add support for paths with spaces on Windows (servo#32936)
The default user name in Windows installations is of the form "FirstName LastName", so it seems likely that there will be spaces in the user's path. Based on my testing on Windows 11, the only Servo's bootstrap script has trouble dealing with spaces in paths. This patch fixes that by quoting such paths correctly. Our direct and indirect dependencies seem to handle these without issue and Servo does build and run correctly with this patch. In this patch, the logic for gstreamer bootstrap now uses powershell instead of directly invoking msiexec.exe via cmd.exe as I was unable to get the installer to run correctly, even with quoting. Some extra hacks were necessary to propagate the exit code correctly to mach. Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
1 parent 0cd1c7d commit f6979fb

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

python/mach_bootstrap.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,8 @@ def bootstrap(topdir):
215215
topdir = os.path.abspath(topdir)
216216

217217
# We don't support paths with spaces for now
218-
# https://github.com/servo/servo/issues/9442
219-
if ' ' in topdir:
218+
# https://github.com/servo/servo/issues/9616
219+
if ' ' in topdir and (not _is_windows()):
220220
print('Cannot run mach in a path with spaces.')
221221
print('Current path:', topdir)
222222
sys.exit(1)

python/servo/platform/windows.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,13 @@
1717
from .. import util
1818
from .base import Base
1919

20-
DEPS_URL = "https://github.com/servo/servo-build-deps/releases/download/msvc-deps/"
20+
DEPS_URL = "https://github.com/servo/servo-build-deps/releases/download/msvc-deps"
2121
DEPENDENCIES = {
2222
"moztools": "4.0",
2323
}
2424

25-
URL_BASE = "https://github.com/servo/servo-build-deps/releases/download/msvc-deps/"
26-
GSTREAMER_URL = f"{URL_BASE}/gstreamer-1.0-msvc-x86_64-1.22.8.msi"
27-
GSTREAMER_DEVEL_URL = f"{URL_BASE}/gstreamer-1.0-devel-msvc-x86_64-1.22.8.msi"
25+
GSTREAMER_URL = f"{DEPS_URL}/gstreamer-1.0-msvc-x86_64-1.22.8.msi"
26+
GSTREAMER_DEVEL_URL = f"{DEPS_URL}/gstreamer-1.0-devel-msvc-x86_64-1.22.8.msi"
2827
DEPENDENCIES_DIR = os.path.join(util.get_target_dir(), "dependencies")
2928

3029

@@ -44,7 +43,7 @@ def executable_suffix(self):
4443
@classmethod
4544
def download_and_extract_dependency(cls, zip_path: str, full_spec: str):
4645
if not os.path.isfile(zip_path):
47-
zip_url = f"{DEPS_URL}{urllib.parse.quote(full_spec)}.zip"
46+
zip_url = f"{DEPS_URL}/{urllib.parse.quote(full_spec)}.zip"
4847
util.download_file(full_spec, zip_url, zip_path)
4948

5049
zip_dir = os.path.dirname(zip_path)
@@ -65,7 +64,7 @@ def _platform_bootstrap(self, force: bool = False) -> bool:
6564
choco_config = os.path.join(util.SERVO_ROOT, "support", "windows", "chocolatey.config")
6665

6766
# This is the format that PowerShell wants arguments passed to it.
68-
cmd_exe_args = f"'/K','choco','install','-y','{choco_config}'"
67+
cmd_exe_args = f"'/K','choco','install','-y', '\"{choco_config}\"'"
6968
if force:
7069
cmd_exe_args += ",'-f'"
7170

@@ -158,12 +157,19 @@ def _platform_bootstrap_gstreamer(self, force: bool) -> bool:
158157

159158
print(f"Installing GStreamer packages to {DEPENDENCIES_DIR}...")
160159
os.makedirs(DEPENDENCIES_DIR, exist_ok=True)
161-
common_args = [
162-
f"TARGETDIR={DEPENDENCIES_DIR}", # Install destination
163-
"/qn", # Quiet mode
164-
]
165-
subprocess.check_call(["msiexec", "/a", libs_msi] + common_args)
166-
subprocess.check_call(["msiexec", "/a", devel_msi] + common_args)
160+
161+
for installer in [libs_msi, devel_msi]:
162+
arguments = [
163+
"/a",
164+
f'"{installer}"'
165+
f'TARGETDIR="{DEPENDENCIES_DIR}"', # Install destination
166+
"/qn", # Quiet mode
167+
]
168+
quoted_arguments = ",".join((f"'{arg}'" for arg in arguments))
169+
subprocess.check_call([
170+
"powershell", "exit (Start-Process", "-PassThru", "-Wait", "-verb", "runAs",
171+
"msiexec.exe", "-ArgumentList", f"@({quoted_arguments})", ").ExitCode"
172+
])
167173

168174
assert self.is_gstreamer_installed(cross_compilation_target=None)
169175
return True

0 commit comments

Comments
 (0)