summaryrefslogtreecommitdiff
path: root/zephyr/zmake/zmake/project.py
diff options
context:
space:
mode:
authorJack Rosenthal <jrosenth@chromium.org>2021-08-31 18:44:15 -0600
committerCommit Bot <commit-bot@chromium.org>2021-09-01 22:57:37 +0000
commit4259d21065b281d8acc58e041d92d64c4db24205 (patch)
tree4aef746387316e6ad61d488ededf5a173335a5cd /zephyr/zmake/zmake/project.py
parent3010ab154cb84277e81e906bc05ae360d263993c (diff)
downloadchrome-ec-4259d21065b281d8acc58e041d92d64c4db24205.tar.gz
zephyr: zmake: implement multiple toolchain support/probing
Our GitLab builder uses different toolchains than the supported ones we use for development. At present, this means that the GitLab CI needs to call -t for each build with the desired toolchain, preventing us from using the more general commands "zmake coverage" or "zmake testall". Extend the idea of toolchain in our config files to be "supported toolchains" instead (i.e., multiple toolchains can be supported instead of one. We do this by refactoring our toolchain support code to consist of two related methods: - "probe" returns True if the toolchain is detected on the system, or False otherwise - "get_toolchain_config" returns the BuildConfig associated with the toolchain for the system, mirroring the functionality previously implemented in lambda functions. Also dropped support for arm-none-eabi, as I believe this was only used early on during scarlet development, and am not aware of any current users. BUG=b:178731498 BRANCH=none TEST=./run_tests.sh TEST=zmake testall Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I9b2ad508ae6703f0c3b56518fc32606c0ff1777c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3134668 Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
Diffstat (limited to 'zephyr/zmake/zmake/project.py')
-rw-r--r--zephyr/zmake/zmake/project.py45
1 files changed, 40 insertions, 5 deletions
diff --git a/zephyr/zmake/zmake/project.py b/zephyr/zmake/zmake/project.py
index 956971a52a..84151a90b3 100644
--- a/zephyr/zmake/zmake/project.py
+++ b/zephyr/zmake/zmake/project.py
@@ -12,6 +12,7 @@ import yaml
import zmake.build_config as build_config
import zmake.modules as modules
import zmake.output_packers as packers
+import zmake.toolchains as toolchains
import zmake.util as util
# The version of jsonschema in the chroot has a bunch of
@@ -55,7 +56,12 @@ class ProjectConfig:
validator = jsonschema.Draft7Validator
schema = {
"type": "object",
- "required": ["supported-zephyr-versions", "board", "output-type", "toolchain"],
+ "required": [
+ "board",
+ "output-type",
+ "supported-toolchains",
+ "supported-zephyr-versions",
+ ],
"properties": {
"supported-zephyr-versions": {
"type": "array",
@@ -80,8 +86,12 @@ class ProjectConfig:
"type": "string",
"enum": list(packers.packer_registry),
},
- "toolchain": {
- "type": "string",
+ "supported-toolchains": {
+ "type": "array",
+ "items": {
+ "type": "string",
+ "enum": list(toolchains.support_classes),
+ },
},
"is-test": {
"type": "boolean",
@@ -120,8 +130,8 @@ class ProjectConfig:
return packers.packer_registry[self.config_dict["output-type"]]
@property
- def toolchain(self):
- return self.config_dict["toolchain"]
+ def supported_toolchains(self):
+ return self.config_dict["supported-toolchains"]
@property
def is_test(self):
@@ -211,3 +221,28 @@ class Project:
"available.".format(module, self.project_dir)
) from e
return result
+
+ def get_toolchain(self, module_paths, override=None):
+ if override:
+ if override not in self.config.supported_toolchains:
+ logging.warning(
+ "Toolchain %r isn't supported by this project. You're on your own.",
+ override,
+ )
+ support_class = toolchains.support_classes.get(
+ override, toolchains.GenericToolchain
+ )
+ return support_class(name=override, modules=module_paths)
+ else:
+ for name in self.config.supported_toolchains:
+ support_class = toolchains.support_classes[name]
+ toolchain = support_class(name=name, modules=module_paths)
+ if toolchain.probe():
+ logging.info("Toolchain %r selected by probe function.", toolchain)
+ return toolchain
+ raise OSError(
+ "No supported toolchains could be found on your system. If you see "
+ "this message in the chroot, it indicates a bug. Otherwise, you'll "
+ "either want to setup your system with a supported toolchain, or "
+ "manually select an unsupported toolchain with the -t flag."
+ )