diff options
author | Raoul Hidalgo Charman <raoul.hidalgocharman@codethink.co.uk> | 2018-11-22 16:51:17 +0000 |
---|---|---|
committer | Raoul Hidalgo Charman <raoul.hidalgocharman@codethink.co.uk> | 2018-12-05 10:37:10 +0000 |
commit | 2f5966bdf5bdc6bbd6db46a7e41c93b32c1d6deb (patch) | |
tree | cb4fff6205d66013cce011f56468950650c66328 /buildstream | |
parent | 761e757021a6c0ecc9da9d9d0df80dd603bdd94d (diff) | |
download | buildstream-2f5966bdf5bdc6bbd6db46a7e41c93b32c1d6deb.tar.gz |
platform.py: Add mapping of uname to OS-independent valueslachlanmackenzie/debug_benchmark_failure
Diffstat (limited to 'buildstream')
-rw-r--r-- | buildstream/_platform/platform.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/buildstream/_platform/platform.py b/buildstream/_platform/platform.py index d3e4b949a..42b360ff8 100644 --- a/buildstream/_platform/platform.py +++ b/buildstream/_platform/platform.py @@ -73,6 +73,44 @@ class Platform(): else: return min(cpu_count, cap) + @staticmethod + def get_host_os(): + return os.uname()[0] + + # 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] + uname_to_arch = { + "aarch64": "aarch64", + "aarch64_be": "aarch64-be", + "amd64": "x86-64", + "arm": "aarch32", + "armv8l": "aarch64", + "armv8b": "aarch64-be", + "i386": "x86-32", + "i486": "x86-32", + "i586": "x86-32", + "i686": "x86-32", + "ppc64": "power-isa-be", + "ppc64le": "power-isa-le", + "sparc": "sparc-v9", + "sparc64": "sparc-v9", + "x86_64": "x86-64" + } + try: + return uname_to_arch[uname_machine] + except KeyError: + raise PlatformError("uname gave unsupported machine architecture: {}" + .format(uname_machine)) + ################################################################## # Sandbox functions # ################################################################## |