diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 84d88b5..dc84a6d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,4 +17,4 @@ jobs: - uses: goto-bus-stop/setup-zig@v2 with: version: 0.12.0 - - run: zig test stable_array.zig + - run: zig build test diff --git a/README.md b/README.md index 3c7cd82..cd218ae 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Typical usage is to specify a large size up-front that the array should not enco Usage: ```zig -var array = StableArray(u8).init(TEST_VIRTUAL_ALLOC_SIZE); +var array = StableArray(u8).init(1024 * 1024 * 1024 * 128); // virtual address reservation of 128 GB try array.appendSlice(&[_]u8{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }); assert(array.calcTotalUsedBytes() == mem.page_size); for (array.items) |v, i| { diff --git a/build.zig b/build.zig new file mode 100644 index 0000000..acc5ed5 --- /dev/null +++ b/build.zig @@ -0,0 +1,22 @@ +const std = @import("std"); + +pub fn build(b: *std.Build) void { + const target = b.standardTargetOptions(.{}); + const optimize = b.standardOptimizeOption(.{}); + + _ = b.addStaticLibrary(.{ + .name = "zig-stable-array", + .root_source_file = b.path("stable_array.zig"), + .target = target, + .optimize = optimize, + }); + + const lib_unit_tests = b.addTest(.{ + .root_source_file = b.path("stable_array.zig"), + .target = target, + .optimize = optimize, + }); + const run_lib_unit_tests = b.addRunArtifact(lib_unit_tests); + const test_step = b.step("test", "Run unit tests"); + test_step.dependOn(&run_lib_unit_tests.step); +} diff --git a/build.zig.zon b/build.zig.zon new file mode 100644 index 0000000..8e0d453 --- /dev/null +++ b/build.zig.zon @@ -0,0 +1,12 @@ +.{ + .name = "zig-stable-array", + .version = "0.1.0", + .dependencies = .{}, + .paths = .{ + "build.zig", + "build.zig.zon", + "stable_array.zig", + "LICENSE", + "README.md", + } +} diff --git a/zigmod.yml b/zigmod.yml deleted file mode 100644 index 44ed377..0000000 --- a/zigmod.yml +++ /dev/null @@ -1,6 +0,0 @@ -id: i77wzadrw768pcl73aopto4xhgxb1oqg3fjqa93tkee4ncyt -name: stable-array -main: stable_array.zig -license: Unlicense -description: Address-stable array with a max size that allocates directly from virtual memory. -dependencies: