Skip to content

Commit

Permalink
feat: bring back some of the original build planner logic
Browse files Browse the repository at this point in the history
  • Loading branch information
mattculler committed Oct 17, 2024
1 parent 30538dc commit f3882fd
Showing 1 changed file with 31 additions and 7 deletions.
38 changes: 31 additions & 7 deletions snapcraft/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from typing_extensions import Annotated, Self, override

from snapcraft import utils
from snapcraft.const import SUPPORTED_ARCHS
from snapcraft.const import SUPPORTED_ARCHS, SnapArch
from snapcraft.elf.elf_utils import get_arch_triplet
from snapcraft.errors import ProjectValidationError
from snapcraft.providers import SNAPCRAFT_BASE_TO_PROVIDER_BASE
Expand Down Expand Up @@ -1197,17 +1197,41 @@ def get_build_plan(self) -> list[BuildInfo]:
snap_type: str | None = None
if self.type in ("base", "kernel", "snapd"):
snap_type = self.type
elif not self.base:
elif self.base is None:
raise ValueError(
"Snap base must be declared when type is not base, kernel or snapd"
)

platforms = None
if self.platforms:
platforms = cast(
Platforms,
{name: platform.marshal() for name, platform in self.platforms.items()},
effective_base = SNAPCRAFT_BASE_TO_PROVIDER_BASE[
str(
get_effective_base(
base=self.base,
build_base=self.build_base,
project_type=self.project_type,
name=self.name,
translate_devel=False, # We want actual "devel" if set.
)
)
]

# set default value
if self.platforms is None:
self.platforms = {
get_host_architecture(): Platform(
build_on=[SnapArch(get_host_architecture()).value],
build_for=[SnapArch(get_host_architecture()).value],
)
}
# For backwards compatibility with core22, convert the platforms.
if effective_base == "22.04" and self.architectures:
self.platforms = ( # type: ignore[reportIncompatibleVariableOverride]
Platform.from_architectures(self.architectures)
)

platforms = cast(
Platforms,
{name: platform.marshal() for name, platform in self.platforms.items()},
)

return [
BuildInfo(
Expand Down

0 comments on commit f3882fd

Please sign in to comment.