forked from Mirror/pmbootstrap
pmb.build: Properly type cross-compilation types (MR 2337)
This commit is contained in:
parent
d6d088b68b
commit
ca6d0eba28
3 changed files with 11 additions and 7 deletions
|
@ -7,6 +7,7 @@ from pmb.core.arch import Arch
|
||||||
from pmb.core.context import Context
|
from pmb.core.context import Context
|
||||||
from pmb.core.pkgrepo import pkgrepo_relative_path
|
from pmb.core.pkgrepo import pkgrepo_relative_path
|
||||||
from pmb.helpers import logging
|
from pmb.helpers import logging
|
||||||
|
from pmb.types import CrossCompileType
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import pmb.build
|
import pmb.build
|
||||||
|
@ -196,7 +197,7 @@ class BuildQueueItem(TypedDict):
|
||||||
output_path: Path
|
output_path: Path
|
||||||
channel: str
|
channel: str
|
||||||
depends: list[str]
|
depends: list[str]
|
||||||
cross: str
|
cross: CrossCompileType
|
||||||
chroot: Chroot
|
chroot: Chroot
|
||||||
|
|
||||||
|
|
||||||
|
@ -337,7 +338,10 @@ def packages(
|
||||||
# Add a package to the build queue, fetch it's dependency, and
|
# Add a package to the build queue, fetch it's dependency, and
|
||||||
# add record build helpers to installed (e.g. sccache)
|
# add record build helpers to installed (e.g. sccache)
|
||||||
def queue_build(
|
def queue_build(
|
||||||
aports: Path, apkbuild: dict[str, Any], depends: list[str], cross: Optional[str] = None
|
aports: Path,
|
||||||
|
apkbuild: dict[str, Any],
|
||||||
|
depends: list[str],
|
||||||
|
cross: CrossCompileType = None,
|
||||||
) -> list[str]:
|
) -> list[str]:
|
||||||
# Skip if already queued
|
# Skip if already queued
|
||||||
name = apkbuild["pkgname"]
|
name = apkbuild["pkgname"]
|
||||||
|
|
|
@ -11,6 +11,7 @@ import pmb.helpers.pmaports
|
||||||
from pmb.core import Chroot
|
from pmb.core import Chroot
|
||||||
from pmb.core.context import get_context
|
from pmb.core.context import get_context
|
||||||
from pmb.meta import Cache
|
from pmb.meta import Cache
|
||||||
|
from pmb.types import CrossCompileType
|
||||||
|
|
||||||
|
|
||||||
# FIXME (#2324): type hint Arch
|
# FIXME (#2324): type hint Arch
|
||||||
|
@ -93,10 +94,8 @@ def chroot(apkbuild: dict[str, str], arch: Arch) -> Chroot:
|
||||||
return Chroot.buildroot(arch)
|
return Chroot.buildroot(arch)
|
||||||
|
|
||||||
|
|
||||||
def crosscompile(apkbuild, arch: Arch):
|
def crosscompile(apkbuild, arch: Arch) -> CrossCompileType:
|
||||||
"""
|
"""Decide the type of compilation necessary to build a given APKBUILD."""
|
||||||
:returns: None, "native", "crossdirect"
|
|
||||||
"""
|
|
||||||
if not get_context().cross:
|
if not get_context().cross:
|
||||||
return None
|
return None
|
||||||
if not arch.cpu_emulation_required():
|
if not arch.cpu_emulation_required():
|
||||||
|
|
|
@ -3,10 +3,11 @@
|
||||||
|
|
||||||
from argparse import Namespace
|
from argparse import Namespace
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Optional, TypedDict, Union
|
from typing import Literal, Optional, TypedDict, Union
|
||||||
|
|
||||||
from pmb.core.arch import Arch
|
from pmb.core.arch import Arch
|
||||||
|
|
||||||
|
CrossCompileType = Optional[Union[Literal["native"], Literal["crossdirect"]]]
|
||||||
PathString = Union[Path, str]
|
PathString = Union[Path, str]
|
||||||
Env = dict[str, PathString]
|
Env = dict[str, PathString]
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue