Clone of official tools

Committer:
The Other Jimmy
Date:
Thu Jun 22 11:12:28 2017 -0500
Revision:
36:96847d42f010
Parent:
35:da9c89f8be7d
Tools release 5.5.1

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