Skip to content
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

[Feature Request] Compile files before upload #71

Open
jayu opened this issue Mar 14, 2020 · 2 comments
Open

[Feature Request] Compile files before upload #71

jayu opened this issue Mar 14, 2020 · 2 comments
Labels
feature-request os/linux linux related issues os/mac apple/macOS related

Comments

@jayu
Copy link

jayu commented Mar 14, 2020

Background

Hey, this tool looks amazing! I'm doing a small research about upgrading my current dev tooling around NodeMCU development.

I used to use ESPlorer, but I'm looking for a more convenient and automated way of uploading and executing scripts on my ESPs. Recently I faced an issue with hight ram usage, due to runtime compilation of '*.lua' files. Due to docs, it is possible to compile source files on PC, before uploading them to ESP. It should save a lot of RAM which is being used to compile files to byte code.

Feature Request

Compiling the code is not yet supported by this tool. Of course, I can first compile the files using luac.cross and then upload them with NodeMCU-Tool, but It would be more convenient to have this feature built-in.

We could introduce an additional params -c and --compiler to upload command that would be used to point luac.cross binary. Then the tool could use this binary to compile provided *.lua files before upload. But it would require checking the files extensions first and might not be intuitive for users.

Another option is to add a new command, e.g compile-upload with -c and --compiler params that would be only for *.lua sources. But this has a drawback, that some users might want to upload not only the *.lua files.

Some users might want to pass additional params to the compiler. E.g. it is possible to build one *.img from many *.lua source files. But it would not fit into any of the above options since we are changing the files that would be uploaded (before we had to just rename them from *.lua to *.lc).

So there is one more possibility. Provide a wrapper over luac.cross that would take a list of files and compile them, and then print paths to files to stdout. Then we could pipe compile and upload
using xargs e.g node-tool compile -c [compiler path] file.lua file2.lua | xargs node-tool upload.
It could be used in both scenarios, meaning whether the user wants to bundle files into an image or not.

Current solution

I found out that there is an option to compile a file on ESP, but if the file is too big it will run out of memory. However, the message is still success. I will open another issue for that.
Compiling on PC will allow handling bigger files and have more source code on ESP.

@AndiDittrich AndiDittrich added feature-request os/linux linux related issues os/mac apple/macOS related labels Mar 14, 2020
@AndiDittrich
Copy link
Owner

Hi @jayu ,

the main issue with such feature is that most nodemcu users are not able to install/setup a full toolchain (which is also platform depended) - therefore i've given up this idea a long time ago.

currently i didn't have any time to implement this (or a similar) feature...sry

@jayu
Copy link
Author

jayu commented Mar 14, 2020

I'm totally fine with that. This feature could be usefull for more advance ppl. Regular users might not have to use it.
And I forgot to mention that I would be happy to contribute! Let me know if you see a place for that kind of feature in this library. If we establish an API for this I can give i a try :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request os/linux linux related issues os/mac apple/macOS related
Projects
None yet
Development

No branches or pull requests

2 participants