summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2019-01-03 18:38:47 +0100
committerJürg Billeter <j@bitron.ch>2019-01-10 10:43:37 +0100
commitc87bb5924d3d809f6f88aec36c61dadf247e6315 (patch)
treef837619ffaba00a69eaf388e56900db1e674bfd6
parentc8f3616d69c4ff58698532750207587936a6e78e (diff)
downloadbuildstream-c87bb5924d3d809f6f88aec36c61dadf247e6315.tar.gz
_platform/platform.py: Add canonicalize_arch() method
-rw-r--r--buildstream/_platform/platform.py42
1 files changed, 28 insertions, 14 deletions
diff --git a/buildstream/_platform/platform.py b/buildstream/_platform/platform.py
index 42b360ff8..73ed571fe 100644
--- a/buildstream/_platform/platform.py
+++ b/buildstream/_platform/platform.py
@@ -77,20 +77,17 @@ class Platform():
def get_host_os():
return os.uname()[0]
- # get_host_arch():
+ # canonicalize_arch():
#
- # This returns the architecture of the host machine. The possible values
- # map from uname -m in order to be a OS independent list.
+ # This returns the canonical, OS-independent architecture name
+ # or raises a PlatformError if the architecture is unknown.
#
- # Returns:
- # (string): String representing the architecture
@staticmethod
- def get_host_arch():
- # get the hardware identifier from uname
- uname_machine = os.uname()[4]
- uname_to_arch = {
+ def canonicalize_arch(arch):
+ aliases = {
+ "aarch32": "aarch32",
"aarch64": "aarch64",
- "aarch64_be": "aarch64-be",
+ "aarch64-be": "aarch64-be",
"amd64": "x86-64",
"arm": "aarch32",
"armv8l": "aarch64",
@@ -99,17 +96,34 @@ class Platform():
"i486": "x86-32",
"i586": "x86-32",
"i686": "x86-32",
+ "power-isa-be": "power-isa-be",
+ "power-isa-le": "power-isa-le",
"ppc64": "power-isa-be",
"ppc64le": "power-isa-le",
"sparc": "sparc-v9",
"sparc64": "sparc-v9",
- "x86_64": "x86-64"
+ "sparc-v9": "sparc-v9",
+ "x86-32": "x86-32",
+ "x86-64": "x86-64"
}
+
try:
- return uname_to_arch[uname_machine]
+ return aliases[arch.replace('_', '-')]
except KeyError:
- raise PlatformError("uname gave unsupported machine architecture: {}"
- .format(uname_machine))
+ raise PlatformError("Unknown architecture: {}".format(arch))
+
+ # get_host_arch():
+ #
+ # This returns the architecture of the host machine. The possible values
+ # map from uname -m in order to be a OS independent list.
+ #
+ # Returns:
+ # (string): String representing the architecture
+ @staticmethod
+ def get_host_arch():
+ # get the hardware identifier from uname
+ uname_machine = os.uname()[4]
+ return Platform.canonicalize_arch(uname_machine)
##################################################################
# Sandbox functions #