Minos Galanakis | f4ca6ac | 2017-12-11 02:39:21 +0100 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | |
| 3 | """ builtin_configs.py: |
| 4 | |
| 5 | Default configuration files used as reference """ |
| 6 | |
| 7 | from __future__ import print_function |
| 8 | |
| 9 | __copyright__ = """ |
| 10 | /* |
| 11 | * Copyright (c) 2018-2019, Arm Limited. All rights reserved. |
| 12 | * |
| 13 | * SPDX-License-Identifier: BSD-3-Clause |
| 14 | * |
| 15 | */ |
| 16 | """ |
| 17 | __author__ = "Minos Galanakis" |
| 18 | __email__ = "minos.galanakis@linaro.org" |
| 19 | __project__ = "Trusted Firmware-M Open CI" |
| 20 | __status__ = "stable" |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame^] | 21 | __version__ = "1.1" |
Minos Galanakis | f4ca6ac | 2017-12-11 02:39:21 +0100 | [diff] [blame] | 22 | |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame^] | 23 | # common parameters for tf-m build system |
| 24 | # This configuration template will be passed into the tfm-builder module after |
| 25 | # the template evaluation is converted to a command |
| 26 | |
| 27 | _common_tfm_builder_cfg = { |
| 28 | "config_type": "tf-m", |
| 29 | "codebase_root_dir": "tf-m", |
| 30 | # Order to which the variants are evaluated. This affects the name of |
| 31 | # variant configuration and the wildcard replacement logic in invalid |
| 32 | # configuration tuples |
| 33 | "sort_order": ["target_platform", |
| 34 | "compiler", |
| 35 | "proj_config", |
| 36 | "cmake_build_type", |
| 37 | "with_mcuboot"], |
| 38 | |
| 39 | # Keys for the templace will come from the combinations of parameters |
| 40 | # provided in the seed dictionary. |
| 41 | |
| 42 | "config_template": ( |
| 43 | "cmake -G \"Unix Makefiles\" " |
| 44 | "-DPROJ_CONFIG=`" |
| 45 | "readlink -f %(codebase_root_dir)s/configs/%(proj_config)s.cmake` " |
| 46 | "-DTARGET_PLATFORM=%(target_platform)s " |
| 47 | "-DCOMPILER=%(compiler)s " |
| 48 | "-DCMAKE_BUILD_TYPE=%(cmake_build_type)s " |
| 49 | "-DBL2=%(with_mcuboot)s " |
| 50 | "%(codebase_root_dir)s"), |
| 51 | |
| 52 | # A small subset of string substitution params is allowed in commands. |
| 53 | # tfm_build_manager will replace %(_tbm_build_dir_)s, %(_tbm_code_dir_)s, |
| 54 | # _tbm_target_platform_ with the paths set when building |
| 55 | |
| 56 | "artifact_capture_rex": (r'%(_tbm_build_dir_)s/install/outputs/' |
| 57 | r'(?:fvp|AN521|AN519|MUSCA_A|MUSCA_B1)' |
| 58 | r'/(\w+\.(?:axf|bin|hex))$'), |
| 59 | |
| 60 | # ALL commands will be executed for every build. |
| 61 | # Other keys will append extra commands when matching target_platform |
| 62 | "build_cmds": {"all": ["cmake --build ./ -- -j 2 install"], |
| 63 | "MUSCA_A": [("srec_cat " |
| 64 | "%(_tbm_build_dir_)s/install/outputs/" |
| 65 | "%(_tbm_target_platform_)s/mcuboot.bin " |
| 66 | "-Binary -offset 0x200000 " |
| 67 | "%(_tbm_build_dir_)s/install/outputs/" |
| 68 | "%(_tbm_target_platform_)s/tfm_sign.bin " |
| 69 | "-Binary -offset 0x220000 -o " |
| 70 | "%(_tbm_build_dir_)s/install/outputs/" |
| 71 | "%(_tbm_target_platform_)s" |
| 72 | "/tfm.hex -Intel")], |
| 73 | "MUSCA_B1": [("srec_cat " |
| 74 | "%(_tbm_build_dir_)s/install/outputs/" |
| 75 | "%(_tbm_target_platform_)s/mcuboot.bin " |
| 76 | "-Binary -offset 0x200000 " |
| 77 | "%(_tbm_build_dir_)s/install/outputs/" |
| 78 | "%(_tbm_target_platform_)s/tfm_sign.bin " |
| 79 | "-Binary -offset 0x220000 -o " |
| 80 | "%(_tbm_build_dir_)s/install/outputs/" |
| 81 | "%(_tbm_target_platform_)s" |
| 82 | "/tfm.hex -Intel")] |
| 83 | }, |
| 84 | |
| 85 | # (Optional) If set will fail if those artefacts are missing post build |
| 86 | "required_artefacts": {"all": [ |
| 87 | "%(_tbm_build_dir_)s/install/outputs/" |
| 88 | "%(_tbm_target_platform_)s/tfm_s.bin", |
| 89 | "%(_tbm_build_dir_)s/install/outputs/" |
| 90 | "%(_tbm_target_platform_)s/tfm_ns.bin"], |
| 91 | "MUSCA_A": [ |
| 92 | "%(_tbm_build_dir_)s/install/outputs/" |
| 93 | "%(_tbm_target_platform_)s/tfm.hex", |
| 94 | "%(_tbm_build_dir_)s/install/outputs/" |
| 95 | "%(_tbm_target_platform_)s/mcuboot.bin", |
| 96 | "%(_tbm_build_dir_)s/install/outputs/" |
| 97 | "%(_tbm_target_platform_)s/tfm_sign.bin"], |
| 98 | "MUSCA_B1": [ |
| 99 | "%(_tbm_build_dir_)s/install/outputs/" |
| 100 | "%(_tbm_target_platform_)s/tfm.hex", |
| 101 | "%(_tbm_build_dir_)s/install/outputs/" |
| 102 | "%(_tbm_target_platform_)s/mcuboot.bin", |
| 103 | "%(_tbm_build_dir_)s/install/outputs/" |
| 104 | "%(_tbm_target_platform_)s/tfm_sign.bin"] |
| 105 | } |
| 106 | } |
Minos Galanakis | f4ca6ac | 2017-12-11 02:39:21 +0100 | [diff] [blame] | 107 | |
| 108 | # Configure build manager to build several combinations |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame^] | 109 | config_AN521 = {"seed_params": { |
| 110 | "target_platform": ["AN521"], |
Minos Galanakis | f4ca6ac | 2017-12-11 02:39:21 +0100 | [diff] [blame] | 111 | "compiler": ["GNUARM"], |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame^] | 112 | "proj_config": ["ConfigRegression", |
| 113 | "ConfigCoreIPC", |
| 114 | "ConfigCoreIPCTfmLevel2", |
| 115 | "ConfigDefault"], |
| 116 | "cmake_build_type": ["Debug", "Release"], |
| 117 | "with_mcuboot": [True, False], |
| 118 | }, |
| 119 | "common_params": _common_tfm_builder_cfg, |
Minos Galanakis | f4ca6ac | 2017-12-11 02:39:21 +0100 | [diff] [blame] | 120 | # invalid configuations can be added as tuples of adjustable |
| 121 | # resolution "AN521" will reject all combinations for that |
| 122 | # platform while ("AN521", "GNUARM") will only reject GCC ones |
| 123 | "invalid": [] |
| 124 | } |
| 125 | |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame^] | 126 | |
| 127 | # Configure build manager to build several combinations |
| 128 | config_AN519 = {"seed_params": { |
| 129 | "target_platform": ["AN519"], |
| 130 | "compiler": ["GNUARM"], |
| 131 | "proj_config": ["ConfigRegression", |
| 132 | "ConfigCoreIPC", |
| 133 | "ConfigCoreIPCTfmLevel2", |
| 134 | "ConfigDefault"], |
| 135 | "cmake_build_type": ["Debug", "Release"], |
| 136 | "with_mcuboot": [True, False], |
| 137 | }, |
| 138 | "common_params": _common_tfm_builder_cfg, |
| 139 | # invalid configuations can be added as tuples of adjustable |
| 140 | # resolution "AN521" will reject all combinations for that |
| 141 | # platform while ("AN521", "GNUARM") will only reject GCC ones |
| 142 | "invalid": [] |
| 143 | } |
| 144 | |
| 145 | config_IPC = {"seed_params": { |
| 146 | "target_platform": ["AN521", "AN519", "MUSCA_A", "MUSCA_B1"], |
| 147 | "compiler": ["ARMCLANG", "GNUARM"], |
| 148 | "proj_config": ["ConfigCoreIPC", |
| 149 | "ConfigCoreIPCTfmLevel2"], |
| 150 | "cmake_build_type": ["Debug", "Release"], |
| 151 | "with_mcuboot": [True, False], |
| 152 | }, |
| 153 | "common_params": _common_tfm_builder_cfg, |
| 154 | # invalid configuations can be added as tuples of adjustable |
| 155 | # resolution "AN521" will reject all combinations for that |
| 156 | # platform while ("AN521", "GNUARM") will only reject GCC |
| 157 | "invalid": [("MUSCA_B1", "*", "*", "*", False)] |
| 158 | } |
| 159 | |
| 160 | # Configure build manager to build the maximum number of configurations |
| 161 | config_full = {"seed_params": { |
| 162 | "target_platform": ["AN521", "AN519", "MUSCA_A", "MUSCA_B1"], |
| 163 | "compiler": ["ARMCLANG", "GNUARM"], |
| 164 | "proj_config": ["ConfigRegression", |
| 165 | "ConfigCoreIPC", |
| 166 | "ConfigCoreIPCTfmLevel2", |
| 167 | "ConfigDefault"], |
| 168 | "cmake_build_type": ["Debug", "Release"], |
| 169 | "with_mcuboot": [True, False], |
| 170 | }, |
| 171 | "common_params": _common_tfm_builder_cfg, |
| 172 | # invalid configuations can be added as tuples of adjustable |
| 173 | # resolution "AN521" will reject all combinations for that |
| 174 | # platform while ("AN521", "GNUARM") will only reject GCC ones |
| 175 | "invalid": [("MUSCA_A", "*", "*", "*", False), |
| 176 | ("MUSCA_B1", "*", "*", "*", False)] |
| 177 | } |
| 178 | |
| 179 | config_MUSCA_A = {"seed_params": { |
| 180 | "target_platform": ["MUSCA_A"], |
| 181 | "compiler": ["GNUARM"], |
| 182 | "proj_config": ["ConfigRegression", |
| 183 | "ConfigCoreIPC", |
| 184 | "ConfigCoreIPCTfmLevel2", |
| 185 | "ConfigDefault"], |
| 186 | "cmake_build_type": ["Debug", "Release"], |
| 187 | "with_mcuboot": [True], |
| 188 | }, |
| 189 | "common_params": _common_tfm_builder_cfg, |
| 190 | # invalid configuations can be added as tuples of adjustable |
| 191 | # resolution "AN521" will reject all combinations for that |
| 192 | # platform while ("AN521", "GNUARM") will only reject GCC |
| 193 | "invalid": [("MUSCA_A", "*", "*", "*", False)] |
| 194 | } |
| 195 | |
| 196 | config_MUSCA_B1 = {"seed_params": { |
| 197 | "target_platform": ["MUSCA_B1"], |
| 198 | "compiler": ["GNUARM"], |
| 199 | "proj_config": ["ConfigRegression", |
| 200 | "ConfigCoreIPC", |
| 201 | "ConfigCoreIPCTfmLevel2", |
| 202 | "ConfigDefault"], |
| 203 | "cmake_build_type": ["Debug", "Release"], |
| 204 | "with_mcuboot": [True], |
| 205 | }, |
| 206 | "common_params": _common_tfm_builder_cfg, |
| 207 | # invalid configuations can be added as tuples of adjustable |
| 208 | # resolution "AN521" will reject all combinations for that |
| 209 | # platform while ("AN521", "GNUARM") will only reject GCC |
| 210 | "invalid": [("MUSCA_B1", "*", "*", "*", False)] |
| 211 | } |
| 212 | |
| 213 | # Configruation used for document building |
| 214 | config_doxygen = {"common_params": { |
| 215 | "config_type": "tf-m_documents", |
| 216 | "codebase_root_dir": "tf-m", |
| 217 | "build_cmds": {"all": ["cmake -G \"Unix Makefiles\" " |
| 218 | "-DPROJ_CONFIG=`readlink -f " |
| 219 | "%(_tbm_code_dir_)s/" |
| 220 | "configs/ConfigDefault.cmake` " |
| 221 | "-DTARGET_PLATFORM=AN521 " |
| 222 | "-DCOMPILER=GNUARM " |
| 223 | "-DCMAKE_BUILD_TYPE=Debug " |
| 224 | "-DBL2=True " |
| 225 | "%(_tbm_code_dir_)s/", |
| 226 | "cmake --build ./ -- install_doc", |
| 227 | "cmake --build ./ " |
| 228 | "-- install_userguide"]}, |
| 229 | "artifact_capture_rex": r'%(_tbm_build_dir_)s/install/' |
| 230 | r'doc/reference_manual/(?:pdf|html)' |
| 231 | r'/(\w+\.(?:html|md|pdf))$', |
| 232 | }, |
| 233 | "invalid": [] |
| 234 | } |
| 235 | |
| 236 | # Configruation used in testing |
| 237 | config_debug = {"seed_params": { |
| 238 | "target_platform": ["AN521"], |
| 239 | "compiler": ["ARMCLANG"], |
| 240 | "proj_config": ["ConfigDefault"], |
| 241 | "cmake_build_type": ["Debug"], |
| 242 | "with_mcuboot": [True], |
| 243 | }, |
| 244 | "common_params": _common_tfm_builder_cfg, |
| 245 | # invalid configuations can be added as tuples of adjustable |
| 246 | # resolution "AN521" will reject all combinations for that |
| 247 | # platform while ("AN521", "GNUARM") will only reject GCC ones |
| 248 | "invalid": [("*", "GNUARM", "*", "*", False), |
| 249 | ("AN521", "ARMCLANG", "ConfigRegression", |
| 250 | "Release", False), |
| 251 | ] |
| 252 | } |
| 253 | |
| 254 | _builtin_configs = {"full": config_full, |
| 255 | "an521": config_AN521, |
| 256 | "an519": config_AN519, |
| 257 | "musca_a": config_MUSCA_A, |
| 258 | "musca_b1": config_MUSCA_B1, |
| 259 | "ipc": config_IPC, |
| 260 | "doxygen": config_doxygen, |
| 261 | "debug": config_debug} |
Minos Galanakis | f4ca6ac | 2017-12-11 02:39:21 +0100 | [diff] [blame] | 262 | |
| 263 | if __name__ == '__main__': |
| 264 | import os |
Minos Galanakis | f4ca6ac | 2017-12-11 02:39:21 +0100 | [diff] [blame] | 265 | |
Minos Galanakis | ea42123 | 2019-06-20 17:11:28 +0100 | [diff] [blame^] | 266 | # Default behavior is to export refference config when called |
| 267 | _dir = os.getcwd() |
| 268 | from utils import save_json |
| 269 | for _cname, _cfg in _builtin_configs.items(): |
| 270 | _fname = os.path.join(_dir, _cname + ".json") |
| 271 | print("Exporting config %s" % _fname) |
| 272 | save_json(_fname, _cfg) |