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...@@ -96,7 +96,7 @@ pub fn detect(allocator: Allocator, native_info: NativeTargetInfo) !NativePaths
96 return self;96 return self;
97 }97 }
9898
99 if (comptime native_target.os.tag == .solaris) {99 if (builtin.os.tag == .solaris) {
100 try self.addLibDir("/usr/lib/64");100 try self.addLibDir("/usr/lib/64");
101 try self.addLibDir("/usr/local/lib/64");101 try self.addLibDir("/usr/local/lib/64");
102 try self.addLibDir("/lib/64");102 try self.addLibDir("/lib/64");
...@@ -107,7 +107,7 @@ pub fn detect(allocator: Allocator, native_info: NativeTargetInfo) !NativePaths...@@ -107,7 +107,7 @@ pub fn detect(allocator: Allocator, native_info: NativeTargetInfo) !NativePaths
107 return self;107 return self;
108 }108 }
109109
110 if (native_target.os.tag != .windows) {110 if (builtin.os.tag != .windows) {
111 const triple = try native_target.linuxTriple(allocator);111 const triple = try native_target.linuxTriple(allocator);
112 defer allocator.free(triple);112 defer allocator.free(triple);
113113
...@@ -136,11 +136,10 @@ pub fn detect(allocator: Allocator, native_info: NativeTargetInfo) !NativePaths...@@ -136,11 +136,10 @@ pub fn detect(allocator: Allocator, native_info: NativeTargetInfo) !NativePaths
136 // libz.so.1 is in /lib/x86_64-linux-gnu (added here)136 // libz.so.1 is in /lib/x86_64-linux-gnu (added here)
137 try self.addLibDirFmt("/lib/{s}", .{triple});137 try self.addLibDirFmt("/lib/{s}", .{triple});
138138
139 // NOTE: distro like guix doesn't use FHS, so it relies on envorinment139 // Distros like guix don't use FHS, so they rely on environment
140 // variables (C_INCLUDE_PATH, CPLUS_INCLUDE_PATH and LIBRARY_PATH) to140 // variables to search for headers and libraries.
141 // search for headers and libraries141 // We use os.getenv here since this part won't be executed on
142 // NOTE: we use os.getenv here since this part won't be executed on142 // windows, to get rid of unnecessary error handling.
143 // windows, to get rid of unnecessary error handling
144 if (std.os.getenv("C_INCLUDE_PATH")) |c_include_path| {143 if (std.os.getenv("C_INCLUDE_PATH")) |c_include_path| {
145 var it = mem.tokenize(u8, c_include_path, ":");144 var it = mem.tokenize(u8, c_include_path, ":");
146 while (it.next()) |dir| {145 while (it.next()) |dir| {