-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Support for Emscripten #2618
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for Emscripten #2618
Conversation
There are a couple of changes that I made which need to be modified to prevent them breaking other builds, but I'll have a look at those tomorrow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you need it I could take a look on it since I have more experience with that. When merged next step would be to configure the repo and CI server to generate and host the prebuild images as releases.
"name": "micropython", | ||
"version": "1.8.6", | ||
"description": "micropython compiled to ASM.js with emscripten", | ||
"main": "main.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nain
file must point to one that can be require()
d (importable), use bin
field and rename the file to server.js
instead, this would allow to exec it with npm start
too :-)
emscripten/package.json
Outdated
"main": "main.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"install": "make" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use prebuild-install
module to install prebuild versions of the module.
Thanks @matthewelse, this is good progress! But please take note of #2602. |
Maybe we could work on @matthewelse fork for the Javascript things (npm, repl...) until main micropython one gets cleaned and later merge both of them... :-) I could clearly work on that area, not only because I proposed the original idea but also I have been working a lot lately with Node.js and know how it and the npm ecosystem works... :-) |
Later it would be just a matter of update the URLs to point to the official repo :-P |
@matthewelse : If you're serious about getting this merged upstream eventually, you would read https://github.com/micropython/micropython/wiki/ContributorGuidelines , especially part around "When you make commits for a change, please follow format of existing commit messages (use "git log" to review them)." |
…taining an init() and a run(code) function - repl.js can now be run, producing a REPL
113fc11
to
b1c42e0
Compare
@pfalcon I've reworded the commit messages to follow the format that seems to be usually followed - once people are happy to merge this, I'll squash the commits down, since there's quite a bit of redundancy |
Sounds good! |
Why the name of |
@piranna - I'm not sure what you mean, are you saying that we should call it |
Yes, that's it. In fact, is you use On a side note, since the binary filename doesn't matter, I usually name it |
I think a small amount of work is needed to set up the Python path and that sort of thing to get importing modules working, but it shouldn't be too bad. |
If we could import both Python and Node.js modules with the same |
Agreed this would be awesome - perhaps we should consider that in another issue/PR, and keep this one primarily for doing the initial implementation of the port so it doesn't get too big. |
Agree, by the moment being able to import Python modules would be enough. |
@piranna I've now implemented basic support for importing modules (for testing purposes), though I think there are better ways of approaching this than the way I've done it currently. Namely, I think we can improve the implementation by abstracting away the |
For Python modules your approach makes sense, and the same your idea about abstract it to allow it to work on browsers. For Node.js modules you can use the Come on, it's almost there! :-P |
I think the problem of Node.js modules allowing to export objects or functions is not a problem at all here, since the only difference would be that the |
@piranna that sounds about right, though I'm not sure it'll be that straight-forward to map a JS object straight over to micropython |
It's not about mapping the objects, but just being able to access to the API of the modules. For simple use cases like JSON or simple function calls a call to |
… customised to fit with different JS environments
I can only point to @dpgeorge's comment above - it make take a few months to get merged, sorry about that. Please spend this time productively with @piranna and other interested parties. There was a bounty somewhere, if you're interested, contact the sponsor to get the exact details what he wants to be done to claim it, etc. And please keep patches clean and conforming to the existing codestyle ;-). |
I would add all the cpython cli arguments, and with a low priority support El 13/11/2016 21:48, "Paul Sokolovsky" notifications@github.com escribió: I can only point to @dpgeorge https://github.com/dpgeorge's comment above
— |
@matthewelse This is very nice. Thanks for applying for the #888 bounty. I will try it as soon as we have a browser version. |
How is the status of that? |
#!/usr/bin/env node | ||
|
||
var repl = require('repl'); | ||
var mpy = require('./main.js'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it's now importable, this line can be var mpy = require('.');
instead, that's cleaner.
@matthewelse Hi, what's the status of this? |
Thanks @matthewelse and others involved here for the effort. Sorry it didn't get merged, but was superseded by #3575 which was merged in 7d675f3 |
Fix alignment warning
This is an initial port of MicroPython to compile to JS with Emscripten. It includes a basic REPL application written in JS for testing, and could easily be extended to run in a browser using jq-console.
It probably needs testing more thoroughly, and additional features such as using JavaScript's GC might be interesting future work.
See previous efforts here: #1561 #888
(Some of the) remaining work to do:
cc: @piranna @jaustin