authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-10-17 14:22:38-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-10-18 16:52:43-07:00
logc7772dd69455f6abf0ff2594f8b049acb078c921
tree0f2ff80cdb4f56b3d515fd75202498c4e921ffc3
parentcaddbbc315e834241c6ae7e22434b574c589e5fc

std.zig.system.NativePaths: avoid calling std.os.getenv on Windows


1 files changed, 6 insertions(+), 7 deletions(-)

lib/std/zig/system/NativePaths.zig+6-7
......@@ -96,7 +96,7 @@ pub fn detect(allocator: Allocator, native_info: NativeTargetInfo) !NativePaths
9696 return self;
9797 }
9898
99 if (comptime native_target.os.tag == .solaris) {
99 if (builtin.os.tag == .solaris) {
100100 try self.addLibDir("/usr/lib/64");
101101 try self.addLibDir("/usr/local/lib/64");
102102 try self.addLibDir("/lib/64");
......@@ -107,7 +107,7 @@ pub fn detect(allocator: Allocator, native_info: NativeTargetInfo) !NativePaths
107107 return self;
108108 }
109109
110 if (native_target.os.tag != .windows) {
110 if (builtin.os.tag != .windows) {
111111 const triple = try native_target.linuxTriple(allocator);
112112 defer allocator.free(triple);
113113
......@@ -136,11 +136,10 @@ pub fn detect(allocator: Allocator, native_info: NativeTargetInfo) !NativePaths
136136 // libz.so.1 is in /lib/x86_64-linux-gnu (added here)
137137 try self.addLibDirFmt("/lib/{s}", .{triple});
138138
139 // NOTE: distro like guix doesn't use FHS, so it relies on envorinment
140 // variables (C_INCLUDE_PATH, CPLUS_INCLUDE_PATH and LIBRARY_PATH) to
141 // search for headers and libraries
142 // NOTE: we use os.getenv here since this part won't be executed on
143 // windows, to get rid of unnecessary error handling
139 // Distros like guix don't use FHS, so they rely on environment
140 // variables to search for headers and libraries.
141 // We use os.getenv here since this part won't be executed on
142 // windows, to get rid of unnecessary error handling.
144143 if (std.os.getenv("C_INCLUDE_PATH")) |c_include_path| {
145144 var it = mem.tokenize(u8, c_include_path, ":");
146145 while (it.next()) |dir| {