aboutsummaryrefslogtreecommitdiff
path: root/kernelci/configs.py
diff options
context:
space:
mode:
authorGuillaume Tucker <guillaume.tucker@collabora.com>2019-04-03 15:40:58 +0200
committerGuillaume Tucker <guillaume.tucker@collabora.com>2019-05-03 12:59:46 +0100
commit3dbfdac5879fa44de951ce2ab834a1fad093c377 (patch)
tree258236a5cfedd0f3a077c362fcd4debdc60de4fe /kernelci/configs.py
parentd44245f3ed8831a9ac51507394f7886f695693c9 (diff)
kernelci.configs.BuildEnvironment: add cross_compile()
Add a BuildEnvironment.cross_compile() method to get the cross-compiler string associated with a build environment for a given CPU architecture. Signed-off-by: Guillaume Tucker <guillaume.tucker@collabora.com>
Diffstat (limited to 'kernelci/configs.py')
-rw-r--r--kernelci/configs.py21
1 files changed, 16 insertions, 5 deletions
diff --git a/kernelci/configs.py b/kernelci/configs.py
index fb9de13..275c422 100644
--- a/kernelci/configs.py
+++ b/kernelci/configs.py
@@ -290,7 +290,8 @@ class Architecture(YAMLObject):
class BuildEnvironment(YAMLObject):
"""Kernel build environment model."""
- def __init__(self, name, cc, cc_version, arch_map=None):
+ def __init__(self, name, cc, cc_version, arch_map=None,
+ cross_compile=None):
"""A build environment is a compiler and tools to build a kernel.
*name* is the name of the build environment so it can be referred to in
@@ -307,11 +308,15 @@ class BuildEnvironment(YAMLObject):
ones used in compiler names. For example, gcc compilers are
the same "x86" for both "i386" and "x86_64" kernel
architectures.
+
+ *cross_compile* is a dictionary mapping kernel CPU architecture names
+ to cross-compiler prefixes.
"""
self._name = name
self._cc = cc
self._cc_version = str(cc_version)
self._arch_map = arch_map or dict()
+ self._cross_compile = cross_compile or dict()
@classmethod
def from_yaml(cls, config, name):
@@ -319,7 +324,7 @@ class BuildEnvironment(YAMLObject):
'name': name,
}
kw.update(cls._kw_from_yaml(
- config, ['name', 'cc', 'cc_version', 'arch_map']))
+ config, ['name', 'cc', 'cc_version', 'arch_map', 'cross_compile']))
return cls(**kw)
@property
@@ -337,6 +342,9 @@ class BuildEnvironment(YAMLObject):
def get_arch_name(self, kernel_arch):
return self._arch_map.get(kernel_arch, kernel_arch)
+ def get_cross_compile(self, kernel_arch):
+ return self._cross_compile.get(kernel_arch, '')
+
class BuildVariant(YAMLObject):
"""A variant of a given build configuration."""
@@ -360,7 +368,7 @@ class BuildVariant(YAMLObject):
to build with this build variant.
"""
self._name = name
- self._architectures = architectures
+ self._architectures = {arch.name: arch for arch in architectures}
self._build_environment = build_environment
self._fragments = fragments or list()
@@ -386,11 +394,14 @@ class BuildVariant(YAMLObject):
@property
def arch_list(self):
- return list(arch.name for arch in self._architectures)
+ return self._architectures.keys()
@property
def architectures(self):
- return list(self._architectures)
+ return list(self._architectures.values())
+
+ def get_arch(self, arch_name):
+ return self._architectures.get(arch_name)
@property
def build_environment(self):