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.
Fork of mbed-sdk-tools by
Diff: build_api.py
- Revision:
- 1:a99c8e460c5c
- Parent:
- 0:66f3b5499f7f
- Child:
- 2:07730b0f452c
diff -r 66f3b5499f7f -r a99c8e460c5c build_api.py --- a/build_api.py Thu May 19 19:44:41 2016 +0100 +++ b/build_api.py Fri May 20 20:16:44 2016 +0100 @@ -23,14 +23,15 @@ from types import ListType from shutil import rmtree from os.path import join, exists, basename, abspath -from os import getcwd +from os import getcwd, walk from time import time +from copy import copy from tools.utils import mkdir, run_cmd, run_cmd_ext, NotSupportedException from tools.paths import MBED_TARGETS_PATH, MBED_LIBRARIES, MBED_API, MBED_HAL, MBED_COMMON from tools.targets import TARGET_NAMES, TARGET_MAP from tools.libraries import Library -from tools.toolchains import TOOLCHAIN_CLASSES +from tools.toolchains import TOOLCHAIN_CLASSES, TOOLCHAIN_PROFILES from jinja2 import FileSystemLoader from jinja2.environment import Environment @@ -82,6 +83,12 @@ jobs=1, silent=False, report=None, properties=None, project_id=None, project_description=None, extra_verbose=False): """ This function builds project. Project can be for example one test / UT """ + src_paths = [src_path] if type(src_path) != ListType else src_path + # We need to remove all paths which are repeated to avoid + # multiple compilations and linking with the same objects + src_paths = [src_paths[0]] + list(set(src_paths[1:])) + project_name = basename(abspath(src_paths[0] if src_paths[0] != "." and src_paths[0] != "./" else getcwd())) + # Toolchain instance try: toolchain = TOOLCHAIN_CLASSES[toolchain_name](target, options, notify, macros, silent, extra_verbose=extra_verbose) @@ -91,12 +98,9 @@ toolchain.VERBOSE = verbose toolchain.jobs = jobs toolchain.build_all = clean - src_paths = [src_path] if type(src_path) != ListType else src_path - # We need to remove all paths which are repeated to avoid - # multiple compilations and linking with the same objects - src_paths = [src_paths[0]] + list(set(src_paths[1:])) - project_name = basename(abspath(src_paths[0] if src_paths[0] != "." and src_paths[0] != "./" else getcwd())) + for path in src_paths: + toolchain.PROFILE = get_build_profile(path, toolchain_name) if name is None: # We will use default project name based on project folder name @@ -749,3 +753,152 @@ with open(filename, 'w+') as f: f.write(template.render(failing_builds=build_report_failing, passing_builds=build_report_passing)) + +def get_build_profile(path, toolchain_name): + profile = None + builds = get_build_ids(path) + for build in builds: + if MBED_SDK_REV_MAP.has_key(build): + idx = MBED_SDK_REV_MAP[build] + + if idx is None: + profile = 'v5' + elif idx <= 43: + profile = 'v1' + elif idx <= 68: + profile = 'v2' + elif idx <= 76: + profile = 'v3' + elif idx <= 105: + profile = 'v4' + else: + profile = 'v5' + + return profile + +def get_build_ids(path): + builds = [] + + for (root, dirs, files) in walk(path): + for d in copy(dirs): + if d.startswith('.'): + dirs.remove(d) + + for filename in filter(lambda s: s.endswith(".bld"), files): + try: + # TODO check user has permission to link against build + url = open(join(root, filename), 'r').read() + builds.append(re.sub(r'^.+/(.*?)$', r'\1', url)) + except: + pass + + return builds + +MBED_SDK_REV_MAP = { + '8ed44a420e5c': 105, + 'b9ad9a133dc7': 104, + 'bad568076d81': 103, + 'da0ca467f8b5': 102, + '7cff1c4259d7': 101, + 'cbbeb26dbd92': 100, + 'dbbf35b96557': 99, + '8ab26030e058': 98, + '433970e64889': 97, + '487b796308b0': 96, + '7e07b6fb45cf': 95, + '9ad691361fac': 94, + 'e188a91d3eaa': 93, + '4fc01daae5a5': 92, + '031413cf7a89': 91, + 'cb3d968589d8': 90, + '552587b429a1': 89, + '9327015d4013': 88, + '6213f644d804': 87, + '04dd9b1680ae': 86, + '024bf7f99721': 85, + '0b3ab51c8877': 84, + '8a40adfe8776': 83, + '6473597d706e': 82, + '7d30d6019079': 81, + '8e73be2a2ac1': 80, + '0c05e21ae27e': 79, + 'ed8466a608b4': 78, + '869cf507173a': 77, + '824293ae5e43': 76, + 'dc225afb6914': 75, + 'a842253909c9': 74, + '1efda918f0ba': 73, + '4096f863f923': 72, + '8fabd470bb6e': 71, + '673126e12c73': 70, + '4a7918f48478': 69, + 'f37f3b9c9f0b': 68, + 'a9913a65894f': 67, + '9c8f0e3462fb': 66, + '5798e58a58b1': 65, + 'e3affc9e7238': 64, + 'b3110cd2dd17': 63, + '7e6c9f46b3bd': 62, + '5e5da4a5990b': 61, + '3d0ef94e36ec': 60, + '0883845fe643': 59, + '0954ebd79f59': 58, + '0480438fc29c': 57, + '3753e96f3c8b': 56, + 'd722ed6a4237': 55, + '71b101360fb9': 54, + '63cdd78b2dc1': 53, + '09236a68d21b': 52, + 'a076018f59af': 51, + 'b60934f96c0c': 50, + 'eeb8a2a33ec9': 49, + '49c296715c73': 48, + '134def52cfa0': 47, + '890817bdcffb': 46, + '3d775a932e1d': 45, + '24d45a770a51': 44, + 'e2ed12d17f06': 43, + 'cd19af002ccc': 42, + '10b9abbe79a6': 41, + '976df7c37ad5': 40, + '737756e0b479': 39, + '4c0c40fd0593': 38, + '14f4805c468c': 37, + 'b4b9f287a47e': 36, + '5284544d04b6': 35, + '7495d544864f': 34, + '5364839841bd': 33, + '3b05dd009342': 32, + 'a7ef757f598c': 31, + '3991a86798e3': 30, + '078e4b97a13e': 29, + '667d61c9177b': 28, + '7110ebee3484': 27, + '63bcd7ba4912': 26, + '9a9732ce53a1': 25, + 'e2ac27c8e93e': 24, + '74b8d43b5817': 23, + '9114680c05da': 22, + '3944f1e2fa4f': 21, + '029aa53d7323': 20, + 'e6be4cd80aad': 19, + 'b3c9f16cbb96': 18, + '49a220cc26e0': 17, + '32af5db564d4': 16, + 'd1a9de3f4fe0': 15, + '20a79241b4a0': 14, + 'a0336ede94ce': 13, + 'f63353af7be8': 12, + '1c1ebd0324fa': 11, + 'fcb9359f0959': 10, + 'cf0d45ce28a6': 9, + '00a04e5cd407': 8, + '15d74db76485': 7, + '3fd6a337c7cc': 6, + '62573be585e9': 5, + '5d1359a283bc': 4, + 'aefd12a1f1c5': 3, + '969fc1867111': 2, + '6b7f447ca868': 1, + '82220227f4fa': 0, +}