Skip to content

Commit

Permalink
Merge pull request #10 from Hanaasagi/zig-0.11
Browse files Browse the repository at this point in the history
chore: move to zig 0.11 new build API.
  • Loading branch information
magurotuna committed Aug 8, 2023
2 parents d4d2845 + 083aeef commit c8ca9d7
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
33 changes: 24 additions & 9 deletions build.zig
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
const std = @import("std");

pub fn build(b: *std.build.Builder) void {
// Standard release options allow the person running `zig build` to select
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
const mode = b.standardReleaseOptions();
const target = b.standardTargetOptions(.{});

const lib = b.addStaticLibrary("zig-deque", "src/deque.zig");
lib.setBuildMode(mode);
lib.install();
const optimize = b.standardOptimizeOption(.{});

const main_tests = b.addTest("src/deque.zig");
main_tests.setBuildMode(mode);
_ = b.addModule("zig-deque", .{
.source_file = .{ .path = "src/deque.zig" },
.dependencies = &.{},
});

const lib = b.addStaticLibrary(.{
.name = "zig-deque",
.root_source_file = .{ .path = "src/deque.zig" },
.target = target,
.optimize = optimize,
});

b.installArtifact(lib);

const main_tests = b.addTest(.{
.root_source_file = .{ .path = "src/deque.zig" },
.target = target,
.optimize = optimize,
});

const run_main_tests = b.addRunArtifact(main_tests);

const test_step = b.step("test", "Run library tests");
test_step.dependOn(&main_tests.step);
test_step.dependOn(&run_main_tests.step);
}
5 changes: 5 additions & 0 deletions build.zig.zon
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.{
.name = "zig-deque",
.version = "0.1.0",
.dependencies = .{},
}
2 changes: 1 addition & 1 deletion src/deque.zig
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub fn Deque(comptime T: type) type {
/// Deinitialize with `deinit`.
pub fn initCapacity(allocator: Allocator, capacity: usize) Allocator.Error!Self {
const effective_cap =
math.ceilPowerOfTwo(usize, math.max(capacity +| 1, MINIMUM_CAPACITY + 1)) catch
math.ceilPowerOfTwo(usize, @max(capacity +| 1, MINIMUM_CAPACITY + 1)) catch
math.ceilPowerOfTwoAssert(usize, INITIAL_CAPACITY + 1);
const buf = try allocator.alloc(T, effective_cap);
return Self{
Expand Down

0 comments on commit c8ca9d7

Please sign in to comment.