Closed erlingrj closed 12 months ago
Producing a json output sounds good to me. It would likely need to have target specific sections, but that should be Ok.
lfc also outputs all sorts of other useful information while compiling which we also need. A potential disadvantage of having it output a JSON is that we might have to wait until the compilation is completed before lfc can output this JSON, this would be very bad for the user experience.
I don't follow this point. Why would we need to wait, and what is bad about it?
If I understand correctly. If we want lfc to output a JSON with both human-readable info about the compilation process (e.g. the "info" and "warning" messages), and also other fields, e.g. compileDefinitions. Then, lfc would need to "build" this JSON string internally, while compiling and write it to stdout at the very end, when it completes. Then we wouldnt get the info and warning messages "as-we-go".
I guess it could continously write this JSON string as it compiles. And Lingo could work with a partial JSON string to forward the info/warning messages. I havent worked much with JSON, is it common to receive a JSON as a stream and parse it partially and work with the partial result and then go back to parsing more of the stream?
This is what lfc does already internally. It collects all errors and warnings and only prints them when exiting. Producing the json would only require a different message printer, which should be quite easy to add. Normally, lfc should run quite fast (if it just does the code generation and no target compilation), so there shouldn't be a noticeable difference anyway.
In today's (July 25th) meeting, we discussed how
lfc
could/should be changed to output JSON on the stdout which can be consumed bylingo
. The usecase motivating this is currently that for the C target,lfc
will generate compile definitions based on the source code, i.e. not only based on the target properties. Currentlylfc
spits out aCompileDefinitions.txt
in the src-gen folder with these compile defs as well. Forlingo
to generate the CMakeLists.txt by itself, it would need this information. Either by using this CompileDefinitions.txt file or, as discussed today, by changing the output oflfc
to be e.g. a JSON which contains this info.lfc
also outputs all sorts of other useful information while compiling which we also need. A potential disadvantage of having it output a JSON is that we might have to wait until the compilation is completed beforelfc
can output this JSON, this would be very bad for the user experience.