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/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", diff --git a/tools/toolchains/__init__.py b/tools/toolchains/__init__.py index d7a9ddf2ab..4dcc59b5c7 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 @@ -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 @@ -363,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 @@ -456,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') @@ -481,16 +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) - # Queue mode (multiprocessing) commands = self.compile_command(source, object, inc_paths) if commands is not None: