replacing env vars by compile options
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const vk = @import("vulkan");
|
||||
const config = @import("config");
|
||||
const config = @import("lib.zig").config;
|
||||
|
||||
const VkError = @import("error_set.zig").VkError;
|
||||
const Dispatchable = @import("Dispatchable.zig").Dispatchable;
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub fn hasEnvVar(name: []const u8) bool {
|
||||
return getEnvVar(name) != null;
|
||||
}
|
||||
|
||||
pub fn getEnvVar(name: []const u8) ?[:0]const u8 {
|
||||
if (builtin.os.tag == .windows)
|
||||
return null;
|
||||
|
||||
if (std.mem.indexOfScalar(u8, name, '=') != null)
|
||||
return null;
|
||||
|
||||
var ptr = std.c.environ;
|
||||
while (ptr[0]) |line| : (ptr += 1) {
|
||||
var line_i: usize = 0;
|
||||
while (line[line_i] != 0) : (line_i += 1) {
|
||||
if (line_i == name.len) break;
|
||||
if (line[line_i] != name[line_i]) break;
|
||||
}
|
||||
if ((line_i != name.len) or (line[line_i] != '=')) continue;
|
||||
|
||||
return std.mem.sliceTo(line + line_i + 1, 0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -11,7 +11,7 @@ pub const errors = @import("error_set.zig");
|
||||
pub const lib_vulkan = @import("lib_vulkan.zig");
|
||||
pub const logger = @import("logger.zig");
|
||||
pub const format = @import("format.zig");
|
||||
pub const env = @import("environment.zig");
|
||||
pub const config = @import("config");
|
||||
|
||||
pub const Dispatchable = @import("Dispatchable.zig").Dispatchable;
|
||||
pub const NonDispatchable = @import("NonDispatchable.zig").NonDispatchable;
|
||||
|
||||
@@ -14,14 +14,14 @@ comptime {
|
||||
var mutex: std.Io.Mutex = .init;
|
||||
|
||||
pub inline fn fixme(comptime format: []const u8, args: anytype) void {
|
||||
if (!lib.env.hasEnvVar("STROLL_DEBUG_LOGS")) {
|
||||
if (!lib.config.logs) {
|
||||
return;
|
||||
}
|
||||
std.log.scoped(.FIXME).warn("FIXME: " ++ format, args);
|
||||
}
|
||||
|
||||
pub fn log(comptime level: std.log.Level, comptime scope: @EnumLiteral(), comptime format: []const u8, args: anytype) void {
|
||||
if (!lib.env.hasEnvVar("STROLL_DEBUG_LOGS")) {
|
||||
if (!lib.config.logs) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user