| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Adds a script that compiles all Betaflight lua files the first time bf.lua is executed. build.sh has been repurposed to create a file containing a table with the files to be compiled. The .lua files are tested for errors using luac -p. No .luac files are created.
| collectgarbage() | ||
| return 0 | ||
| end | ||
| local file = io.open("COMPILE/scripts_compiled.lua", 'w') |
There was a problem hiding this comment.
I had been looking for a way to persist state in lua - this seems to be a good way to do so.
Sorry, something went wrong.
There was a problem hiding this comment.
👍 . The first iteration of this had compile.lua delete it's contents when finished. Quickly abandoned that idea lol.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Adds a script that compiles all Betaflight lua files the first time bf.lua is executed.
build.sh has been repurposed to create a file containing a table with the files to be compiled. The .lua files are tested for errors using luac -p. No .luac files are created.
As discussed in #281 the main memory issue we have now is running out of memory when compiling the betaflight lua scripts on the TX. OpenTX uses a modified version of LUA 5.2.2 with lua tiny RAM applied. This means that precompiled scripts will not work unless they are created with a version of lua that has had the same mod applied.
I believe the problem with on device compilation is that we're trying to load too many files in one lua cycle(bf.lua). The solution is to use a compile script that loads and compiles one file each lua cycle.
compile.lua will only run the first time bf.luais executed. It loads and compiles all files listed in scripts.lua one by one and exits when done. The next time bf.lua is executed everything will be as normal. compile.lua will not run again unless scripts_compiled.lua is modified or overwritten(new bf lua version).
"Free mem" in OpenTX shows over 40KB after running this(used to be close to 0 or out of memory).