Skip to content

Commit

Permalink
fix: use correct type for build-on and build-for in build plans (#…
Browse files Browse the repository at this point in the history
…5043)

Signed-off-by: Callahan Kovacs <callahan.kovacs@canonical.com>
  • Loading branch information
mr-cal authored Sep 16, 2024
1 parent 4f94112 commit 19699c1
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 2 deletions.
4 changes: 2 additions & 2 deletions snapcraft/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -1222,8 +1222,8 @@ def get_build_plan(self) -> list[BuildInfo]:
)

for platform_entry, platform in self.platforms.items():
for build_for in platform.build_for or [SnapArch(platform_entry)]:
for build_on in platform.build_on or [SnapArch(platform_entry)]:
for build_for in platform.build_for or [SnapArch(platform_entry).value]:
for build_on in platform.build_on or [SnapArch(platform_entry).value]:
build_infos.append(
BuildInfo(
platform=platform_entry,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
implicit-build-for_1.0_riscv64.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: implicit-build-for
version: "1.0"
summary: test
description: |
Use the platform name implicitly for the `build-for`.
confinement: strict
base: core24

platforms:
riscv64:
build-on: [amd64]

parts:
my-part:
plugin: nil
1 change: 1 addition & 0 deletions tests/spread/core24/platforms/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ environment:
SNAP/env_var_all: env-var-all
SNAP/env_var_match: env-var-match
SNAP/env_var_no_match: env-var-no-match
SNAP/implicit_build_for: implicit-build-for
SNAP/multiple_build_for: multiple-build-for
SNAP/platform_all: platform-all
SNAP/platform_match: platform-match
Expand Down
31 changes: 31 additions & 0 deletions tests/unit/models/test_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -2068,6 +2068,37 @@ def test_root_packages_transform_no_affect(self, project_yaml_data):
],
id="single_platform_as_arch",
),
pytest.param(
{
"s390x": {
"build-on": "s390x",
},
"riscv64": {
"build-on": ["amd64", "riscv64"],
},
},
[
BuildInfo(
build_on="s390x",
build_for="s390x",
base=BaseName(name="ubuntu", version="24.04"),
platform="s390x",
),
BuildInfo(
build_on="amd64",
build_for="riscv64",
base=BaseName(name="ubuntu", version="24.04"),
platform="riscv64",
),
BuildInfo(
build_on="riscv64",
build_for="riscv64",
base=BaseName(name="ubuntu", version="24.04"),
platform="riscv64",
),
],
id="implicit_build_for",
),
pytest.param(
{
"arm64": {
Expand Down

0 comments on commit 19699c1

Please sign in to comment.