Closed tarruda closed 8 years ago
Well, the best way to do this would probably be by making a new "action" in a new module.
More about actions here: https://github.com/premake/premake-core/wiki/Adding-a-New-Action
and there is plenty of modules as examples here: https://github.com/premake/premake-core/wiki/Modules
Then to write json, I would suggest just writing text, just like most other actions do, importing a json library, while there is pure lua versions seems complicated for simply writing a json file. Parsing is another story obviously...
Thanks for the pointers, I have a proof of concept implementation here: https://github.com/tarruda/premake-export-compile-commands
Would you mind reviewing it? There are a few things that still need to improve, in particular, how do I get flags for files with custom compilation options that differ that differ from the rest of the project?
Well, I don't know much about the json compilation database, but this module looks fine to me.
As for how to get flags for files individually, I don't know exactly, however the vs2010_vcxproj.lua script does something similar for the visual studio projects it outputs, so maybe you can use that as a reference to figure that out... I think the "m.emitFiles" method in that file would be a good start...
Hi
I just started experimenting with premake and I'm loving it so far, thanks for this great project!
One thing I like about cmake is that it can emit clang's json compilation database, which is a simple json file that contains a list of compilation commands for individual files in the project. This database can be used by text-editors to provide code assist features(syntax/semantic highlight, semantic completion, ...). The format is described here: http://clang.llvm.org/docs/JSONCompilationDatabase.html
What's the best way to implement this feature in a way that is easily reusable in other premake projects? If you give me some pointers I can give it a shot. Specifically, this is what I'm looking for:
CMAKE_EXPORT_COMPILE_COMMANDS
option)