diff --git a/.gitignore b/.gitignore index 758c9f0..e93cff3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ .zig-cache/ zig-cache/ zig-out/ +compile_commands.json +.cache/ diff --git a/build.zig b/build.zig index 08ba1c8..c9b307f 100644 --- a/build.zig +++ b/build.zig @@ -1,16 +1,19 @@ const std = @import("std"); +const zcc = @import("compile_commands"); const executable_name = "wc"; pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); + var targets = std.ArrayList(*std.Build.Step.Compile).init(b.allocator); const exe = b.addExecutable(.{ .name = executable_name, .target = target, .optimize = optimize, }); + targets.append(exe) catch @panic("OOM"); const cpp_sources = [_][]const u8{ "src/main.cpp", @@ -40,4 +43,5 @@ pub fn build(b: *std.Build) void { const run_step = b.step("run", "Run the app"); run_step.dependOn(&run_cmd.step); + zcc.createStep(b, "cdb", targets.toOwnedSlice() catch @panic("OOM")); } diff --git a/build.zig.zon b/build.zig.zon index 52e2b40..db75dd9 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -3,6 +3,12 @@ .fingerprint = 0xf51ccd2c9e770ecf, .version = "0.1.0", .minimum_zig_version = "0.14.0", + .dependencies = .{ + .compile_commands = .{ + .url = "https://github.com/the-argus/zig-compile-commands/archive/1a71188d1816cc0741785d4694f790a1106a150a.tar.gz", + .hash = "N-V-__8AABjOAAD9JOGy29zdkAQcgyQyd0NaOn0zP0KyC40W", + }, + }, .paths = .{ "build.zig", "build.zig.zon",