ardupilot icon indicating copy to clipboard operation
ardupilot copied to clipboard

AP_Scripting: add ROMFS to lua path

Open IamPete1 opened this issue 1 year ago • 1 comments

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.

IamPete1 avatar Feb 06 '24 22:02 IamPete1

This resolves https://github.com/ArduPilot/ardupilot/issues/26155

rmackay9 avatar Feb 06 '24 22:02 rmackay9

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.

IamPete1 avatar Feb 23 '24 01:02 IamPete1