WIP: build: rewrite package builder (MR 2252)

The package builder has long been a pain point since it recurses the
entire dependency tree.

Convert it to run in two stages, first it walks through the package
dependencies, descending into each one and processing them in a queue.
If a package is determined to need building then it gets pushed onto the
build_queue.

Then, it pops each package off the build queue (which is actually a
stack..) and builds it.

This avoids recursion entirely and should open the door to optimisations
in the future.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
Caleb Connolly 2024-06-09 12:52:15 +02:00 committed by Oliver Smith
parent 338e0890ba
commit 3ad4ba2818
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
3 changed files with 140 additions and 175 deletions

View file

@ -86,7 +86,7 @@ def chroot(apkbuild: Dict[str, str], arch: Arch) -> Chroot:
return Chroot.buildroot(arch)
def crosscompile(apkbuild, arch: Arch, suffix: Chroot):
def crosscompile(apkbuild, arch: Arch):
"""
:returns: None, "native", "crossdirect"
"""
@ -94,7 +94,7 @@ def crosscompile(apkbuild, arch: Arch, suffix: Chroot):
return None
if not arch.cpu_emulation_required():
return None
if suffix.type == ChrootType.NATIVE:
if arch.is_native() or "pmb:cross-native" in apkbuild["options"]:
return "native"
if "!pmb:crossdirect" in apkbuild["options"]:
return None