Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-tools by
build_release.py
00001 #! /usr/bin/env python 00002 """ 00003 mbed SDK 00004 Copyright (c) 2011-2013 ARM Limited 00005 00006 Licensed under the Apache License, Version 2.0 (the "License"); 00007 you may not use this file except in compliance with the License. 00008 You may obtain a copy of the License at 00009 00010 http://www.apache.org/licenses/LICENSE-2.0 00011 00012 Unless required by applicable law or agreed to in writing, software 00013 distributed under the License is distributed on an "AS IS" BASIS, 00014 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 See the License for the specific language governing permissions and 00016 limitations under the License. 00017 """ 00018 import sys 00019 from time import time 00020 from os.path import join, abspath, dirname, normpath 00021 from optparse import OptionParser 00022 import json 00023 00024 # Be sure that the tools directory is in the search path 00025 ROOT = abspath(join(dirname(__file__), "..")) 00026 sys.path.insert(0, ROOT) 00027 00028 from tools.build_api import build_mbed_libs 00029 from tools.build_api import write_build_report 00030 from tools.targets import TARGET_MAP 00031 from tools.test_exporters import ReportExporter, ResultExporterType 00032 from tools.test_api import SingleTestRunner 00033 from tools.test_api import singletest_in_cli_mode 00034 from tools.paths import TEST_DIR 00035 from tools.tests import TEST_MAP 00036 00037 OFFICIAL_MBED_LIBRARY_BUILD = ( 00038 ('LPC11U24', ('ARM', 'uARM', 'GCC_ARM', 'IAR')), 00039 ('LPC1768', ('ARM', 'GCC_ARM', 'GCC_CR', 'IAR')), 00040 ('UBLOX_C027', ('ARM', 'GCC_ARM', 'GCC_CR', 'IAR')), 00041 ('ARCH_PRO', ('ARM', 'GCC_ARM', 'GCC_CR', 'IAR')), 00042 ('LPC2368', ('ARM', 'GCC_ARM')), 00043 ('LPC2460', ('GCC_ARM',)), 00044 ('LPC812', ('uARM','IAR')), 00045 ('LPC824', ('uARM', 'GCC_ARM', 'IAR', 'GCC_CR')), 00046 ('SSCI824', ('uARM','GCC_ARM')), 00047 ('LPC1347', ('ARM','IAR')), 00048 ('LPC4088', ('ARM', 'GCC_ARM', 'GCC_CR', 'IAR')), 00049 ('LPC4088_DM', ('ARM', 'GCC_ARM', 'GCC_CR', 'IAR')), 00050 ('LPC1114', ('uARM','GCC_ARM', 'GCC_CR', 'IAR')), 00051 ('LPC11U35_401', ('ARM', 'uARM','GCC_ARM','GCC_CR', 'IAR')), 00052 ('LPC11U35_501', ('ARM', 'uARM','GCC_ARM','GCC_CR', 'IAR')), 00053 ('LPC1549', ('uARM','GCC_ARM','GCC_CR', 'IAR')), 00054 ('XADOW_M0', ('ARM', 'uARM','GCC_ARM','GCC_CR')), 00055 ('ARCH_GPRS', ('ARM', 'uARM', 'GCC_ARM', 'GCC_CR', 'IAR')), 00056 ('LPC4337', ('ARM',)), 00057 ('LPC11U37H_401', ('ARM', 'uARM','GCC_ARM','GCC_CR')), 00058 ('MICRONFCBOARD', ('ARM', 'uARM','GCC_ARM')), 00059 00060 ('KL05Z', ('ARM', 'uARM', 'GCC_ARM', 'IAR')), 00061 ('KL25Z', ('ARM', 'GCC_ARM', 'IAR')), 00062 ('KL43Z', ('ARM', 'GCC_ARM')), 00063 ('KL46Z', ('ARM', 'GCC_ARM', 'IAR')), 00064 ('K64F', ('ARM', 'GCC_ARM', 'IAR')), 00065 ('K22F', ('ARM', 'GCC_ARM', 'IAR')), 00066 ('K20D50M', ('ARM', 'GCC_ARM' , 'IAR')), 00067 ('TEENSY3_1', ('ARM', 'GCC_ARM')), 00068 00069 ('B96B_F446VE', ('ARM', 'uARM', 'IAR', 'GCC_ARM')), 00070 ('NUCLEO_F030R8', ('ARM', 'uARM', 'IAR', 'GCC_ARM')), 00071 ('NUCLEO_F031K6', ('ARM', 'uARM', 'IAR', 'GCC_ARM')), 00072 ('NUCLEO_F042K6', ('ARM', 'uARM', 'IAR', 'GCC_ARM')), 00073 ('NUCLEO_F070RB', ('ARM', 'uARM', 'IAR', 'GCC_ARM')), 00074 ('NUCLEO_F072RB', ('ARM', 'uARM', 'IAR', 'GCC_ARM')), 00075 ('NUCLEO_F091RC', ('ARM', 'uARM', 'IAR', 'GCC_ARM')), 00076 ('NUCLEO_F103RB', ('ARM', 'uARM', 'IAR', 'GCC_ARM')), 00077 ('NUCLEO_F302R8', ('ARM', 'uARM', 'IAR', 'GCC_ARM')), 00078 ('NUCLEO_F303K8', ('ARM', 'uARM', 'IAR', 'GCC_ARM')), 00079 ('NUCLEO_F303RE', ('ARM', 'uARM', 'IAR')), 00080 ('NUCLEO_F334R8', ('ARM', 'uARM', 'IAR', 'GCC_ARM')), 00081 ('NUCLEO_F401RE', ('ARM', 'uARM', 'IAR', 'GCC_ARM')), 00082 ('NUCLEO_F410RB', ('ARM', 'uARM', 'IAR', 'GCC_ARM')), 00083 ('NUCLEO_F411RE', ('ARM', 'uARM', 'IAR', 'GCC_ARM')), 00084 ('NUCLEO_F446RE', ('ARM', 'uARM', 'IAR', 'GCC_ARM')), 00085 ('ELMO_F411RE', ('ARM', 'uARM', 'GCC_ARM')), 00086 ('NUCLEO_L053R8', ('ARM', 'uARM', 'IAR', 'GCC_ARM')), 00087 ('NUCLEO_L152RE', ('ARM', 'uARM', 'IAR', 'GCC_ARM')), 00088 ('MTS_MDOT_F405RG', ('ARM', 'uARM', 'IAR', 'GCC_ARM')), 00089 ('MTS_MDOT_F411RE', ('ARM', 'uARM', 'IAR', 'GCC_ARM')), 00090 ('MTS_DRAGONFLY_F411RE', ('ARM', 'uARM', 'IAR', 'GCC_ARM')), 00091 ('DISCO_L053C8', ('ARM', 'uARM', 'IAR', 'GCC_ARM')), 00092 ('DISCO_F334C8', ('ARM', 'uARM', 'IAR', 'GCC_ARM')), 00093 ('DISCO_F429ZI', ('ARM', 'uARM', 'IAR', 'GCC_ARM')), 00094 ('DISCO_F469NI', ('ARM', 'uARM', 'IAR', 'GCC_ARM')), 00095 ('DISCO_F746NG', ('ARM', 'uARM', 'GCC_ARM','IAR')), 00096 ('DISCO_L476VG', ('ARM', 'uARM', 'IAR', 'GCC_ARM')), 00097 ('NUCLEO_L476RG', ('ARM', 'uARM', 'IAR', 'GCC_ARM')), 00098 ('NUCLEO_F746ZG', ('ARM', 'uARM', 'GCC_ARM', 'IAR')), 00099 ('NUCLEO_L073RZ', ('ARM', 'uARM', 'GCC_ARM', 'IAR')), 00100 00101 ('MOTE_L152RC', ('ARM', 'uARM', 'IAR', 'GCC_ARM')), 00102 00103 ('ARCH_MAX', ('ARM', 'GCC_ARM')), 00104 00105 ('NRF51822', ('ARM', 'GCC_ARM', 'IAR')), 00106 ('NRF51_DK', ('ARM', 'GCC_ARM', 'IAR')), 00107 ('NRF51_DONGLE', ('ARM', 'GCC_ARM', 'IAR')), 00108 ('HRM1017', ('ARM', 'GCC_ARM', 'IAR')), 00109 ('ARCH_BLE', ('ARM', 'GCC_ARM', 'IAR')), 00110 ('SEEED_TINY_BLE', ('ARM', 'GCC_ARM', 'IAR')), 00111 ('RBLAB_NRF51822', ('ARM', 'GCC_ARM')), 00112 ('RBLAB_BLENANO', ('ARM', 'GCC_ARM')), 00113 ('WALLBOT_BLE', ('ARM', 'GCC_ARM')), 00114 ('DELTA_DFCM_NNN40', ('ARM', 'GCC_ARM')), 00115 ('NRF51_MICROBIT', ('ARM',)), 00116 ('NRF51_MICROBIT_B', ('ARM',)), 00117 ('TY51822R3', ('ARM', 'GCC_ARM')), 00118 00119 ('LPC11U68', ('ARM', 'uARM','GCC_ARM','GCC_CR', 'IAR')), 00120 ('OC_MBUINO', ('ARM', 'uARM', 'GCC_ARM', 'IAR')), 00121 00122 ('ARM_MPS2_M0' , ('ARM',)), 00123 ('ARM_MPS2_M0P' , ('ARM',)), 00124 ('ARM_MPS2_M3' , ('ARM',)), 00125 ('ARM_MPS2_M4' , ('ARM',)), 00126 ('ARM_MPS2_M7' , ('ARM',)), 00127 ('ARM_MPS2_BEID' , ('ARM',)), 00128 00129 ('RZ_A1H' , ('ARM', 'GCC_ARM', 'IAR')), 00130 00131 ('EFM32ZG_STK3200', ('GCC_ARM', 'uARM')), 00132 ('EFM32HG_STK3400', ('GCC_ARM', 'uARM')), 00133 ('EFM32LG_STK3600', ('ARM', 'GCC_ARM', 'uARM')), 00134 ('EFM32GG_STK3700', ('ARM', 'GCC_ARM', 'uARM')), 00135 ('EFM32WG_STK3800', ('ARM', 'GCC_ARM', 'uARM')), 00136 00137 ('MAXWSNENV', ('ARM', 'GCC_ARM', 'IAR')), 00138 ('MAX32600MBED', ('ARM', 'GCC_ARM', 'IAR')), 00139 00140 ('WIZWIKI_W7500', ('ARM', 'uARM')), 00141 ('WIZWIKI_W7500P',('ARM', 'uARM')), 00142 ('WIZWIKI_W7500ECO',('ARM', 'uARM')), 00143 00144 ('SAMR21G18A',('ARM', 'uARM', 'GCC_ARM')), 00145 ('SAMD21J18A',('ARM', 'uARM', 'GCC_ARM')), 00146 ('SAMD21G18A',('ARM', 'uARM', 'GCC_ARM')), 00147 00148 ) 00149 00150 00151 if __name__ == '__main__': 00152 parser = OptionParser() 00153 parser.add_option('-o', '--official', dest="official_only", default=False, action="store_true", 00154 help="Build using only the official toolchain for each target") 00155 parser.add_option("-j", "--jobs", type="int", dest="jobs", 00156 default=1, help="Number of concurrent jobs (default 1). Use 0 for auto based on host machine's number of CPUs") 00157 parser.add_option("-v", "--verbose", action="store_true", dest="verbose", 00158 default=False, help="Verbose diagnostic output") 00159 parser.add_option("-t", "--toolchains", dest="toolchains", help="Use toolchains names separated by comma") 00160 00161 parser.add_option("-p", "--platforms", dest="platforms", default="", help="Build only for the platform namesseparated by comma") 00162 00163 parser.add_option("-L", "--list-config", action="store_true", dest="list_config", 00164 default=False, help="List the platforms and toolchains in the release in JSON") 00165 00166 parser.add_option("", "--report-build", dest="report_build_file_name", help="Output the build results to an junit xml file") 00167 00168 parser.add_option("", "--build-tests", dest="build_tests", help="Build all tests in the given directories (relative to /libraries/tests)") 00169 00170 00171 options, args = parser.parse_args() 00172 00173 00174 00175 if options.list_config: 00176 print json.dumps(OFFICIAL_MBED_LIBRARY_BUILD, indent=4) 00177 sys.exit() 00178 00179 start = time() 00180 build_report = {} 00181 build_properties = {} 00182 00183 platforms = None 00184 if options.platforms != "": 00185 platforms = set(options.platforms.split(",")) 00186 00187 if options.build_tests: 00188 # Get all paths 00189 directories = options.build_tests.split(',') 00190 for i in range(len(directories)): 00191 directories[i] = normpath(join(TEST_DIR, directories[i])) 00192 00193 test_names = [] 00194 00195 for test_id in TEST_MAP.keys(): 00196 # Prevents tests with multiple source dirs from being checked 00197 if isinstance( TEST_MAP[test_id].source_dir, basestring): 00198 test_path = normpath(TEST_MAP[test_id].source_dir) 00199 for directory in directories: 00200 if directory in test_path: 00201 test_names.append(test_id) 00202 00203 mut_counter = 1 00204 mut = {} 00205 test_spec = { 00206 "targets": {} 00207 } 00208 00209 for target_name, toolchain_list in OFFICIAL_MBED_LIBRARY_BUILD: 00210 toolchains = None 00211 if platforms is not None and not target_name in platforms: 00212 print("Excluding %s from release" % target_name) 00213 continue 00214 00215 if options.official_only: 00216 toolchains = (getattr(TARGET_MAP[target_name], 'default_toolchain', 'ARM'),) 00217 else: 00218 toolchains = toolchain_list 00219 00220 if options.toolchains: 00221 print "Only building using the following toolchains: %s" % (options.toolchains) 00222 toolchainSet = set(toolchains) 00223 toolchains = toolchainSet.intersection(set((options.toolchains).split(','))) 00224 00225 mut[str(mut_counter)] = { 00226 "mcu": target_name 00227 } 00228 00229 mut_counter += 1 00230 00231 test_spec["targets"][target_name] = toolchains 00232 00233 single_test = SingleTestRunner(_muts=mut, 00234 _opts_report_build_file_name=options.report_build_file_name, 00235 _test_spec=test_spec, 00236 _opts_test_by_names=",".join(test_names), 00237 _opts_verbose=options.verbose, 00238 _opts_only_build_tests=True, 00239 _opts_suppress_summary=True, 00240 _opts_jobs=options.jobs, 00241 _opts_include_non_automated=True, 00242 _opts_build_report=build_report, 00243 _opts_build_properties=build_properties) 00244 # Runs test suite in CLI mode 00245 test_summary, shuffle_seed, test_summary_ext, test_suite_properties_ext, new_build_report, new_build_properties = single_test.execute() 00246 else: 00247 for target_name, toolchain_list in OFFICIAL_MBED_LIBRARY_BUILD: 00248 if platforms is not None and not target_name in platforms: 00249 print("Excluding %s from release" % target_name) 00250 continue 00251 00252 if options.official_only: 00253 toolchains = (getattr(TARGET_MAP[target_name], 'default_toolchain', 'ARM'),) 00254 else: 00255 toolchains = toolchain_list 00256 00257 if options.toolchains: 00258 print "Only building using the following toolchains: %s" % (options.toolchains) 00259 toolchainSet = set(toolchains) 00260 toolchains = toolchainSet.intersection(set((options.toolchains).split(','))) 00261 00262 for toolchain in toolchains: 00263 id = "%s::%s" % (target_name, toolchain) 00264 00265 try: 00266 built_mbed_lib = build_mbed_libs(TARGET_MAP[target_name], toolchain, verbose=options.verbose, jobs=options.jobs, report=build_report, properties=build_properties) 00267 00268 except Exception, e: 00269 print str(e) 00270 00271 # Write summary of the builds 00272 if options.report_build_file_name: 00273 file_report_exporter = ReportExporter(ResultExporterType.JUNIT, package="build") 00274 file_report_exporter.report_to_file(build_report, options.report_build_file_name, test_suite_properties=build_properties) 00275 00276 print "\n\nCompleted in: (%.2f)s" % (time() - start) 00277 00278 print_report_exporter = ReportExporter(ResultExporterType.PRINT, package="build") 00279 status = print_report_exporter.report(build_report) 00280 00281 if not status: 00282 sys.exit(1)
Generated on Thu Jun 15 2023 14:54:59 by
