From 68b2882172219abe5b2d3b0bae611109c9b8f5cd Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Thu, 4 Jul 2024 09:47:16 +0200 Subject: [PATCH] feat: Added zig build check https://kristoff.it/blog/improving-your-zls-experience/ --- build.zig | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/build.zig b/build.zig index 6a71d8e9..860b185c 100644 --- a/build.zig +++ b/build.zig @@ -302,6 +302,16 @@ pub fn build(b: *Build) !void { }); b.installArtifact(exe); + var exe_check = b.addExecutable(.{ + .name = "buzz", + .root_source_file = b.path("src/main.zig"), + .target = target, + .optimize = build_mode, + }); + + const check = b.step("check", "Check if buzz compiles"); + check.dependOn(&exe_check.step); + if (is_wasm) { exe.global_base = 6560; exe.entry = .disabled; @@ -322,20 +332,25 @@ pub fn build(b: *Build) !void { for (includes.items) |include| { exe.addIncludePath(b.path(include)); + exe_check.addIncludePath(b.path(include)); } for (llibs.items) |lib| { exe.addLibraryPath(b.path(lib)); + exe_check.addLibraryPath(b.path(lib)); } for (sys_libs.items) |slib| { // FIXME: if mir is linked as static library (libmir.a), here also need to link libc // it's better to built it with Zig's build system exe.linkSystemLibrary(slib); + exe_check.linkSystemLibrary(slib); } if (build_options.needLibC()) { exe.linkLibC(); + exe_check.linkLibC(); } exe.root_module.addImport("build_options", build_option_module); + exe_check.root_module.addImport("build_options", build_option_module); if (!is_wasm) { // Building buzz api library @@ -380,8 +395,10 @@ pub fn build(b: *Build) !void { // So that JIT compiled function can reference buzz_api exe.linkLibrary(lib); + exe_check.linkLibrary(lib); if (lib_linenoise) |ln| { exe.linkLibrary(ln); + exe_check.linkLibrary(ln); } b.default_step.dependOn(&exe.step);