Add support for generating compile_commands.json

- Integrate premake-ecc module for generating compile_commands.json
- Add .clangd config pointing to build/ directory
- Add 'Generate compile_commands.json' task
- Run compile_commands generation automatically on build
This commit is contained in:
Peter0x44
2025-12-03 05:16:23 +00:00
parent acc91fd5a8
commit a6c1b96d0a
8 changed files with 268 additions and 1 deletions

35
build/ecc/_preload.lua Normal file
View File

@@ -0,0 +1,35 @@
local p = premake
newoption {
trigger = "config",
value = "CFG",
description = "Select config for export compile_commands.json"
}
newaction {
trigger = "ecc",
shortname = "Export compile commands",
description = "Export compile_commands.json for language server",
toolset = "gcc",
valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib" },
valid_languages = { "C", "C++" },
valid_tools = {
cc = { "clang", "gcc" }
},
onStart = function()
p.indent(" ")
end,
execute = function()
local dir = {}
dir.location = _MAIN_SCRIPT_DIR
p.generate(dir, "compile_commands.json", p.modules.ecc.generateFile)
end
}
return function(cfg)
return (_ACTION == "ecc")
end