generated from canonical/starbase
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(application): enable build plans
Enable multi-artefact builds by using the application-defined build plan resolver to create multiple provider instances. Further refactoring may be necessary if applications such as Rockcraft and Charmcraft require additional features. Signed-off-by: Claudio Matsuoka <[email protected]>
- Loading branch information
Showing
18 changed files
with
316 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# This file is part of craft_application. | ||
# | ||
# Copyright 2023 Canonical Ltd. | ||
# | ||
# This program is free software: you can redistribute it and/or modify it | ||
# under the terms of the GNU Lesser General Public License version 3, as | ||
# published by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, | ||
# SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
# Lesser General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public License along | ||
# with this program. If not, see <http://www.gnu.org/licenses/>. | ||
"""OS and architecture helpers for craft applications.""" | ||
from __future__ import annotations | ||
|
||
import functools | ||
import platform | ||
|
||
|
||
@functools.lru_cache(maxsize=1) | ||
def get_host_architecture() -> str: | ||
"""Get host architecture in deb format.""" | ||
machine = platform.machine() | ||
return _ARCH_TRANSLATIONS_PLATFORM_TO_DEB.get(machine, machine) | ||
|
||
|
||
def convert_architecture_deb_to_platform(arch: str) -> str: | ||
"""Convert an architecture from deb/snap syntax to platform syntax. | ||
:param architecture: architecture string in debian/snap syntax | ||
:return: architecture in platform syntax | ||
""" | ||
return _ARCH_TRANSLATIONS_DEB_TO_PLATFORM.get(arch, arch) | ||
|
||
|
||
# architecture translations from the platform syntax to the deb/snap syntax | ||
# These two architecture mappings are almost inverses of each other, except one map is | ||
# not reversible (same value for different keys) | ||
_ARCH_TRANSLATIONS_PLATFORM_TO_DEB = { | ||
"aarch64": "arm64", | ||
"armv7l": "armhf", | ||
"i686": "i386", | ||
"ppc": "powerpc", | ||
"ppc64le": "ppc64el", | ||
"x86_64": "amd64", | ||
"AMD64": "amd64", # Windows support | ||
"s390x": "s390x", | ||
"riscv64": "riscv64", | ||
} | ||
|
||
# architecture translations from the deb/snap syntax to the platform syntax | ||
_ARCH_TRANSLATIONS_DEB_TO_PLATFORM = { | ||
"arm64": "aarch64", | ||
"armhf": "armv7l", | ||
"i386": "i686", | ||
"powerpc": "ppc", | ||
"ppc64el": "ppc64le", | ||
"amd64": "x86_64", | ||
"s390x": "s390x", | ||
"riscv64": "riscv64", | ||
} | ||
|
Oops, something went wrong.