mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-29 17:47:14 +02:00
Added support for a new "headers" field in "library.json"
This commit is contained in:
@ -11,6 +11,7 @@ PlatformIO Core 5
|
||||
5.2.4 (2021-??-??)
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
- Added support for a new ``headers`` field in `library.json <https://docs.platformio.org/en/latest/librarymanager/config.html>`__ (declare a list of header files that can be included in a project source files using ``#include <...>`` directive)
|
||||
- Improved support for projects located on a network share (`issue #3417 <https://github.com/platformio/platformio-core/issues/3417>`_, `issue #3926 <https://github.com/platformio/platformio-core/issues/3926>`_, `issue #4099 <https://github.com/platformio/platformio-core/issues/4099>`_)
|
||||
- Upgraded build engine to the SCons 4.3 (`release notes <https://github.com/SCons/scons/blob/rel_4.3.0/CHANGES.txt>`__)
|
||||
- Fixed an issue with the CLion project generator when a macro contains a space (`issue #4102 <https://github.com/platformio/platformio-core/issues/4102>`_)
|
||||
|
2
docs
2
docs
Submodule docs updated: 7b3abdb696...1e2679b0ef
@ -167,7 +167,7 @@ class BaseManifestParser(object):
|
||||
return self._data
|
||||
|
||||
@staticmethod
|
||||
def str_to_list(value, sep=",", lowercase=True):
|
||||
def str_to_list(value, sep=",", lowercase=False):
|
||||
if isinstance(value, string_types):
|
||||
value = value.split(sep)
|
||||
assert isinstance(value, list)
|
||||
@ -323,8 +323,10 @@ class LibraryJsonManifestParser(BaseManifestParser):
|
||||
# normalize Union[str, list] fields
|
||||
for k in ("keywords", "platforms", "frameworks"):
|
||||
if k in data:
|
||||
data[k] = self.str_to_list(data[k], sep=",")
|
||||
data[k] = self.str_to_list(data[k], sep=",", lowercase=True)
|
||||
|
||||
if "headers" in data:
|
||||
data["headers"] = self.str_to_list(data["headers"], sep=",")
|
||||
if "authors" in data:
|
||||
data["authors"] = self._parse_authors(data["authors"])
|
||||
if "platforms" in data:
|
||||
@ -430,7 +432,9 @@ class ModuleJsonManifestParser(BaseManifestParser):
|
||||
if "dependencies" in data:
|
||||
data["dependencies"] = self._parse_dependencies(data["dependencies"])
|
||||
if "keywords" in data:
|
||||
data["keywords"] = self.str_to_list(data["keywords"], sep=",")
|
||||
data["keywords"] = self.str_to_list(
|
||||
data["keywords"], sep=",", lowercase=True
|
||||
)
|
||||
return data
|
||||
|
||||
def _parse_authors(self, raw):
|
||||
@ -480,6 +484,9 @@ class LibraryPropertiesManifestParser(BaseManifestParser):
|
||||
export=self._parse_export(),
|
||||
)
|
||||
)
|
||||
if "includes" in data:
|
||||
data["headers"] = self.str_to_list(data["includes"], ",")
|
||||
del data["includes"]
|
||||
if "author" in data:
|
||||
data["authors"] = self._parse_authors(data)
|
||||
for key in ("author", "maintainer"):
|
||||
@ -674,7 +681,9 @@ class PackageJsonManifestParser(BaseManifestParser):
|
||||
def parse(self, contents):
|
||||
data = json.loads(contents)
|
||||
if "keywords" in data:
|
||||
data["keywords"] = self.str_to_list(data["keywords"], sep=",")
|
||||
data["keywords"] = self.str_to_list(
|
||||
data["keywords"], sep=",", lowercase=True
|
||||
)
|
||||
data = self._parse_system(data)
|
||||
data = self._parse_homepage(data)
|
||||
data = self._parse_repository(data)
|
||||
|
@ -209,6 +209,13 @@ class ManifestSchema(BaseSchema):
|
||||
]
|
||||
)
|
||||
)
|
||||
headers = StrictListField(
|
||||
fields.Str(
|
||||
validate=[
|
||||
validate.Length(min=1, max=255),
|
||||
]
|
||||
)
|
||||
)
|
||||
|
||||
# platform.json specific
|
||||
title = fields.Str(validate=validate.Length(min=1, max=100))
|
||||
|
@ -29,6 +29,7 @@ def test_library_json_parser():
|
||||
{
|
||||
"name": "TestPackage",
|
||||
"keywords": "kw1, KW2, kw3",
|
||||
"headers": "include1.h, Include2.hpp",
|
||||
"platforms": ["atmelavr", "espressif"],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -62,6 +63,7 @@ def test_library_json_parser():
|
||||
},
|
||||
"export": {"exclude": [".gitignore", "tests"], "include": ["mylib"]},
|
||||
"keywords": ["kw1", "kw2", "kw3"],
|
||||
"headers": ["include1.h", "Include2.hpp"],
|
||||
"homepage": "http://old.url.format",
|
||||
"build": {"flags": ["-DHELLO"]},
|
||||
"dependencies": [
|
||||
@ -76,6 +78,7 @@ def test_library_json_parser():
|
||||
contents = """
|
||||
{
|
||||
"keywords": ["sound", "audio", "music", "SD", "card", "playback"],
|
||||
"headers": ["include 1.h", "include Space.hpp"],
|
||||
"frameworks": "arduino",
|
||||
"platforms": "atmelavr",
|
||||
"export": {
|
||||
@ -94,6 +97,7 @@ def test_library_json_parser():
|
||||
raw_data,
|
||||
{
|
||||
"keywords": ["sound", "audio", "music", "sd", "card", "playback"],
|
||||
"headers": ["include 1.h", "include Space.hpp"],
|
||||
"frameworks": ["arduino"],
|
||||
"export": {"exclude": ["audio_samples"]},
|
||||
"platforms": ["atmelavr"],
|
||||
@ -205,6 +209,7 @@ sentence=This is Arduino library
|
||||
customField=Custom Value
|
||||
depends=First Library (=2.0.0), Second Library (>=1.2.0), Third
|
||||
ignore_empty_field=
|
||||
includes=Arduino.h, Arduino Space.hpp
|
||||
"""
|
||||
raw_data = parser.LibraryPropertiesManifestParser(contents).as_dict()
|
||||
raw_data["dependencies"] = sorted(raw_data["dependencies"], key=lambda a: a["name"])
|
||||
@ -225,6 +230,7 @@ ignore_empty_field=
|
||||
{"name": "Maintainer Author", "maintainer": True},
|
||||
],
|
||||
"keywords": ["uncategorized"],
|
||||
"headers": ["Arduino.h", "Arduino Space.hpp"],
|
||||
"customField": "Custom Value",
|
||||
"depends": "First Library (=2.0.0), Second Library (>=1.2.0), Third",
|
||||
"dependencies": [
|
||||
@ -530,6 +536,7 @@ includes=MozziGuts.h
|
||||
},
|
||||
"platforms": ["*"],
|
||||
"frameworks": ["arduino"],
|
||||
"headers": ["MozziGuts.h"],
|
||||
"export": {
|
||||
"exclude": ["extras", "docs", "tests", "test", "*.doxyfile", "*.pdf"]
|
||||
},
|
||||
|
Reference in New Issue
Block a user