Clone of official tools

Committer:
screamer
Date:
Thu Jul 14 20:37:27 2016 +0100
Revision:
14:ee1b877e6839
Child:
15:cd36228f7d73
Apply legacy build system profiles

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 14:ee1b877e6839 23 from os.path import join
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'
screamer 14:ee1b877e6839 48 elif idx <= 121:
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 14:ee1b877e6839 72 # Toolchain profiles for backward compatibility with old mbed SDK library releases
screamer 14:ee1b877e6839 73 TOOLCHAIN_PROFILES = {
screamer 14:ee1b877e6839 74 'ARM_STD' : {
screamer 14:ee1b877e6839 75 'v5': {
screamer 14:ee1b877e6839 76 'version': '5.06',
screamer 14:ee1b877e6839 77 'common': ['-c', '--gnu', '-O3', '-Otime', '--split_sections', '--apcs=interwork'],
screamer 14:ee1b877e6839 78 'cxx': ['--cpp', '--no_rtti'],
screamer 14:ee1b877e6839 79 'COMPILE_C_AS_CPP': False,
screamer 14:ee1b877e6839 80 },
screamer 14:ee1b877e6839 81 'v4': {
screamer 14:ee1b877e6839 82 'version': '5.03',
screamer 14:ee1b877e6839 83 'common': ['-c', '--gnu', '-O3', '-Otime', '--split_sections', '--apcs=interwork'],
screamer 14:ee1b877e6839 84 'cxx': ['--cpp', '--no_rtti'],
screamer 14:ee1b877e6839 85 'COMPILE_C_AS_CPP': False,
screamer 14:ee1b877e6839 86 },
screamer 14:ee1b877e6839 87 'v3': {
screamer 14:ee1b877e6839 88 'version': '5.01',
screamer 14:ee1b877e6839 89 'common': ['-c', '--gnu', '-Ospace', '--split_sections', '--apcs=interwork'],
screamer 14:ee1b877e6839 90 'cxx': ['--cpp', '--no_rtti'],
screamer 14:ee1b877e6839 91 'COMPILE_C_AS_CPP': False,
screamer 14:ee1b877e6839 92 },
screamer 14:ee1b877e6839 93 'v2': {
screamer 14:ee1b877e6839 94 'version': '5.01',
screamer 14:ee1b877e6839 95 'common': ['-c', '--gnu', '-Ospace', '--split_sections', '--apcs=interwork'],
screamer 14:ee1b877e6839 96 'cxx': ['--cpp', '--no_rtti'],
screamer 14:ee1b877e6839 97 'COMPILE_C_AS_CPP': False,
screamer 14:ee1b877e6839 98 },
screamer 14:ee1b877e6839 99 'v1': {
screamer 14:ee1b877e6839 100 'version': '4',
screamer 14:ee1b877e6839 101 'common': ['-c', '--gnu', '-Otime', '--split_sections', '--apcs=interwork'],
screamer 14:ee1b877e6839 102 'cxx': ['--cpp'],
screamer 14:ee1b877e6839 103 'COMPILE_C_AS_CPP': True,
screamer 14:ee1b877e6839 104 }
screamer 14:ee1b877e6839 105 },
screamer 14:ee1b877e6839 106 'ARM_MICRO' : {
screamer 14:ee1b877e6839 107 'v5': {
screamer 14:ee1b877e6839 108 'version': '5.06',
screamer 14:ee1b877e6839 109 'common': ['-c', '--gnu', '-O3', '-Otime', '--split_sections', '--apcs=interwork'],
screamer 14:ee1b877e6839 110 'cxx': ['--cpp', '--no_rtti'],
screamer 14:ee1b877e6839 111 },
screamer 14:ee1b877e6839 112 'v4': {
screamer 14:ee1b877e6839 113 'version': '5.03',
screamer 14:ee1b877e6839 114 'common': ['-c', '--gnu', '-O3', '-Otime', '--split_sections', '--apcs=interwork'],
screamer 14:ee1b877e6839 115 'cxx': ['--cpp', '--no_rtti'],
screamer 14:ee1b877e6839 116 },
screamer 14:ee1b877e6839 117 'v3': {
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 },
screamer 14:ee1b877e6839 122 'v2': {
screamer 14:ee1b877e6839 123 'version': '4',
screamer 14:ee1b877e6839 124 'common': ['-c', '--gnu', '-Ospace', '--split_sections', '--apcs=interwork'],
screamer 14:ee1b877e6839 125 'cxx': ['--cpp', '--no_rtti'],
screamer 14:ee1b877e6839 126 'PATCHED_LIBRARY' : True,
screamer 14:ee1b877e6839 127 },
screamer 14:ee1b877e6839 128 'v1': {
screamer 14:ee1b877e6839 129 'version': '4.1',
screamer 14:ee1b877e6839 130 'common': ['-c', '--gnu', '-Otime', '--split_sections', '--apcs=interwork'],
screamer 14:ee1b877e6839 131 'cxx': ['--cpp'],
screamer 14:ee1b877e6839 132 'COMPILE_C_AS_CPP': True,
screamer 14:ee1b877e6839 133 'PATCHED_LIBRARY' : True,
screamer 14:ee1b877e6839 134 }
screamer 14:ee1b877e6839 135 },
screamer 14:ee1b877e6839 136 'GCC_ARM' : {
screamer 14:ee1b877e6839 137 'v5': {
screamer 14:ee1b877e6839 138 'ld': ['-Wl,--gc-sections', '-Wl,--wrap,main'],
screamer 14:ee1b877e6839 139 },
screamer 14:ee1b877e6839 140 'v2': {
screamer 14:ee1b877e6839 141 'common': ["-c", "-Wall", "-fmessage-length=0", "-fno-exceptions", "-fno-builtin", "-ffunction-sections", "-fdata-sections"],
screamer 14:ee1b877e6839 142 'cxx': ['-std=gnu++98'],
screamer 14:ee1b877e6839 143 'ld': ['-Wl,--gc-sections'],
screamer 14:ee1b877e6839 144 },
screamer 14:ee1b877e6839 145 'v1': {
screamer 14:ee1b877e6839 146 'common': ["-c", "-Wall", "-fmessage-length=0", "-fno-exceptions", "-fno-builtin", "-ffunction-sections", "-fdata-sections"],
screamer 14:ee1b877e6839 147 'cxx': ['-std=gnu++98'],
screamer 14:ee1b877e6839 148 'ld': ['-Wl,--gc-sections'],
screamer 14:ee1b877e6839 149 }
screamer 14:ee1b877e6839 150 }
screamer 14:ee1b877e6839 151 }
screamer 14:ee1b877e6839 152
screamer 14:ee1b877e6839 153 MBED_SDK_REV_MAP = {
screamer 14:ee1b877e6839 154 '6c34061e7c34': 121,
screamer 14:ee1b877e6839 155 '7c328cabac7e': 120,
screamer 14:ee1b877e6839 156 'aae6fcc7d9bb': 119,
screamer 14:ee1b877e6839 157 '082adc85693f': 118,
screamer 14:ee1b877e6839 158 '99a22ba036c9': 117,
screamer 14:ee1b877e6839 159 'c0f6e94411f5': 116,
screamer 14:ee1b877e6839 160 '87f2f5183dfb': 115,
screamer 14:ee1b877e6839 161 '252557024ec3': 114,
screamer 14:ee1b877e6839 162 'f141b2784e32': 113,
screamer 14:ee1b877e6839 163 '6f327212ef96': 112,
screamer 14:ee1b877e6839 164 '4336505e4b1c': 111,
screamer 14:ee1b877e6839 165 '165afa46840b': 110,
screamer 14:ee1b877e6839 166 '9296ab0bfc11': 109,
screamer 14:ee1b877e6839 167 '34e6b704fe68': 108,
screamer 14:ee1b877e6839 168 '4f6c30876dfa': 107,
screamer 14:ee1b877e6839 169 'ba1f97679dad': 106,
screamer 14:ee1b877e6839 170 '8ed44a420e5c': 105,
screamer 14:ee1b877e6839 171 'b9ad9a133dc7': 104,
screamer 14:ee1b877e6839 172 'bad568076d81': 103,
screamer 14:ee1b877e6839 173 'da0ca467f8b5': 102,
screamer 14:ee1b877e6839 174 '7cff1c4259d7': 101,
screamer 14:ee1b877e6839 175 'cbbeb26dbd92': 100,
screamer 14:ee1b877e6839 176 'dbbf35b96557': 99,
screamer 14:ee1b877e6839 177 '8ab26030e058': 98,
screamer 14:ee1b877e6839 178 '433970e64889': 97,
screamer 14:ee1b877e6839 179 '487b796308b0': 96,
screamer 14:ee1b877e6839 180 '7e07b6fb45cf': 95,
screamer 14:ee1b877e6839 181 '9ad691361fac': 94,
screamer 14:ee1b877e6839 182 'e188a91d3eaa': 93,
screamer 14:ee1b877e6839 183 '4fc01daae5a5': 92,
screamer 14:ee1b877e6839 184 '031413cf7a89': 91,
screamer 14:ee1b877e6839 185 'cb3d968589d8': 90,
screamer 14:ee1b877e6839 186 '552587b429a1': 89,
screamer 14:ee1b877e6839 187 '9327015d4013': 88,
screamer 14:ee1b877e6839 188 '6213f644d804': 87,
screamer 14:ee1b877e6839 189 '04dd9b1680ae': 86,
screamer 14:ee1b877e6839 190 '024bf7f99721': 85,
screamer 14:ee1b877e6839 191 '0b3ab51c8877': 84,
screamer 14:ee1b877e6839 192 '8a40adfe8776': 83,
screamer 14:ee1b877e6839 193 '6473597d706e': 82,
screamer 14:ee1b877e6839 194 '7d30d6019079': 81,
screamer 14:ee1b877e6839 195 '8e73be2a2ac1': 80,
screamer 14:ee1b877e6839 196 '0c05e21ae27e': 79,
screamer 14:ee1b877e6839 197 'ed8466a608b4': 78,
screamer 14:ee1b877e6839 198 '869cf507173a': 77,
screamer 14:ee1b877e6839 199 '824293ae5e43': 76,
screamer 14:ee1b877e6839 200 'dc225afb6914': 75,
screamer 14:ee1b877e6839 201 'a842253909c9': 74,
screamer 14:ee1b877e6839 202 '1efda918f0ba': 73,
screamer 14:ee1b877e6839 203 '4096f863f923': 72,
screamer 14:ee1b877e6839 204 '8fabd470bb6e': 71,
screamer 14:ee1b877e6839 205 '673126e12c73': 70,
screamer 14:ee1b877e6839 206 '4a7918f48478': 69,
screamer 14:ee1b877e6839 207 'f37f3b9c9f0b': 68,
screamer 14:ee1b877e6839 208 'a9913a65894f': 67,
screamer 14:ee1b877e6839 209 '9c8f0e3462fb': 66,
screamer 14:ee1b877e6839 210 '5798e58a58b1': 65,
screamer 14:ee1b877e6839 211 'e3affc9e7238': 64,
screamer 14:ee1b877e6839 212 'b3110cd2dd17': 63,
screamer 14:ee1b877e6839 213 '7e6c9f46b3bd': 62,
screamer 14:ee1b877e6839 214 '5e5da4a5990b': 61,
screamer 14:ee1b877e6839 215 '3d0ef94e36ec': 60,
screamer 14:ee1b877e6839 216 '0883845fe643': 59,
screamer 14:ee1b877e6839 217 '0954ebd79f59': 58,
screamer 14:ee1b877e6839 218 '0480438fc29c': 57,
screamer 14:ee1b877e6839 219 '3753e96f3c8b': 56,
screamer 14:ee1b877e6839 220 'd722ed6a4237': 55,
screamer 14:ee1b877e6839 221 '71b101360fb9': 54,
screamer 14:ee1b877e6839 222 '63cdd78b2dc1': 53,
screamer 14:ee1b877e6839 223 '09236a68d21b': 52,
screamer 14:ee1b877e6839 224 'a076018f59af': 51,
screamer 14:ee1b877e6839 225 'b60934f96c0c': 50,
screamer 14:ee1b877e6839 226 'eeb8a2a33ec9': 49,
screamer 14:ee1b877e6839 227 '49c296715c73': 48,
screamer 14:ee1b877e6839 228 '134def52cfa0': 47,
screamer 14:ee1b877e6839 229 '890817bdcffb': 46,
screamer 14:ee1b877e6839 230 '3d775a932e1d': 45,
screamer 14:ee1b877e6839 231 '24d45a770a51': 44,
screamer 14:ee1b877e6839 232 'e2ed12d17f06': 43,
screamer 14:ee1b877e6839 233 'cd19af002ccc': 42,
screamer 14:ee1b877e6839 234 '10b9abbe79a6': 41,
screamer 14:ee1b877e6839 235 '976df7c37ad5': 40,
screamer 14:ee1b877e6839 236 '737756e0b479': 39,
screamer 14:ee1b877e6839 237 '4c0c40fd0593': 38,
screamer 14:ee1b877e6839 238 '14f4805c468c': 37,
screamer 14:ee1b877e6839 239 'b4b9f287a47e': 36,
screamer 14:ee1b877e6839 240 '5284544d04b6': 35,
screamer 14:ee1b877e6839 241 '7495d544864f': 34,
screamer 14:ee1b877e6839 242 '5364839841bd': 33,
screamer 14:ee1b877e6839 243 '3b05dd009342': 32,
screamer 14:ee1b877e6839 244 'a7ef757f598c': 31,
screamer 14:ee1b877e6839 245 '3991a86798e3': 30,
screamer 14:ee1b877e6839 246 '078e4b97a13e': 29,
screamer 14:ee1b877e6839 247 '667d61c9177b': 28,
screamer 14:ee1b877e6839 248 '7110ebee3484': 27,
screamer 14:ee1b877e6839 249 '63bcd7ba4912': 26,
screamer 14:ee1b877e6839 250 '9a9732ce53a1': 25,
screamer 14:ee1b877e6839 251 'e2ac27c8e93e': 24,
screamer 14:ee1b877e6839 252 '74b8d43b5817': 23,
screamer 14:ee1b877e6839 253 '9114680c05da': 22,
screamer 14:ee1b877e6839 254 '3944f1e2fa4f': 21,
screamer 14:ee1b877e6839 255 '029aa53d7323': 20,
screamer 14:ee1b877e6839 256 'e6be4cd80aad': 19,
screamer 14:ee1b877e6839 257 'b3c9f16cbb96': 18,
screamer 14:ee1b877e6839 258 '49a220cc26e0': 17,
screamer 14:ee1b877e6839 259 '32af5db564d4': 16,
screamer 14:ee1b877e6839 260 'd1a9de3f4fe0': 15,
screamer 14:ee1b877e6839 261 '20a79241b4a0': 14,
screamer 14:ee1b877e6839 262 'a0336ede94ce': 13,
screamer 14:ee1b877e6839 263 'f63353af7be8': 12,
screamer 14:ee1b877e6839 264 '1c1ebd0324fa': 11,
screamer 14:ee1b877e6839 265 'fcb9359f0959': 10,
screamer 14:ee1b877e6839 266 'cf0d45ce28a6': 9,
screamer 14:ee1b877e6839 267 '00a04e5cd407': 8,
screamer 14:ee1b877e6839 268 '15d74db76485': 7,
screamer 14:ee1b877e6839 269 '3fd6a337c7cc': 6,
screamer 14:ee1b877e6839 270 '62573be585e9': 5,
screamer 14:ee1b877e6839 271 '5d1359a283bc': 4,
screamer 14:ee1b877e6839 272 'aefd12a1f1c5': 3,
screamer 14:ee1b877e6839 273 '969fc1867111': 2,
screamer 14:ee1b877e6839 274 '6b7f447ca868': 1,
screamer 14:ee1b877e6839 275 '82220227f4fa': 0,
screamer 14:ee1b877e6839 276 }