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:
Ali Chraghi 2022-09-29 19:11:46 +03:30 committed by GitHub
parent a8d8fedf95
commit 82e10f4f28
Failed to generate hash of commit
13 changed files with 196 additions and 148 deletions

View file

@ -5,7 +5,7 @@ const mem = std.mem;
const fs = std.fs;
const build = std.build;
const www_dir_path = thisDir() ++ "/www";
const www_dir_path = sdkPath("/www");
const buffer_size = 2048;
const esc = struct {
pub const reset = "\x1b[0m";
@ -334,6 +334,10 @@ fn logErr(err: anyerror, src: std.builtin.SourceLocation) void {
}
}
fn thisDir() []const u8 {
return 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;
};
}