Add support for Arm Mbed "module.json" `dependencies` field // Resolve #3400

This commit is contained in:
Ivan Kravets
2020-03-03 23:10:19 +02:00
parent 0c0ceb2caa
commit 261c46d4ef
3 changed files with 24 additions and 0 deletions

View File

@ -9,6 +9,7 @@ PlatformIO Core 4
4.2.2 (2020-??-??)
~~~~~~~~~~~~~~~~~~
* Added support for Arm Mbed "module.json" ``dependencies`` field (`issue #3400 <https://github.com/platformio/platformio-core/issues/3400>`_)
* Fixed an issue when quitting from PlatformIO IDE does not shutdown PIO Home server
* Fixed an issue "the JSON object must be str, not 'bytes'" when PIO Home is used with Python 3.5 (`issue #3396 <https://github.com/platformio/platformio-core/issues/3396>`_)

View File

@ -392,6 +392,8 @@ class ModuleJsonManifestParser(BaseManifestParser):
if "licenses" in data:
data["license"] = self._parse_license(data.get("licenses"))
del data["licenses"]
if "dependencies" in data:
data["dependencies"] = self._parse_dependencies(data["dependencies"])
return data
def _parse_authors(self, raw):
@ -411,6 +413,15 @@ class ModuleJsonManifestParser(BaseManifestParser):
return None
return raw[0].get("type")
@staticmethod
def _parse_dependencies(raw):
if isinstance(raw, dict):
return [
dict(name=name, version=version, frameworks=["mbed"])
for name, version in raw.items()
]
raise ManifestParserError("Invalid dependencies format, should be a dictionary")
class LibraryPropertiesManifestParser(BaseManifestParser):
manifest_type = ManifestFileType.LIBRARY_PROPERTIES

View File

@ -154,6 +154,10 @@ def test_module_json_parser():
"url": "git@github.com:username/repo.git"
},
"version": "1.2.3",
"dependencies": {
"usefulmodule": "^1.2.3",
"simplelog": "ARMmbed/simplelog#~0.0.1"
},
"customField": "Custom Value"
}
"""
@ -173,6 +177,14 @@ def test_module_json_parser():
"authors": [{"email": "name@surname.com", "name": "Name Surname"}],
"version": "1.2.3",
"repository": {"type": "git", "url": "git@github.com:username/repo.git"},
"dependencies": [
{"name": "usefulmodule", "version": "^1.2.3", "frameworks": ["mbed"]},
{
"name": "simplelog",
"version": "ARMmbed/simplelog#~0.0.1",
"frameworks": ["mbed"],
},
],
"customField": "Custom Value",
},
)