From 3c540293fdb521157492cf0e240591d53dedfc92 Mon Sep 17 00:00:00 2001 From: foxnne Date: Thu, 3 Dec 2020 15:59:28 -0600 Subject: [PATCH 1/2] add getPackage to build.zig --- zig-ecs/build.zig | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/zig-ecs/build.zig b/zig-ecs/build.zig index 7a099dd..b126d3c 100644 --- a/zig-ecs/build.zig +++ b/zig-ecs/build.zig @@ -55,8 +55,15 @@ pub const LibType = enum(i32) { exe_compiled, }; -/// rel_path is used to add package paths. It should be the the same path used to include this build file -pub fn linkArtifact(b: *Builder, artifact: *std.build.LibExeObjStep, target: std.build.Target, lib_type: LibType, rel_path: []const u8) void { +pub fn getPackage(comptime prefix_path: []const u8) std.build.Pkg { + return .{ + .name = "ecs", + .path = prefix_path ++ "src/ecs.zig", + }; +} + +/// prefix_path is used to add package paths. It should be the the same path used to include this build file +pub fn linkArtifact(b: *Builder, artifact: *std.build.LibExeObjStep, target: std.build.Target, lib_type: LibType, prefix_path: []const u8) void { switch (lib_type) { .static => { const lib = b.addStaticLibrary("ecs", "ecs.zig"); @@ -75,5 +82,5 @@ pub fn linkArtifact(b: *Builder, artifact: *std.build.LibExeObjStep, target: std else => {}, } - artifact.addPackagePath("ecs", std.fs.path.join(b.allocator, &[_][]const u8{ rel_path, "ecs.zig" }) catch unreachable); + artifact.addPackage(getPackage(prefix_path)); } From 737e5a9b3913f0a95542bf01b1e273ddb349b4f4 Mon Sep 17 00:00:00 2001 From: foxnne Date: Thu, 3 Dec 2020 16:23:29 -0600 Subject: [PATCH 2/2] fix error in linkArtifact --- zig-ecs/build.zig | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/zig-ecs/build.zig b/zig-ecs/build.zig index b126d3c..5dd9bf1 100644 --- a/zig-ecs/build.zig +++ b/zig-ecs/build.zig @@ -63,7 +63,8 @@ pub fn getPackage(comptime prefix_path: []const u8) std.build.Pkg { } /// prefix_path is used to add package paths. It should be the the same path used to include this build file -pub fn linkArtifact(b: *Builder, artifact: *std.build.LibExeObjStep, target: std.build.Target, lib_type: LibType, prefix_path: []const u8) void { +pub fn linkArtifact(b: *Builder, artifact: *std.build.LibExeObjStep, target: std.build.Target, lib_type: LibType, comptime prefix_path: []const u8) void { + const buildMode = b.standardReleaseOptions(); switch (lib_type) { .static => { const lib = b.addStaticLibrary("ecs", "ecs.zig"); @@ -73,7 +74,7 @@ pub fn linkArtifact(b: *Builder, artifact: *std.build.LibExeObjStep, target: std artifact.linkLibrary(lib); }, .dynamic => { - const lib = b.addSharedLibrary("ecs", "ecs.zig", null); + const lib = b.addSharedLibrary("ecs", "ecs.zig", .unversioned); lib.setBuildMode(buildMode); lib.install();