deevus/compile_flagz
No description provided.
A Zig library for generating compile_flags.txt
files to improve C/C++ IDE integration in projects that use Zig as their build system.
compile_flagz
enables better C/C++ development experience in projects that use Zig's build system by automatically generating compile_flags.txt
files. This allows C/C++ language servers (like clangd) to understand your project's include paths, providing better code completion, error detection, and navigation when working on C/C++ code within Zig-built projects.
build.zig
instead of Make/CMakeAdd compile_flagz
to your project:
zig fetch --save git+https://github.com/deevus/compile_flagz
This will automatically add the dependency to your build.zig.zon
file.
In your build.zig
:
const compile_flagz = @import("compile_flagz");
pub fn build(b: *std.Build) void {
// Your existing build configuration...
// Create compile flags generator
var cflags = compile_flagz.addCompileFlags(b);
// Add include paths
cflags.addIncludePath(b.path("include"));
cflags.addIncludePath(dependency.builder.path("include"));
// Create the build step
const cflags_step = b.step("compile-flags", "Generate compile_flags.txt for C/C++ IDE support");
cflags_step.dependOn(&cflags.step);
}
Generate the file:
zig build compile-flags
This creates a compile_flags.txt
file with your include paths formatted for C/C++ language servers.
See the example/
directory for a complete working project that demonstrates usage with SDL dependency.
Build the library:
zig build
Generate API documentation:
zig build docs
The generated documentation will be available in zig-out/docs/
.
MIT License - see LICENSE file for details.