Closed dansanderson closed 2 years ago
On further consideration, I'm thinking there isn't a use case where picotool should preserve #include in its output, and it's sufficient to always interpolate them on input of a .p8 file and never preserve them. At least, this is less expensive than something fancier, and a cheap solution would cover most useful cases for now. Further ideas welcome.
Implemented in d8c51e58416f8010dc8c0fba3df5f0424b5bb852.
PICO-8's #include
supports including anything in the carts directory, including anything that's a parent to the including cart. picotool tries to support this by detecting whether the input cart is in a standard PICO-8 carts directory. If it isn't (which picotool allows), it restricts includes to the input file's directory and subdirectories. I'm open to a feature request to expand this capability (e.g. a --carts-dir=... parameter), but for now I suspect people don't need this.
Like PICO-8, picotool supports including from .lua, .p8, or .p8.png files, and supports including only a tab from a .p8 or .p8.png file (#include inc.p8:2
). Also like PICO-8, the included file is not allowed to contain #include
statements of its own: these are left uninterpolated and reported as syntax errors, just like PICO-8.
I doubt anyone needed me to do this but I feel better knowing that it works.
PICO-8 now has a
#include
preprocessor directive in its .p8 file format. picotool needs to recognize and preserve this for .p8 files, and evaluate it identically to PICO-8 (I believe it's straight lexical inclusion, with file path requirements) when converting to other formats.Notice that picotool does not need to know anything about generating
#include
directives. picotool just needs to recognize them as part of the syntax and preserve them in .p8-to-.p8 actions.As an exception, luamin must evaluate them instead of trying to preserve them, even when producing a .p8 cart format, because it needs to lex the complete set of code to calculate new label names. I can't think of a reason to try to preserve (and recursively minify!)
#include
-d files.