forked from Mirror/pmbootstrap
pmb.types.CrossCompileType: split up None
Replace None with the three things it is actually used for to make the code easier to follow: * "autodetect" * "unnecessary" * "qemu-only" I've used the term "unnecessary" instead of "native", because "native" was previously used for "cross-native", then "cross-native2" and it still sounds similar to these. Part-of: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2568
This commit is contained in:
parent
0625ece550
commit
bef3b43343
4 changed files with 17 additions and 12 deletions
|
@ -405,15 +405,15 @@ def process_package(
|
||||||
dep = depends.pop(0)
|
dep = depends.pop(0)
|
||||||
if is_cached_or_cache(arch, pmb.helpers.package.remove_operators(dep)):
|
if is_cached_or_cache(arch, pmb.helpers.package.remove_operators(dep)):
|
||||||
continue
|
continue
|
||||||
cross = None
|
|
||||||
|
|
||||||
aports, apkbuild = get_apkbuild(dep)
|
aports, apkbuild = get_apkbuild(dep)
|
||||||
if not apkbuild:
|
if not apkbuild:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
cross = pmb.build.autodetect.crosscompile(apkbuild, arch)
|
||||||
|
|
||||||
if context.no_depends:
|
if context.no_depends:
|
||||||
pmb.helpers.repo.update(arch)
|
pmb.helpers.repo.update(arch)
|
||||||
cross = pmb.build.autodetect.crosscompile(apkbuild, arch)
|
|
||||||
_dep_arch = Arch.native() if cross == "cross-native2" else arch
|
_dep_arch = Arch.native() if cross == "cross-native2" else arch
|
||||||
if not pmb.parse.apkindex.package(dep, _dep_arch, False):
|
if not pmb.parse.apkindex.package(dep, _dep_arch, False):
|
||||||
raise RuntimeError(
|
raise RuntimeError(
|
||||||
|
@ -493,7 +493,7 @@ def packages(
|
||||||
aports: Path,
|
aports: Path,
|
||||||
apkbuild: dict[str, Any],
|
apkbuild: dict[str, Any],
|
||||||
depends: list[str],
|
depends: list[str],
|
||||||
cross: CrossCompileType = None,
|
cross: CrossCompileType = "autodetect",
|
||||||
) -> list[str]:
|
) -> list[str]:
|
||||||
# Skip if already queued
|
# Skip if already queued
|
||||||
name = apkbuild["pkgname"]
|
name = apkbuild["pkgname"]
|
||||||
|
@ -501,7 +501,6 @@ def packages(
|
||||||
return []
|
return []
|
||||||
|
|
||||||
pkg_arch = pmb.build.autodetect.arch(apkbuild) if arch is None else arch
|
pkg_arch = pmb.build.autodetect.arch(apkbuild) if arch is None else arch
|
||||||
chroot = pmb.build.autodetect.chroot(apkbuild, pkg_arch)
|
|
||||||
cross = cross or pmb.build.autodetect.crosscompile(apkbuild, pkg_arch)
|
cross = cross or pmb.build.autodetect.crosscompile(apkbuild, pkg_arch)
|
||||||
pkgver = get_pkgver(apkbuild["pkgver"], src is None)
|
pkgver = get_pkgver(apkbuild["pkgver"], src is None)
|
||||||
channel = pmb.config.pmaports.read_config(aports)["channel"]
|
channel = pmb.config.pmaports.read_config(aports)["channel"]
|
||||||
|
@ -614,8 +613,8 @@ def packages(
|
||||||
" build the package with --src again."
|
" build the package with --src again."
|
||||||
)
|
)
|
||||||
|
|
||||||
cross = None
|
cross = "autodetect"
|
||||||
prev_cross = None
|
prev_cross = "autodetect"
|
||||||
hostchroot = None # buildroot for the architecture we're building for
|
hostchroot = None # buildroot for the architecture we're building for
|
||||||
|
|
||||||
total_pkgs = len(build_queue)
|
total_pkgs = len(build_queue)
|
||||||
|
@ -664,7 +663,7 @@ def packages(
|
||||||
if "rust" in all_dependencies or "cargo" in all_dependencies:
|
if "rust" in all_dependencies or "cargo" in all_dependencies:
|
||||||
pmb.chroot.apk.install(["sccache"], chroot)
|
pmb.chroot.apk.install(["sccache"], chroot)
|
||||||
|
|
||||||
if cross != prev_cross:
|
if cross != prev_cross and cross not in ["unnecessary", "qemu-only"]:
|
||||||
pmb.build.init_compiler(context, pkg_depends, cross, pkg_arch)
|
pmb.build.init_compiler(context, pkg_depends, cross, pkg_arch)
|
||||||
if cross == "crossdirect":
|
if cross == "crossdirect":
|
||||||
pmb.chroot.mount_native_into_foreign(chroot)
|
pmb.chroot.mount_native_into_foreign(chroot)
|
||||||
|
|
|
@ -95,13 +95,13 @@ def chroot(apkbuild: Apkbuild, arch: Arch) -> Chroot:
|
||||||
def crosscompile(apkbuild: Apkbuild, arch: Arch) -> CrossCompileType:
|
def crosscompile(apkbuild: Apkbuild, arch: Arch) -> CrossCompileType:
|
||||||
"""Decide the type of compilation necessary to build a given APKBUILD."""
|
"""Decide the type of compilation necessary to build a given APKBUILD."""
|
||||||
if not get_context().cross:
|
if not get_context().cross:
|
||||||
return None
|
return "qemu-only"
|
||||||
if not arch.cpu_emulation_required():
|
if not arch.cpu_emulation_required():
|
||||||
return None
|
return "unnecessary"
|
||||||
if "pmb:cross-native" in apkbuild["options"]:
|
if "pmb:cross-native" in apkbuild["options"]:
|
||||||
return "cross-native"
|
return "cross-native"
|
||||||
if arch.is_native() or "pmb:cross-native2" in apkbuild["options"]:
|
if arch.is_native() or "pmb:cross-native2" in apkbuild["options"]:
|
||||||
return "cross-native2"
|
return "cross-native2"
|
||||||
if "!pmb:crossdirect" in apkbuild["options"]:
|
if "!pmb:crossdirect" in apkbuild["options"]:
|
||||||
return None
|
return "qemu-only"
|
||||||
return "crossdirect"
|
return "crossdirect"
|
||||||
|
|
|
@ -202,7 +202,6 @@ def run_abuild(
|
||||||
depending on the cross-compiler method and target architecture), copy
|
depending on the cross-compiler method and target architecture), copy
|
||||||
the aport to the chroot and execute abuild.
|
the aport to the chroot and execute abuild.
|
||||||
|
|
||||||
:param cross: None, "cross-native", "cross-native2" or "crossdirect"
|
|
||||||
:param src: override source used to build the package with a local folder
|
:param src: override source used to build the package with a local folder
|
||||||
:param bootstrap_stage: pass a BOOTSTRAP= env var with the value to abuild
|
:param bootstrap_stage: pass a BOOTSTRAP= env var with the value to abuild
|
||||||
:returns: (output, cmd, env), output is the destination apk path relative
|
:returns: (output, cmd, env), output is the destination apk path relative
|
||||||
|
|
|
@ -8,7 +8,14 @@ from typing import Any, Literal, TypedDict
|
||||||
|
|
||||||
from pmb.core.arch import Arch
|
from pmb.core.arch import Arch
|
||||||
|
|
||||||
CrossCompileType = Literal["crossdirect", "cross-native", "cross-native2"] | None
|
CrossCompileType = Literal[
|
||||||
|
"autodetect",
|
||||||
|
"unnecessary",
|
||||||
|
"qemu-only",
|
||||||
|
"crossdirect",
|
||||||
|
"cross-native",
|
||||||
|
"cross-native2",
|
||||||
|
]
|
||||||
RunOutputTypeDefault = Literal["log", "stdout", "interactive", "tui", "null"]
|
RunOutputTypeDefault = Literal["log", "stdout", "interactive", "tui", "null"]
|
||||||
RunOutputTypePopen = Literal["background", "pipe"]
|
RunOutputTypePopen = Literal["background", "pipe"]
|
||||||
RunOutputType = RunOutputTypeDefault | RunOutputTypePopen
|
RunOutputType = RunOutputTypeDefault | RunOutputTypePopen
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue