takashi kadono
/
Nucleo446_SSD1331
Color Oled(SSD1331) connect to STMicroelectronics Nucleo-F466
mbed-os/tools/build.py@3:f3764f852aa8, 2018-10-11 (annotated)
- Committer:
- kadonotakashi
- Date:
- Thu Oct 11 02:27:46 2018 +0000
- Revision:
- 3:f3764f852aa8
- Parent:
- 0:8fdf9a60065b
Nucreo 446 + SSD1331 test version;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kadonotakashi | 0:8fdf9a60065b | 1 | #! /usr/bin/env python2 |
kadonotakashi | 0:8fdf9a60065b | 2 | """ |
kadonotakashi | 0:8fdf9a60065b | 3 | mbed SDK |
kadonotakashi | 0:8fdf9a60065b | 4 | Copyright (c) 2011-2013 ARM Limited |
kadonotakashi | 0:8fdf9a60065b | 5 | |
kadonotakashi | 0:8fdf9a60065b | 6 | Licensed under the Apache License, Version 2.0 (the "License"); |
kadonotakashi | 0:8fdf9a60065b | 7 | you may not use this file except in compliance with the License. |
kadonotakashi | 0:8fdf9a60065b | 8 | You may obtain a copy of the License at |
kadonotakashi | 0:8fdf9a60065b | 9 | |
kadonotakashi | 0:8fdf9a60065b | 10 | http://www.apache.org/licenses/LICENSE-2.0 |
kadonotakashi | 0:8fdf9a60065b | 11 | |
kadonotakashi | 0:8fdf9a60065b | 12 | Unless required by applicable law or agreed to in writing, software |
kadonotakashi | 0:8fdf9a60065b | 13 | distributed under the License is distributed on an "AS IS" BASIS, |
kadonotakashi | 0:8fdf9a60065b | 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
kadonotakashi | 0:8fdf9a60065b | 15 | See the License for the specific language governing permissions and |
kadonotakashi | 0:8fdf9a60065b | 16 | limitations under the License. |
kadonotakashi | 0:8fdf9a60065b | 17 | |
kadonotakashi | 0:8fdf9a60065b | 18 | LIBRARIES BUILD |
kadonotakashi | 0:8fdf9a60065b | 19 | """ |
kadonotakashi | 0:8fdf9a60065b | 20 | from __future__ import print_function, division, absolute_import |
kadonotakashi | 0:8fdf9a60065b | 21 | |
kadonotakashi | 0:8fdf9a60065b | 22 | import sys |
kadonotakashi | 0:8fdf9a60065b | 23 | from time import time |
kadonotakashi | 0:8fdf9a60065b | 24 | from os.path import join, abspath, dirname |
kadonotakashi | 0:8fdf9a60065b | 25 | |
kadonotakashi | 0:8fdf9a60065b | 26 | |
kadonotakashi | 0:8fdf9a60065b | 27 | # Be sure that the tools directory is in the search path |
kadonotakashi | 0:8fdf9a60065b | 28 | ROOT = abspath(join(dirname(__file__), "..")) |
kadonotakashi | 0:8fdf9a60065b | 29 | sys.path.insert(0, ROOT) |
kadonotakashi | 0:8fdf9a60065b | 30 | |
kadonotakashi | 0:8fdf9a60065b | 31 | |
kadonotakashi | 0:8fdf9a60065b | 32 | from tools.toolchains import TOOLCHAINS, TOOLCHAIN_CLASSES, TOOLCHAIN_PATHS |
kadonotakashi | 0:8fdf9a60065b | 33 | from tools.toolchains import mbedToolchain |
kadonotakashi | 0:8fdf9a60065b | 34 | from tools.targets import TARGET_NAMES, TARGET_MAP |
kadonotakashi | 0:8fdf9a60065b | 35 | from tools.options import get_default_options_parser |
kadonotakashi | 0:8fdf9a60065b | 36 | from tools.options import extract_profile |
kadonotakashi | 0:8fdf9a60065b | 37 | from tools.options import extract_mcus |
kadonotakashi | 0:8fdf9a60065b | 38 | from tools.build_api import build_library, build_mbed_libs, build_lib |
kadonotakashi | 0:8fdf9a60065b | 39 | from tools.build_api import mcu_toolchain_matrix |
kadonotakashi | 0:8fdf9a60065b | 40 | from tools.build_api import print_build_results |
kadonotakashi | 0:8fdf9a60065b | 41 | from tools.settings import CPPCHECK_CMD, CPPCHECK_MSG_FORMAT |
kadonotakashi | 0:8fdf9a60065b | 42 | from tools.settings import CPPCHECK_CMD, CPPCHECK_MSG_FORMAT, CLI_COLOR_MAP |
kadonotakashi | 0:8fdf9a60065b | 43 | from tools.notifier.term import TerminalNotifier |
kadonotakashi | 0:8fdf9a60065b | 44 | from tools.utils import argparse_filestring_type, args_error, argparse_many |
kadonotakashi | 0:8fdf9a60065b | 45 | from tools.utils import argparse_filestring_type, argparse_dir_not_parent |
kadonotakashi | 0:8fdf9a60065b | 46 | |
kadonotakashi | 0:8fdf9a60065b | 47 | if __name__ == '__main__': |
kadonotakashi | 0:8fdf9a60065b | 48 | start = time() |
kadonotakashi | 0:8fdf9a60065b | 49 | |
kadonotakashi | 0:8fdf9a60065b | 50 | # Parse Options |
kadonotakashi | 0:8fdf9a60065b | 51 | parser = get_default_options_parser() |
kadonotakashi | 0:8fdf9a60065b | 52 | |
kadonotakashi | 0:8fdf9a60065b | 53 | parser.add_argument("--source", dest="source_dir", type=argparse_filestring_type, |
kadonotakashi | 0:8fdf9a60065b | 54 | default=None, help="The source (input) directory", action="append") |
kadonotakashi | 0:8fdf9a60065b | 55 | |
kadonotakashi | 0:8fdf9a60065b | 56 | parser.add_argument("--build", dest="build_dir", type=argparse_dir_not_parent(ROOT), |
kadonotakashi | 0:8fdf9a60065b | 57 | default=None, help="The build (output) directory") |
kadonotakashi | 0:8fdf9a60065b | 58 | |
kadonotakashi | 0:8fdf9a60065b | 59 | parser.add_argument("--no-archive", dest="no_archive", action="store_true", |
kadonotakashi | 0:8fdf9a60065b | 60 | default=False, help="Do not produce archive (.ar) file, but rather .o") |
kadonotakashi | 0:8fdf9a60065b | 61 | |
kadonotakashi | 0:8fdf9a60065b | 62 | # Extra libraries |
kadonotakashi | 0:8fdf9a60065b | 63 | parser.add_argument("-r", "--rtos", |
kadonotakashi | 0:8fdf9a60065b | 64 | action="store_true", |
kadonotakashi | 0:8fdf9a60065b | 65 | dest="rtos", |
kadonotakashi | 0:8fdf9a60065b | 66 | default=False, |
kadonotakashi | 0:8fdf9a60065b | 67 | help="Compile the rtos") |
kadonotakashi | 0:8fdf9a60065b | 68 | |
kadonotakashi | 0:8fdf9a60065b | 69 | parser.add_argument("--rpc", |
kadonotakashi | 0:8fdf9a60065b | 70 | action="store_true", |
kadonotakashi | 0:8fdf9a60065b | 71 | dest="rpc", |
kadonotakashi | 0:8fdf9a60065b | 72 | default=False, |
kadonotakashi | 0:8fdf9a60065b | 73 | help="Compile the rpc library") |
kadonotakashi | 0:8fdf9a60065b | 74 | |
kadonotakashi | 0:8fdf9a60065b | 75 | parser.add_argument("-u", "--usb", |
kadonotakashi | 0:8fdf9a60065b | 76 | action="store_true", |
kadonotakashi | 0:8fdf9a60065b | 77 | dest="usb", |
kadonotakashi | 0:8fdf9a60065b | 78 | default=False, |
kadonotakashi | 0:8fdf9a60065b | 79 | help="Compile the USB Device library") |
kadonotakashi | 0:8fdf9a60065b | 80 | |
kadonotakashi | 0:8fdf9a60065b | 81 | parser.add_argument("-d", "--dsp", |
kadonotakashi | 0:8fdf9a60065b | 82 | action="store_true", |
kadonotakashi | 0:8fdf9a60065b | 83 | dest="dsp", |
kadonotakashi | 0:8fdf9a60065b | 84 | default=False, |
kadonotakashi | 0:8fdf9a60065b | 85 | help="Compile the DSP library") |
kadonotakashi | 0:8fdf9a60065b | 86 | |
kadonotakashi | 0:8fdf9a60065b | 87 | parser.add_argument( "--cpputest", |
kadonotakashi | 0:8fdf9a60065b | 88 | action="store_true", |
kadonotakashi | 0:8fdf9a60065b | 89 | dest="cpputest_lib", |
kadonotakashi | 0:8fdf9a60065b | 90 | default=False, |
kadonotakashi | 0:8fdf9a60065b | 91 | help="Compiles 'cpputest' unit test library (library should be on the same directory level as mbed repository)") |
kadonotakashi | 0:8fdf9a60065b | 92 | |
kadonotakashi | 0:8fdf9a60065b | 93 | parser.add_argument("-D", |
kadonotakashi | 0:8fdf9a60065b | 94 | action="append", |
kadonotakashi | 0:8fdf9a60065b | 95 | dest="macros", |
kadonotakashi | 0:8fdf9a60065b | 96 | help="Add a macro definition") |
kadonotakashi | 0:8fdf9a60065b | 97 | |
kadonotakashi | 0:8fdf9a60065b | 98 | parser.add_argument("-S", "--supported-toolchains", |
kadonotakashi | 0:8fdf9a60065b | 99 | action="store_true", |
kadonotakashi | 0:8fdf9a60065b | 100 | dest="supported_toolchains", |
kadonotakashi | 0:8fdf9a60065b | 101 | default=False, |
kadonotakashi | 0:8fdf9a60065b | 102 | help="Displays supported matrix of MCUs and toolchains") |
kadonotakashi | 0:8fdf9a60065b | 103 | |
kadonotakashi | 0:8fdf9a60065b | 104 | parser.add_argument('-f', '--filter', |
kadonotakashi | 0:8fdf9a60065b | 105 | dest='general_filter_regex', |
kadonotakashi | 0:8fdf9a60065b | 106 | default=None, |
kadonotakashi | 0:8fdf9a60065b | 107 | help='For some commands you can use filter to filter out results') |
kadonotakashi | 0:8fdf9a60065b | 108 | |
kadonotakashi | 0:8fdf9a60065b | 109 | parser.add_argument("-j", "--jobs", type=int, dest="jobs", |
kadonotakashi | 0:8fdf9a60065b | 110 | default=0, help="Number of concurrent jobs. Default: 0/auto (based on host machine's number of CPUs)") |
kadonotakashi | 0:8fdf9a60065b | 111 | parser.add_argument("-N", "--artifact-name", dest="artifact_name", |
kadonotakashi | 0:8fdf9a60065b | 112 | default=None, help="The built project's name") |
kadonotakashi | 0:8fdf9a60065b | 113 | |
kadonotakashi | 0:8fdf9a60065b | 114 | parser.add_argument("-v", "--verbose", |
kadonotakashi | 0:8fdf9a60065b | 115 | action="store_true", |
kadonotakashi | 0:8fdf9a60065b | 116 | dest="verbose", |
kadonotakashi | 0:8fdf9a60065b | 117 | default=False, |
kadonotakashi | 0:8fdf9a60065b | 118 | help="Verbose diagnostic output") |
kadonotakashi | 0:8fdf9a60065b | 119 | |
kadonotakashi | 0:8fdf9a60065b | 120 | parser.add_argument("--silent", |
kadonotakashi | 0:8fdf9a60065b | 121 | action="store_true", |
kadonotakashi | 0:8fdf9a60065b | 122 | dest="silent", |
kadonotakashi | 0:8fdf9a60065b | 123 | default=False, |
kadonotakashi | 0:8fdf9a60065b | 124 | help="Silent diagnostic output (no copy, compile notification)") |
kadonotakashi | 0:8fdf9a60065b | 125 | |
kadonotakashi | 0:8fdf9a60065b | 126 | parser.add_argument("-x", "--extra-verbose-notifications", |
kadonotakashi | 0:8fdf9a60065b | 127 | action="store_true", |
kadonotakashi | 0:8fdf9a60065b | 128 | dest="extra_verbose_notify", |
kadonotakashi | 0:8fdf9a60065b | 129 | default=False, |
kadonotakashi | 0:8fdf9a60065b | 130 | help="Makes compiler more verbose, CI friendly.") |
kadonotakashi | 0:8fdf9a60065b | 131 | |
kadonotakashi | 0:8fdf9a60065b | 132 | parser.add_argument("--ignore", dest="ignore", type=argparse_many(str), |
kadonotakashi | 0:8fdf9a60065b | 133 | default=None, help="Comma separated list of patterns to add to mbedignore (eg. ./main.cpp)") |
kadonotakashi | 0:8fdf9a60065b | 134 | |
kadonotakashi | 0:8fdf9a60065b | 135 | options = parser.parse_args() |
kadonotakashi | 0:8fdf9a60065b | 136 | |
kadonotakashi | 0:8fdf9a60065b | 137 | # Only prints matrix of supported toolchains |
kadonotakashi | 0:8fdf9a60065b | 138 | if options.supported_toolchains: |
kadonotakashi | 0:8fdf9a60065b | 139 | print(mcu_toolchain_matrix(platform_filter=options.general_filter_regex)) |
kadonotakashi | 0:8fdf9a60065b | 140 | exit(0) |
kadonotakashi | 0:8fdf9a60065b | 141 | |
kadonotakashi | 0:8fdf9a60065b | 142 | |
kadonotakashi | 0:8fdf9a60065b | 143 | # Get target list |
kadonotakashi | 0:8fdf9a60065b | 144 | targets = extract_mcus(parser, options) if options.mcu else TARGET_NAMES |
kadonotakashi | 0:8fdf9a60065b | 145 | |
kadonotakashi | 0:8fdf9a60065b | 146 | # Get toolchains list |
kadonotakashi | 0:8fdf9a60065b | 147 | toolchains = options.tool if options.tool else TOOLCHAINS |
kadonotakashi | 0:8fdf9a60065b | 148 | |
kadonotakashi | 0:8fdf9a60065b | 149 | if options.source_dir and not options.build_dir: |
kadonotakashi | 0:8fdf9a60065b | 150 | args_error(parser, "argument --build is required by argument --source") |
kadonotakashi | 0:8fdf9a60065b | 151 | |
kadonotakashi | 0:8fdf9a60065b | 152 | |
kadonotakashi | 0:8fdf9a60065b | 153 | # Get libraries list |
kadonotakashi | 0:8fdf9a60065b | 154 | libraries = [] |
kadonotakashi | 0:8fdf9a60065b | 155 | |
kadonotakashi | 0:8fdf9a60065b | 156 | # Additional Libraries |
kadonotakashi | 0:8fdf9a60065b | 157 | if options.rpc: |
kadonotakashi | 0:8fdf9a60065b | 158 | libraries.extend(["rpc"]) |
kadonotakashi | 0:8fdf9a60065b | 159 | if options.usb: |
kadonotakashi | 0:8fdf9a60065b | 160 | libraries.append("usb") |
kadonotakashi | 0:8fdf9a60065b | 161 | if options.dsp: |
kadonotakashi | 0:8fdf9a60065b | 162 | libraries.extend(["dsp"]) |
kadonotakashi | 0:8fdf9a60065b | 163 | if options.cpputest_lib: |
kadonotakashi | 0:8fdf9a60065b | 164 | libraries.extend(["cpputest"]) |
kadonotakashi | 0:8fdf9a60065b | 165 | |
kadonotakashi | 0:8fdf9a60065b | 166 | # Build results |
kadonotakashi | 0:8fdf9a60065b | 167 | failures = [] |
kadonotakashi | 0:8fdf9a60065b | 168 | successes = [] |
kadonotakashi | 0:8fdf9a60065b | 169 | skipped = [] |
kadonotakashi | 0:8fdf9a60065b | 170 | |
kadonotakashi | 0:8fdf9a60065b | 171 | for toolchain in toolchains: |
kadonotakashi | 0:8fdf9a60065b | 172 | if not TOOLCHAIN_CLASSES[toolchain].check_executable(): |
kadonotakashi | 0:8fdf9a60065b | 173 | search_path = TOOLCHAIN_PATHS[toolchain] or "No path set" |
kadonotakashi | 0:8fdf9a60065b | 174 | args_error(parser, "Could not find executable for %s.\n" |
kadonotakashi | 0:8fdf9a60065b | 175 | "Currently set search path: %s" |
kadonotakashi | 0:8fdf9a60065b | 176 | % (toolchain, search_path)) |
kadonotakashi | 0:8fdf9a60065b | 177 | |
kadonotakashi | 0:8fdf9a60065b | 178 | for toolchain in toolchains: |
kadonotakashi | 0:8fdf9a60065b | 179 | for target in targets: |
kadonotakashi | 0:8fdf9a60065b | 180 | tt_id = "%s::%s" % (toolchain, target) |
kadonotakashi | 0:8fdf9a60065b | 181 | if toolchain not in TARGET_MAP[target].supported_toolchains: |
kadonotakashi | 0:8fdf9a60065b | 182 | # Log this later |
kadonotakashi | 0:8fdf9a60065b | 183 | print("%s skipped: toolchain not supported" % tt_id) |
kadonotakashi | 0:8fdf9a60065b | 184 | skipped.append(tt_id) |
kadonotakashi | 0:8fdf9a60065b | 185 | else: |
kadonotakashi | 0:8fdf9a60065b | 186 | try: |
kadonotakashi | 0:8fdf9a60065b | 187 | notifier = TerminalNotifier(options.verbose, options.silent) |
kadonotakashi | 0:8fdf9a60065b | 188 | mcu = TARGET_MAP[target] |
kadonotakashi | 0:8fdf9a60065b | 189 | profile = extract_profile(parser, options, toolchain) |
kadonotakashi | 0:8fdf9a60065b | 190 | if options.source_dir: |
kadonotakashi | 0:8fdf9a60065b | 191 | lib_build_res = build_library( |
kadonotakashi | 0:8fdf9a60065b | 192 | options.source_dir, options.build_dir, mcu, toolchain, |
kadonotakashi | 0:8fdf9a60065b | 193 | jobs=options.jobs, |
kadonotakashi | 0:8fdf9a60065b | 194 | clean=options.clean, |
kadonotakashi | 0:8fdf9a60065b | 195 | archive=(not options.no_archive), |
kadonotakashi | 0:8fdf9a60065b | 196 | macros=options.macros, |
kadonotakashi | 0:8fdf9a60065b | 197 | name=options.artifact_name, |
kadonotakashi | 0:8fdf9a60065b | 198 | build_profile=profile, |
kadonotakashi | 0:8fdf9a60065b | 199 | ignore=options.ignore, |
kadonotakashi | 0:8fdf9a60065b | 200 | notify = notifier, |
kadonotakashi | 0:8fdf9a60065b | 201 | ) |
kadonotakashi | 0:8fdf9a60065b | 202 | else: |
kadonotakashi | 0:8fdf9a60065b | 203 | lib_build_res = build_mbed_libs( |
kadonotakashi | 0:8fdf9a60065b | 204 | mcu, toolchain, |
kadonotakashi | 0:8fdf9a60065b | 205 | jobs=options.jobs, |
kadonotakashi | 0:8fdf9a60065b | 206 | clean=options.clean, |
kadonotakashi | 0:8fdf9a60065b | 207 | macros=options.macros, |
kadonotakashi | 0:8fdf9a60065b | 208 | build_profile=profile, |
kadonotakashi | 0:8fdf9a60065b | 209 | ignore=options.ignore, |
kadonotakashi | 0:8fdf9a60065b | 210 | notify=notifier, |
kadonotakashi | 0:8fdf9a60065b | 211 | ) |
kadonotakashi | 0:8fdf9a60065b | 212 | |
kadonotakashi | 0:8fdf9a60065b | 213 | for lib_id in libraries: |
kadonotakashi | 0:8fdf9a60065b | 214 | build_lib( |
kadonotakashi | 0:8fdf9a60065b | 215 | lib_id, mcu, toolchain, |
kadonotakashi | 0:8fdf9a60065b | 216 | clean=options.clean, |
kadonotakashi | 0:8fdf9a60065b | 217 | macros=options.macros, |
kadonotakashi | 0:8fdf9a60065b | 218 | jobs=options.jobs, |
kadonotakashi | 0:8fdf9a60065b | 219 | build_profile=profile, |
kadonotakashi | 0:8fdf9a60065b | 220 | ignore=options.ignore, |
kadonotakashi | 0:8fdf9a60065b | 221 | ) |
kadonotakashi | 0:8fdf9a60065b | 222 | if lib_build_res: |
kadonotakashi | 0:8fdf9a60065b | 223 | successes.append(tt_id) |
kadonotakashi | 0:8fdf9a60065b | 224 | else: |
kadonotakashi | 0:8fdf9a60065b | 225 | skipped.append(tt_id) |
kadonotakashi | 0:8fdf9a60065b | 226 | except Exception as e: |
kadonotakashi | 0:8fdf9a60065b | 227 | if options.verbose: |
kadonotakashi | 0:8fdf9a60065b | 228 | import traceback |
kadonotakashi | 0:8fdf9a60065b | 229 | traceback.print_exc(file=sys.stdout) |
kadonotakashi | 0:8fdf9a60065b | 230 | sys.exit(1) |
kadonotakashi | 0:8fdf9a60065b | 231 | failures.append(tt_id) |
kadonotakashi | 0:8fdf9a60065b | 232 | print(e) |
kadonotakashi | 0:8fdf9a60065b | 233 | |
kadonotakashi | 0:8fdf9a60065b | 234 | # Write summary of the builds |
kadonotakashi | 0:8fdf9a60065b | 235 | print("\nCompleted in: (%.2f)s\n" % (time() - start)) |
kadonotakashi | 0:8fdf9a60065b | 236 | |
kadonotakashi | 0:8fdf9a60065b | 237 | for report, report_name in [(successes, "Build successes:"), |
kadonotakashi | 0:8fdf9a60065b | 238 | (skipped, "Build skipped:"), |
kadonotakashi | 0:8fdf9a60065b | 239 | (failures, "Build failures:"), |
kadonotakashi | 0:8fdf9a60065b | 240 | ]: |
kadonotakashi | 0:8fdf9a60065b | 241 | if report: |
kadonotakashi | 0:8fdf9a60065b | 242 | print(print_build_results(report, report_name)) |
kadonotakashi | 0:8fdf9a60065b | 243 | |
kadonotakashi | 0:8fdf9a60065b | 244 | if failures: |
kadonotakashi | 0:8fdf9a60065b | 245 | sys.exit(1) |