From ef4376740b8060a0f3f8e9467c92cbcb4ee4363f Mon Sep 17 00:00:00 2001 From: bridadan Date: Wed, 6 Apr 2016 16:02:11 +0100 Subject: [PATCH 1/5] Allowing "--source" to be specified multiple times. Allowing you to compose builds from separate directories. --- tools/make.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/make.py b/tools/make.py index adfd82bf39..c50005fbc5 100755 --- a/tools/make.py +++ b/tools/make.py @@ -94,7 +94,7 @@ if __name__ == '__main__': parser.add_option("--dep", dest="dependencies", default=None, help="Dependencies") parser.add_option("--source", dest="source_dir", - default=None, help="The source (input) directory") + default=None, help="The source (input) directory", action="append") parser.add_option("--duration", type="int", dest="duration", default=None, help="Duration of the test") parser.add_option("--build", dest="build_dir", From 1b4d69aa8fd959c11c5e63094655f6c81710000c Mon Sep 17 00:00:00 2001 From: screamer Date: Tue, 5 Apr 2016 21:48:32 +0100 Subject: [PATCH 2/5] The build system respects -DUVISOR_PRESENT and dynamically disables floating point support --- tools/toolchains/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/toolchains/__init__.py b/tools/toolchains/__init__.py index d7a9ddf2ab..fde3603fb3 100644 --- a/tools/toolchains/__init__.py +++ b/tools/toolchains/__init__.py @@ -216,6 +216,9 @@ class mbedToolchain: self.CHROOT = None self.mp_pool = None + + if 'UVISOR_PRESENT' in self.macros: + self.target.core = re.sub(r"F$", '', self.target.core) def get_output(self): return self.output From 5094b10964d32fdf199164ef3e019763985df134 Mon Sep 17 00:00:00 2001 From: screamer Date: Tue, 5 Apr 2016 22:07:27 +0100 Subject: [PATCH 3/5] Add exception for TESTS folders to be excluded from the builds --- tools/toolchains/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/toolchains/__init__.py b/tools/toolchains/__init__.py index fde3603fb3..ecb097c5f7 100644 --- a/tools/toolchains/__init__.py +++ b/tools/toolchains/__init__.py @@ -366,7 +366,8 @@ class mbedToolchain: if ((d.startswith('.') or d in self.legacy_ignore_dirs) or (d.startswith('TARGET_') and d[7:] not in labels['TARGET']) or - (d.startswith('TOOLCHAIN_') and d[10:] not in labels['TOOLCHAIN'])): + (d.startswith('TOOLCHAIN_') and d[10:] not in labels['TOOLCHAIN']) or + (d == 'TESTS')): dirs.remove(d) # Add root to include paths From 228d83193c77d959132ef293c4a2555d4be3843f Mon Sep 17 00:00:00 2001 From: screamer Date: Wed, 6 Apr 2016 03:08:27 +0100 Subject: [PATCH 4/5] Properly support relative and absolute paths for source and build dirs --- tools/toolchains/__init__.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/tools/toolchains/__init__.py b/tools/toolchains/__init__.py index ecb097c5f7..86b2ddd65b 100644 --- a/tools/toolchains/__init__.py +++ b/tools/toolchains/__init__.py @@ -17,7 +17,7 @@ limitations under the License. import re import sys -from os import stat, walk +from os import stat, walk, getcwd from copy import copy from time import time, sleep from types import ListType @@ -460,7 +460,13 @@ class mbedToolchain: def relative_object_path(self, build_path, base_dir, source): source_dir, name, _ = split_path(source) - obj_dir = join(build_path, relpath(source_dir, base_dir)) + + if build_path.startswith(base_dir): + # absolute path + obj_dir = join(build_path, relpath(source_dir, base_dir)) + else: + # relative path + obj_dir = join(base_dir, build_path) mkdir(obj_dir) return join(obj_dir, name + '.o') @@ -485,15 +491,12 @@ class mbedToolchain: # The dependency checking for C/C++ is delegated to the compiler base_path = resources.base_path files_to_compile.sort() + work_dir = getcwd() + for source in files_to_compile: _, name, _ = split_path(source) object = self.relative_object_path(build_path, base_path, source) - - # Avoid multiple mkdir() calls on same work directory - work_dir = dirname(object) - if work_dir is not prev_dir: - prev_dir = work_dir - mkdir(work_dir) + print object # Queue mode (multiprocessing) commands = self.compile_command(source, object, inc_paths) From ab0fc59e52628f32e91b5625c6039f09ff728f5e Mon Sep 17 00:00:00 2001 From: screamer Date: Wed, 6 Apr 2016 03:21:24 +0100 Subject: [PATCH 5/5] Add support for project naming based on current directory Cleanup print output --- tools/build_api.py | 9 +++++---- tools/toolchains/__init__.py | 1 - 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/build_api.py b/tools/build_api.py index 6a19eb0483..76a627c463 100644 --- a/tools/build_api.py +++ b/tools/build_api.py @@ -23,6 +23,7 @@ import colorama from types import ListType from shutil import rmtree from os.path import join, exists, basename +from os import getcwd from time import time from tools.utils import mkdir, run_cmd, run_cmd_ext, NotSupportedException @@ -91,15 +92,15 @@ def build_project(src_path, build_path, target, toolchain_name, # 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_BASENAME = basename(src_paths[0]) + project_name = basename(src_paths[0] if src_paths[0] != "." and src_paths[0] != "./" else getcwd()) if name is None: # We will use default project name based on project folder name - name = PROJECT_BASENAME - toolchain.info("Building project %s (%s, %s)" % (PROJECT_BASENAME.upper(), target.name, toolchain_name)) + name = project_name + toolchain.info("Building project %s (%s, %s)" % (project_name, target.name, toolchain_name)) else: # User used custom global project name to have the same name for the - toolchain.info("Building project %s to %s (%s, %s)" % (PROJECT_BASENAME.upper(), name, target.name, toolchain_name)) + toolchain.info("Building project %s to %s (%s, %s)" % (project_name, name, target.name, toolchain_name)) if report != None: diff --git a/tools/toolchains/__init__.py b/tools/toolchains/__init__.py index 86b2ddd65b..4dcc59b5c7 100644 --- a/tools/toolchains/__init__.py +++ b/tools/toolchains/__init__.py @@ -496,7 +496,6 @@ class mbedToolchain: for source in files_to_compile: _, name, _ = split_path(source) object = self.relative_object_path(build_path, base_path, source) - print object # Queue mode (multiprocessing) commands = self.compile_command(source, object, inc_paths)