ardupilot
ardupilot copied to clipboard
AP_Scripting: add ROMFS to lua path
This allows require to find modules in ROMFS. Possibly helps with other file system methods too. Note that this adds the new search path even if we don't have ROMFS compiled in. I think it will be fine, but I have not tested.
Adding "./modules/?.lua;" "./modules/?/init.lua" to get to the same place relative to a script loaded in ROMFS does not seem to work, I'm not sure why.
This should allow a SD card script to require something from ROMFS, which using relative paths would not. Because of the ordering it should also mean a SD card version of the same file gets priority over a ROMFS copy. Its convenient for development but might give users a very exciting way to break stuff. We could swap the ordering so ROMFS takes priority. Again, I have not tested this.
This resolves https://github.com/ArduPilot/ardupilot/issues/26155
This now works as expected while abiding by SCR_DIR_DISABLE, the approach using defines is not very scalable it would fall over if we added another directory, but for now it keeps it simple.