Skip to content

Truly independent web browser

Meta: Stop building vcpkg dependencies serially

Ali Mohammad Pur4c118b4b5a89
diff --git a/Meta/Utils/vcpkg_deps.py b/Meta/Utils/vcpkg_deps.py
new file mode 100644
index 00000000000..ebc62dbcd2e
--- /dev/null
+++ b/Meta/Utils/vcpkg_deps.py
@@ -0,0 +1,560 @@
+#!/usr/bin/env python3
+
+# Copyright (c) 2026, Ali Mohammad Pur <[email protected]>
+#
+# SPDX-License-Identifier: BSD-2-Clause
+
+import argparse
+import json
+import os
+import re
+import shutil
+import subprocess
+import sys
+
+from pathlib import Path
+from typing import Optional
+
+META_SOURCE_DIR = Path(__file__).resolve().parent.parent
+LADYBIRD_SOURCE_DIR = META_SOURCE_DIR.parent
+
+sys.path.append(str(META_SOURCE_DIR))
+
+from Utils.host_platform import HostArchitecture # noqa: E402
+from Utils.host_platform import HostSystem # noqa: E402
+from Utils.host_platform import Platform # noqa: E402
+
+DEPEND_INFO_REGEX = re.compile(r"^([a-zA-Z0-9-]+)(?:\[([^]]*)\])?(:host)?:\s*(.*)$")
+
+
+def vcpkg_type(preset: str) -> str:
+ # environment.cmake derives the overlay triplets from LADYBIRD_VCPKG_TYPE, which each preset sets in its _base.
+ presets_path = LADYBIRD_SOURCE_DIR / "Meta" / "CMake" / "presets" / "CMakeBasePresets.json"
+ with open(presets_path, "r") as presets_file:
+ presets = json.load(presets_file)["configurePresets"]
+ for entry in presets:
+ if entry["name"] == f"{preset}_base":
+ return entry["cacheVariables"]["LADYBIRD_VCPKG_TYPE"]
+ raise RuntimeError(f"No LADYBIRD_VCPKG_TYPE for preset {preset} in {presets_path}")
+
+
+def vcpkg_root() -> Path:
+ if root := os.environ.get("VCPKG_ROOT"):
+ return Path(root)
+ return LADYBIRD_SOURCE_DIR / "Build" / "vcpkg"
+
+
+def vcpkg_executable(platform: Platform) -> Path:
+ exe = "vcpkg.exe" if platform.host_system == HostSystem.Windows else "vcpkg"
+ return vcpkg_root() / exe
+
+
+def determine_triplet(platform: Platform, preset: str) -> str:
+ # Keep in sync with the triplet munging in Meta/CMake/vcpkg/generate_vcpkg_toolchain_variables.cmake.
+ if platform.host_architecture == HostArchitecture.x86_64:
+ arch = "x64"
+ elif platform.host_architecture == HostArchitecture.AArch64:
+ arch = "arm64"
+ elif platform.host_architecture == HostArchitecture.riscv64:
+ arch = "riscv64"
+ else:
+ raise RuntimeError(f"Unable to determine vcpkg triplet for architecture {platform.architecture}")
+
+ if platform.host_system == HostSystem.Linux:
+ os_name = "linux"
+ elif platform.host_system == HostSystem.macOS:
+ os_name = "osx"
+ elif platform.host_system == HostSystem.Windows:
+ os_name = "windows"
+ elif platform.system == "FreeBSD":
+ os_name = "freebsd"
+ else:
+ raise RuntimeError(f"Unable to determine vcpkg triplet for host system {platform.system}")
+
+ triplet = f"{arch}-{os_name}"
+
+ if vcpkg_type(preset) != "distribution":
+ if platform.host_system != HostSystem.Windows:
+ triplet += "-dynamic"
+ elif platform.host_system == HostSystem.Windows:
+ triplet += "-static"
+
+ return triplet
+
+
+def overlay_triplets_dir(preset: str) -> Path:
+ return LADYBIRD_SOURCE_DIR / "Meta" / "CMake" / "vcpkg" / f"{vcpkg_type(preset)}-triplets"
+
+
+def deps_dir_for(build_dir: Path) -> Path:
+ return build_dir / "vcpkg-deps"
+
+
+def overlay_ports_dir() -> Path:
+ return LADYBIRD_SOURCE_DIR / "Meta" / "CMake" / "vcpkg" / "overlay-ports"
+
+
+def binary_cache_dir() -> Path:
+ return LADYBIRD_SOURCE_DIR / "Build" / "caches" / "vcpkg-binary-cache"
+
+
+def write_if_changed(path: Path, content: str) -> bool:
+ if path.exists() and path.read_text() == content:
+ return False
+ path.parent.mkdir(parents=True, exist_ok=True)
+ path.write_text(content)
+ return True
+
+
+def extra_vcpkg_variables(platform: Platform, cc: str, cxx: str) -> str:
+ # The data generated by this must be exactly identical to the one generated by Meta/CMake/vcpkg/generate_vcpkg_toolchain_variables.cmake;
+ # as vcpkg will use the identity of that as part of the ABI hash.
+ variables = ""
+ if platform.host_system != HostSystem.Windows:
+ variables += f"set(ENV{{CC}} {cc})\n"
+ variables += f"set(ENV{{CXX}} {cxx})\n"
+ if platform.host_system == HostSystem.Linux and not os.environ.get("LAGOM_USE_LINKER"):
+ variables += "set(ENV{LDFLAGS} -Wl,-z,noseparate-code)\n"
+ if platform.host_system == HostSystem.macOS:
+ # Keep the fallback in sync with CMAKE_OSX_DEPLOYMENT_TARGET in the top-level CMakeLists.txt.
+ deployment_target = os.environ.get("CMAKE_OSX_DEPLOYMENT_TARGET") or "14.4"
+ variables += f"set(VCPKG_OSX_DEPLOYMENT_TARGET {deployment_target})\n"
+ return variables
+
+
+def vcpkg_environment() -> dict[str, str]:
+ env = os.environ.copy()
+ env["VCPKG_ROOT"] = str(vcpkg_root())
+
+ # Keep in sync with the environment blocks in Meta/CMake/presets/CMakeBasePresets.json.
+ binary_sources = f"clear;files,{binary_cache_dir()},readwrite"
+ if env.get("VCPKG_BINARY_SOURCES"):
+ binary_sources += f";{env['VCPKG_BINARY_SOURCES']}"
+ env["VCPKG_BINARY_SOURCES"] = binary_sources
+
+ sas = env.get("VCPKG_CACHE_SAS", "")
+ mode = env.get("VCPKG_CACHE_MODE", "")
+ env["X_VCPKG_ASSET_SOURCES"] = (
+ f"clear;x-azurl,https://vcpkg-cache.app.ladybird.org/ladybird/source-assets/,{sas},read{mode}"
+ )
+
+ return env
+
+
+def common_vcpkg_arguments(triplet: str, preset: str) -> list[str]:
+ return [
+ f"--triplet={triplet}",
+ f"--host-triplet={triplet}",
+ f"--overlay-triplets={overlay_triplets_dir(preset)}",
+ ]
+
+
+def vcpkg_install_arguments(vcpkg: Path, triplet: str, preset: str) -> list[str]:
+ return [str(vcpkg), "install", *common_vcpkg_arguments(triplet, preset), "--no-print-usage"]
+
+
+class PortNode:
+ def __init__(self, name: str):
+ self.name = name
+ self.features: set[str] = set()
+ self.dependencies: set[str] = set()
+
+
+def query_dependency_graph(vcpkg: Path, triplet: str, preset: str) -> dict[str, PortNode]:
+ result = subprocess.run(
+ [str(vcpkg), "depend-info", *common_vcpkg_arguments(triplet, preset), "--format=list"],
+ cwd=LADYBIRD_SOURCE_DIR,
+ env=vcpkg_environment(),
+ capture_output=True,
+ text=True,
+ )
+ if result.returncode != 0:
+ print(result.stdout, file=sys.stderr)
+ print(result.stderr, file=sys.stderr)
+ raise RuntimeError("vcpkg depend-info failed")
+
+ # NOTE: This folds host and target entries, same as what vcpkg does.
+ # FIXME: Investigate when cross-compilation becomes a problem this has to touch.
+ graph: dict[str, PortNode] = {}
+ for line in (result.stdout + result.stderr).splitlines():
+ match = DEPEND_INFO_REGEX.match(line.strip())
+ if not match:
+ continue
+ name, features, _, dependencies = match.groups()
+
+ node = graph.setdefault(name, PortNode(name))
+ if features:
+ node.features.update(f for f in (feature.strip() for feature in features.split(",")) if f and f != "core")
+
+ for dependency in dependencies.split(","):
+ dependency = dependency.strip()
+ if not dependency:
+ continue
+ dependency = dependency.split("[")[0].removesuffix(":host")
+ if dependency != name:
+ node.dependencies.add(dependency)
+
+ return graph
+
+
+def dependency_closure(graph: dict[str, PortNode], port: str) -> set[str]:
+ closure: set[str] = set()
+ queue = [port]
+ while queue:
+ current = queue.pop()
+ if current in closure:
+ continue
+ closure.add(current)
+ queue.extend(graph[current].dependencies)
+ return closure
+
+
+def solo_manifest(graph: dict[str, PortNode], port: str, baseline: str, overrides: list) -> str:
+ # Resolve the largest set of features requested by any dependency, for any dependency; we will build every dep exactly once, so we must know the closure in advance.
+ dependencies = []
+ for name in sorted(dependency_closure(graph, port)):
+ dependency: dict = {"name": name, "default-features": False}
+ if graph[name].features:
+ dependency["features"] = sorted(graph[name].features)
+ dependencies.append(dependency)
+
+ manifest = {
+ "builtin-baseline": baseline,
+ "dependencies": dependencies,
+ "overrides": overrides,
+ }
+ return json.dumps(manifest, indent=2) + "\n"
+
+
+def ninja_escape(value: str) -> str:
+ return value.replace("$", "$$").replace(" ", "$ ").replace(":", "$:")
+
+
+def generate_build_files(
+ platform: Platform,
+ preset: str,
+ build_dir: Path,
+ vcpkg: Path,
+ triplet: str,
+ graph: dict[str, PortNode],
+) -> Path:
+ deps_dir = deps_dir_for(build_dir)
+ deps_dir.mkdir(parents=True, exist_ok=True)
+
+ with open(LADYBIRD_SOURCE_DIR / "vcpkg.json", "r") as vcpkg_json_file:
+ vcpkg_json = json.load(vcpkg_json_file)
+ baseline = vcpkg_json["builtin-baseline"]
+ overrides = vcpkg_json.get("overrides", [])
+
+ variables = extra_vcpkg_variables_path(build_dir).read_text()
+
+ triplet_inputs = []
+ for triplet_dir in (
+ overlay_triplets_dir(preset),
+ overlay_triplets_dir(preset).parent / "base-triplets",
+ ):
+ triplet_inputs.extend(sorted(str(f) for f in triplet_dir.glob("*.cmake")))
+
+ lines = [
+ "ninja_required_version = 1.5",
+ "",
+ "rule vcpkg_port",
+ f' command = "{sys.executable}" "{Path(__file__).resolve()}" run-node'
+ f' --vcpkg "{vcpkg}" --triplet {triplet} --preset {preset} --node-dir "$node_dir" --stamp "$out"',
+ " description = vcpkg $port",
+ "",
+ ]
+
+ heavy_ports = set(SEED_HEAVY_PORTS) | historically_heavy_ports(deps_dir)
+
+ for name in sorted(graph):
+ node_dir = deps_dir / name
+ write_if_changed(node_dir / "vcpkg.json", solo_manifest(graph, name, baseline, overrides))
+ write_if_changed(node_dir / "build-vcpkg-variables.cmake", variables)
+ write_if_changed(node_dir / ".weight", "heavy\n" if name in heavy_ports else "light\n")
+
+ inputs = [
+ str(node_dir / "vcpkg.json"),
+ str(node_dir / "build-vcpkg-variables.cmake"),
+ ]
+ inputs.extend(triplet_inputs)
+
+ overlay_port = overlay_ports_dir() / name
+ if overlay_port.is_dir():
+ inputs.extend(sorted(str(f) for f in overlay_port.rglob("*") if f.is_file()))
+
+ order_only = [str(deps_dir / dependency / ".stamp") for dependency in sorted(graph[name].dependencies)]
+
+ build_line = f"build {ninja_escape(str(node_dir / '.stamp'))}: vcpkg_port"
+ build_line += " " + " ".join(ninja_escape(i) for i in inputs)
+ if order_only:
+ build_line += " || " + " ".join(ninja_escape(o) for o in order_only)
+
+ lines.append(build_line)
+ lines.append(f" node_dir = {ninja_escape(str(node_dir))}")
+ lines.append(f" port = {name}")
+ lines.append("")
+
+ write_if_changed(deps_dir / "build.ninja", "\n".join(lines))
+ return deps_dir
+
+
+def extra_vcpkg_variables_path(build_dir: Path) -> Path:
+ return build_dir / "build-vcpkg-variables.cmake"
+
+
+def historically_heavy_ports(deps_dir: Path) -> set[str]:
+ heavy = set()
+ log_path = deps_dir / ".ninja_log"
+ if not log_path.exists():
+ return heavy
+ for line in log_path.read_text().splitlines():
+ if line.startswith("#"):
+ continue
+ fields = line.split("\t")
+ if len(fields) < 4:
+ continue
+ try:
+ duration = int(fields[1]) - int(fields[0])
+ except ValueError:
+ continue
+ if duration >= HEAVY_THRESHOLD_MS:
+ heavy.add(Path(fields[3]).parent.name)
+ return heavy
+
+
+# Large enough that the configure time is insignificant compared to build time, build parallelism will determine build time if on the critical path.
+SEED_HEAVY_PORTS = {
+ "abseil",
+ "angle",
+ "curl",
+ "ffmpeg",
+ "harfbuzz",
+ "icu",
+ "libjxl",
+ "libvpx",
+ "openssl",
+ "qtbase",
+ "sdl3",
+ "skia",
+}
+HEAVY_THRESHOLD_MS = 45_000
+
+
+def acquire_build_tokens(fifo_fd: int, pool: int, heavy: bool) -> int:
+ # For light nodes, a single token is sufficient, so they get dispatched as soon as there's one free and run at whatever parallelism is there.
+ # heavy nodes need guaranteed available compute to not thrash on the build, so they hold off until there are enough tokens to guarantee a parallel build.
+ held = len(os.read(fifo_fd, 1))
+ if not heavy:
+ return held
+
+ target = min(pool, max(2, pool // 4))
+ while held < target:
+ held += len(os.read(fifo_fd, 1))
+
+ cap = max(target, pool - 8)
+ os.set_blocking(fifo_fd, False)
+ try:
+ while held < cap:
+ extra = os.read(fifo_fd, cap - held)
+ if not extra:
+ break
+ held += len(extra)
+ except BlockingIOError:
+ pass
+ finally:
+ os.set_blocking(fifo_fd, True)
+ return held
+
+
+def run_node(arguments: argparse.Namespace):
+ node_dir = Path(arguments.node_dir)
+ install_arguments = vcpkg_install_arguments(Path(arguments.vcpkg), arguments.triplet, arguments.preset)
+ install_arguments.extend(
+ [
+ f"--overlay-ports={overlay_ports_dir()}",
+ f"--x-manifest-root={node_dir}",
+ f"--x-install-root={node_dir / 'vcpkg_installed'}",
+ f"--x-packages-root={node_dir / 'packages'}",
+ # vcpkg really likes locks, so we give it a new build tree to lock to its heart's content.
+ f"--x-buildtrees-root={node_dir / 'buildtrees'}",
+ "--clean-buildtrees-after-build",
+ "--clean-packages-after-build",
+ ]
+ )
+
+ environment = vcpkg_environment()
+
+ fifo_fd = None
+ held = 0
+ heavy = False
+ token_fifo = environment.get("LADYBIRD_VCPKG_TOKEN_FIFO")
+ if token_fifo and Path(token_fifo).exists():
+ pool = int(environment.get("LADYBIRD_VCPKG_TOKEN_POOL", "0")) or (os.cpu_count() or 2) + 2
+ heavy = (node_dir / ".weight").exists() and (node_dir / ".weight").read_text().strip() == "heavy"
+ fifo_fd = os.open(token_fifo, os.O_RDWR)
+ held = acquire_build_tokens(fifo_fd, pool, heavy)
+ environment["VCPKG_MAX_CONCURRENCY"] = str(held if heavy else 2)
+
+ log_path = node_dir / "build.log"
+ try:
+ with open(log_path, "w") as log:
+ if held:
+ weight = "heavy" if heavy else "light"
+ log.write(
+ f"[vcpkg-deps] {weight}, {held} of {environment.get('LADYBIRD_VCPKG_TOKEN_POOL')}"
+ f" build tokens, -j{environment['VCPKG_MAX_CONCURRENCY']}\n"
+ )
+ log.flush()
+ result = subprocess.run(install_arguments, env=environment, stdout=log, stderr=subprocess.STDOUT)
+ finally:
+ if fifo_fd is not None:
+ os.write(fifo_fd, b"x" * held)
+ os.close(fifo_fd)
+
+ if result.returncode != 0:
+ log_lines = log_path.read_text().splitlines()
+ print("\n".join(log_lines[-60:]), file=sys.stderr)
+ print(f"\nFull build log: {log_path}", file=sys.stderr)
+ sys.exit(result.returncode)
+
+ Path(arguments.stamp).touch()
+
+
+def run_quietly(arguments: list[str], log_path: Path, environment: dict[str, str]):
+ with open(log_path, "w") as log:
+ result = subprocess.run(
+ arguments,
+ cwd=LADYBIRD_SOURCE_DIR,
+ env=environment,
+ stdout=log,
+ stderr=subprocess.STDOUT,
+ )
+ if result.returncode != 0:
+ log_lines = log_path.read_text().splitlines()
+ print("\n".join(log_lines[-60:]), file=sys.stderr)
+ print(f"\nFull log: {log_path}", file=sys.stderr)
+ raise subprocess.CalledProcessError(result.returncode, arguments)
+
+
+def install_is_stale(deps_dir: Path, graph: dict[str, PortNode], install_root: Path) -> bool:
+ restore_stamp = deps_dir / ".restore-stamp"
+ if not restore_stamp.exists() or not (install_root / "vcpkg").is_dir():
+ return True
+
+ restore_time = restore_stamp.stat().st_mtime
+ for name in graph:
+ stamp = deps_dir / name / ".stamp"
+ if not stamp.exists() or stamp.stat().st_mtime > restore_time:
+ return True
+
+ return False
+
+
+def build_dependencies(
+ platform: Platform,
+ preset: str,
+ build_dir: Path,
+ cc: str,
+ cxx: str,
+ jobs: Optional[str] = None,
+ fetch_only: bool = False,
+ rebuild: bool = False,
+) -> str:
+ vcpkg = vcpkg_executable(platform)
+ triplet = determine_triplet(platform, preset)
+ environment = vcpkg_environment()
+
+ import fcntl
+
+ # Hold the lock while generating inputs too, so a concurrent invocation can't rewrite them under our build.
+ deps_dir = deps_dir_for(build_dir)
+ deps_dir.mkdir(parents=True, exist_ok=True)
+ lock_fd = os.open(deps_dir / ".lock", os.O_RDWR | os.O_CREAT, 0o644)
+ try:
+ try:
+ fcntl.flock(lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
+ except BlockingIOError:
+ print("Another dependency build is running against this build directory; waiting for it to finish...")
+ fcntl.flock(lock_fd, fcntl.LOCK_EX)
+
+ write_if_changed(extra_vcpkg_variables_path(build_dir), extra_vcpkg_variables(platform, cc, cxx))
+
+ manifest_arguments = vcpkg_install_arguments(vcpkg, triplet, preset)
+ manifest_arguments.append(f"--x-install-root={build_dir / 'vcpkg_installed'}")
+
+ if fetch_only:
+ subprocess.check_call(
+ manifest_arguments + ["--only-downloads"],
+ cwd=LADYBIRD_SOURCE_DIR,
+ env=environment,
+ )
+ return triplet
+
+ graph = query_dependency_graph(vcpkg, triplet, preset)
+ generate_build_files(platform, preset, build_dir, vcpkg, triplet, graph)
+
+ # Wipe the stamps if the binary cache is gone.
+ have_stamps = any((deps_dir / name / ".stamp").exists() for name in graph)
+ cache_is_empty = not any(binary_cache_dir().glob("*/*.zip"))
+ if rebuild or (have_stamps and cache_is_empty):
+ if not rebuild:
+ print("Binary cache is empty but dependency stamps exist; rebuilding dependencies from scratch.")
+ for name in graph:
+ (deps_dir / name / ".stamp").unlink(missing_ok=True)
+ shutil.rmtree(deps_dir / name / "vcpkg_installed", ignore_errors=True)
+
+ check = subprocess.run(["ninja", "-C", str(deps_dir), "-n"], capture_output=True, text=True)
+ have_work = "no work to do" not in check.stdout
+
+ if have_work:
+ run_quietly(manifest_arguments + ["--dry-run"], deps_dir / "plan.log", environment)
+
+ tokens = int(jobs) if jobs else (os.cpu_count() or 2) + 2
+ token_fifo = deps_dir / ".tokens"
+ token_fifo.unlink(missing_ok=True)
+ os.mkfifo(token_fifo)
+ fifo_fd = os.open(token_fifo, os.O_RDWR)
+ os.write(fifo_fd, b"x" * tokens)
+
+ ninja_environment = os.environ.copy()
+ ninja_environment["LADYBIRD_VCPKG_TOKEN_FIFO"] = str(token_fifo)
+ ninja_environment["LADYBIRD_VCPKG_TOKEN_POOL"] = str(tokens)
+
+ try:
+ ninja_arguments = ["ninja", "-C", str(deps_dir)]
+ if jobs:
+ ninja_arguments.extend(["-j", jobs])
+ subprocess.check_call(ninja_arguments, env=ninja_environment)
+ finally:
+ os.close(fifo_fd)
+ token_fifo.unlink(missing_ok=True)
+
+ if install_is_stale(deps_dir, graph, build_dir / "vcpkg_installed"):
+ print("Installing dependencies from the binary cache...")
+ run_quietly(manifest_arguments, deps_dir / "restore.log", environment)
+ (deps_dir / ".restore-stamp").touch()
+ finally:
+ os.close(lock_fd)
+
+ return triplet
+
+
+def main():
+ parser = argparse.ArgumentParser(description="vcpkg dependency build node")
+ subparsers = parser.add_subparsers(dest="command", required=True)
+
+ node_parser = subparsers.add_parser("run-node")
+ node_parser.add_argument("--vcpkg", required=True)
+ node_parser.add_argument("--triplet", required=True)
+ node_parser.add_argument("--preset", required=True)
+ node_parser.add_argument("--node-dir", required=True)
+ node_parser.add_argument("--stamp", required=True)
+
+ arguments = parser.parse_args()
+ if arguments.command == "run-node":
+ run_node(arguments)
+
+
+if __name__ == "__main__":
+ main()
diff --git a/Meta/ladybird.py b/Meta/ladybird.py
index 5915aaa1932..d121adf9116 100755
--- a/Meta/ladybird.py
+++ b/Meta/ladybird.py
@@ -3,6 +3,7 @@
# Copyright (c) 2025, ayeteadoe <[email protected]>
# Copyright (c) 2025, Tim Flynn <[email protected]>
# Copyright (c) 2025, Nicolas Danelon <[email protected]>
+# Copyright (c) 2026, Ali Mohammad Pur <[email protected]>
#
# SPDX-License-Identifier: BSD-2-Clause
@@ -23,6 +24,7 @@ from Utils.host_platform import HostArchitecture
from Utils.host_platform import HostSystem
from Utils.host_platform import Platform
from Utils.utils import run_command
+from Utils.vcpkg_deps import build_dependencies
LADYBIRD_SOURCE_DIR = Path(__file__).resolve().parent.parent
@@ -108,6 +110,14 @@ def main():
)
vcpkg_parser.add_argument("--jobs", "-j", required=False)
+ deps_parser = subparsers.add_parser(
+ "deps", help="Builds the third-party dependencies", parents=[preset_parser, compiler_parser]
+ )
+ deps_parser.add_argument("--fetch", action="store_true", help="Only download dependency sources")
+ deps_parser.add_argument(
+ "--rebuild", action="store_true", help="Rebuild all dependencies through the graph, ignoring prior state"
+ )
+
subparsers.add_parser("clean", help="Cleans the build environment", parents=[preset_parser])
rebuild_parser = subparsers.add_parser(
@@ -193,6 +203,17 @@ def main():
build_dir = configure_main(platform, args.preset, args.cc, args.cxx, args.jobs)
build_main(build_dir, args.jobs, args.target, args.args)
build_main(build_dir, args.jobs, "install", args.args)
+ elif args.command == "deps":
+ if platform.host_system == HostSystem.Windows:
+ parser.error(
+ "The deps command is not supported on Windows; dependencies are built during CMake configuration"
+ )
+ build_preset_dir, vcpkg_preset_dir = configure_build_env(platform, args.preset, args.jobs)
+ build_vcpkg(vcpkg_preset_dir)
+ (cc, cxx) = pick_host_compiler(platform, args.cc, args.cxx)
+ build_dependencies(
+ platform, args.preset, build_preset_dir, cc, cxx, args.jobs, fetch_only=args.fetch, rebuild=args.rebuild
+ )
elif args.command == "clean":
clean_main(platform, args.preset)
elif args.command == "rebuild":
@@ -209,12 +230,21 @@ def configure_main(platform: Platform, preset: str, cc: str, cxx: str, jobs: Opt
build_preset_dir, vcpkg_preset_dir = configure_build_env(platform, preset, jobs)
build_vcpkg(vcpkg_preset_dir)
+ # On Windows the dependencies are still built by vcpkg's toolchain file at configure time.
+ staged_deps = platform.host_system != HostSystem.Windows
+ vcpkg_triplet = None
+
+ if staged_deps:
+ (cc, cxx) = pick_host_compiler(platform, cc, cxx)
+ vcpkg_triplet = build_dependencies(platform, preset, build_preset_dir, cc, cxx, jobs)
+
if build_preset_dir.joinpath("build.ninja").exists() or build_preset_dir.joinpath("ladybird.sln").exists():
return build_preset_dir
validate_cmake_version()
- (cc, cxx) = pick_host_compiler(platform, cc, cxx)
+ if not staged_deps:
+ (cc, cxx) = pick_host_compiler(platform, cc, cxx)
config_args = [
"cmake",
@@ -228,6 +258,15 @@ def configure_main(platform: Platform, preset: str, cc: str, cxx: str, jobs: Opt
f"-DCMAKE_CXX_COMPILER={cxx}",
]
+ if staged_deps:
+ config_args.extend(
+ [
+ "-DVCPKG_MANIFEST_INSTALL=OFF",
+ f"-DVCPKG_TARGET_TRIPLET={vcpkg_triplet}",
+ f"-DVCPKG_HOST_TRIPLET={vcpkg_triplet}",
+ ]
+ )
+
if platform.host_system == HostSystem.Linux and platform.host_architecture == HostArchitecture.AArch64:
config_args.extend(configure_skia_jemalloc())