aboutsummaryrefslogtreecommitdiffstats
path: root/python/servo/command_base.py
diff options
context:
space:
mode:
authorJonathan Schwender <55576758+jschwe@users.noreply.github.com>2025-04-04 10:07:32 +0200
committerGitHub <noreply@github.com>2025-04-04 08:07:32 +0000
commitd6d610ef6d1671edd182a27141cf499906d8e1fa (patch)
tree4f1e042d2d9cdcc68ac04818fb362e8676385fab /python/servo/command_base.py
parent0d693114ad4f27a07a3cd18c4c34da53be55d1bc (diff)
downloadservo-d6d610ef6d1671edd182a27141cf499906d8e1fa.tar.gz
servo-d6d610ef6d1671edd182a27141cf499906d8e1fa.zip
mach: Fix cross-compiling from windows to non windows (#36070)
Since we switched to using `aws-lc-rs` instead of `ring`, cross-compiling on windows (to non-windows) had been broken. Using the default MSVC Generator results in CMake erroneously being configured for the host platform, with failing compiler checks. Switching to Ninja fixes that issue. The CMake build rules of aws-lc-rs also make use of `tr` and assume it is installed, hence we provide a helpful error message suggesting to try using mach from `git bash` which does provide the `tr` command. <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix cross-compiling servo on windows hosts to non-windows targets - [x] These changes do not require tests because: We don't test cross-compiling from windows hosts in CI. These changes were manually tested by compiling for OpenHarmony on windows. Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
Diffstat (limited to 'python/servo/command_base.py')
-rw-r--r--python/servo/command_base.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/python/servo/command_base.py b/python/servo/command_base.py
index 799fbdca8ee..1a704bf7c05 100644
--- a/python/servo/command_base.py
+++ b/python/servo/command_base.py
@@ -512,6 +512,19 @@ class CommandBase(object):
self.target.configure_build_environment(env, self.config, self.context.topdir)
+ if sys.platform == 'win32' and 'windows' not in self.target.triple():
+ # aws-lc-rs only supports the Ninja Generator when cross-compiling on windows hosts to non-windows.
+ env['TARGET_CMAKE_GENERATOR'] = "Ninja"
+ if shutil.which('ninja') is None:
+ print("Error: Cross-compiling servo on windows requires the Ninja tool to be installed and in PATH.")
+ print("Hint: Ninja-build is available on github at: https://github.com/ninja-build/ninja/releases")
+ exit(1)
+ # `tr` is also required by the CMake build rules of `aws-lc-rs`
+ if shutil.which('tr') is None:
+ print("Error: Cross-compiling servo on windows requires the `tr` tool, which was not found.")
+ print("Hint: Try running ./mach from `git bash` instead of powershell.")
+ exit(1)
+
return env
@staticmethod