Skip to content

Commit 152ac44

Browse files
committed
Update build logic for unsupported libraries in mbed 2 mode
Include paths for mbed 2 libraries should be prepended because of conflicts with header files from main part of the framework (e.g. USBDevice.h)
1 parent de9e6b0 commit 152ac44

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

platformio-build.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import warnings
1818
from shutil import copyfile
1919
from os import makedirs
20-
from os.path import basename, isdir, isfile, join
20+
from os.path import basename, isabs, isdir, isfile, join
2121

2222
from SCons.Script import COMMAND_LINE_TARGETS, Builder, DefaultEnvironment
2323

@@ -93,7 +93,9 @@ def _fix_paths(paths, lib_path):
9393

9494
config = lib_processor.extract_project_info(generate_config=False)
9595
src_files = _fix_paths(config.get("src_files"), lib_path)
96-
inc_dirs = _fix_paths(config.get("inc_dirs"), lib_path)
96+
97+
inc_dirs = [join(FRAMEWORK_DIR, d).replace("\\", "/") for d in config.get(
98+
"inc_dirs") if not isabs(d)]
9799

98100
name = basename(lib_path)
99101

@@ -106,8 +108,14 @@ def _fix_paths(paths, lib_path):
106108
}
107109
}
108110

109-
manifest['build']['flags'].extend(
110-
['-I "%s"' % d for d in inc_dirs])
111+
if inc_dirs:
112+
extra_script = join(env.subst("$BUILD_DIR"), name + "_extra_script.py")
113+
manifest['build']['extraScript'] = extra_script.replace("\\", "/")
114+
if not isfile(extra_script):
115+
with open(extra_script, "w") as fp:
116+
fp.write("Import('env')\n")
117+
fp.write(
118+
"env.Prepend(CPPPATH=[%s])" % ("'" + "', '".join(inc_dirs) + "'"))
111119

112120
for f in src_files:
113121
manifest['build']['srcFilter'].extend([" +<%s>" % f])

0 commit comments

Comments
 (0)