8000 tools/manifestfile.py: Optional includes and include-directory. · micropython/micropython@2ab50b7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2ab50b7

Browse files
committed
tools/manifestfile.py: Optional includes and include-directory.
Simplifies the "include manifest if it exists" pattern used by a few boards. If an include path is a directory, then it implicitly grabs the manifest.py file inside that directory. This simplifies most manifest.py files. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
1 parent dbab78a commit 2ab50b7

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tools/manifestfile.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,13 @@ def _search(self, base_path, package_path, files, exts, kind, version=None, opt=
182182
if base_path:
183183
os.chdir(prev_cwd)
184184

185+
def include_maybe(self, manifest_path, **kwargs):
186+
"""
187+
Include the manifest file if it exists. See docs for include().
188+
"""
189+
if os.path.exists(manifest_path):
190+
self.include(manifest_path, **kwargs)
191+
185192
def include(self, manifest_path, **kwargs):
186193
"""
187194
Include another manifest.
@@ -191,6 +198,9 @@ def include(self, manifest_path, **kwargs):
191198
192199
Relative paths are resolved with respect to the current manifest file.
193200
201+
If the path is to a directory, then it implicitly includes the
202+
manifest.py file inside that directory.
203+
194204
Optional kwargs can be provided which will be available to the
195205
included script via the `options` variable.
196206
@@ -210,6 +220,9 @@ def include(self, manifest_path, **kwargs):
210220
self.include(m)
211221
else:
212222
manifest_path = self._resolve_path(manifest_path)
223+
# Including a directory grabs the manifest.py inside it.
224+
if os.path.isdir(manifest_path):
225+
manifest_path = os.path.join(manifest_path, "manifest.py")
213226
if manifest_path in self._visited:
214227
return
215228
self._visited.add(manifest_path)

0 commit comments

Comments
 (0)
0