Skip to content

Commit

Permalink
fix: build (#16)
Browse files Browse the repository at this point in the history
* fix: build

* chore: remove unused import

* chore: remove unused import & fix sleep
  • Loading branch information
usdogu authored May 21, 2024
1 parent 4ed53e1 commit 8f0248c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const builtin = @import("builtin");
pub fn build(b: *std.Build) void {
comptime {
const current_zig = builtin.zig_version;
const min_zig = std.SemanticVersion.parse("0.12.0-dev.2030") catch unreachable; // build system changes: ziglang/zig#18160
const min_zig = std.SemanticVersion.parse("0.13.0-dev.230+50a141945") catch unreachable; // build system changes: ziglang/zig#19597
if (current_zig.order(min_zig) == .lt) {
@compileError(std.fmt.comptimePrint("Your Zig version v{} does not meet the minimum build requirement of v{}", .{ current_zig, min_zig }));
}
Expand All @@ -14,20 +14,20 @@ pub fn build(b: *std.Build) void {
const optimize = b.standardOptimizeOption(.{});

const extism_module = b.addModule("extism", .{
.root_source_file = .{ .path = "src/main.zig" },
.root_source_file = b.path("src/main.zig"),
});

var tests = b.addTest(.{
.name = "Library Tests",
.root_source_file = .{ .path = "test.zig" },
.root_source_file = b.path("test.zig"),
.target = target,
.optimize = optimize,
});

tests.root_module.addImport("extism", extism_module);
tests.linkLibC();
tests.addIncludePath(.{ .path = "/usr/local/include" });
tests.addLibraryPath(.{ .path = "/usr/local/lib" });
tests.addIncludePath(.{ .cwd_relative = "/usr/local/include" });
tests.addLibraryPath(.{ .cwd_relative = "/usr/local/lib" });
tests.linkSystemLibrary("extism");
const tests_run_step = b.addRunArtifact(tests);

Expand All @@ -36,15 +36,15 @@ pub fn build(b: *std.Build) void {

var example = b.addExecutable(.{
.name = "Example",
.root_source_file = .{ .path = "examples/basic.zig" },
.root_source_file = b.path("examples/basic.zig"),
.target = target,
.optimize = optimize,
});

example.root_module.addImport("extism", extism_module);
example.linkLibC();
example.addIncludePath(.{ .path = "/usr/local/include" });
example.addLibraryPath(.{ .path = "/usr/local/lib" });
example.addIncludePath(.{ .cwd_relative = "/usr/local/include" });
example.addLibraryPath(.{ .cwd_relative = "/usr/local/lib" });
example.linkSystemLibrary("extism");
const example_run_step = b.addRunArtifact(example);

Expand All @@ -56,7 +56,7 @@ pub fn addLibrary(to: *std.Build.Step.Compile, b: *std.Build) void {
to.root_module.addImport("extism", b.dependency("extism", .{}).module("extism"));
to.linkLibC();
// TODO: switch based on platform and use platform-specific paths here
to.addIncludePath(.{ .path = "/usr/local/include" });
to.addLibraryPath(.{ .path = "/usr/local/lib" });
to.addIncludePath(.{ .cwd_relative = "/usr/local/include" });
to.addLibraryPath(.{ .cwd_relative = "/usr/local/lib" });
to.linkSystemLibrary("extism");
}
2 changes: 1 addition & 1 deletion test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ test "Plugin Cancellation" {
var handle = plugin.cancelHandle();
const S = struct {
fn _test(h: *sdk.CancelHandle) void {
std.os.nanosleep(1, 0);
std.time.sleep(1 * std.time.ns_per_s);
_ = h.cancel();
}
};
Expand Down

0 comments on commit 8f0248c

Please sign in to comment.