Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Build with latest master #8

Merged
merged 1 commit into from
Jan 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 18 additions & 4 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,17 @@ pub fn build(b: *std.Build) void {
"Output directory for coverage data",
) orelse b.pathFromRoot("cover");

_ = b.addModule("txtar", .{
.source_file = .{ .path = "src/txtar.zig" },
});
if (@hasDecl(std.Build, "CreateModuleOptions")) {
// Zig 0.11
_ = b.addModule("txtar", .{
.source_file = .{ .path = "src/txtar.zig" },
});
} else {
// Zig 0.12
_ = b.addModule("txtar", .{
.root_source_file = .{ .path = "src/txtar.zig" },
});
}

const unit_tests = b.addTest(.{
.root_source_file = .{ .path = "src/txtar.zig" },
Expand All @@ -24,9 +32,15 @@ pub fn build(b: *std.Build) void {
const test_step = b.step("test", "Run tests");
const run_unit_tests = b.addRunArtifact(unit_tests);

const RunStep = if (@hasDecl(std, "build") and @hasDecl(std.build, "RunStep"))
std.build.RunStep // Zig 0.11
else
std.Build.Step.Run // Zig 0.12
;

if (cover) {
run_unit_tests.has_side_effects = true;
run_unit_tests.argv.insertSlice(0, &[_]std.build.RunStep.Arg{
run_unit_tests.argv.insertSlice(0, &[_]RunStep.Arg{
.{ .bytes = b.dupe("kcov") },
.{ .bytes = b.fmt("--include-path={s}", .{b.pathFromRoot("src")}) },
.{ .bytes = b.fmt("--strip-path={s}", .{b.pathFromRoot(".")}) },
Expand Down