Skip to content

Commit 42561b9

Browse files
authored
Merge pull request #1958 from screamerbg/fixed-features2
Fix for libraries being built with features support
2 parents ac1a63f + e44566b commit 42561b9

File tree

3 files changed

+19
-17
lines changed

3 files changed

+19
-17
lines changed

tools/build_api.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -336,16 +336,6 @@ def build_library(src_paths, build_path, target, toolchain_name,
336336
for path in src_paths:
337337
# Scan resources
338338
resource = toolchain.scan_resources(path)
339-
340-
# Copy headers, objects and static libraries - all files needed for static lib
341-
toolchain.copy_files(resource.headers, build_path, rel_path=resource.base_path)
342-
toolchain.copy_files(resource.objects, build_path, rel_path=resource.base_path)
343-
toolchain.copy_files(resource.libraries, build_path, rel_path=resource.base_path)
344-
if resource.linker_script:
345-
toolchain.copy_files(resource.linker_script, build_path, rel_path=resource.base_path)
346-
347-
if resource.hex_files:
348-
toolchain.copy_files(resource.hex_files, build_path, rel_path=resource.base_path)
349339

350340
# Extend resources collection
351341
if not resources:
@@ -404,6 +394,16 @@ def build_library(src_paths, build_path, target, toolchain_name,
404394
# And add the configuration macros to the toolchain
405395
toolchain.add_macros(config.get_config_data_macros())
406396

397+
# Copy headers, objects and static libraries - all files needed for static lib
398+
toolchain.copy_files(resources.headers, build_path, resources=resources)
399+
toolchain.copy_files(resources.objects, build_path, resources=resources)
400+
toolchain.copy_files(resources.libraries, build_path, resources=resources)
401+
if resources.linker_script:
402+
toolchain.copy_files(resources.linker_script, build_path, resources=resources)
403+
404+
if resource.hex_files:
405+
toolchain.copy_files(resources.hex_files, build_path, resources=resources)
406+
407407
# Compile Sources
408408
objects = toolchain.compile_sources(resources, abspath(tmp_path), resources.inc_dirs)
409409
resources.objects.extend(objects)
@@ -544,7 +544,7 @@ def build_lib(lib_id, target, toolchain_name, options=None, verbose=False, clean
544544

545545
# Copy Headers
546546
for resource in resources:
547-
toolchain.copy_files(resource.headers, build_path, rel_path=resource.base_path)
547+
toolchain.copy_files(resource.headers, build_path, resources=resource)
548548

549549
dependencies_include_dir.extend(toolchain.scan_resources(build_path).inc_dirs)
550550

@@ -643,7 +643,7 @@ def build_mbed_libs(target, toolchain_name, options=None, verbose=False, clean=F
643643
# Target specific sources
644644
HAL_SRC = join(MBED_TARGETS_PATH, "hal")
645645
hal_implementation = toolchain.scan_resources(HAL_SRC)
646-
toolchain.copy_files(hal_implementation.headers + hal_implementation.hex_files + hal_implementation.libraries, BUILD_TARGET, HAL_SRC)
646+
toolchain.copy_files(hal_implementation.headers + hal_implementation.hex_files + hal_implementation.libraries, BUILD_TARGET, resources=hal_implementation)
647647
incdirs = toolchain.scan_resources(BUILD_TARGET).inc_dirs
648648
objects = toolchain.compile_sources(hal_implementation, TMP_PATH, [MBED_LIBRARIES] + incdirs)
649649

@@ -821,7 +821,7 @@ def static_analysis_scan(target, toolchain_name, CPPCHECK_CMD, CPPCHECK_MSG_FORM
821821
hal_implementation = toolchain.scan_resources(HAL_SRC)
822822

823823
# Copy files before analysis
824-
toolchain.copy_files(hal_implementation.headers + hal_implementation.hex_files, BUILD_TARGET, HAL_SRC)
824+
toolchain.copy_files(hal_implementation.headers + hal_implementation.hex_files, BUILD_TARGET, resources=hal_implementation)
825825
incdirs = toolchain.scan_resources(BUILD_TARGET)
826826

827827
target_includes = ["-I%s" % i for i in incdirs.inc_dirs]
@@ -925,7 +925,7 @@ def static_analysis_scan_library(src_paths, build_path, target, toolchain_name,
925925

926926
# Copy Headers
927927
for resource in resources:
928-
toolchain.copy_files(resource.headers, build_path, rel_path=resource.base_path)
928+
toolchain.copy_files(resource.headers, build_path, resources=resource)
929929
includes += ["-I%s" % i for i in resource.inc_dirs]
930930
c_sources += " ".join(resource.c_sources) + " "
931931
cpp_sources += " ".join(resource.cpp_sources) + " "

tools/export/exporters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def __scan_and_copy(self, src_path, trg_path):
5757
'lib_builds', 'lib_refs', 'repo_files', 'hex_files', 'bin_files']:
5858
r = getattr(resources, r_type)
5959
if r:
60-
self.toolchain.copy_files(r, trg_path, rel_path=src_path)
60+
self.toolchain.copy_files(r, trg_path, resources=resources)
6161
return resources
6262

6363
@staticmethod

tools/toolchains/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ def scan_repository(self, path):
546546

547547
return resources
548548

549-
def copy_files(self, files_paths, trg_path, rel_path=None):
549+
def copy_files(self, files_paths, trg_path, resources=None, rel_path=None):
550550

551551
# Handle a single file
552552
if type(files_paths) != ListType: files_paths = [files_paths]
@@ -556,7 +556,9 @@ def copy_files(self, files_paths, trg_path, rel_path=None):
556556
files_paths.remove(source)
557557

558558
for source in files_paths:
559-
if rel_path is not None:
559+
if resources is not None:
560+
relative_path = relpath(source, resources.file_basepath[source])
561+
elif rel_path is not None:
560562
relative_path = relpath(source, rel_path)
561563
else:
562564
_, relative_path = split(source)

0 commit comments

Comments
 (0)