From ffb49c28bc1bba6e66938898678dd2bc659bbf2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Do=C4=9Fu=20Us?= <73913444+usdogu@users.noreply.github.com> Date: Tue, 31 Oct 2023 23:03:59 +0300 Subject: [PATCH] feat: use the new module system (#1) --- .gitignore | 3 ++- build.zig | 14 +++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 0b4957c..55cdb70 100644 --- a/.gitignore +++ b/.gitignore @@ -15,4 +15,5 @@ zig-out/ /debug/ /build/ /build-*/ -/docgen_tmp/ \ No newline at end of file +/docgen_tmp/ +*.log \ No newline at end of file diff --git a/build.zig b/build.zig index 2cd4e20..b916c38 100644 --- a/build.zig +++ b/build.zig @@ -13,13 +13,9 @@ pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); - const lib = b.addStaticLibrary(.{ - .name = "extism", - .root_source_file = .{ .path = "src/main.zig" }, - .target = target, - .optimize = optimize, + const extism_module = b.addModule("extism", .{ + .source_file = .{ .path = "src/main.zig" }, }); - b.installArtifact(lib); var tests = b.addTest(.{ .name = "Library Tests", @@ -28,7 +24,7 @@ pub fn build(b: *std.Build) void { .optimize = optimize, }); - tests.addAnonymousModule("extism", .{ .source_file = .{ .path = "src/main.zig" } }); + tests.addModule("extism", extism_module); tests.linkLibC(); tests.addIncludePath(.{ .path = "/usr/local/include" }); tests.addLibraryPath(.{ .path = "/usr/local/lib" }); @@ -45,13 +41,13 @@ pub fn build(b: *std.Build) void { .optimize = optimize, }); - example.addAnonymousModule("extism", .{ .source_file = .{ .path = "src/main.zig" } }); + example.addModule("extism", extism_module); example.linkLibC(); example.addIncludePath(.{ .path = "/usr/local/include" }); example.addLibraryPath(.{ .path = "/usr/local/lib" }); example.linkSystemLibrary("extism"); const example_run_step = b.addRunArtifact(example); - const example_step = b.step("run_example", "Build basic_example"); + const example_step = b.step("run_example", "Run the basic example"); example_step.dependOn(&example_run_step.step); }