all: build: thisDir improvements (#570)
* build:all: thisDir improvements more performant output, usage code reducement and compileError for wrong usage * glfw: update deprecated code
This commit is contained in:
parent
a8d8fedf95
commit
82e10f4f28
13 changed files with 196 additions and 148 deletions
|
|
@ -2,7 +2,7 @@ const std = @import("std");
|
|||
|
||||
pub const pkg = std.build.Pkg{
|
||||
.name = "ecs",
|
||||
.source = .{ .path = thisDir() ++ "/src/main.zig" },
|
||||
.source = .{ .path = sdkPath("/src/main.zig") },
|
||||
.dependencies = &[_]std.build.Pkg{},
|
||||
};
|
||||
|
||||
|
|
@ -14,13 +14,17 @@ pub fn build(b: *std.build.Builder) void {
|
|||
}
|
||||
|
||||
pub fn testStep(b: *std.build.Builder, mode: std.builtin.Mode, target: std.zig.CrossTarget) *std.build.RunStep {
|
||||
const main_tests = b.addTestExe("ecs-tests", (comptime thisDir()) ++ "/src/main.zig");
|
||||
const main_tests = b.addTestExe("ecs-tests", sdkPath("/src/main.zig"));
|
||||
main_tests.setBuildMode(mode);
|
||||
main_tests.setTarget(target);
|
||||
main_tests.install();
|
||||
return main_tests.run();
|
||||
}
|
||||
|
||||
fn thisDir() []const u8 {
|
||||
return std.fs.path.dirname(@src().file) orelse ".";
|
||||
fn sdkPath(comptime suffix: []const u8) []const u8 {
|
||||
if (suffix[0] != '/') @compileError("suffix must be an absolute path");
|
||||
return comptime blk: {
|
||||
const root_dir = std.fs.path.dirname(@src().file) orelse ".";
|
||||
break :blk root_dir ++ suffix;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue