| author | |
| committer | |
| log | f25de4c7a238d46a20c6a22e3b951ee09ecfb962 |
| tree | 4471537c73338973f1cb50bd97ab629b019aa491 |
| parent | 17c7a339d87b8029436c676582e9c54720e6c180 |
3 files changed, 6 insertions(+), 10 deletions(-)
lib/std/zig.zig+3| ... | ... | @@ -763,6 +763,9 @@ pub const EnvVar = enum { |
| 763 | 763 | // Windows SDK integration |
| 764 | 764 | PROGRAMDATA, |
| 765 | 765 | |
| 766 | // Homebrew integration | |
| 767 | HOMEBREW_PREFIX, | |
| 768 | ||
| 766 | 769 | pub fn isSet(ev: EnvVar, map: *const std.process.Environ.Map) bool { |
| 767 | 770 | return map.contains(@tagName(ev)); |
| 768 | 771 | } |
lib/std/zig/system/NativePaths.zig+1-3| ... | ... | @@ -121,7 +121,7 @@ pub fn detect( |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | // Check for homebrew paths |
| 124 | if (std.posix.getenv("HOMEBREW_PREFIX")) |prefix| { | |
| 124 | if (std.zig.EnvVar.HOMEBREW_PREFIX.get(env_map)) |prefix| { | |
| 125 | 125 | try self.addLibDir(try std.fs.path.join(arena, &.{ prefix, "/lib" })); |
| 126 | 126 | try self.addIncludeDir(try std.fs.path.join(arena, &.{ prefix, "/include" })); |
| 127 | 127 | } |
| ... | ... | @@ -177,8 +177,6 @@ pub fn detect( |
| 177 | 177 | |
| 178 | 178 | // Distros like guix don't use FHS, so they rely on environment |
| 179 | 179 | // variables to search for headers and libraries. |
| 180 | // We use os.getenv here since this part won't be executed on | |
| 181 | // windows, to get rid of unnecessary error handling. | |
| 182 | 180 | if (std.zig.EnvVar.C_INCLUDE_PATH.get(env_map)) |c_include_path| { |
| 183 | 181 | var it = mem.tokenizeScalar(u8, c_include_path, ':'); |
| 184 | 182 | while (it.next()) |dir| { |
test/standalone/posix/getenv.zig+2-7| ... | ... | @@ -4,13 +4,8 @@ const std = @import("std"); |
| 4 | 4 | const builtin = @import("builtin"); |
| 5 | 5 | |
| 6 | 6 | pub fn main(init: std.process.Init.Minimal) !void { |
| 7 | if (builtin.target.os.tag == .windows) { | |
| 8 | return; // Windows env strings are WTF-16, so not supported by Zig's std.posix.getenv() | |
| 9 | } | |
| 10 | ||
| 11 | if (builtin.target.os.tag == .wasi and !builtin.link_libc) { | |
| 12 | return; // std.posix.getenv is not supported on WASI due to the need of allocation | |
| 13 | } | |
| 7 | if (builtin.target.os.tag == .windows) return; | |
| 8 | if (builtin.target.os.tag == .wasi and !builtin.link_libc) return; | |
| 14 | 9 | |
| 15 | 10 | const environ = init.environ; |
| 16 | 11 |