diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7b09a0b..517f483 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,9 +15,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: mlugg/setup-zig@v1 + - uses: mlugg/setup-zig@v2 with: - version: 0.14.0 + version: 0.15.1 - run: | zig build -Dtarget=x86_64-windows zig build -Dtarget=aarch64-windows diff --git a/.gitignore b/.gitignore index e93cff3..b0f82ee 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ zig-cache/ zig-out/ compile_commands.json .cache/ + +.DS_STORE diff --git a/README.md b/README.md index b500c3d..1edfb03 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ The project aims to implement all core utilities, including but not limited to: ### Prerequisites -- Zig compiler (0.14 recommended) +- Zig compiler (0.15.1 recommended) ### Building from Source diff --git a/build.zig b/build.zig index ce9c3e5..5b1b2a3 100644 --- a/build.zig +++ b/build.zig @@ -14,13 +14,15 @@ const Executable = struct { }; } - fn build(self: Executable, b: *std.Build, optimize: std.builtin.Mode, target: std.Build.ResolvedTarget, targets: *std.ArrayList(*std.Build.Step.Compile)) void { + fn build(self: Executable, b: *std.Build, optimize: std.builtin.OptimizeMode, target: std.Build.ResolvedTarget, targets: *std.ArrayList(*std.Build.Step.Compile)) void { const exe = b.addExecutable(.{ .name = self.name, - .target = target, - .optimize = optimize, + .root_module = b.createModule(.{ + .target = target, + .optimize = optimize, + }) }); - targets.append(exe) catch @panic("OOM"); + for (self.cpp_sources) |source| { exe.addCSourceFile(.{ .file = b.path(source), @@ -32,6 +34,7 @@ const Executable = struct { exe.addIncludePath(b.path(include_path)); } b.installArtifact(exe); + targets.append(b.allocator, exe) catch @panic("OOM"); const run_cmd_name = std.fmt.allocPrint(b.allocator, "run-{s}", .{self.name}) catch @panic("OOM"); const run_cmd_info = std.fmt.allocPrint(b.allocator, "Run the {s} app", .{self.name}) catch @panic("OOM"); @@ -49,8 +52,8 @@ const Executable = struct { 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); - defer targets.deinit(); + var targets : std.ArrayList(*std.Build.Step.Compile) = .empty; + defer targets.deinit(b.allocator); Executable.init("wc", &[_][]const u8{ "src/wc/main.cpp", @@ -73,5 +76,5 @@ pub fn build(b: *std.Build) void { "src/false", }).build(b, optimize, target, &targets); - zcc.createStep(b, "cdb", targets.toOwnedSlice() catch @panic("OOM")); + _ = zcc.createStep(b, "cdb", targets.toOwnedSlice(b.allocator) catch @panic("OOM")); } diff --git a/build.zig.zon b/build.zig.zon index db75dd9..f41276b 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -2,11 +2,11 @@ .name = .wc, .fingerprint = 0xf51ccd2c9e770ecf, .version = "0.1.0", - .minimum_zig_version = "0.14.0", + .minimum_zig_version = "0.15.1", .dependencies = .{ .compile_commands = .{ - .url = "https://github.com/the-argus/zig-compile-commands/archive/1a71188d1816cc0741785d4694f790a1106a150a.tar.gz", - .hash = "N-V-__8AABjOAAD9JOGy29zdkAQcgyQyd0NaOn0zP0KyC40W", + .url = "https://github.com/the-argus/zig-compile-commands/archive/70fb439897e12cae896c071717d7c9c382918689.tar.gz", + .hash = "zig_compile_commands-0.0.1-OZg5-ULBAABTh3NXO3WXoSUX1474ez0EouuoT2yDANhz", }, }, .paths = .{