Merge pull request #2 from mjs-arm/merge-from-classic

Merge from classic
Mihail Stoyanov 2016-04-06 18:11:44 +01:00
commit 1ee1150924
3 changed files with 21 additions and 14 deletions

View File

@ -23,6 +23,7 @@ import colorama
from types import ListType from types import ListType
from shutil import rmtree from shutil import rmtree
from os.path import join, exists, basename from os.path import join, exists, basename
from os import getcwd
from time import time from time import time
from tools.utils import mkdir, run_cmd, run_cmd_ext, NotSupportedException 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 # We need to remove all paths which are repeated to avoid
# multiple compilations and linking with the same objects # multiple compilations and linking with the same objects
src_paths = [src_paths[0]] + list(set(src_paths[1:])) 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: if name is None:
# We will use default project name based on project folder name # We will use default project name based on project folder name
name = PROJECT_BASENAME name = project_name
toolchain.info("Building project %s (%s, %s)" % (PROJECT_BASENAME.upper(), target.name, toolchain_name)) toolchain.info("Building project %s (%s, %s)" % (project_name, target.name, toolchain_name))
else: else:
# User used custom global project name to have the same name for the # 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: if report != None:

View File

@ -94,7 +94,7 @@ if __name__ == '__main__':
parser.add_option("--dep", dest="dependencies", parser.add_option("--dep", dest="dependencies",
default=None, help="Dependencies") default=None, help="Dependencies")
parser.add_option("--source", dest="source_dir", 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", parser.add_option("--duration", type="int", dest="duration",
default=None, help="Duration of the test") default=None, help="Duration of the test")
parser.add_option("--build", dest="build_dir", parser.add_option("--build", dest="build_dir",

View File

@ -17,7 +17,7 @@ limitations under the License.
import re import re
import sys import sys
from os import stat, walk from os import stat, walk, getcwd
from copy import copy from copy import copy
from time import time, sleep from time import time, sleep
from types import ListType from types import ListType
@ -216,6 +216,9 @@ class mbedToolchain:
self.CHROOT = None self.CHROOT = None
self.mp_pool = 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): def get_output(self):
return self.output return self.output
@ -363,7 +366,8 @@ class mbedToolchain:
if ((d.startswith('.') or d in self.legacy_ignore_dirs) or if ((d.startswith('.') or d in self.legacy_ignore_dirs) or
(d.startswith('TARGET_') and d[7:] not in labels['TARGET']) 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) dirs.remove(d)
# Add root to include paths # Add root to include paths
@ -456,7 +460,13 @@ class mbedToolchain:
def relative_object_path(self, build_path, base_dir, source): def relative_object_path(self, build_path, base_dir, source):
source_dir, name, _ = split_path(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) mkdir(obj_dir)
return join(obj_dir, name + '.o') return join(obj_dir, name + '.o')
@ -481,16 +491,12 @@ class mbedToolchain:
# The dependency checking for C/C++ is delegated to the compiler # The dependency checking for C/C++ is delegated to the compiler
base_path = resources.base_path base_path = resources.base_path
files_to_compile.sort() files_to_compile.sort()
work_dir = getcwd()
for source in files_to_compile: for source in files_to_compile:
_, name, _ = split_path(source) _, name, _ = split_path(source)
object = self.relative_object_path(build_path, base_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) # Queue mode (multiprocessing)
commands = self.compile_command(source, object, inc_paths) commands = self.compile_command(source, object, inc_paths)
if commands is not None: if commands is not None: