Skip to content

Commit ac1a63f

Browse files
authored
Merge pull request #1956 from screamerbg/fix-features3
Fixed features not being included
2 parents 934951a + a81746c commit ac1a63f

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

tools/build_api.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ def build_project(src_path, build_path, target, toolchain_name,
227227

228228
for feature in features:
229229
if feature in resources.features:
230-
resources += resources.features[feature]
230+
resources.add(resources.features[feature])
231231

232232
prev_features = features
233233
config.validate_config()
@@ -236,10 +236,8 @@ def build_project(src_path, build_path, target, toolchain_name,
236236
toolchain.add_macros(config.get_config_data_macros())
237237

238238
# Compile Sources
239-
for path in src_paths:
240-
src = toolchain.scan_resources(path)
241-
objects = toolchain.compile_sources(src, build_path, resources.inc_dirs)
242-
resources.objects.extend(objects)
239+
objects = toolchain.compile_sources(resources, build_path, resources.inc_dirs)
240+
resources.objects.extend(objects)
243241

244242
# Link Program
245243
res, _ = toolchain.link_program(resources, build_path, name)
@@ -398,7 +396,7 @@ def build_library(src_paths, build_path, target, toolchain_name,
398396

399397
for feature in features:
400398
if feature in resources.features:
401-
resources += resources.features[feature]
399+
resources.add(resources.features[feature])
402400

403401
prev_features = features
404402
config.validate_config()
@@ -407,10 +405,8 @@ def build_library(src_paths, build_path, target, toolchain_name,
407405
toolchain.add_macros(config.get_config_data_macros())
408406

409407
# Compile Sources
410-
for path in src_paths:
411-
src = toolchain.scan_resources(path)
412-
objects = toolchain.compile_sources(src, abspath(tmp_path), resources.inc_dirs)
413-
resources.objects.extend(objects)
408+
objects = toolchain.compile_sources(resources, abspath(tmp_path), resources.inc_dirs)
409+
resources.objects.extend(objects)
414410

415411
if archive:
416412
toolchain.build_library(objects, build_path, name)

tools/toolchains/__init__.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ class Resources:
6464
def __init__(self, base_path=None):
6565
self.base_path = base_path
6666

67+
self.file_basepath = {}
68+
6769
self.inc_dirs = []
6870
self.headers = []
6971

@@ -105,6 +107,9 @@ def __radd__(self, resources):
105107
return self.add(resources)
106108

107109
def add(self, resources):
110+
for f,p in resources.file_basepath.items():
111+
self.file_basepath[f] = p
112+
108113
self.inc_dirs += resources.inc_dirs
109114
self.headers += resources.headers
110115

@@ -404,9 +409,14 @@ def is_ignored(self, file_path):
404409
return True
405410
return False
406411

407-
def scan_resources(self, path, exclude_paths=None):
412+
def scan_resources(self, path, exclude_paths=None, base_path=None):
408413
labels = self.get_labels()
414+
409415
resources = Resources(path)
416+
if not base_path:
417+
base_path = path
418+
resources.base_path = base_path
419+
410420
self.has_config = False
411421

412422
""" os.walk(top[, topdown=True[, onerror=None[, followlinks=False]]])
@@ -445,7 +455,7 @@ def scan_resources(self, path, exclude_paths=None):
445455
dirs.remove(d)
446456

447457
if (d.startswith('FEATURE_')):
448-
resources.features[d[8:]] = self.scan_resources(dir_path)
458+
resources.features[d[8:]] = self.scan_resources(dir_path, base_path=base_path)
449459
dirs.remove(d)
450460

451461
# Remove dirs that already match the ignorepatterns
@@ -467,6 +477,8 @@ def scan_resources(self, path, exclude_paths=None):
467477
for file in files:
468478
file_path = join(root, file)
469479

480+
resources.file_basepath[file_path] = base_path
481+
470482
if self.is_ignored(file_path):
471483
continue
472484

@@ -597,15 +609,13 @@ def compile_sources(self, resources, build_path, inc_dirs=None):
597609
queue = []
598610
prev_dir = None
599611

600-
# The dependency checking for C/C++ is delegated to the compiler
601-
base_path = resources.base_path
602612
# Sort compile queue for consistency
603613
files_to_compile.sort()
604614
work_dir = getcwd()
605615

606616
for source in files_to_compile:
607617
_, name, _ = split_path(source)
608-
object = self.relative_object_path(build_path, base_path, source)
618+
object = self.relative_object_path(build_path, resources.file_basepath[source], source)
609619

610620
# Queue mode (multiprocessing)
611621
commands = self.compile_command(source, object, inc_paths)

0 commit comments

Comments
 (0)