Minos Galanakis | f4ca6ac | 2017-12-11 02:39:21 +0100 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | |
| 3 | """ tfm_build_manager.py: |
| 4 | |
| 5 | Controlling class managing multiple build configruations for tfm """ |
| 6 | |
| 7 | from __future__ import print_function |
| 8 | |
| 9 | __copyright__ = """ |
| 10 | /* |
Xinyu Zhang | 7c038b0 | 2021-04-20 10:27:49 +0800 | [diff] [blame] | 11 | * Copyright (c) 2018-2021, Arm Limited. All rights reserved. |
Minos Galanakis | f4ca6ac | 2017-12-11 02:39:21 +0100 | [diff] [blame] | 12 | * |
| 13 | * SPDX-License-Identifier: BSD-3-Clause |
| 14 | * |
| 15 | */ |
| 16 | """ |
Karl Zhang | 08681e6 | 2020-10-30 13:56:03 +0800 | [diff] [blame] | 17 | |
| 18 | __author__ = "tf-m@lists.trustedfirmware.org" |
Minos Galanakis | f4ca6ac | 2017-12-11 02:39:21 +0100 | [diff] [blame] | 19 | __project__ = "Trusted Firmware-M Open CI" |
Xinyu Zhang | 06286a9 | 2021-07-22 14:00:51 +0800 | [diff] [blame] | 20 | __version__ = "1.4.0" |
Minos Galanakis | f4ca6ac | 2017-12-11 02:39:21 +0100 | [diff] [blame] | 21 | |
| 22 | import os |
| 23 | import sys |
Karl Zhang | aff558a | 2020-05-15 14:28:23 +0100 | [diff] [blame] | 24 | from .utils import * |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame] | 25 | from time import time |
Minos Galanakis | f4ca6ac | 2017-12-11 02:39:21 +0100 | [diff] [blame] | 26 | from copy import deepcopy |
| 27 | from .utils import gen_cfg_combinations, list_chunks, load_json,\ |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame] | 28 | save_json, print_test, show_progress, \ |
| 29 | resolve_rel_path |
Minos Galanakis | f4ca6ac | 2017-12-11 02:39:21 +0100 | [diff] [blame] | 30 | from .structured_task import structuredTask |
| 31 | from .tfm_builder import TFM_Builder |
| 32 | |
| 33 | |
Xinyu Zhang | 38b7674 | 2021-11-11 13:57:56 +0800 | [diff] [blame] | 34 | mapPlatform = {"cypress/psoc64": "psoc64", |
| 35 | "arm/mps2/an519": "AN519", |
| 36 | "arm/mps2/an521": "AN521", |
| 37 | "arm/mps2/an539": "AN539", |
| 38 | "arm/mps2/sse-200_aws": "SSE-200_AWS", |
| 39 | "arm/mps3/an524": "AN524", |
| 40 | "arm/musca_b1/sse_200": "MUSCA_B1", |
| 41 | "arm/musca_b1/secure_enclave": "MUSCA_B1_SE", |
| 42 | "arm/musca_s1": "MUSCA_S1", |
| 43 | "stm/stm32l562e_dk": "stm32l562e_dk", |
| 44 | "arm/corstone1000": "corstone1000", |
| 45 | "nxp/lpcxpresso55s69": "lpcxpresso55s69", |
| 46 | "arm/mps3/an547": "AN547", |
| 47 | "arm/mps3/corstone_polaris": "Polaris", |
| 48 | "lairdconnectivity/bl5340_dvk_cpuapp": "BL5340", |
| 49 | "nordic_nrf/nrf5340dk_nrf5340_cpuapp": "nrf5340dk", |
| 50 | "nordic_nrf/nrf9160dk_nrf9160": "nrf9160dk", |
| 51 | "nuvoton/m2351": "M2351", |
| 52 | "nuvoton/m2354": "M2354", |
| 53 | "stm/b_u585i_iot02a": "b_u585i_iot02a", |
| 54 | "stm/nucleo_l552ze_q": "nucleo_l552ze_q"} |
Xinyu Zhang | 1078e81 | 2020-10-15 11:52:36 +0800 | [diff] [blame] | 55 | |
| 56 | mapCompiler = {"toolchain_GNUARM.cmake": "GNUARM", |
| 57 | "toolchain_ARMCLANG.cmake": "ARMCLANG"} |
| 58 | |
Xinyu Zhang | c371af6 | 2020-10-21 10:41:57 +0800 | [diff] [blame] | 59 | mapTestPsaApi = {"IPC": "FF", |
Xinyu Zhang | 1078e81 | 2020-10-15 11:52:36 +0800 | [diff] [blame] | 60 | "CRYPTO": "CRYPTO", |
Xinyu Zhang | 1078e81 | 2020-10-15 11:52:36 +0800 | [diff] [blame] | 61 | "INITIAL_ATTESTATION": "ATTEST", |
Xinyu Zhang | 39acb41 | 2021-07-09 20:35:19 +0800 | [diff] [blame] | 62 | "STORAGE": "STORAGE"} |
Xinyu Zhang | 1078e81 | 2020-10-15 11:52:36 +0800 | [diff] [blame] | 63 | |
Xinyu Zhang | 9fd7424 | 2020-10-22 11:30:50 +0800 | [diff] [blame] | 64 | mapProfile = {"profile_small": "SMALL", |
Xinyu Zhang | 9b1aef9 | 2021-03-12 15:36:44 +0800 | [diff] [blame] | 65 | "profile_medium": "MEDIUM", |
| 66 | "profile_large": "LARGE"} |
Xinyu Zhang | 1078e81 | 2020-10-15 11:52:36 +0800 | [diff] [blame] | 67 | |
Feder Liang | 567e8c2 | 2021-10-26 14:16:21 +0800 | [diff] [blame] | 68 | mapSFPOption = {"0": "SFP0", |
| 69 | "1": "SFP1", |
| 70 | "2": "SFP2"} |
Xinyu Zhang | 1078e81 | 2020-10-15 11:52:36 +0800 | [diff] [blame] | 71 | |
Xinyu Zhang | fd2e115 | 2021-12-17 18:09:01 +0800 | [diff] [blame] | 72 | mapExtraParams = {"": "", |
| 73 | "CRYPTO_OFF": ("-DTEST_S_CRYPTO=OFF " |
| 74 | "-DTEST_NS_CRYPTO=OFF "), |
| 75 | "NS_ATTEST_ON": ("-DTEST_S_CRYPTO=OFF " |
| 76 | "-DTEST_NS_CRYPTO=OFF " |
| 77 | "-DTEST_S_ITS=OFF " |
| 78 | "-DTEST_NS_ITS=OFF " |
| 79 | "-DTEST_S_PLATFORM=OFF " |
| 80 | "-DTEST_NS_PLATFORM=OFF " |
| 81 | "-DTEST_NS_ATTESTATION=ON " |
| 82 | "-DTEST_S_ATTESTATION=OFF " |
| 83 | "-DTEST_NS_QCBOR=OFF " |
| 84 | "-DTEST_S_QCBOR=OFF " |
| 85 | "-DTEST_NS_T_COSE=OFF " |
| 86 | "-DTEST_S_T_COSE=OFF " |
| 87 | "-DTEST_NS_PS=OFF " |
Xinyu Zhang | 6761299 | 2021-12-20 14:11:27 +0800 | [diff] [blame] | 88 | "-DTEST_S_PS=OFF "), |
Xinyu Zhang | 3bb01af | 2021-12-20 14:45:49 +0800 | [diff] [blame^] | 89 | "NSCE": "-DTFM_NS_MANAGE_NSID=ON ", |
| 90 | "MMIO": "-DPSA_FRAMEWORK_HAS_MM_IOVEC=ON "} |
Xinyu Zhang | fd2e115 | 2021-12-17 18:09:01 +0800 | [diff] [blame] | 91 | |
Minos Galanakis | f4ca6ac | 2017-12-11 02:39:21 +0100 | [diff] [blame] | 92 | class TFM_Build_Manager(structuredTask): |
| 93 | """ Class that will load a configuration out of a json file, schedule |
| 94 | the builds, and produce a report """ |
| 95 | |
| 96 | def __init__(self, |
| 97 | tfm_dir, # TFM root directory |
| 98 | work_dir, # Current working directory(ie logs) |
| 99 | cfg_dict, # Input config dictionary of the following form |
| 100 | # input_dict = {"PROJ_CONFIG": "ConfigRegression", |
| 101 | # "TARGET_PLATFORM": "MUSCA_A", |
| 102 | # "COMPILER": "ARMCLANG", |
| 103 | # "CMAKE_BUILD_TYPE": "Debug"} |
| 104 | report=None, # File to produce report |
| 105 | parallel_builds=3, # Number of builds to run in parallel |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame] | 106 | build_threads=3, # Number of threads used per build |
| 107 | install=False, # Install libraries after build |
| 108 | img_sizes=False, # Use arm-none-eabi-size for size info |
| 109 | relative_paths=False): # Store relative paths in report |
Minos Galanakis | f4ca6ac | 2017-12-11 02:39:21 +0100 | [diff] [blame] | 110 | self._tbm_build_threads = build_threads |
| 111 | self._tbm_conc_builds = parallel_builds |
| 112 | self._tbm_install = install |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame] | 113 | self._tbm_img_sizes = img_sizes |
| 114 | self._tbm_relative_paths = relative_paths |
Minos Galanakis | f4ca6ac | 2017-12-11 02:39:21 +0100 | [diff] [blame] | 115 | |
| 116 | # Required by other methods, always set working directory first |
| 117 | self._tbm_work_dir = os.path.abspath(os.path.expanduser(work_dir)) |
| 118 | |
| 119 | self._tbm_tfm_dir = os.path.abspath(os.path.expanduser(tfm_dir)) |
| 120 | |
Karl Zhang | aff558a | 2020-05-15 14:28:23 +0100 | [diff] [blame] | 121 | print("bm param tfm_dir %s" % tfm_dir) |
| 122 | print("bm %s %s %s" % (work_dir, cfg_dict, self._tbm_work_dir)) |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame] | 123 | # Internal flag to tag simple (non combination formatted configs) |
| 124 | self.simple_config = False |
Minos Galanakis | f4ca6ac | 2017-12-11 02:39:21 +0100 | [diff] [blame] | 125 | self._tbm_report = report |
| 126 | |
Minos Galanakis | f4ca6ac | 2017-12-11 02:39:21 +0100 | [diff] [blame] | 127 | self._tbm_cfg = self.load_config(cfg_dict, self._tbm_work_dir) |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame] | 128 | self._tbm_build_cfg, \ |
| 129 | self.tbm_common_cfg = self.parse_config(self._tbm_cfg) |
Karl Zhang | aff558a | 2020-05-15 14:28:23 +0100 | [diff] [blame] | 130 | self._tfb_code_base_updated = False |
| 131 | self._tfb_log_f = "CodeBasePrepare.log" |
Minos Galanakis | f4ca6ac | 2017-12-11 02:39:21 +0100 | [diff] [blame] | 132 | |
| 133 | super(TFM_Build_Manager, self).__init__(name="TFM_Build_Manager") |
| 134 | |
Dean Birch | a6ede7e | 2020-03-13 14:00:33 +0000 | [diff] [blame] | 135 | def get_config(self): |
| 136 | return list(self._tbm_build_cfg.keys()) |
Dean Birch | 5cb5a88 | 2020-01-24 11:37:13 +0000 | [diff] [blame] | 137 | |
Dean Birch | a6ede7e | 2020-03-13 14:00:33 +0000 | [diff] [blame] | 138 | def print_config_environment(self, config, silence_stderr=False): |
Dean Birch | 5cb5a88 | 2020-01-24 11:37:13 +0000 | [diff] [blame] | 139 | """ |
| 140 | For a given build configuration from output of print_config |
| 141 | method, print environment variables to build. |
| 142 | """ |
| 143 | if config not in self._tbm_build_cfg: |
Dean Birch | a6ede7e | 2020-03-13 14:00:33 +0000 | [diff] [blame] | 144 | if not silence_stderr: |
| 145 | print("Error: no such config {}".format(config), file=sys.stderr) |
Dean Birch | 5cb5a88 | 2020-01-24 11:37:13 +0000 | [diff] [blame] | 146 | sys.exit(1) |
| 147 | config_details = self._tbm_build_cfg[config] |
| 148 | argument_list = [ |
Dean Birch | d0f9f8c | 2020-03-26 11:10:33 +0000 | [diff] [blame] | 149 | "CONFIG_NAME={}", |
Xinyu Zhang | b708f57 | 2020-09-15 11:43:46 +0800 | [diff] [blame] | 150 | "TFM_PLATFORM={}", |
| 151 | "TOOLCHAIN_FILE={}", |
Xinyu Zhang | 73ed299 | 2021-09-15 11:38:23 +0800 | [diff] [blame] | 152 | "LIB_MODEL={}", |
Xinyu Zhang | b708f57 | 2020-09-15 11:43:46 +0800 | [diff] [blame] | 153 | "ISOLATION_LEVEL={}", |
| 154 | "TEST_REGRESSION={}", |
| 155 | "TEST_PSA_API={}", |
Dean Birch | 5cb5a88 | 2020-01-24 11:37:13 +0000 | [diff] [blame] | 156 | "CMAKE_BUILD_TYPE={}", |
Xinyu Zhang | b708f57 | 2020-09-15 11:43:46 +0800 | [diff] [blame] | 157 | "OTP={}", |
Dean Birch | 5cb5a88 | 2020-01-24 11:37:13 +0000 | [diff] [blame] | 158 | "BL2={}", |
Xinyu Zhang | b708f57 | 2020-09-15 11:43:46 +0800 | [diff] [blame] | 159 | "NS={}", |
Xinyu Zhang | 9fd7424 | 2020-10-22 11:30:50 +0800 | [diff] [blame] | 160 | "PROFILE={}", |
Xinyu Zhang | 9bfe8a9 | 2021-10-28 16:27:12 +0800 | [diff] [blame] | 161 | "PARTITION_PS={}", |
Feder Liang | 567e8c2 | 2021-10-26 14:16:21 +0800 | [diff] [blame] | 162 | "FP={}", |
Xinyu Zhang | fd2e115 | 2021-12-17 18:09:01 +0800 | [diff] [blame] | 163 | "LAZY={}", |
| 164 | "EXTRA_PARAMS={}" |
Dean Birch | 5cb5a88 | 2020-01-24 11:37:13 +0000 | [diff] [blame] | 165 | ] |
| 166 | print( |
| 167 | "\n".join(argument_list) |
| 168 | .format( |
Dean Birch | d0f9f8c | 2020-03-26 11:10:33 +0000 | [diff] [blame] | 169 | config, |
Xinyu Zhang | b708f57 | 2020-09-15 11:43:46 +0800 | [diff] [blame] | 170 | config_details.tfm_platform, |
| 171 | config_details.toolchain_file, |
Xinyu Zhang | 73ed299 | 2021-09-15 11:38:23 +0800 | [diff] [blame] | 172 | config_details.lib_model, |
Xinyu Zhang | b708f57 | 2020-09-15 11:43:46 +0800 | [diff] [blame] | 173 | config_details.isolation_level, |
| 174 | config_details.test_regression, |
| 175 | config_details.test_psa_api, |
Dean Birch | 5cb5a88 | 2020-01-24 11:37:13 +0000 | [diff] [blame] | 176 | config_details.cmake_build_type, |
Xinyu Zhang | b708f57 | 2020-09-15 11:43:46 +0800 | [diff] [blame] | 177 | config_details.with_otp, |
| 178 | config_details.with_bl2, |
| 179 | config_details.with_ns, |
Xinyu Zhang | 9fd7424 | 2020-10-22 11:30:50 +0800 | [diff] [blame] | 180 | "N.A" if not config_details.profile else config_details.profile, |
Xinyu Zhang | 9bfe8a9 | 2021-10-28 16:27:12 +0800 | [diff] [blame] | 181 | config_details.partition_ps, |
Feder Liang | 567e8c2 | 2021-10-26 14:16:21 +0800 | [diff] [blame] | 182 | config_details.fp, |
Xinyu Zhang | fd2e115 | 2021-12-17 18:09:01 +0800 | [diff] [blame] | 183 | config_details.lazy, |
| 184 | "N.A" if not config_details.extra_params else config_details.extra_params, |
Dean Birch | 5cb5a88 | 2020-01-24 11:37:13 +0000 | [diff] [blame] | 185 | ) |
| 186 | .strip() |
| 187 | ) |
| 188 | |
Dean Birch | d0f9f8c | 2020-03-26 11:10:33 +0000 | [diff] [blame] | 189 | def print_build_commands(self, config, silence_stderr=False): |
| 190 | config_details = self._tbm_build_cfg[config] |
| 191 | codebase_dir = os.path.join(os.getcwd(),"trusted-firmware-m") |
Xinyu Zhang | b708f57 | 2020-09-15 11:43:46 +0800 | [diff] [blame] | 192 | build_dir=os.path.join(os.getcwd(),"trusted-firmware-m/build") |
Dean Birch | d0f9f8c | 2020-03-26 11:10:33 +0000 | [diff] [blame] | 193 | build_config = self.get_build_config(config_details, config, silence=silence_stderr, build_dir=build_dir, codebase_dir=codebase_dir) |
Xinyu Zhang | 694eb49 | 2020-11-04 18:29:08 +0800 | [diff] [blame] | 194 | build_commands = [build_config["config_template"]] |
| 195 | for command in build_config["build_cmds"]: |
| 196 | build_commands.append(command) |
Xinyu Zhang | b708f57 | 2020-09-15 11:43:46 +0800 | [diff] [blame] | 197 | print(" ;\n".join(build_commands)) |
Dean Birch | d0f9f8c | 2020-03-26 11:10:33 +0000 | [diff] [blame] | 198 | |
Minos Galanakis | f4ca6ac | 2017-12-11 02:39:21 +0100 | [diff] [blame] | 199 | def pre_eval(self): |
| 200 | """ Tests that need to be run in set-up state """ |
| 201 | return True |
| 202 | |
| 203 | def pre_exec(self, eval_ret): |
| 204 | """ """ |
| 205 | |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame] | 206 | def override_tbm_cfg_params(self, config, override_keys, **params): |
| 207 | """ Using a dictionay as input, for each key defined in |
| 208 | override_keys it will replace the config[key] entries with |
| 209 | the key=value parameters provided """ |
| 210 | |
| 211 | for key in override_keys: |
| 212 | if isinstance(config[key], list): |
| 213 | config[key] = [n % params for n in config[key]] |
| 214 | elif isinstance(config[key], str): |
| 215 | config[key] = config[key] % params |
| 216 | else: |
| 217 | raise Exception("Config does not contain key %s " |
| 218 | "of type %s" % (key, config[key])) |
| 219 | return config |
| 220 | |
Karl Zhang | aff558a | 2020-05-15 14:28:23 +0100 | [diff] [blame] | 221 | def pre_build(self, build_cfg): |
| 222 | print("pre_build start %s \r\nself._tfb_cfg %s\r\n" % |
| 223 | (self, build_cfg)) |
| 224 | |
| 225 | try: |
| 226 | if self._tfb_code_base_updated: |
| 227 | print("Code base has been updated") |
| 228 | return True |
| 229 | |
| 230 | self._tfb_code_base_updated = True |
| 231 | |
| 232 | if "build_psa_api" in build_cfg: |
| 233 | # FF IPC build needs repo manifest update for TFM and PSA arch test |
| 234 | if "build_ff_ipc" in build_cfg: |
| 235 | print("Checkout to FF IPC code base") |
| 236 | os.chdir(build_cfg["codebase_root_dir"] + "/../psa-arch-tests/api-tests") |
| 237 | _api_test_manifest = "git checkout . ; python3 tools/scripts/manifest_update.py" |
| 238 | if subprocess_log(_api_test_manifest, |
| 239 | self._tfb_log_f, |
| 240 | append=True, |
| 241 | prefix=_api_test_manifest): |
| 242 | |
| 243 | raise Exception("Python Failed please check log: %s" % |
| 244 | self._tfb_log_f) |
| 245 | |
| 246 | _api_test_manifest_tfm = "python3 tools/tfm_parse_manifest_list.py -m tools/tfm_psa_ff_test_manifest_list.yaml append" |
| 247 | os.chdir(build_cfg["codebase_root_dir"]) |
| 248 | if subprocess_log(_api_test_manifest_tfm, |
| 249 | self._tfb_log_f, |
| 250 | append=True, |
| 251 | prefix=_api_test_manifest_tfm): |
| 252 | |
| 253 | raise Exception("Python TFM Failed please check log: %s" % |
| 254 | self._tfb_log_f) |
| 255 | return True |
| 256 | |
| 257 | print("Checkout to default code base") |
| 258 | os.chdir(build_cfg["codebase_root_dir"] + "/../psa-arch-tests/api-tests") |
| 259 | _api_test_manifest = "git checkout ." |
| 260 | if subprocess_log(_api_test_manifest, |
| 261 | self._tfb_log_f, |
| 262 | append=True, |
| 263 | prefix=_api_test_manifest): |
| 264 | |
| 265 | raise Exception("Python Failed please check log: %s" % |
| 266 | self._tfb_log_f) |
| 267 | |
| 268 | _api_test_manifest_tfm = "python3 tools/tfm_parse_manifest_list.py" |
| 269 | os.chdir(build_cfg["codebase_root_dir"]) |
| 270 | if subprocess_log(_api_test_manifest_tfm, |
| 271 | self._tfb_log_f, |
| 272 | append=True, |
| 273 | prefix=_api_test_manifest_tfm): |
| 274 | |
| 275 | raise Exception("Python TFM Failed please check log: %s" % |
| 276 | self._tfb_log_f) |
| 277 | finally: |
| 278 | print("python pass after builder prepare") |
| 279 | os.chdir(build_cfg["codebase_root_dir"] + "/../") |
| 280 | |
Minos Galanakis | f4ca6ac | 2017-12-11 02:39:21 +0100 | [diff] [blame] | 281 | def task_exec(self): |
| 282 | """ Create a build pool and execute them in parallel """ |
| 283 | |
| 284 | build_pool = [] |
Minos Galanakis | f4ca6ac | 2017-12-11 02:39:21 +0100 | [diff] [blame] | 285 | |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame] | 286 | # When a config is flagged as a single build config. |
| 287 | # Name is evaluated by config type |
| 288 | if self.simple_config: |
| 289 | |
| 290 | build_cfg = deepcopy(self.tbm_common_cfg) |
| 291 | |
| 292 | # Extract the common for all elements of config |
| 293 | for key in ["build_cmds", "required_artefacts"]: |
| 294 | try: |
| 295 | build_cfg[key] = build_cfg[key]["all"] |
| 296 | except KeyError: |
| 297 | build_cfg[key] = [] |
| 298 | name = build_cfg["config_type"] |
| 299 | |
| 300 | # Override _tbm_xxx paths in commands |
| 301 | # plafrom in not guaranteed without seeds so _tbm_target_platform |
| 302 | # is ignored |
| 303 | over_dict = {"_tbm_build_dir_": os.path.join(self._tbm_work_dir, |
| 304 | name), |
| 305 | "_tbm_code_dir_": build_cfg["codebase_root_dir"]} |
| 306 | |
| 307 | build_cfg = self.override_tbm_cfg_params(build_cfg, |
| 308 | ["build_cmds", |
| 309 | "required_artefacts", |
| 310 | "artifact_capture_rex"], |
| 311 | **over_dict) |
| 312 | |
| 313 | # Overrides path in expected artefacts |
Minos Galanakis | f4ca6ac | 2017-12-11 02:39:21 +0100 | [diff] [blame] | 314 | print("Loading config %s" % name) |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame] | 315 | |
| 316 | build_pool.append(TFM_Builder( |
| 317 | name=name, |
| 318 | work_dir=self._tbm_work_dir, |
| 319 | cfg_dict=build_cfg, |
| 320 | build_threads=self._tbm_build_threads, |
| 321 | img_sizes=self._tbm_img_sizes, |
| 322 | relative_paths=self._tbm_relative_paths)) |
| 323 | # When a seed pool is provided iterate through the entries |
| 324 | # and update platform spefific parameters |
| 325 | elif len(self._tbm_build_cfg): |
Karl Zhang | aff558a | 2020-05-15 14:28:23 +0100 | [diff] [blame] | 326 | print("\r\n_tbm_build_cfg %s\r\n tbm_common_cfg %s\r\n" \ |
| 327 | % (self._tbm_build_cfg, self.tbm_common_cfg)) |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame] | 328 | for name, i in self._tbm_build_cfg.items(): |
| 329 | # Do not modify the original config |
Dean Birch | d0f9f8c | 2020-03-26 11:10:33 +0000 | [diff] [blame] | 330 | build_cfg = self.get_build_config(i, name) |
Karl Zhang | aff558a | 2020-05-15 14:28:23 +0100 | [diff] [blame] | 331 | self.pre_build(build_cfg) |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame] | 332 | # Overrides path in expected artefacts |
| 333 | print("Loading config %s" % name) |
| 334 | |
| 335 | build_pool.append(TFM_Builder( |
| 336 | name=name, |
| 337 | work_dir=self._tbm_work_dir, |
| 338 | cfg_dict=build_cfg, |
| 339 | build_threads=self._tbm_build_threads, |
| 340 | img_sizes=self._tbm_img_sizes, |
| 341 | relative_paths=self._tbm_relative_paths)) |
| 342 | else: |
| 343 | print("Could not find any configuration. Check the rejection list") |
Minos Galanakis | f4ca6ac | 2017-12-11 02:39:21 +0100 | [diff] [blame] | 344 | |
| 345 | status_rep = {} |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame] | 346 | build_rep = {} |
| 347 | completed_build_count = 0 |
Minos Galanakis | f4ca6ac | 2017-12-11 02:39:21 +0100 | [diff] [blame] | 348 | print("Build: Running %d parallel build jobs" % self._tbm_conc_builds) |
| 349 | for build_pool_slice in list_chunks(build_pool, self._tbm_conc_builds): |
| 350 | |
| 351 | # Start the builds |
| 352 | for build in build_pool_slice: |
| 353 | # Only produce output for the first build |
| 354 | if build_pool_slice.index(build) != 0: |
| 355 | build.mute() |
| 356 | print("Build: Starting %s" % build.get_name()) |
| 357 | build.start() |
| 358 | |
| 359 | # Wait for the builds to complete |
| 360 | for build in build_pool_slice: |
| 361 | # Wait for build to finish |
| 362 | build.join() |
| 363 | # Similarly print the logs of the other builds as they complete |
| 364 | if build_pool_slice.index(build) != 0: |
| 365 | build.log() |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame] | 366 | completed_build_count += 1 |
Minos Galanakis | f4ca6ac | 2017-12-11 02:39:21 +0100 | [diff] [blame] | 367 | print("Build: Finished %s" % build.get_name()) |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame] | 368 | print("Build Progress:") |
| 369 | show_progress(completed_build_count, len(build_pool)) |
Minos Galanakis | f4ca6ac | 2017-12-11 02:39:21 +0100 | [diff] [blame] | 370 | |
| 371 | # Store status in report |
| 372 | status_rep[build.get_name()] = build.get_status() |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame] | 373 | build_rep[build.get_name()] = build.report() |
| 374 | |
| 375 | # Include the original input configuration in the report |
| 376 | |
| 377 | metadata = {"input_build_cfg": self._tbm_cfg, |
| 378 | "build_dir": self._tbm_work_dir |
| 379 | if not self._tbm_relative_paths |
| 380 | else resolve_rel_path(self._tbm_work_dir), |
| 381 | "time": time()} |
| 382 | |
| 383 | full_rep = {"report": build_rep, |
| 384 | "_metadata_": metadata} |
| 385 | |
Minos Galanakis | f4ca6ac | 2017-12-11 02:39:21 +0100 | [diff] [blame] | 386 | # Store the report |
| 387 | self.stash("Build Status", status_rep) |
| 388 | self.stash("Build Report", full_rep) |
| 389 | |
| 390 | if self._tbm_report: |
| 391 | print("Exported build report to file:", self._tbm_report) |
| 392 | save_json(self._tbm_report, full_rep) |
| 393 | |
Dean Birch | d0f9f8c | 2020-03-26 11:10:33 +0000 | [diff] [blame] | 394 | def get_build_config(self, i, name, silence=False, build_dir=None, codebase_dir=None): |
| 395 | psa_build_dir = self._tbm_work_dir + "/" + name + "/BUILD" |
| 396 | if not build_dir: |
| 397 | build_dir = os.path.join(self._tbm_work_dir, name) |
| 398 | else: |
| 399 | psa_build_dir = os.path.join(build_dir, "../../psa-arch-tests/api-tests/build") |
| 400 | build_cfg = deepcopy(self.tbm_common_cfg) |
| 401 | if not codebase_dir: |
| 402 | codebase_dir = build_cfg["codebase_root_dir"] |
| 403 | else: |
| 404 | # Would prefer to do all with the new variable |
| 405 | # However, many things use this from build_cfg elsewhere |
| 406 | build_cfg["codebase_root_dir"] = codebase_dir |
| 407 | # Extract the common for all elements of config |
| 408 | for key in ["build_cmds", "required_artefacts"]: |
| 409 | try: |
| 410 | build_cfg[key] = deepcopy(self.tbm_common_cfg[key] |
| 411 | ["all"]) |
| 412 | except KeyError as E: |
| 413 | build_cfg[key] = [] |
| 414 | # Extract the platform specific elements of config |
| 415 | for key in ["build_cmds", "required_artefacts"]: |
| 416 | try: |
Xinyu Zhang | 694eb49 | 2020-11-04 18:29:08 +0800 | [diff] [blame] | 417 | if i.tfm_platform in self.tbm_common_cfg[key].keys() and i.with_ns: |
Dean Birch | d0f9f8c | 2020-03-26 11:10:33 +0000 | [diff] [blame] | 418 | build_cfg[key] += deepcopy(self.tbm_common_cfg[key] |
Xinyu Zhang | b708f57 | 2020-09-15 11:43:46 +0800 | [diff] [blame] | 419 | [i.tfm_platform]) |
Dean Birch | d0f9f8c | 2020-03-26 11:10:33 +0000 | [diff] [blame] | 420 | except Exception as E: |
| 421 | pass |
Karl Zhang | 1eed632 | 2020-07-01 15:38:10 +0800 | [diff] [blame] | 422 | |
| 423 | if os.cpu_count() >= 8: |
| 424 | #run in a serviver with scripts, parallel build will use CPU numbers |
| 425 | thread_no = " -j 2" |
| 426 | else: |
| 427 | #run in a docker, usually docker with CPUs less than 8 |
| 428 | thread_no = " -j " + str(os.cpu_count()) |
Xinyu Zhang | b708f57 | 2020-09-15 11:43:46 +0800 | [diff] [blame] | 429 | build_cfg["build_cmds"][0] += thread_no |
| 430 | overwrite_params = {"codebase_root_dir": build_cfg["codebase_root_dir"], |
| 431 | "tfm_platform": i.tfm_platform, |
| 432 | "toolchain_file": i.toolchain_file, |
Xinyu Zhang | 73ed299 | 2021-09-15 11:38:23 +0800 | [diff] [blame] | 433 | "lib_model": i.lib_model, |
Xinyu Zhang | b708f57 | 2020-09-15 11:43:46 +0800 | [diff] [blame] | 434 | "isolation_level": i.isolation_level, |
| 435 | "test_regression": i.test_regression, |
| 436 | "test_psa_api": i.test_psa_api, |
| 437 | "cmake_build_type": i.cmake_build_type, |
| 438 | "with_otp": i.with_otp, |
| 439 | "with_bl2": i.with_bl2, |
| 440 | "with_ns": i.with_ns, |
Xinyu Zhang | 9fd7424 | 2020-10-22 11:30:50 +0800 | [diff] [blame] | 441 | "profile": "" if i.profile=="N.A" else i.profile, |
Xinyu Zhang | 9bfe8a9 | 2021-10-28 16:27:12 +0800 | [diff] [blame] | 442 | "partition_ps": i.partition_ps, |
Feder Liang | 567e8c2 | 2021-10-26 14:16:21 +0800 | [diff] [blame] | 443 | "fp": i.fp, |
Xinyu Zhang | fd2e115 | 2021-12-17 18:09:01 +0800 | [diff] [blame] | 444 | "lazy": i.lazy, |
| 445 | "extra_params": mapExtraParams[i.extra_params]} |
Xinyu Zhang | a008602 | 2020-11-10 18:11:12 +0800 | [diff] [blame] | 446 | if i.test_psa_api == "IPC": |
Xinyu Zhang | cd1ed96 | 2020-11-11 16:00:52 +0800 | [diff] [blame] | 447 | overwrite_params["test_psa_api"] += " -DINCLUDE_PANIC_TESTS=1" |
Xinyu Zhang | 8cee331 | 2021-11-12 11:06:39 +0800 | [diff] [blame] | 448 | if i.tfm_platform == "arm/musca_b1/sse_200": |
| 449 | overwrite_params["test_psa_api"] += " -DITS_RAM_FS=ON -DPS_RAM_FS=ON" |
Feder Liang | 567e8c2 | 2021-10-26 14:16:21 +0800 | [diff] [blame] | 450 | if i.fp == "1" or i.fp == "2": |
| 451 | overwrite_params["test_psa_api"] += " -DTEST_S_FPU=ON -DTEST_NS_FPU=ON" |
Xinyu Zhang | b708f57 | 2020-09-15 11:43:46 +0800 | [diff] [blame] | 452 | build_cfg["config_template"] %= overwrite_params |
Xinyu Zhang | 694eb49 | 2020-11-04 18:29:08 +0800 | [diff] [blame] | 453 | if len(build_cfg["build_cmds"]) > 1: |
| 454 | overwrite_build_dir = {"_tbm_build_dir_": build_dir} |
| 455 | build_cfg["build_cmds"][1] %= overwrite_build_dir |
Dean Birch | d0f9f8c | 2020-03-26 11:10:33 +0000 | [diff] [blame] | 456 | return build_cfg |
| 457 | |
Minos Galanakis | f4ca6ac | 2017-12-11 02:39:21 +0100 | [diff] [blame] | 458 | def post_eval(self): |
| 459 | """ If a single build failed fail the test """ |
| 460 | try: |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame] | 461 | status_dict = self.unstash("Build Status") |
| 462 | if not status_dict: |
| 463 | raise Exception() |
| 464 | retcode_sum = sum(status_dict.values()) |
Minos Galanakis | f4ca6ac | 2017-12-11 02:39:21 +0100 | [diff] [blame] | 465 | if retcode_sum != 0: |
| 466 | raise Exception() |
| 467 | return True |
| 468 | except Exception as e: |
| 469 | return False |
| 470 | |
| 471 | def post_exec(self, eval_ret): |
| 472 | """ Generate a report and fail the script if build == unsuccessfull""" |
| 473 | |
| 474 | self.print_summary() |
| 475 | if not eval_ret: |
| 476 | print("ERROR: ====> Build Failed! %s" % self.get_name()) |
| 477 | self.set_status(1) |
| 478 | else: |
| 479 | print("SUCCESS: ====> Build Complete!") |
| 480 | self.set_status(0) |
| 481 | |
| 482 | def get_report(self): |
| 483 | """ Expose the internal report to a new object for external classes """ |
| 484 | return deepcopy(self.unstash("Build Report")) |
| 485 | |
Minos Galanakis | f4ca6ac | 2017-12-11 02:39:21 +0100 | [diff] [blame] | 486 | def load_config(self, config, work_dir): |
| 487 | try: |
| 488 | # passing config_name param supersseeds fileparam |
| 489 | if isinstance(config, dict): |
| 490 | ret_cfg = deepcopy(config) |
| 491 | elif isinstance(config, str): |
| 492 | # If the string does not descrive a file try to look for it in |
| 493 | # work directory |
| 494 | if not os.path.isfile(config): |
| 495 | # remove path from file |
| 496 | config_2 = os.path.split(config)[-1] |
| 497 | # look in the current working directory |
| 498 | config_2 = os.path.join(work_dir, config_2) |
| 499 | if not os.path.isfile(config_2): |
| 500 | m = "Could not find cfg in %s or %s " % (config, |
| 501 | config_2) |
| 502 | raise Exception(m) |
| 503 | # If fille exists in working directory |
| 504 | else: |
| 505 | config = config_2 |
| 506 | ret_cfg = load_json(config) |
| 507 | |
| 508 | else: |
| 509 | raise Exception("Need to provide a valid config name or file." |
| 510 | "Please use --config/--config-file parameter.") |
| 511 | except Exception as e: |
| 512 | print("Error:%s \nCould not load a valid config" % e) |
| 513 | sys.exit(1) |
| 514 | |
Minos Galanakis | f4ca6ac | 2017-12-11 02:39:21 +0100 | [diff] [blame] | 515 | return ret_cfg |
| 516 | |
| 517 | def parse_config(self, cfg): |
| 518 | """ Parse a valid configuration file into a set of build dicts """ |
| 519 | |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame] | 520 | ret_cfg = {} |
Minos Galanakis | f4ca6ac | 2017-12-11 02:39:21 +0100 | [diff] [blame] | 521 | |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame] | 522 | # Config entries which are not subject to changes during combinations |
| 523 | static_cfg = cfg["common_params"] |
Minos Galanakis | f4ca6ac | 2017-12-11 02:39:21 +0100 | [diff] [blame] | 524 | |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame] | 525 | # Converth the code path to absolute path |
| 526 | abs_code_dir = static_cfg["codebase_root_dir"] |
| 527 | abs_code_dir = os.path.abspath(os.path.expanduser(abs_code_dir)) |
| 528 | static_cfg["codebase_root_dir"] = abs_code_dir |
Minos Galanakis | f4ca6ac | 2017-12-11 02:39:21 +0100 | [diff] [blame] | 529 | |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame] | 530 | # seed_params is an optional field. Do not proccess if it is missing |
| 531 | if "seed_params" in cfg: |
| 532 | comb_cfg = cfg["seed_params"] |
| 533 | # Generate a list of all possible confugration combinations |
| 534 | ret_cfg = TFM_Build_Manager.generate_config_list(comb_cfg, |
| 535 | static_cfg) |
Minos Galanakis | f4ca6ac | 2017-12-11 02:39:21 +0100 | [diff] [blame] | 536 | |
Xinyu Zhang | 2c63ce7 | 2021-07-23 14:01:59 +0800 | [diff] [blame] | 537 | # valid is an optional field. Do not proccess if it is missing |
| 538 | if "valid" in cfg: |
| 539 | # Valid configurations(Need to build) |
| 540 | valid_cfg = cfg["valid"] |
| 541 | # Add valid configs to build list |
| 542 | ret_cfg.update(TFM_Build_Manager.generate_optional_list( |
| 543 | comb_cfg, |
| 544 | static_cfg, |
| 545 | valid_cfg)) |
| 546 | |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame] | 547 | # invalid is an optional field. Do not proccess if it is missing |
| 548 | if "invalid" in cfg: |
| 549 | # Invalid configurations(Do not build) |
| 550 | invalid_cfg = cfg["invalid"] |
| 551 | # Remove the rejected entries from the test list |
Xinyu Zhang | 0581b08 | 2021-05-17 10:46:57 +0800 | [diff] [blame] | 552 | rejection_cfg = TFM_Build_Manager.generate_optional_list( |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame] | 553 | comb_cfg, |
| 554 | static_cfg, |
| 555 | invalid_cfg) |
Minos Galanakis | f4ca6ac | 2017-12-11 02:39:21 +0100 | [diff] [blame] | 556 | |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame] | 557 | # Subtract the two configurations |
| 558 | ret_cfg = {k: v for k, v in ret_cfg.items() |
| 559 | if k not in rejection_cfg} |
| 560 | self.simple_config = False |
| 561 | else: |
| 562 | self.simple_config = True |
| 563 | return ret_cfg, static_cfg |
Minos Galanakis | f4ca6ac | 2017-12-11 02:39:21 +0100 | [diff] [blame] | 564 | |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame] | 565 | # ----- Override bellow methods when subclassing for other projects ----- # |
Minos Galanakis | f4ca6ac | 2017-12-11 02:39:21 +0100 | [diff] [blame] | 566 | |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame] | 567 | def print_summary(self): |
| 568 | """ Print an comprehensive list of the build jobs with their status """ |
Minos Galanakis | f4ca6ac | 2017-12-11 02:39:21 +0100 | [diff] [blame] | 569 | |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame] | 570 | try: |
| 571 | full_rep = self.unstash("Build Report")["report"] |
| 572 | fl = ([k for k, v in full_rep.items() if v['status'] == 'Failed']) |
| 573 | ps = ([k for k, v in full_rep.items() if v['status'] == 'Success']) |
| 574 | except Exception as E: |
Karl Zhang | aff558a | 2020-05-15 14:28:23 +0100 | [diff] [blame] | 575 | print("No report generated", E) |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame] | 576 | return |
| 577 | if fl: |
| 578 | print_test(t_list=fl, status="failed", tname="Builds") |
| 579 | if ps: |
| 580 | print_test(t_list=ps, status="passed", tname="Builds") |
Minos Galanakis | f4ca6ac | 2017-12-11 02:39:21 +0100 | [diff] [blame] | 581 | |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame] | 582 | @staticmethod |
| 583 | def generate_config_list(seed_config, static_config): |
| 584 | """ Generate all possible configuration combinations from a group of |
| 585 | lists of compiler options""" |
| 586 | config_list = [] |
| 587 | |
| 588 | if static_config["config_type"] == "tf-m": |
| 589 | cfg_name = "TFM_Build_CFG" |
| 590 | # Ensure the fieds are sorted in the desired order |
| 591 | # seed_config can be a subset of sort order for configurations with |
| 592 | # optional parameters. |
| 593 | tags = [n for n in static_config["sort_order"] |
| 594 | if n in seed_config.keys()] |
Karl Zhang | aff558a | 2020-05-15 14:28:23 +0100 | [diff] [blame] | 595 | print("!!!!!!!!!!!gen list %s\r\n" % tags) |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame] | 596 | |
| 597 | data = [] |
| 598 | for key in tags: |
| 599 | data.append(seed_config[key]) |
| 600 | config_list = gen_cfg_combinations(cfg_name, |
| 601 | " ".join(tags), |
| 602 | *data) |
| 603 | else: |
| 604 | print("Not information for project type: %s." |
| 605 | " Please check config" % static_config["config_type"]) |
| 606 | |
| 607 | ret_cfg = {} |
| 608 | # Notify the user for the rejected configuations |
| 609 | for i in config_list: |
Xinyu Zhang | 1078e81 | 2020-10-15 11:52:36 +0800 | [diff] [blame] | 610 | # Convert named tuples to string in a brief format |
| 611 | config_param = [] |
| 612 | config_param.append(mapPlatform[list(i)[0]]) |
| 613 | config_param.append(mapCompiler[list(i)[1]]) |
Xinyu Zhang | 73ed299 | 2021-09-15 11:38:23 +0800 | [diff] [blame] | 614 | if list(i)[2]: # LIB_MODEL |
| 615 | config_param.append("LIB") |
| 616 | else: |
| 617 | config_param.append("IPC") |
Xinyu Zhang | 1078e81 | 2020-10-15 11:52:36 +0800 | [diff] [blame] | 618 | config_param.append(list(i)[3]) # ISOLATION_LEVEL |
| 619 | if list(i)[4]: # TEST_REGRESSION |
| 620 | config_param.append("REG") |
| 621 | if list(i)[5] != "OFF": #TEST_PSA_API |
| 622 | config_param.append(mapTestPsaApi[list(i)[5]]) |
| 623 | config_param.append(list(i)[6]) # BUILD_TYPE |
Xinyu Zhang | a50432e | 2020-10-23 18:00:18 +0800 | [diff] [blame] | 624 | if list(i)[7] == "ENABLED": # OTP |
Xinyu Zhang | 1078e81 | 2020-10-15 11:52:36 +0800 | [diff] [blame] | 625 | config_param.append("OTP") |
| 626 | if list(i)[8]: # BL2 |
| 627 | config_param.append("BL2") |
| 628 | if list(i)[9]: # NS |
| 629 | config_param.append("NS") |
| 630 | if list(i)[10]: # PROFILE |
| 631 | config_param.append(mapProfile[list(i)[10]]) |
Xinyu Zhang | 9fd7424 | 2020-10-22 11:30:50 +0800 | [diff] [blame] | 632 | if list(i)[11] == "OFF": #PARTITION_PS |
| 633 | config_param.append("PSOFF") |
Xinyu Zhang | 3bb01af | 2021-12-20 14:45:49 +0800 | [diff] [blame^] | 634 | if list(i)[12] == "1" or list(i)[12] == "2": |
| 635 | config_param.append(mapSFPOption[list(i)[12]]) #FP |
| 636 | if list(i)[13] == "ON": # LAZY |
Feder Liang | 567e8c2 | 2021-10-26 14:16:21 +0800 | [diff] [blame] | 637 | config_param.append("SLAZY") |
Xinyu Zhang | 3bb01af | 2021-12-20 14:45:49 +0800 | [diff] [blame^] | 638 | if list(i)[14]: # EXTRA_PARAMS |
| 639 | config_param.append(list(i)[14]) |
Xinyu Zhang | 1078e81 | 2020-10-15 11:52:36 +0800 | [diff] [blame] | 640 | i_str = "_".join(config_param) |
Karl Zhang | aff558a | 2020-05-15 14:28:23 +0100 | [diff] [blame] | 641 | ret_cfg[i_str] = i |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame] | 642 | return ret_cfg |
| 643 | |
| 644 | @staticmethod |
Xinyu Zhang | 0581b08 | 2021-05-17 10:46:57 +0800 | [diff] [blame] | 645 | def generate_optional_list(seed_config, |
| 646 | static_config, |
| 647 | optional_list): |
| 648 | optional_cfg = {} |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame] | 649 | |
| 650 | if static_config["config_type"] == "tf-m": |
| 651 | |
Xinyu Zhang | 0581b08 | 2021-05-17 10:46:57 +0800 | [diff] [blame] | 652 | # If optional list is empty do nothing |
| 653 | if not optional_list: |
| 654 | return optional_cfg |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame] | 655 | |
| 656 | tags = [n for n in static_config["sort_order"] |
| 657 | if n in seed_config.keys()] |
| 658 | sorted_default_lst = [seed_config[k] for k in tags] |
| 659 | |
Xinyu Zhang | 0581b08 | 2021-05-17 10:46:57 +0800 | [diff] [blame] | 660 | # If tags are not alligned with optional list entries quit |
| 661 | if len(tags) != len(optional_list[0]): |
| 662 | print(len(tags), len(optional_list[0])) |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame] | 663 | print("Error, tags should be assigned to each " |
Xinyu Zhang | 0581b08 | 2021-05-17 10:46:57 +0800 | [diff] [blame] | 664 | "of the optional inputs") |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame] | 665 | return [] |
| 666 | |
| 667 | # Replace wildcard ( "*") entries with every |
| 668 | # inluded in cfg variant |
Xinyu Zhang | 0581b08 | 2021-05-17 10:46:57 +0800 | [diff] [blame] | 669 | for k in optional_list: |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame] | 670 | # Pad the omitted values with wildcard char * |
| 671 | res_list = list(k) + ["*"] * (5 - len(k)) |
Xinyu Zhang | 0581b08 | 2021-05-17 10:46:57 +0800 | [diff] [blame] | 672 | print("Working on optional input: %s" % (res_list)) |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame] | 673 | |
| 674 | for n in range(len(res_list)): |
| 675 | |
| 676 | res_list[n] = [res_list[n]] if res_list[n] != "*" \ |
| 677 | else sorted_default_lst[n] |
| 678 | |
| 679 | # Generate a configuration and a name for the completed array |
Xinyu Zhang | 0581b08 | 2021-05-17 10:46:57 +0800 | [diff] [blame] | 680 | op_cfg = TFM_Build_Manager.generate_config_list( |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame] | 681 | dict(zip(tags, res_list)), |
| 682 | static_config) |
| 683 | |
| 684 | # Append the configuration to the existing ones |
Xinyu Zhang | 0581b08 | 2021-05-17 10:46:57 +0800 | [diff] [blame] | 685 | optional_cfg = dict(optional_cfg, **op_cfg) |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame] | 686 | |
Xinyu Zhang | 0581b08 | 2021-05-17 10:46:57 +0800 | [diff] [blame] | 687 | # Notify the user for the optional configuations |
| 688 | for i in optional_cfg.keys(): |
| 689 | print("Generating optional config %s" % i) |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame] | 690 | else: |
| 691 | print("Not information for project type: %s." |
| 692 | " Please check config" % static_config["config_type"]) |
Xinyu Zhang | 0581b08 | 2021-05-17 10:46:57 +0800 | [diff] [blame] | 693 | return optional_cfg |