Meta: Support Swift_Release preset in ladybird.py

This commit is contained in:
Andrew Kaster 2025-06-09 18:32:00 -06:00 committed by Andrew Kaster
commit ab661467e7
Notes: github-actions[bot] 2025-06-11 17:56:04 +00:00
2 changed files with 35 additions and 1 deletions

View file

@ -168,6 +168,32 @@ def pick_host_compiler(platform: Platform, cc: str, cxx: str) -> tuple[str, str]
sys.exit(1)
def pick_swift_compilers(platform: Platform, project_root: Path) -> tuple[Path, Path, Path]:
if platform.host_system == HostSystem.Windows:
print("Swift builds are not supported on Windows", file=sys.stderr)
sys.exit(1)
if not shutil.which("swiftly"):
print("swiftly is required to manage Swift toolchains", file=sys.stderr)
sys.exit(1)
swiftly_toolchain_path = run_command(["swiftly", "use", "--print-location"], return_output=True, cwd=project_root)
if not swiftly_toolchain_path:
run_command(["swiftly", "install"], exit_on_failure=True, cwd=project_root)
swiftly_toolchain_path = run_command(
["swiftly", "use", "--print-location"], return_output=True, exit_on_failure=True, cwd=project_root
)
swiftly_toolchain_path = Path(swiftly_toolchain_path.strip())
swiftly_bin_dir = swiftly_toolchain_path.joinpath("usr", "bin")
if not swiftly_toolchain_path.exists() or not swiftly_bin_dir.exists():
print(f"swiftly toolchain path {swiftly_toolchain_path} does not exist", file=sys.stderr)
sys.exit(1)
return swiftly_bin_dir / "clang", swiftly_bin_dir / "clang++", swiftly_bin_dir / "swiftc"
def main():
platform = Platform()
(default_cc, default_cxx) = platform.default_compiler()