Croteam-official/Serious-Engine

Ecc Fails on Empty Files

Closed this issue · 6 comments

I noticed that the Ecc in this repository fails when invoked against a file with no content like Sources/EntitiesMP/ParticleCloudsMarker.es where really the only thing in it is a block comment. It became apparent when I instructed my local repo to recursively build all the Es files: Ragora@375bdb6

So, either we'll need to fix Ecc to generate files with essentially nothing in them or otherwise modify such files to have no-op code in them so that Ecc builds down the line don't fail. I'm not all that familiar with the toolkits used for Ecc to parse and build the files, or I'd fix it myself.

Usually this is resolved by marking unused .ES files as "Excluded from build".

I'd have to write up a blacklist for CMake to compare against in the meantime for that to work as this on a Linux Box just blindly recursing over everything. Though we shouldn't have to really work around a buggy tool, it ideally would notice the file is no-op instead of us explicitly blacklisting the file.

Well, you can very easily add a check to the beginning of ECC main function. Right after it loads a file, it can check whether it's valid or not. I'd be grateful if you do that.

Could probably do it with some quick regex, though I don't know if you want to be C++11 bound on std::regex or to add more dependencies. It looks like the parser returns 0 on success and 1 for any error, but I don't know how (within just the current toolset) to check if a file is a no-op. We want the regex so we can do something like a full strip in some temporary buffer of things like commenting and then to return gracefully if there's nothing but whitespace left.

Though I have an alternative idea that'll work without it, just give me a bit on that.

All code in .ES files always begins with a unique number. Perhaps the easiest way to check .ES file validity is to scan it until the first line that contains a single number, skipping all comment lines. If the file is still invalid despite having that number, a parser will fail, which is okay because it'd be an actual parse error, not just empty file.
Introducing STL into engine is a different topic. @alenl probably has something to say about that.
Either way it'd be better to skip all .ES files that are excluded from build because they refer to resources that are not included with this engine (Huanman.es, Mantaman.es etc). Even if they don't produce build errors, those entities will crash the editor application once you attempt to use them.

It does seem like the first non-nop line should be a single integer, so that does make this significantly easier. Thanks!