Skip to content

Instantly share code, notes, and snippets.

@Brugarolas
Created October 15, 2024 15:44
Show Gist options
  • Select an option

  • Save Brugarolas/3767dca42b6d676f993cb5d11aa765bb to your computer and use it in GitHub Desktop.

Select an option

Save Brugarolas/3767dca42b6d676f993cb5d11aa765bb to your computer and use it in GitHub Desktop.
Zig build for string library
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
// Add static library
const lib = b.addStaticLibrary(.{
.name = "zig-string",
.root_source_file = b.path("src/string.zig"),
.target = target,
.optimize = optimize,
});
b.installArtifact(lib);
// Add and run unit tests
const unit_tests = b.addTest(.{
.root_source_file = b.path("src/test.zig"),
.target = target,
.optimize = optimize,
});
b.default_step.dependOn(&unit_tests.step);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment