Skip to content

Commit

Permalink
Add support for Arm Mbed "module.json" dependencies field // Resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
ivankravets committed Mar 3, 2020
1 parent 0c0ceb2 commit 261c46d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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>`_)

Expand Down
11 changes: 11 additions & 0 deletions platformio/package/manifest/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,8 @@ def parse(self, contents):
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):
Expand All @@ -411,6 +413,15 @@ def _parse_license(raw):
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
Expand Down
12 changes: 12 additions & 0 deletions tests/package/test_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ def test_module_json_parser():
"url": "[email protected]:username/repo.git"
},
"version": "1.2.3",
"dependencies": {
"usefulmodule": "^1.2.3",
"simplelog": "ARMmbed/simplelog#~0.0.1"
},
"customField": "Custom Value"
}
"""
Expand All @@ -173,6 +177,14 @@ def test_module_json_parser():
"authors": [{"email": "[email protected]", "name": "Name Surname"}],
"version": "1.2.3",
"repository": {"type": "git", "url": "[email protected]: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",
},
)
Expand Down

0 comments on commit 261c46d

Please sign in to comment.