8000 WIP: add manifest support · dpgeorge/micropython@2431419 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2431419

Browse files
committed
WIP: add manifest support
won't work when mpremote is pip installed, because micropython-lib is not available! so would need to fetch via URL Signed-off-by: Damien George <damien@micropython.org>
1 parent dfeec44 commit 2431419

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tools/mpremote/mpremote/romfs.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,28 @@ def copy_recursively(vfs, src_dir, print_prefix, mpy_cross):
127127

128128

129129
def make_romfs(src_dir, *, mpy_cross):
130+
if src_dir.endswith(".py"):
131+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../.."))
132+
import manifestfile
133+
134+
VARS = {}
135+
VARS["MPY_LIB_DIR"] = os.path.abspath("../../lib/micropython-lib")
136+
manifest = manifestfile.ManifestFile(manifestfile.MODE_FREEZE, VARS)
137+
try:
138+
manifest.execute(src_dir)
139+
except manifestfile.ManifestFileError as er:
140+
print('freeze error executing "{}": {}'.format(src_dir, er.args[0]))
141+
sys.exit(1)
142+
143+
manifest_dir_structure = {}
144+
for result in manifest.files():
145+
components = result.target_path.split("/")
146+
s = manifest_dir_structure
147+
for x in components[:-1]:
148+
s = s.setdefault(x, {})
149+
s[components[-1]] = result
150+
return
151+
130152
if not src_dir.endswith("/"):
131153
src_dir += "/"
132154

0 commit comments

Comments
 (0)
0