Skip to content

Commit

Permalink
Update build logic for unsupported libraries in mbed 2 mode
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
valeros committed Jan 13, 2020
1 parent de9e6b0 commit 152ac44
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions platformio-build.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import warnings
from shutil import copyfile
from os import makedirs
from os.path import basename, isdir, isfile, join
from os.path import basename, isabs, isdir, isfile, join

from SCons.Script import COMMAND_LINE_TARGETS, Builder, DefaultEnvironment

Expand Down Expand Up @@ -93,7 +93,9 @@ def _fix_paths(paths, lib_path):

config = lib_processor.extract_project_info(generate_config=False)
src_files = _fix_paths(config.get("src_files"), lib_path)
inc_dirs = _fix_paths(config.get("inc_dirs"), lib_path)

inc_dirs = [join(FRAMEWORK_DIR, d).replace("\\", "/") for d in config.get(
"inc_dirs") if not isabs(d)]

name = basename(lib_path)

Expand All @@ -106,8 +108,14 @@ def _fix_paths(paths, lib_path):
}
}

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

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

0 comments on commit 152ac44

Please sign in to comment.