5.2.1 - Updated I2C files
Dependents: mbed-TFT-example-NCS36510 mbed-Accelerometer-example-NCS36510 mbed-Accelerometer-example-NCS36510
tools/build_release.py@0:098463de4c5d, 2017-01-25 (annotated)
- Committer:
- group-onsemi
- Date:
- Wed Jan 25 20:34:15 2017 +0000
- Revision:
- 0:098463de4c5d
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
group-onsemi | 0:098463de4c5d | 1 | #! /usr/bin/env python |
group-onsemi | 0:098463de4c5d | 2 | """ |
group-onsemi | 0:098463de4c5d | 3 | mbed SDK |
group-onsemi | 0:098463de4c5d | 4 | Copyright (c) 2011-2013 ARM Limited |
group-onsemi | 0:098463de4c5d | 5 | |
group-onsemi | 0:098463de4c5d | 6 | Licensed under the Apache License, Version 2.0 (the "License"); |
group-onsemi | 0:098463de4c5d | 7 | you may not use this file except in compliance with the License. |
group-onsemi | 0:098463de4c5d | 8 | You may obtain a copy of the License at |
group-onsemi | 0:098463de4c5d | 9 | |
group-onsemi | 0:098463de4c5d | 10 | http://www.apache.org/licenses/LICENSE-2.0 |
group-onsemi | 0:098463de4c5d | 11 | |
group-onsemi | 0:098463de4c5d | 12 | Unless required by applicable law or agreed to in writing, software |
group-onsemi | 0:098463de4c5d | 13 | distributed under the License is distributed on an "AS IS" BASIS, |
group-onsemi | 0:098463de4c5d | 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
group-onsemi | 0:098463de4c5d | 15 | See the License for the specific language governing permissions and |
group-onsemi | 0:098463de4c5d | 16 | limitations under the License. |
group-onsemi | 0:098463de4c5d | 17 | """ |
group-onsemi | 0:098463de4c5d | 18 | import sys |
group-onsemi | 0:098463de4c5d | 19 | from time import time |
group-onsemi | 0:098463de4c5d | 20 | from os.path import join, abspath, dirname, normpath |
group-onsemi | 0:098463de4c5d | 21 | from optparse import OptionParser |
group-onsemi | 0:098463de4c5d | 22 | import json |
group-onsemi | 0:098463de4c5d | 23 | from shutil import copy |
group-onsemi | 0:098463de4c5d | 24 | |
group-onsemi | 0:098463de4c5d | 25 | # Be sure that the tools directory is in the search path |
group-onsemi | 0:098463de4c5d | 26 | ROOT = abspath(join(dirname(__file__), "..")) |
group-onsemi | 0:098463de4c5d | 27 | sys.path.insert(0, ROOT) |
group-onsemi | 0:098463de4c5d | 28 | |
group-onsemi | 0:098463de4c5d | 29 | from tools.build_api import build_mbed_libs |
group-onsemi | 0:098463de4c5d | 30 | from tools.build_api import write_build_report |
group-onsemi | 0:098463de4c5d | 31 | from tools.build_api import get_mbed_official_release |
group-onsemi | 0:098463de4c5d | 32 | from tools.options import extract_profile |
group-onsemi | 0:098463de4c5d | 33 | from tools.targets import TARGET_MAP, TARGET_NAMES |
group-onsemi | 0:098463de4c5d | 34 | from tools.test_exporters import ReportExporter, ResultExporterType |
group-onsemi | 0:098463de4c5d | 35 | from tools.test_api import SingleTestRunner |
group-onsemi | 0:098463de4c5d | 36 | from tools.test_api import singletest_in_cli_mode |
group-onsemi | 0:098463de4c5d | 37 | from tools.paths import TEST_DIR, MBED_LIBRARIES |
group-onsemi | 0:098463de4c5d | 38 | from tools.tests import TEST_MAP |
group-onsemi | 0:098463de4c5d | 39 | |
group-onsemi | 0:098463de4c5d | 40 | OFFICIAL_MBED_LIBRARY_BUILD = get_mbed_official_release('2') |
group-onsemi | 0:098463de4c5d | 41 | |
group-onsemi | 0:098463de4c5d | 42 | if __name__ == '__main__': |
group-onsemi | 0:098463de4c5d | 43 | parser = OptionParser() |
group-onsemi | 0:098463de4c5d | 44 | parser.add_option('-o', '--official', dest="official_only", default=False, action="store_true", |
group-onsemi | 0:098463de4c5d | 45 | help="Build using only the official toolchain for each target") |
group-onsemi | 0:098463de4c5d | 46 | parser.add_option("-j", "--jobs", type="int", dest="jobs", |
group-onsemi | 0:098463de4c5d | 47 | default=1, help="Number of concurrent jobs (default 1). Use 0 for auto based on host machine's number of CPUs") |
group-onsemi | 0:098463de4c5d | 48 | parser.add_option("-v", "--verbose", action="store_true", dest="verbose", |
group-onsemi | 0:098463de4c5d | 49 | default=False, help="Verbose diagnostic output") |
group-onsemi | 0:098463de4c5d | 50 | parser.add_option("-t", "--toolchains", dest="toolchains", help="Use toolchains names separated by comma") |
group-onsemi | 0:098463de4c5d | 51 | |
group-onsemi | 0:098463de4c5d | 52 | parser.add_option("--profile", dest="profile", action="append", default=[]) |
group-onsemi | 0:098463de4c5d | 53 | |
group-onsemi | 0:098463de4c5d | 54 | parser.add_option("-p", "--platforms", dest="platforms", default="", help="Build only for the platform namesseparated by comma") |
group-onsemi | 0:098463de4c5d | 55 | |
group-onsemi | 0:098463de4c5d | 56 | parser.add_option("-L", "--list-config", action="store_true", dest="list_config", |
group-onsemi | 0:098463de4c5d | 57 | default=False, help="List the platforms and toolchains in the release in JSON") |
group-onsemi | 0:098463de4c5d | 58 | |
group-onsemi | 0:098463de4c5d | 59 | parser.add_option("", "--report-build", dest="report_build_file_name", help="Output the build results to an junit xml file") |
group-onsemi | 0:098463de4c5d | 60 | |
group-onsemi | 0:098463de4c5d | 61 | parser.add_option("", "--build-tests", dest="build_tests", help="Build all tests in the given directories (relative to /libraries/tests)") |
group-onsemi | 0:098463de4c5d | 62 | |
group-onsemi | 0:098463de4c5d | 63 | |
group-onsemi | 0:098463de4c5d | 64 | options, args = parser.parse_args() |
group-onsemi | 0:098463de4c5d | 65 | |
group-onsemi | 0:098463de4c5d | 66 | |
group-onsemi | 0:098463de4c5d | 67 | |
group-onsemi | 0:098463de4c5d | 68 | if options.list_config: |
group-onsemi | 0:098463de4c5d | 69 | print json.dumps(OFFICIAL_MBED_LIBRARY_BUILD, indent=4) |
group-onsemi | 0:098463de4c5d | 70 | sys.exit() |
group-onsemi | 0:098463de4c5d | 71 | |
group-onsemi | 0:098463de4c5d | 72 | start = time() |
group-onsemi | 0:098463de4c5d | 73 | build_report = {} |
group-onsemi | 0:098463de4c5d | 74 | build_properties = {} |
group-onsemi | 0:098463de4c5d | 75 | |
group-onsemi | 0:098463de4c5d | 76 | platforms = None |
group-onsemi | 0:098463de4c5d | 77 | if options.platforms != "": |
group-onsemi | 0:098463de4c5d | 78 | platforms = set(options.platforms.split(",")) |
group-onsemi | 0:098463de4c5d | 79 | |
group-onsemi | 0:098463de4c5d | 80 | if options.build_tests: |
group-onsemi | 0:098463de4c5d | 81 | # Get all paths |
group-onsemi | 0:098463de4c5d | 82 | directories = options.build_tests.split(',') |
group-onsemi | 0:098463de4c5d | 83 | for i in range(len(directories)): |
group-onsemi | 0:098463de4c5d | 84 | directories[i] = normpath(join(TEST_DIR, directories[i])) |
group-onsemi | 0:098463de4c5d | 85 | |
group-onsemi | 0:098463de4c5d | 86 | test_names = [] |
group-onsemi | 0:098463de4c5d | 87 | |
group-onsemi | 0:098463de4c5d | 88 | for test_id in TEST_MAP.keys(): |
group-onsemi | 0:098463de4c5d | 89 | # Prevents tests with multiple source dirs from being checked |
group-onsemi | 0:098463de4c5d | 90 | if isinstance( TEST_MAP[test_id].source_dir, basestring): |
group-onsemi | 0:098463de4c5d | 91 | test_path = normpath(TEST_MAP[test_id].source_dir) |
group-onsemi | 0:098463de4c5d | 92 | for directory in directories: |
group-onsemi | 0:098463de4c5d | 93 | if directory in test_path: |
group-onsemi | 0:098463de4c5d | 94 | test_names.append(test_id) |
group-onsemi | 0:098463de4c5d | 95 | |
group-onsemi | 0:098463de4c5d | 96 | mut_counter = 1 |
group-onsemi | 0:098463de4c5d | 97 | mut = {} |
group-onsemi | 0:098463de4c5d | 98 | test_spec = { |
group-onsemi | 0:098463de4c5d | 99 | "targets": {} |
group-onsemi | 0:098463de4c5d | 100 | } |
group-onsemi | 0:098463de4c5d | 101 | |
group-onsemi | 0:098463de4c5d | 102 | if options.toolchains: |
group-onsemi | 0:098463de4c5d | 103 | print "Only building using the following toolchains: %s" % (options.toolchains) |
group-onsemi | 0:098463de4c5d | 104 | |
group-onsemi | 0:098463de4c5d | 105 | for target_name, toolchain_list in OFFICIAL_MBED_LIBRARY_BUILD: |
group-onsemi | 0:098463de4c5d | 106 | toolchains = None |
group-onsemi | 0:098463de4c5d | 107 | if platforms is not None and not target_name in platforms: |
group-onsemi | 0:098463de4c5d | 108 | print("Excluding %s from release" % target_name) |
group-onsemi | 0:098463de4c5d | 109 | continue |
group-onsemi | 0:098463de4c5d | 110 | |
group-onsemi | 0:098463de4c5d | 111 | if target_name not in TARGET_NAMES: |
group-onsemi | 0:098463de4c5d | 112 | print "Target '%s' is not a valid target. Excluding from release" |
group-onsemi | 0:098463de4c5d | 113 | continue |
group-onsemi | 0:098463de4c5d | 114 | |
group-onsemi | 0:098463de4c5d | 115 | if options.official_only: |
group-onsemi | 0:098463de4c5d | 116 | toolchains = (getattr(TARGET_MAP[target_name], 'default_toolchain', 'ARM'),) |
group-onsemi | 0:098463de4c5d | 117 | else: |
group-onsemi | 0:098463de4c5d | 118 | toolchains = toolchain_list |
group-onsemi | 0:098463de4c5d | 119 | |
group-onsemi | 0:098463de4c5d | 120 | if options.toolchains: |
group-onsemi | 0:098463de4c5d | 121 | toolchainSet = set(toolchains) |
group-onsemi | 0:098463de4c5d | 122 | toolchains = toolchainSet.intersection(set((options.toolchains).split(','))) |
group-onsemi | 0:098463de4c5d | 123 | |
group-onsemi | 0:098463de4c5d | 124 | mut[str(mut_counter)] = { |
group-onsemi | 0:098463de4c5d | 125 | "mcu": target_name |
group-onsemi | 0:098463de4c5d | 126 | } |
group-onsemi | 0:098463de4c5d | 127 | |
group-onsemi | 0:098463de4c5d | 128 | mut_counter += 1 |
group-onsemi | 0:098463de4c5d | 129 | |
group-onsemi | 0:098463de4c5d | 130 | test_spec["targets"][target_name] = toolchains |
group-onsemi | 0:098463de4c5d | 131 | |
group-onsemi | 0:098463de4c5d | 132 | single_test = SingleTestRunner(_muts=mut, |
group-onsemi | 0:098463de4c5d | 133 | _parser=parser, |
group-onsemi | 0:098463de4c5d | 134 | _opts=options, |
group-onsemi | 0:098463de4c5d | 135 | _opts_report_build_file_name=options.report_build_file_name, |
group-onsemi | 0:098463de4c5d | 136 | _test_spec=test_spec, |
group-onsemi | 0:098463de4c5d | 137 | _opts_test_by_names=",".join(test_names), |
group-onsemi | 0:098463de4c5d | 138 | _opts_verbose=options.verbose, |
group-onsemi | 0:098463de4c5d | 139 | _opts_only_build_tests=True, |
group-onsemi | 0:098463de4c5d | 140 | _opts_suppress_summary=True, |
group-onsemi | 0:098463de4c5d | 141 | _opts_jobs=options.jobs, |
group-onsemi | 0:098463de4c5d | 142 | _opts_include_non_automated=True, |
group-onsemi | 0:098463de4c5d | 143 | _opts_build_report=build_report, |
group-onsemi | 0:098463de4c5d | 144 | _opts_build_properties=build_properties) |
group-onsemi | 0:098463de4c5d | 145 | # Runs test suite in CLI mode |
group-onsemi | 0:098463de4c5d | 146 | test_summary, shuffle_seed, test_summary_ext, test_suite_properties_ext, new_build_report, new_build_properties = single_test.execute() |
group-onsemi | 0:098463de4c5d | 147 | else: |
group-onsemi | 0:098463de4c5d | 148 | for target_name, toolchain_list in OFFICIAL_MBED_LIBRARY_BUILD: |
group-onsemi | 0:098463de4c5d | 149 | if platforms is not None and not target_name in platforms: |
group-onsemi | 0:098463de4c5d | 150 | print("Excluding %s from release" % target_name) |
group-onsemi | 0:098463de4c5d | 151 | continue |
group-onsemi | 0:098463de4c5d | 152 | |
group-onsemi | 0:098463de4c5d | 153 | if target_name not in TARGET_NAMES: |
group-onsemi | 0:098463de4c5d | 154 | print "Target '%s' is not a valid target. Excluding from release" |
group-onsemi | 0:098463de4c5d | 155 | continue |
group-onsemi | 0:098463de4c5d | 156 | |
group-onsemi | 0:098463de4c5d | 157 | if options.official_only: |
group-onsemi | 0:098463de4c5d | 158 | toolchains = (getattr(TARGET_MAP[target_name], 'default_toolchain', 'ARM'),) |
group-onsemi | 0:098463de4c5d | 159 | else: |
group-onsemi | 0:098463de4c5d | 160 | toolchains = toolchain_list |
group-onsemi | 0:098463de4c5d | 161 | |
group-onsemi | 0:098463de4c5d | 162 | if options.toolchains: |
group-onsemi | 0:098463de4c5d | 163 | print "Only building using the following toolchains: %s" % (options.toolchains) |
group-onsemi | 0:098463de4c5d | 164 | toolchainSet = set(toolchains) |
group-onsemi | 0:098463de4c5d | 165 | toolchains = toolchainSet.intersection(set((options.toolchains).split(','))) |
group-onsemi | 0:098463de4c5d | 166 | |
group-onsemi | 0:098463de4c5d | 167 | for toolchain in toolchains: |
group-onsemi | 0:098463de4c5d | 168 | id = "%s::%s" % (target_name, toolchain) |
group-onsemi | 0:098463de4c5d | 169 | |
group-onsemi | 0:098463de4c5d | 170 | profile = extract_profile(parser, options, toolchain) |
group-onsemi | 0:098463de4c5d | 171 | |
group-onsemi | 0:098463de4c5d | 172 | try: |
group-onsemi | 0:098463de4c5d | 173 | built_mbed_lib = build_mbed_libs(TARGET_MAP[target_name], |
group-onsemi | 0:098463de4c5d | 174 | toolchain, |
group-onsemi | 0:098463de4c5d | 175 | verbose=options.verbose, |
group-onsemi | 0:098463de4c5d | 176 | jobs=options.jobs, |
group-onsemi | 0:098463de4c5d | 177 | report=build_report, |
group-onsemi | 0:098463de4c5d | 178 | properties=build_properties, |
group-onsemi | 0:098463de4c5d | 179 | build_profile=profile) |
group-onsemi | 0:098463de4c5d | 180 | |
group-onsemi | 0:098463de4c5d | 181 | except Exception, e: |
group-onsemi | 0:098463de4c5d | 182 | print str(e) |
group-onsemi | 0:098463de4c5d | 183 | |
group-onsemi | 0:098463de4c5d | 184 | # copy targets.json file as part of the release |
group-onsemi | 0:098463de4c5d | 185 | copy(join(dirname(abspath(__file__)), '..', 'targets', 'targets.json'), MBED_LIBRARIES) |
group-onsemi | 0:098463de4c5d | 186 | |
group-onsemi | 0:098463de4c5d | 187 | # Write summary of the builds |
group-onsemi | 0:098463de4c5d | 188 | if options.report_build_file_name: |
group-onsemi | 0:098463de4c5d | 189 | file_report_exporter = ReportExporter(ResultExporterType.JUNIT, package="build") |
group-onsemi | 0:098463de4c5d | 190 | file_report_exporter.report_to_file(build_report, options.report_build_file_name, test_suite_properties=build_properties) |
group-onsemi | 0:098463de4c5d | 191 | |
group-onsemi | 0:098463de4c5d | 192 | print "\n\nCompleted in: (%.2f)s" % (time() - start) |
group-onsemi | 0:098463de4c5d | 193 | |
group-onsemi | 0:098463de4c5d | 194 | print_report_exporter = ReportExporter(ResultExporterType.PRINT, package="build") |
group-onsemi | 0:098463de4c5d | 195 | status = print_report_exporter.report(build_report) |
group-onsemi | 0:098463de4c5d | 196 | |
group-onsemi | 0:098463de4c5d | 197 | if not status: |
group-onsemi | 0:098463de4c5d | 198 | sys.exit(1) |