pmb.build: fix internal cross compiling names

Use the same names as in the documentation for:
"cross-native" (not "kernel")
"cross-native2" (not "native")

Part-of: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2568
This commit is contained in:
Oliver Smith 2025-03-14 17:44:50 +01:00
parent 53d705194f
commit 9e0c4a8393
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
4 changed files with 11 additions and 11 deletions

View file

@ -414,7 +414,7 @@ def process_package(
if context.no_depends:
pmb.helpers.repo.update(arch)
cross = pmb.build.autodetect.crosscompile(apkbuild, arch)
_dep_arch = Arch.native() if cross == "native" else arch
_dep_arch = Arch.native() if cross == "cross-native2" else arch
if not pmb.parse.apkindex.package(dep, _dep_arch, False):
raise RuntimeError(
"Missing binary package for dependency '" + dep + "' of '" + parent + "', but"
@ -652,7 +652,7 @@ def packages(
# (re)-initialize the cross compiler stuff when cross method changes
prev_cross = cross
cross = pmb.build.autodetect.crosscompile(pkg["apkbuild"], pkg_arch)
if cross == "native" or cross == "kernel":
if cross == "cross-native2" or cross == "cross-native":
chroot = Chroot.native()
# One time chroot initialization

View file

@ -100,9 +100,9 @@ def crosscompile(apkbuild: Apkbuild, arch: Arch) -> CrossCompileType:
return None
# deprecated cross-native environment for building kernels
if "pmb:cross-native" in apkbuild["options"]:
return "kernel"
return "cross-native"
if arch.is_native() or "pmb:cross-native2" in apkbuild["options"]:
return "native"
return "cross-native2"
if "!pmb:crossdirect" in apkbuild["options"]:
return None
return "crossdirect"

View file

@ -202,7 +202,7 @@ def run_abuild(
depending on the cross-compiler method and target architecture), copy
the aport to the chroot and execute abuild.
:param cross: None, "native", or "crossdirect"
:param cross: None, "cross-native", "cross-native2" or "crossdirect"
: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
:returns: (output, cmd, env), output is the destination apk path relative
@ -211,7 +211,7 @@ def run_abuild(
the environment variables dict generated in this function.
"""
# Sanity check
if cross == "kernel" and "!tracedeps" not in apkbuild["options"]:
if cross == "cross-native" and "!tracedeps" not in apkbuild["options"]:
logging.warning(
"WARNING: Option !tracedeps is not set, but cross compiling with"
" cross-native (version 1). This will probably fail!"
@ -219,10 +219,10 @@ def run_abuild(
# For cross-native2 compilation, bindmount the "host" rootfs to /mnt/sysroot
# it will be used as the "sysroot"
if cross == "native":
if cross == "cross-native2":
pmb.mount.bind(hostchroot.path, Chroot.native() / "/mnt/sysroot", umount=True)
chroot = Chroot.native() if cross == "native" else hostchroot
chroot = Chroot.native() if cross == "cross-native2" else hostchroot
pkgdir = context.config.work / "packages" / channel
if not pkgdir.exists():
@ -247,11 +247,11 @@ def run_abuild(
# Environment variables
env: Env = {"SUDO_APK": "abuild-apk --no-progress"}
if cross == "kernel":
if cross == "cross-native":
hostspec = arch.alpine_triple()
env["CROSS_COMPILE"] = hostspec + "-"
env["CC"] = hostspec + "-gcc"
if cross == "native":
if cross == "cross-native2":
env["CHOST"] = str(arch)
env["CBUILDROOT"] = "/mnt/sysroot"
env["CFLAGS"] = "-Wl,-rpath-link=/mnt/sysroot/usr/lib"

View file

@ -8,7 +8,7 @@ from typing import Any, Literal, TypedDict
from pmb.core.arch import Arch
CrossCompileType = Literal["native", "crossdirect", "kernel"] | None
CrossCompileType = Literal["crossdirect", "cross-native", "cross-native2"] | None
RunOutputTypeDefault = Literal["log", "stdout", "interactive", "tui", "null"]
RunOutputTypePopen = Literal["background", "pipe"]
RunOutputType = RunOutputTypeDefault | RunOutputTypePopen