Clone of official tools

Committer:
The Other Jimmy
Date:
Wed Feb 15 13:53:18 2017 -0600
Revision:
35:da9c89f8be7d
Parent:
34:42f20e28adf5
Child:
36:96847d42f010
Update tools to mbed-os 5.3.5

Who changed what in which revision?

UserRevisionLine numberNew contents of line
screamer 14:ee1b877e6839 1 """
screamer 14:ee1b877e6839 2 mbed SDK
screamer 14:ee1b877e6839 3 Copyright (c) 2011-2013 ARM Limited
screamer 14:ee1b877e6839 4
screamer 14:ee1b877e6839 5 Licensed under the Apache License, Version 2.0 (the "License");
screamer 14:ee1b877e6839 6 you may not use this file except in compliance with the License.
screamer 14:ee1b877e6839 7 You may obtain a copy of the License at
screamer 14:ee1b877e6839 8
screamer 14:ee1b877e6839 9 http://www.apache.org/licenses/LICENSE-2.0
screamer 14:ee1b877e6839 10
screamer 14:ee1b877e6839 11 Unless required by applicable law or agreed to in writing, software
screamer 14:ee1b877e6839 12 distributed under the License is distributed on an "AS IS" BASIS,
screamer 14:ee1b877e6839 13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
screamer 14:ee1b877e6839 14 See the License for the specific language governing permissions and
screamer 14:ee1b877e6839 15 limitations under the License.
screamer 14:ee1b877e6839 16 """
screamer 14:ee1b877e6839 17
screamer 14:ee1b877e6839 18 import re
screamer 14:ee1b877e6839 19 import tempfile
screamer 14:ee1b877e6839 20 import colorama
screamer 14:ee1b877e6839 21
screamer 14:ee1b877e6839 22 from copy import copy
screamer 24:25bff2709c20 23 from os.path import join, abspath, exists
screamer 14:ee1b877e6839 24 from os import walk
screamer 14:ee1b877e6839 25 import fnmatch
screamer 14:ee1b877e6839 26
screamer 14:ee1b877e6839 27
screamer 14:ee1b877e6839 28 def get_toolchain_profile(toolchain, profile):
screamer 14:ee1b877e6839 29 if profile and (TOOLCHAIN_PROFILES.get(toolchain, None) and
screamer 14:ee1b877e6839 30 TOOLCHAIN_PROFILES[toolchain].get(profile)):
screamer 14:ee1b877e6839 31 return TOOLCHAIN_PROFILES[toolchain].get(profile)
screamer 14:ee1b877e6839 32
screamer 14:ee1b877e6839 33 def find_build_profile(path):
screamer 14:ee1b877e6839 34 profile = None
screamer 14:ee1b877e6839 35 builds = find_build_ids(path)
screamer 14:ee1b877e6839 36 for build in builds:
screamer 14:ee1b877e6839 37 if MBED_SDK_REV_MAP.has_key(build):
screamer 14:ee1b877e6839 38 idx = MBED_SDK_REV_MAP[build]
screamer 14:ee1b877e6839 39
screamer 14:ee1b877e6839 40 if idx <= 43:
screamer 14:ee1b877e6839 41 profile = 'v1'
screamer 14:ee1b877e6839 42 elif idx <= 68:
screamer 14:ee1b877e6839 43 profile = 'v2'
screamer 14:ee1b877e6839 44 elif idx <= 76:
screamer 14:ee1b877e6839 45 profile = 'v3'
screamer 14:ee1b877e6839 46 elif idx <= 105:
screamer 14:ee1b877e6839 47 profile = 'v4'
The Other Jimmy 33:c8effba9595f 48 elif idx <= 135:
screamer 14:ee1b877e6839 49 profile = 'v5'
screamer 14:ee1b877e6839 50
screamer 14:ee1b877e6839 51 return profile
screamer 14:ee1b877e6839 52
screamer 14:ee1b877e6839 53 def find_build_ids(path):
screamer 14:ee1b877e6839 54 builds = []
screamer 14:ee1b877e6839 55
screamer 14:ee1b877e6839 56 for (root, dirs, files) in walk(path):
screamer 14:ee1b877e6839 57 for d in copy(dirs):
screamer 14:ee1b877e6839 58 if d.startswith('.'):
screamer 14:ee1b877e6839 59 dirs.remove(d)
screamer 14:ee1b877e6839 60
screamer 14:ee1b877e6839 61 for filename in filter(lambda s: s.endswith(".bld"), files):
screamer 14:ee1b877e6839 62 try:
screamer 14:ee1b877e6839 63 # TODO check user has permission to link against build
screamer 14:ee1b877e6839 64 url = open(join(root, filename), 'r').read().strip()
screamer 14:ee1b877e6839 65 builds.append(re.sub(r'^.+/(.*?)$', r'\1', url))
screamer 14:ee1b877e6839 66 except:
screamer 14:ee1b877e6839 67 pass
screamer 14:ee1b877e6839 68
screamer 14:ee1b877e6839 69 return builds
screamer 14:ee1b877e6839 70
screamer 14:ee1b877e6839 71
screamer 24:25bff2709c20 72 def find_targets_json(path, depth=1):
screamer 24:25bff2709c20 73 f = 'targets.json'
screamer 24:25bff2709c20 74 if exists(join(path, f)):
screamer 24:25bff2709c20 75 return os.path.abspath(join(path, f))
screamer 24:25bff2709c20 76
screamer 24:25bff2709c20 77 if depth > 2:
screamer 24:25bff2709c20 78 return None
screamer 24:25bff2709c20 79
screamer 24:25bff2709c20 80 for root, dirs, files in walk(path):
screamer 24:25bff2709c20 81 for d in copy(dirs):
screamer 24:25bff2709c20 82 if d.startswith('.'):
screamer 24:25bff2709c20 83 dirs.remove(d)
The Other Jimmy 34:42f20e28adf5 84 continue
screamer 24:25bff2709c20 85
screamer 24:25bff2709c20 86 if exists(join(root, d, f)):
screamer 24:25bff2709c20 87 return abspath(join(root, d, f))
screamer 24:25bff2709c20 88 else:
screamer 24:25bff2709c20 89 found = find_targets_json(join(root, d), depth+1)
screamer 24:25bff2709c20 90 if found:
screamer 24:25bff2709c20 91 return found
screamer 24:25bff2709c20 92
screamer 24:25bff2709c20 93 return None
screamer 24:25bff2709c20 94
screamer 24:25bff2709c20 95
screamer 14:ee1b877e6839 96 # Toolchain profiles for backward compatibility with old mbed SDK library releases
screamer 14:ee1b877e6839 97 TOOLCHAIN_PROFILES = {
screamer 14:ee1b877e6839 98 'ARM_STD' : {
screamer 14:ee1b877e6839 99 'v5': {
screamer 14:ee1b877e6839 100 'version': '5.06',
screamer 14:ee1b877e6839 101 'common': ['-c', '--gnu', '-O3', '-Otime', '--split_sections', '--apcs=interwork'],
screamer 14:ee1b877e6839 102 'cxx': ['--cpp', '--no_rtti'],
screamer 14:ee1b877e6839 103 'COMPILE_C_AS_CPP': False,
screamer 14:ee1b877e6839 104 },
screamer 14:ee1b877e6839 105 'v4': {
screamer 14:ee1b877e6839 106 'version': '5.03',
screamer 14:ee1b877e6839 107 'common': ['-c', '--gnu', '-O3', '-Otime', '--split_sections', '--apcs=interwork'],
screamer 14:ee1b877e6839 108 'cxx': ['--cpp', '--no_rtti'],
screamer 14:ee1b877e6839 109 'COMPILE_C_AS_CPP': False,
screamer 14:ee1b877e6839 110 },
screamer 14:ee1b877e6839 111 'v3': {
screamer 14:ee1b877e6839 112 'version': '5.01',
screamer 14:ee1b877e6839 113 'common': ['-c', '--gnu', '-Ospace', '--split_sections', '--apcs=interwork'],
screamer 14:ee1b877e6839 114 'cxx': ['--cpp', '--no_rtti'],
screamer 14:ee1b877e6839 115 'COMPILE_C_AS_CPP': False,
screamer 14:ee1b877e6839 116 },
screamer 14:ee1b877e6839 117 'v2': {
screamer 14:ee1b877e6839 118 'version': '5.01',
screamer 14:ee1b877e6839 119 'common': ['-c', '--gnu', '-Ospace', '--split_sections', '--apcs=interwork'],
screamer 14:ee1b877e6839 120 'cxx': ['--cpp', '--no_rtti'],
screamer 14:ee1b877e6839 121 'COMPILE_C_AS_CPP': False,
screamer 14:ee1b877e6839 122 },
screamer 14:ee1b877e6839 123 'v1': {
screamer 14:ee1b877e6839 124 'version': '4',
screamer 14:ee1b877e6839 125 'common': ['-c', '--gnu', '-Otime', '--split_sections', '--apcs=interwork'],
screamer 14:ee1b877e6839 126 'cxx': ['--cpp'],
screamer 14:ee1b877e6839 127 'COMPILE_C_AS_CPP': True,
screamer 14:ee1b877e6839 128 }
screamer 14:ee1b877e6839 129 },
screamer 14:ee1b877e6839 130 'ARM_MICRO' : {
screamer 14:ee1b877e6839 131 'v5': {
screamer 14:ee1b877e6839 132 'version': '5.06',
screamer 14:ee1b877e6839 133 'common': ['-c', '--gnu', '-O3', '-Otime', '--split_sections', '--apcs=interwork'],
screamer 14:ee1b877e6839 134 'cxx': ['--cpp', '--no_rtti'],
screamer 14:ee1b877e6839 135 },
screamer 14:ee1b877e6839 136 'v4': {
screamer 14:ee1b877e6839 137 'version': '5.03',
screamer 14:ee1b877e6839 138 'common': ['-c', '--gnu', '-O3', '-Otime', '--split_sections', '--apcs=interwork'],
screamer 14:ee1b877e6839 139 'cxx': ['--cpp', '--no_rtti'],
screamer 14:ee1b877e6839 140 },
screamer 14:ee1b877e6839 141 'v3': {
screamer 14:ee1b877e6839 142 'version': '5.01',
screamer 14:ee1b877e6839 143 'common': ['-c', '--gnu', '-Ospace', '--split_sections', '--apcs=interwork'],
screamer 14:ee1b877e6839 144 'cxx': ['--cpp', '--no_rtti'],
screamer 14:ee1b877e6839 145 },
screamer 14:ee1b877e6839 146 'v2': {
screamer 14:ee1b877e6839 147 'version': '4',
screamer 14:ee1b877e6839 148 'common': ['-c', '--gnu', '-Ospace', '--split_sections', '--apcs=interwork'],
screamer 14:ee1b877e6839 149 'cxx': ['--cpp', '--no_rtti'],
screamer 14:ee1b877e6839 150 'PATCHED_LIBRARY' : True,
screamer 14:ee1b877e6839 151 },
screamer 14:ee1b877e6839 152 'v1': {
screamer 14:ee1b877e6839 153 'version': '4.1',
screamer 14:ee1b877e6839 154 'common': ['-c', '--gnu', '-Otime', '--split_sections', '--apcs=interwork'],
screamer 14:ee1b877e6839 155 'cxx': ['--cpp'],
screamer 14:ee1b877e6839 156 'COMPILE_C_AS_CPP': True,
screamer 14:ee1b877e6839 157 'PATCHED_LIBRARY' : True,
screamer 14:ee1b877e6839 158 }
screamer 14:ee1b877e6839 159 },
screamer 14:ee1b877e6839 160 'GCC_ARM' : {
screamer 14:ee1b877e6839 161 'v5': {
screamer 14:ee1b877e6839 162 'ld': ['-Wl,--gc-sections', '-Wl,--wrap,main'],
screamer 14:ee1b877e6839 163 },
screamer 15:cd36228f7d73 164 'v4': {
screamer 15:cd36228f7d73 165 'ld': ['-Wl,--gc-sections', '-Wl,--wrap,main'],
screamer 15:cd36228f7d73 166 },
screamer 15:cd36228f7d73 167 'v3': {
screamer 15:cd36228f7d73 168 'ld': ['-Wl,--gc-sections', '-Wl,--wrap,main'],
screamer 15:cd36228f7d73 169 },
screamer 14:ee1b877e6839 170 'v2': {
screamer 14:ee1b877e6839 171 'common': ["-c", "-Wall", "-fmessage-length=0", "-fno-exceptions", "-fno-builtin", "-ffunction-sections", "-fdata-sections"],
screamer 14:ee1b877e6839 172 'cxx': ['-std=gnu++98'],
screamer 14:ee1b877e6839 173 'ld': ['-Wl,--gc-sections'],
screamer 14:ee1b877e6839 174 },
screamer 14:ee1b877e6839 175 'v1': {
screamer 14:ee1b877e6839 176 'common': ["-c", "-Wall", "-fmessage-length=0", "-fno-exceptions", "-fno-builtin", "-ffunction-sections", "-fdata-sections"],
screamer 14:ee1b877e6839 177 'cxx': ['-std=gnu++98'],
screamer 14:ee1b877e6839 178 'ld': ['-Wl,--gc-sections'],
screamer 14:ee1b877e6839 179 }
screamer 14:ee1b877e6839 180 }
screamer 14:ee1b877e6839 181 }
screamer 14:ee1b877e6839 182
screamer 14:ee1b877e6839 183 MBED_SDK_REV_MAP = {
The Other Jimmy 33:c8effba9595f 184 '6f4d9ba055b3': 122,
The Other Jimmy 33:c8effba9595f 185 'c1a077c0ccc5': 123,
The Other Jimmy 33:c8effba9595f 186 'f1e13e937fab': 124,
The Other Jimmy 33:c8effba9595f 187 'a974dc8aa35b': 125,
The Other Jimmy 33:c8effba9595f 188 '4132e2258101': 126,
The Other Jimmy 33:c8effba9595f 189 '62ea7dd49f26': 127,
The Other Jimmy 33:c8effba9595f 190 'e6f9c99959f3': 128,
The Other Jimmy 33:c8effba9595f 191 '31768d6a83cd': 129,
The Other Jimmy 33:c8effba9595f 192 '620374818e03': 130,
The Other Jimmy 33:c8effba9595f 193 'f4b892cad2b9': 131,
The Other Jimmy 33:c8effba9595f 194 '9c0c086c88f0': 132,
The Other Jimmy 33:c8effba9595f 195 'a1e1b8eadde3': 133,
The Other Jimmy 33:c8effba9595f 196 '1a303c31ec8f': 134,
The Other Jimmy 33:c8effba9595f 197 '0b434d521da0': 135,
The Other Jimmy 35:da9c89f8be7d 198 '2abc4044d39c': 136,
screamer 14:ee1b877e6839 199 '6c34061e7c34': 121,
screamer 14:ee1b877e6839 200 '7c328cabac7e': 120,
screamer 14:ee1b877e6839 201 'aae6fcc7d9bb': 119,
screamer 14:ee1b877e6839 202 '082adc85693f': 118,
screamer 14:ee1b877e6839 203 '99a22ba036c9': 117,
screamer 14:ee1b877e6839 204 'c0f6e94411f5': 116,
screamer 14:ee1b877e6839 205 '87f2f5183dfb': 115,
screamer 14:ee1b877e6839 206 '252557024ec3': 114,
screamer 14:ee1b877e6839 207 'f141b2784e32': 113,
screamer 14:ee1b877e6839 208 '6f327212ef96': 112,
screamer 14:ee1b877e6839 209 '4336505e4b1c': 111,
screamer 14:ee1b877e6839 210 '165afa46840b': 110,
screamer 14:ee1b877e6839 211 '9296ab0bfc11': 109,
screamer 14:ee1b877e6839 212 '34e6b704fe68': 108,
screamer 14:ee1b877e6839 213 '4f6c30876dfa': 107,
screamer 14:ee1b877e6839 214 'ba1f97679dad': 106,
screamer 14:ee1b877e6839 215 '8ed44a420e5c': 105,
screamer 14:ee1b877e6839 216 'b9ad9a133dc7': 104,
screamer 14:ee1b877e6839 217 'bad568076d81': 103,
screamer 14:ee1b877e6839 218 'da0ca467f8b5': 102,
screamer 14:ee1b877e6839 219 '7cff1c4259d7': 101,
screamer 14:ee1b877e6839 220 'cbbeb26dbd92': 100,
screamer 14:ee1b877e6839 221 'dbbf35b96557': 99,
screamer 14:ee1b877e6839 222 '8ab26030e058': 98,
screamer 14:ee1b877e6839 223 '433970e64889': 97,
screamer 14:ee1b877e6839 224 '487b796308b0': 96,
screamer 14:ee1b877e6839 225 '7e07b6fb45cf': 95,
screamer 14:ee1b877e6839 226 '9ad691361fac': 94,
screamer 14:ee1b877e6839 227 'e188a91d3eaa': 93,
screamer 14:ee1b877e6839 228 '4fc01daae5a5': 92,
screamer 14:ee1b877e6839 229 '031413cf7a89': 91,
screamer 14:ee1b877e6839 230 'cb3d968589d8': 90,
screamer 14:ee1b877e6839 231 '552587b429a1': 89,
screamer 14:ee1b877e6839 232 '9327015d4013': 88,
screamer 14:ee1b877e6839 233 '6213f644d804': 87,
screamer 14:ee1b877e6839 234 '04dd9b1680ae': 86,
screamer 14:ee1b877e6839 235 '024bf7f99721': 85,
screamer 14:ee1b877e6839 236 '0b3ab51c8877': 84,
screamer 14:ee1b877e6839 237 '8a40adfe8776': 83,
screamer 14:ee1b877e6839 238 '6473597d706e': 82,
screamer 14:ee1b877e6839 239 '7d30d6019079': 81,
screamer 14:ee1b877e6839 240 '8e73be2a2ac1': 80,
screamer 14:ee1b877e6839 241 '0c05e21ae27e': 79,
screamer 14:ee1b877e6839 242 'ed8466a608b4': 78,
screamer 14:ee1b877e6839 243 '869cf507173a': 77,
screamer 14:ee1b877e6839 244 '824293ae5e43': 76,
screamer 14:ee1b877e6839 245 'dc225afb6914': 75,
screamer 14:ee1b877e6839 246 'a842253909c9': 74,
screamer 14:ee1b877e6839 247 '1efda918f0ba': 73,
screamer 14:ee1b877e6839 248 '4096f863f923': 72,
screamer 14:ee1b877e6839 249 '8fabd470bb6e': 71,
screamer 14:ee1b877e6839 250 '673126e12c73': 70,
screamer 14:ee1b877e6839 251 '4a7918f48478': 69,
screamer 14:ee1b877e6839 252 'f37f3b9c9f0b': 68,
screamer 14:ee1b877e6839 253 'a9913a65894f': 67,
screamer 14:ee1b877e6839 254 '9c8f0e3462fb': 66,
screamer 14:ee1b877e6839 255 '5798e58a58b1': 65,
screamer 14:ee1b877e6839 256 'e3affc9e7238': 64,
screamer 14:ee1b877e6839 257 'b3110cd2dd17': 63,
screamer 14:ee1b877e6839 258 '7e6c9f46b3bd': 62,
screamer 14:ee1b877e6839 259 '5e5da4a5990b': 61,
screamer 14:ee1b877e6839 260 '3d0ef94e36ec': 60,
screamer 14:ee1b877e6839 261 '0883845fe643': 59,
screamer 14:ee1b877e6839 262 '0954ebd79f59': 58,
screamer 14:ee1b877e6839 263 '0480438fc29c': 57,
screamer 14:ee1b877e6839 264 '3753e96f3c8b': 56,
screamer 14:ee1b877e6839 265 'd722ed6a4237': 55,
screamer 14:ee1b877e6839 266 '71b101360fb9': 54,
screamer 14:ee1b877e6839 267 '63cdd78b2dc1': 53,
screamer 14:ee1b877e6839 268 '09236a68d21b': 52,
screamer 14:ee1b877e6839 269 'a076018f59af': 51,
screamer 14:ee1b877e6839 270 'b60934f96c0c': 50,
screamer 14:ee1b877e6839 271 'eeb8a2a33ec9': 49,
screamer 14:ee1b877e6839 272 '49c296715c73': 48,
screamer 14:ee1b877e6839 273 '134def52cfa0': 47,
screamer 14:ee1b877e6839 274 '890817bdcffb': 46,
screamer 14:ee1b877e6839 275 '3d775a932e1d': 45,
screamer 14:ee1b877e6839 276 '24d45a770a51': 44,
screamer 14:ee1b877e6839 277 'e2ed12d17f06': 43,
screamer 14:ee1b877e6839 278 'cd19af002ccc': 42,
screamer 14:ee1b877e6839 279 '10b9abbe79a6': 41,
screamer 14:ee1b877e6839 280 '976df7c37ad5': 40,
screamer 14:ee1b877e6839 281 '737756e0b479': 39,
screamer 14:ee1b877e6839 282 '4c0c40fd0593': 38,
screamer 14:ee1b877e6839 283 '14f4805c468c': 37,
screamer 14:ee1b877e6839 284 'b4b9f287a47e': 36,
screamer 14:ee1b877e6839 285 '5284544d04b6': 35,
screamer 14:ee1b877e6839 286 '7495d544864f': 34,
screamer 14:ee1b877e6839 287 '5364839841bd': 33,
screamer 14:ee1b877e6839 288 '3b05dd009342': 32,
screamer 14:ee1b877e6839 289 'a7ef757f598c': 31,
screamer 14:ee1b877e6839 290 '3991a86798e3': 30,
screamer 14:ee1b877e6839 291 '078e4b97a13e': 29,
screamer 14:ee1b877e6839 292 '667d61c9177b': 28,
screamer 14:ee1b877e6839 293 '7110ebee3484': 27,
screamer 14:ee1b877e6839 294 '63bcd7ba4912': 26,
screamer 14:ee1b877e6839 295 '9a9732ce53a1': 25,
screamer 14:ee1b877e6839 296 'e2ac27c8e93e': 24,
screamer 14:ee1b877e6839 297 '74b8d43b5817': 23,
screamer 14:ee1b877e6839 298 '9114680c05da': 22,
screamer 14:ee1b877e6839 299 '3944f1e2fa4f': 21,
screamer 14:ee1b877e6839 300 '029aa53d7323': 20,
screamer 14:ee1b877e6839 301 'e6be4cd80aad': 19,
screamer 14:ee1b877e6839 302 'b3c9f16cbb96': 18,
screamer 14:ee1b877e6839 303 '49a220cc26e0': 17,
screamer 14:ee1b877e6839 304 '32af5db564d4': 16,
screamer 14:ee1b877e6839 305 'd1a9de3f4fe0': 15,
screamer 14:ee1b877e6839 306 '20a79241b4a0': 14,
screamer 14:ee1b877e6839 307 'a0336ede94ce': 13,
screamer 14:ee1b877e6839 308 'f63353af7be8': 12,
screamer 14:ee1b877e6839 309 '1c1ebd0324fa': 11,
screamer 14:ee1b877e6839 310 'fcb9359f0959': 10,
screamer 14:ee1b877e6839 311 'cf0d45ce28a6': 9,
screamer 14:ee1b877e6839 312 '00a04e5cd407': 8,
screamer 14:ee1b877e6839 313 '15d74db76485': 7,
screamer 14:ee1b877e6839 314 '3fd6a337c7cc': 6,
screamer 14:ee1b877e6839 315 '62573be585e9': 5,
screamer 14:ee1b877e6839 316 '5d1359a283bc': 4,
screamer 14:ee1b877e6839 317 'aefd12a1f1c5': 3,
screamer 14:ee1b877e6839 318 '969fc1867111': 2,
screamer 14:ee1b877e6839 319 '6b7f447ca868': 1,
screamer 14:ee1b877e6839 320 '82220227f4fa': 0,
The Other Jimmy 33:c8effba9595f 321 }