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

add support for the latest version of zig 0.13.0 #2

Merged
merged 5 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/zig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

- uses: goto-bus-stop/setup-zig@v1
with:
version: 0.9.1
version: 0.13.0

- name: Run tests
run: zig build test
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
zig-cache
zig-out
zig-out
.zig-cache
47 changes: 30 additions & 17 deletions build.zig
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const std = @import("std");

const stringPackagePath = "deps/string/string.zig";

pub fn build(b: *std.build.Builder) void {
pub fn build(b: *std.Build) void {
// Standard target options allows the person running `zig build` to choose
// what target to build for. Here we do not override the defaults, which
// means any target is allowed, and the default is native. Other options
Expand All @@ -11,28 +9,43 @@ 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 exe = b.addExecutable("monkey-zig", "src/main.zig");
exe.addPackagePath("string", stringPackagePath);
exe.setTarget(target);
exe.setBuildMode(mode);
exe.install();

const run_cmd = exe.run();
const mode = b.standardOptimizeOption(.{});

const stringLib = b.dependency("string", .{
.target = target,
.optimize = mode,
});
const stringModule = stringLib.module("string");

// Add a build step to compile the app
const exe = b.addExecutable(.{
.name = "monkey-zig",
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = mode,
});
exe.root_module.addImport("string", stringModule);

const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
}

// Add a test step
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);

const exe_tests = b.addTest("src/main.zig");
exe_tests.addPackagePath("string", stringPackagePath);
exe_tests.setTarget(target);
exe_tests.setBuildMode(mode);
const exe_tests = b.addTest(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = mode,
});
exe_tests.root_module.addImport("string", stringModule);

const run_tests = b.addRunArtifact(exe_tests);
run_tests.has_side_effects = true;

const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&exe_tests.step);
test_step.dependOn(&run_tests.step);
}
16 changes: 16 additions & 0 deletions build.zig.zon
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.{
.name = "monky-zig",
.version = "0.2.0",
.minimum_zig_version = "0.13.0",

.dependencies = .{
.string = .{
.url = "https://github.com/JakubSzark/zig-string/archive/refs/heads/master.tar.gz",
.hash = "122047e740a48165ed1cdd10b8c595cb5b37d2ae2128364957ba0a8de5c7dc396adf",
},
},

.paths = .{
"",
},
}
Loading
Loading