Merge pull request #8 from foxnne/pkg

Added getPackage and fixed errors
master
prime31 4 years ago committed by GitHub
commit dec796d256

@ -55,8 +55,16 @@ 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, comptime prefix_path: []const u8) void {
const buildMode = b.standardReleaseOptions();
switch (lib_type) {
.static => {
const lib = b.addStaticLibrary("ecs", "ecs.zig");
@ -66,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();
@ -75,5 +83,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));
}

Loading…
Cancel
Save