phoddie / runmod

Dynamically install JavaScript modules on a microcontroller
17 stars 2 forks source link

wasm tools #6

Open phoddie opened 5 years ago

phoddie commented 5 years ago

This issue is for discussion of the XS and Moddable SDK tools for wasm.

Today we pushed changes to bring just about all the Moddable SDK tools to wasm. They include a new mcruntool to build mods from manifests, just as mcconfig is used to builds hosts from manifests. In particular, mcrun supports adding and transforming resources into the mod archive binary.

A brief introductory document is here.

FWeinb commented 5 years ago

I updated the WebIDE with support for mcrun. The only thing I needed to change was changing the build environment to worker. Here is a diff:

--- a/build/makefiles/wasm/tools.mk
+++ b/build/makefiles/wasm/tools.mk
@@ -217,7 +217,7 @@ LIBRARIES = -ldl -lm

 # LINK_FLAGS = -arch i386
 LINK_FLAGS =\
-       -s ENVIRONMENT=web\
+       -s ENVIRONMENT=worker\
        -s ALLOW_MEMORY_GROWTH=1\
        -s MODULARIZE=1\
        -s EXPORT_ES6=1\

I also added support for json files in the WebIDE, all projects require a manifest.json in the root now.

WebIDE

phoddie commented 5 years ago

Nice. That was quick. I'll give it a look a little later.

FWeinb commented 5 years ago

@phoddie I just pushed another update to the WebIDE, the mcrun tool could only be used once before. I was not cleaning up correctly.

The moddable zero was in the mail today (thank a lot) and got it running with the WebIDE (click to see a video): Video Preview

phoddie commented 5 years ago

Nice demo. Great to see it running with the display on Moddable Zero.

FWIW - I pushed a couple reliability fixes to the install upload last night.

FWeinb commented 5 years ago

I just tested these changes, everything is working fine!

I think drag&drop support for adding files and folders is needed. I would also like to include drag and drop support for files inside the file explorer to reorganise projects. I might be able to reuse the vscode file explorer to handle all this stuff. Need to figure out how to do that.

Another thing is that currently projects aren't really shareable because everything is persisted locally and with images and other files we can't use gists anymore.

What I also noticed is that currently the runmod application needs to be recompiled if we want to include more system modules. Would it be possible to precompile these and have the compiler just include these pre-builds when referencing a path like "$(MODULES)/network/http/*" to test this we could use emscriptens -preload-file to include these files inside the tools file system. If that works another step would be to only dynamically load these so we don't ship such a huge payload to the browser each time. I guess these pre-builds would be platform specific but with the dynamic loading approach we could add a platform switch to the UI and load the appropriate builds for each platform.