Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
build_profiles.py
00001 """ 00002 mbed SDK 00003 Copyright (c) 2011-2013 ARM Limited 00004 00005 Licensed under the Apache License, Version 2.0 (the "License"); 00006 you may not use this file except in compliance with the License. 00007 You may obtain a copy of the License at 00008 00009 http://www.apache.org/licenses/LICENSE-2.0 00010 00011 Unless required by applicable law or agreed to in writing, software 00012 distributed under the License is distributed on an "AS IS" BASIS, 00013 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 See the License for the specific language governing permissions and 00015 limitations under the License. 00016 """ 00017 00018 import re 00019 import tempfile 00020 import colorama 00021 00022 from copy import copy 00023 from os.path import join, abspath, exists 00024 from os import walk 00025 import fnmatch 00026 00027 00028 def get_toolchain_profile(toolchain, profile): 00029 if profile and (TOOLCHAIN_PROFILES.get(toolchain, None) and 00030 TOOLCHAIN_PROFILES[toolchain].get(profile)): 00031 return TOOLCHAIN_PROFILES[toolchain].get(profile) 00032 00033 def find_build_profile(path): 00034 profile = None 00035 builds = find_build_ids(path) 00036 for build in builds: 00037 if MBED_SDK_REV_MAP.has_key(build): 00038 idx = MBED_SDK_REV_MAP[build] 00039 00040 if idx <= 43: 00041 profile = 'v1' 00042 elif idx <= 68: 00043 profile = 'v2' 00044 elif idx <= 76: 00045 profile = 'v3' 00046 elif idx <= 105: 00047 profile = 'v4' 00048 elif idx <= 135: 00049 profile = 'v5' 00050 00051 return profile 00052 00053 def find_build_ids(path): 00054 builds = [] 00055 00056 for (root, dirs, files) in walk(path): 00057 for d in copy(dirs): 00058 if d.startswith('.'): 00059 dirs.remove(d) 00060 00061 for filename in filter(lambda s: s.endswith(".bld"), files): 00062 try: 00063 url = open(join(root, filename), 'r').read().strip() 00064 builds.append(re.sub(r'^.+/(.*?)$', r'\1', url)) 00065 except: 00066 pass 00067 00068 return builds 00069 00070 00071 def find_targets_json(path, depth=1): 00072 f = 'targets.json' 00073 if exists(join(path, f)): 00074 return abspath(join(path, f)) 00075 00076 if depth > 2: 00077 return None 00078 00079 for root, dirs, files in walk(path): 00080 for d in copy(dirs): 00081 if d.startswith('.'): 00082 dirs.remove(d) 00083 continue 00084 00085 if exists(join(root, d, f)): 00086 return abspath(join(root, d, f)) 00087 else: 00088 found = find_targets_json(join(root, d), depth+1) 00089 if found: 00090 return found 00091 00092 return None 00093 00094 00095 # Toolchain profiles for backward compatibility with old mbed SDK library releases 00096 TOOLCHAIN_PROFILES = { 00097 'ARM_STD' : { 00098 'v5': { 00099 'version': '5.06', 00100 'common': ['-c', '--gnu', '-O3', '-Otime', '--split_sections', '--apcs=interwork'], 00101 'cxx': ['--cpp', '--no_rtti'], 00102 'COMPILE_C_AS_CPP': False, 00103 }, 00104 'v4': { 00105 'version': '5.03', 00106 'common': ['-c', '--gnu', '-O3', '-Otime', '--split_sections', '--apcs=interwork'], 00107 'cxx': ['--cpp', '--no_rtti'], 00108 'COMPILE_C_AS_CPP': False, 00109 }, 00110 'v3': { 00111 'version': '5.01', 00112 'common': ['-c', '--gnu', '-Ospace', '--split_sections', '--apcs=interwork'], 00113 'cxx': ['--cpp', '--no_rtti'], 00114 'COMPILE_C_AS_CPP': False, 00115 }, 00116 'v2': { 00117 'version': '5.01', 00118 'common': ['-c', '--gnu', '-Ospace', '--split_sections', '--apcs=interwork'], 00119 'cxx': ['--cpp', '--no_rtti'], 00120 'COMPILE_C_AS_CPP': False, 00121 }, 00122 'v1': { 00123 'version': '4', 00124 'common': ['-c', '--gnu', '-Otime', '--split_sections', '--apcs=interwork'], 00125 'cxx': ['--cpp'], 00126 'COMPILE_C_AS_CPP': True, 00127 } 00128 }, 00129 'ARM_MICRO' : { 00130 'v5': { 00131 'version': '5.06', 00132 'common': ['-c', '--gnu', '-O3', '-Otime', '--split_sections', '--apcs=interwork'], 00133 'cxx': ['--cpp', '--no_rtti'], 00134 }, 00135 'v4': { 00136 'version': '5.03', 00137 'common': ['-c', '--gnu', '-O3', '-Otime', '--split_sections', '--apcs=interwork'], 00138 'cxx': ['--cpp', '--no_rtti'], 00139 }, 00140 'v3': { 00141 'version': '5.01', 00142 'common': ['-c', '--gnu', '-Ospace', '--split_sections', '--apcs=interwork'], 00143 'cxx': ['--cpp', '--no_rtti'], 00144 }, 00145 'v2': { 00146 'version': '4', 00147 'common': ['-c', '--gnu', '-Ospace', '--split_sections', '--apcs=interwork'], 00148 'cxx': ['--cpp', '--no_rtti'], 00149 'PATCHED_LIBRARY' : True, 00150 }, 00151 'v1': { 00152 'version': '4.1', 00153 'common': ['-c', '--gnu', '-Otime', '--split_sections', '--apcs=interwork'], 00154 'cxx': ['--cpp'], 00155 'COMPILE_C_AS_CPP': True, 00156 'PATCHED_LIBRARY' : True, 00157 } 00158 }, 00159 'GCC_ARM' : { 00160 'v5': { 00161 'ld': ['-Wl,--gc-sections', '-Wl,--wrap,main'], 00162 }, 00163 'v4': { 00164 'ld': ['-Wl,--gc-sections', '-Wl,--wrap,main'], 00165 }, 00166 'v3': { 00167 'ld': ['-Wl,--gc-sections', '-Wl,--wrap,main'], 00168 }, 00169 'v2': { 00170 'common': ["-c", "-Wall", "-fmessage-length=0", "-fno-exceptions", "-fno-builtin", "-ffunction-sections", "-fdata-sections"], 00171 'cxx': ['-std=gnu++98'], 00172 'ld': ['-Wl,--gc-sections'], 00173 }, 00174 'v1': { 00175 'common': ["-c", "-Wall", "-fmessage-length=0", "-fno-exceptions", "-fno-builtin", "-ffunction-sections", "-fdata-sections"], 00176 'cxx': ['-std=gnu++98'], 00177 'ld': ['-Wl,--gc-sections'], 00178 } 00179 } 00180 } 00181 00182 MBED_SDK_REV_MAP = { 00183 '6f4d9ba055b3': 122, 00184 'c1a077c0ccc5': 123, 00185 'f1e13e937fab': 124, 00186 'a974dc8aa35b': 125, 00187 '4132e2258101': 126, 00188 '62ea7dd49f26': 127, 00189 'e6f9c99959f3': 128, 00190 '31768d6a83cd': 129, 00191 '620374818e03': 130, 00192 'f4b892cad2b9': 131, 00193 '9c0c086c88f0': 132, 00194 'a1e1b8eadde3': 133, 00195 '1a303c31ec8f': 134, 00196 '0b434d521da0': 135, 00197 '2abc4044d39c': 136, 00198 'c2078c12af99': 137, 00199 '86e42d5e9f93': 138, 00200 '4ba4acebdbae': 139, 00201 '608e850de46b': 140, 00202 'd616554d63fc': 141, 00203 '46ffe6167a0b': 142, 00204 'c417c1db60ce': 143, 00205 '6b1076ac9921': 144, 00206 '6c34061e7c34': 121, 00207 '7c328cabac7e': 120, 00208 'aae6fcc7d9bb': 119, 00209 '082adc85693f': 118, 00210 '99a22ba036c9': 117, 00211 'c0f6e94411f5': 116, 00212 '87f2f5183dfb': 115, 00213 '252557024ec3': 114, 00214 'f141b2784e32': 113, 00215 '6f327212ef96': 112, 00216 '4336505e4b1c': 111, 00217 '165afa46840b': 110, 00218 '9296ab0bfc11': 109, 00219 '34e6b704fe68': 108, 00220 '4f6c30876dfa': 107, 00221 'ba1f97679dad': 106, 00222 '8ed44a420e5c': 105, 00223 'b9ad9a133dc7': 104, 00224 'bad568076d81': 103, 00225 'da0ca467f8b5': 102, 00226 '7cff1c4259d7': 101, 00227 'cbbeb26dbd92': 100, 00228 'dbbf35b96557': 99, 00229 '8ab26030e058': 98, 00230 '433970e64889': 97, 00231 '487b796308b0': 96, 00232 '7e07b6fb45cf': 95, 00233 '9ad691361fac': 94, 00234 'e188a91d3eaa': 93, 00235 '4fc01daae5a5': 92, 00236 '031413cf7a89': 91, 00237 'cb3d968589d8': 90, 00238 '552587b429a1': 89, 00239 '9327015d4013': 88, 00240 '6213f644d804': 87, 00241 '04dd9b1680ae': 86, 00242 '024bf7f99721': 85, 00243 '0b3ab51c8877': 84, 00244 '8a40adfe8776': 83, 00245 '6473597d706e': 82, 00246 '7d30d6019079': 81, 00247 '8e73be2a2ac1': 80, 00248 '0c05e21ae27e': 79, 00249 'ed8466a608b4': 78, 00250 '869cf507173a': 77, 00251 '824293ae5e43': 76, 00252 'dc225afb6914': 75, 00253 'a842253909c9': 74, 00254 '1efda918f0ba': 73, 00255 '4096f863f923': 72, 00256 '8fabd470bb6e': 71, 00257 '673126e12c73': 70, 00258 '4a7918f48478': 69, 00259 'f37f3b9c9f0b': 68, 00260 'a9913a65894f': 67, 00261 '9c8f0e3462fb': 66, 00262 '5798e58a58b1': 65, 00263 'e3affc9e7238': 64, 00264 'b3110cd2dd17': 63, 00265 '7e6c9f46b3bd': 62, 00266 '5e5da4a5990b': 61, 00267 '3d0ef94e36ec': 60, 00268 '0883845fe643': 59, 00269 '0954ebd79f59': 58, 00270 '0480438fc29c': 57, 00271 '3753e96f3c8b': 56, 00272 'd722ed6a4237': 55, 00273 '71b101360fb9': 54, 00274 '63cdd78b2dc1': 53, 00275 '09236a68d21b': 52, 00276 'a076018f59af': 51, 00277 'b60934f96c0c': 50, 00278 'eeb8a2a33ec9': 49, 00279 '49c296715c73': 48, 00280 '134def52cfa0': 47, 00281 '890817bdcffb': 46, 00282 '3d775a932e1d': 45, 00283 '24d45a770a51': 44, 00284 'e2ed12d17f06': 43, 00285 'cd19af002ccc': 42, 00286 '10b9abbe79a6': 41, 00287 '976df7c37ad5': 40, 00288 '737756e0b479': 39, 00289 '4c0c40fd0593': 38, 00290 '14f4805c468c': 37, 00291 'b4b9f287a47e': 36, 00292 '5284544d04b6': 35, 00293 '7495d544864f': 34, 00294 '5364839841bd': 33, 00295 '3b05dd009342': 32, 00296 'a7ef757f598c': 31, 00297 '3991a86798e3': 30, 00298 '078e4b97a13e': 29, 00299 '667d61c9177b': 28, 00300 '7110ebee3484': 27, 00301 '63bcd7ba4912': 26, 00302 '9a9732ce53a1': 25, 00303 'e2ac27c8e93e': 24, 00304 '74b8d43b5817': 23, 00305 '9114680c05da': 22, 00306 '3944f1e2fa4f': 21, 00307 '029aa53d7323': 20, 00308 'e6be4cd80aad': 19, 00309 'b3c9f16cbb96': 18, 00310 '49a220cc26e0': 17, 00311 '32af5db564d4': 16, 00312 'd1a9de3f4fe0': 15, 00313 '20a79241b4a0': 14, 00314 'a0336ede94ce': 13, 00315 'f63353af7be8': 12, 00316 '1c1ebd0324fa': 11, 00317 'fcb9359f0959': 10, 00318 'cf0d45ce28a6': 9, 00319 '00a04e5cd407': 8, 00320 '15d74db76485': 7, 00321 '3fd6a337c7cc': 6, 00322 '62573be585e9': 5, 00323 '5d1359a283bc': 4, 00324 'aefd12a1f1c5': 3, 00325 '969fc1867111': 2, 00326 '6b7f447ca868': 1, 00327 '82220227f4fa': 0, 00328 }
Generated on Tue Jul 12 2022 17:12:47 by
