mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 01:57:13 +02:00
Fix an issue when PlatformIO Build System does not pick up "mbed_lib.json" files from libraries // Resolve #2164
This commit is contained in:
@ -18,6 +18,8 @@ PlatformIO 3.0
|
|||||||
|
|
||||||
* Project Generator: fixed a warning "Property !!! WARNING !!! is not allowed" for VSCode
|
* Project Generator: fixed a warning "Property !!! WARNING !!! is not allowed" for VSCode
|
||||||
(`issue #2243 <https://github.com/platformio/platformio-core/issues/2243>`_)
|
(`issue #2243 <https://github.com/platformio/platformio-core/issues/2243>`_)
|
||||||
|
* Fixed an issue when PlatformIO Build System does not pick up "mbed_lib.json" files from libraries
|
||||||
|
(`issue #2164 <https://github.com/platformio/platformio-core/issues/2164>`_)
|
||||||
* Fixed an error with conflicting declaration of a prototype (Arduino sketch preprocessor)
|
* Fixed an error with conflicting declaration of a prototype (Arduino sketch preprocessor)
|
||||||
* Fixed "FileExistsError" when `platformio ci <https://docs.platformio.org/en/latest/userguide/cmd_ci.html>`__ command is used in pair with ``--keep-build-dir`` option
|
* Fixed "FileExistsError" when `platformio ci <https://docs.platformio.org/en/latest/userguide/cmd_ci.html>`__ command is used in pair with ``--keep-build-dir`` option
|
||||||
|
|
||||||
|
@ -71,6 +71,8 @@ class LibBuilderFactory(object):
|
|||||||
|
|
||||||
# check source files
|
# check source files
|
||||||
for root, _, files in os.walk(path, followlinks=True):
|
for root, _, files in os.walk(path, followlinks=True):
|
||||||
|
if "mbed_lib.json" in files:
|
||||||
|
return ["mbed"]
|
||||||
for fname in files:
|
for fname in files:
|
||||||
if not env.IsFileWithExt(
|
if not env.IsFileWithExt(
|
||||||
fname, piotool.SRC_BUILD_EXT + piotool.SRC_HEADER_EXT):
|
fname, piotool.SRC_BUILD_EXT + piotool.SRC_HEADER_EXT):
|
||||||
@ -262,7 +264,6 @@ class LibBuilderBase(object):
|
|||||||
|
|
||||||
def process_extra_options(self):
|
def process_extra_options(self):
|
||||||
with util.cd(self.path):
|
with util.cd(self.path):
|
||||||
self.env.ProcessUnFlags(self.build_unflags)
|
|
||||||
self.env.ProcessFlags(self.build_flags)
|
self.env.ProcessFlags(self.build_flags)
|
||||||
if self.extra_script:
|
if self.extra_script:
|
||||||
self.env.SConscriptChdir(1)
|
self.env.SConscriptChdir(1)
|
||||||
@ -272,6 +273,7 @@ class LibBuilderBase(object):
|
|||||||
"env": self.env,
|
"env": self.env,
|
||||||
"pio_lib_builder": self
|
"pio_lib_builder": self
|
||||||
})
|
})
|
||||||
|
self.env.ProcessUnFlags(self.build_unflags)
|
||||||
|
|
||||||
def process_dependencies(self):
|
def process_dependencies(self):
|
||||||
if not self.dependencies:
|
if not self.dependencies:
|
||||||
@ -591,6 +593,59 @@ class MbedLibBuilder(LibBuilderBase):
|
|||||||
def is_frameworks_compatible(self, frameworks):
|
def is_frameworks_compatible(self, frameworks):
|
||||||
return util.items_in_list(frameworks, ["mbed"])
|
return util.items_in_list(frameworks, ["mbed"])
|
||||||
|
|
||||||
|
@property
|
||||||
|
def build_flags(self):
|
||||||
|
return self._mbed_lib_json_to_build_flags()
|
||||||
|
|
||||||
|
def _mbed_lib_json_to_build_flags(self): # pylint: disable=too-many-locals
|
||||||
|
json_files = [
|
||||||
|
join(root, "mbed_lib.json")
|
||||||
|
for root, _, files in os.walk(self.path)
|
||||||
|
if "mbed_lib.json" in files
|
||||||
|
]
|
||||||
|
if not json_files:
|
||||||
|
return None
|
||||||
|
|
||||||
|
build_flags = []
|
||||||
|
cppdefines = str(self.env.Flatten(self.env.subst("$CPPDEFINES")))
|
||||||
|
for p in json_files:
|
||||||
|
manifest = util.load_json(p)
|
||||||
|
|
||||||
|
# default macros
|
||||||
|
build_flags.extend(["-D" + m for m in manifest.get("macros", [])])
|
||||||
|
|
||||||
|
macros = {}
|
||||||
|
# configuration items
|
||||||
|
for key, options in manifest.get("config", {}).items():
|
||||||
|
if "value" not in options:
|
||||||
|
continue
|
||||||
|
macros[key] = dict(
|
||||||
|
name=options.get("macro_name"), value=options.get("value"))
|
||||||
|
# overrode items per target
|
||||||
|
for target, options in manifest.get("target_overrides",
|
||||||
|
{}).items():
|
||||||
|
if target != "*" and "TARGET_" + target not in cppdefines:
|
||||||
|
continue
|
||||||
|
build_flags.extend(
|
||||||
|
["-D" + m for m in options.get("target.macros_add", [])])
|
||||||
|
for key, value in options.items():
|
||||||
|
if not key.startswith("target.") and key in macros:
|
||||||
|
macros[key]['value'] = value
|
||||||
|
for key, macro in macros.items():
|
||||||
|
name = macro['name']
|
||||||
|
value = macro['value']
|
||||||
|
if not name:
|
||||||
|
name = key
|
||||||
|
if "." not in name:
|
||||||
|
name = manifest.get("name") + "." + name
|
||||||
|
name = re.sub(r"[^a-z\d]+", "_", name, flags=re.I).upper()
|
||||||
|
name = "MBED_CONF_" + name
|
||||||
|
if isinstance(value, bool):
|
||||||
|
value = 1 if value else 0
|
||||||
|
build_flags.append("-D%s=%s" % (name, value))
|
||||||
|
|
||||||
|
return build_flags
|
||||||
|
|
||||||
|
|
||||||
class PlatformIOLibBuilder(LibBuilderBase):
|
class PlatformIOLibBuilder(LibBuilderBase):
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user