#Zig build C project with compile_commands.json

1 messages · Page 1 of 1 (latest)

jaunty aspen
tender dew
#

I dont think there an option for that yet. I looked through the source code and didn't find any reference to that and there is no issue created on the zig github for that

queen grove
#

what's compile_commands.json?

bright rivet
trail spire
# jaunty aspen Hello, I wanted to check out zig to build my c projects so that I can avoid CMak...

oh thats neat. heres a super rough alternative that i did. ive since significantly improved things, but its sitting unpushed on a packed up pc
https://github.com/We-the-People-civ4col-mod/Mod/blob/zig/build.zig#L105-L139

GitHub

This is the repository where the mod resides. . Contribute to We-the-People-civ4col-mod/Mod development by creating an account on GitHub.

#

i dont know if that template's supports caching, but mine does through a pretty hacky mechanism tbh

jaunty aspen
tender dew
#

i dont think bear will help here

jaunty aspen
#

idk, im currently on windows, im using a super convoluted setup

#

cmake, visual studio, msbuild, clang power tools, batch

#

ill try to move it to zig...

bright rivet
tender dew
#

I'll see if it's easy to add to zig. I need it myself as well (when mixing c and zig in one project)

jaunty aspen
#

it'll help me get rid of cmake and msbuild lol 😆

#

i use a VS plugin to generate them

#

i think u need to zig cc -MJ

#

to generate

#

here's my convoluted setup lol

tender dew
#

hmm I took at look at it and it's not that hard to just add the files, include flags and linker flags to create a compile_commands.json file from a build.zig file. However if you want the zig added defines to be included then it's harder. Zig adds NDEBUG and you can choose which c compiler to use and all that, but that part is linked to the caching system. So if you run zig build once then it will no longer output that data. You can see that if you do zig build --verbose-cc

jaunty aspen
jaunty aspen
#

this uses vcpkg