mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 12:59:04 +00:00
std.zig: search include dir and lib dir from environment variables (#13145)
* minor fix based on feedback from @marler8997 Co-authored-by: dan <i@dan.games>
This commit is contained in:
parent
c750d95417
commit
ca1c185eb6
@ -135,6 +135,32 @@ pub fn detect(allocator: Allocator, native_info: NativeTargetInfo) !NativePaths
|
||||
// zlib.h is in /usr/include (added above)
|
||||
// libz.so.1 is in /lib/x86_64-linux-gnu (added here)
|
||||
try self.addLibDirFmt("/lib/{s}", .{triple});
|
||||
|
||||
// NOTE: distro like guix doesn't use FHS, so it relies on envorinment
|
||||
// variables (C_INCLUDE_PATH, CPLUS_INCLUDE_PATH and LIBRARY_PATH) to
|
||||
// search for headers and libraries
|
||||
// NOTE: we use os.getenv here since this part won't be executed on
|
||||
// windows, to get rid of unnecessary error handling
|
||||
if (std.os.getenv("C_INCLUDE_PATH")) |c_include_path| {
|
||||
var it = mem.tokenize(u8, c_include_path, ":");
|
||||
while (it.next()) |dir| {
|
||||
try self.addIncludeDir(dir);
|
||||
}
|
||||
}
|
||||
|
||||
if (std.os.getenv("CPLUS_INCLUDE_PATH")) |cplus_include_path| {
|
||||
var it = mem.tokenize(u8, cplus_include_path, ":");
|
||||
while (it.next()) |dir| {
|
||||
try self.addIncludeDir(dir);
|
||||
}
|
||||
}
|
||||
|
||||
if (std.os.getenv("LIBRARY_PATH")) |library_path| {
|
||||
var it = mem.tokenize(u8, library_path, ":");
|
||||
while (it.next()) |dir| {
|
||||
try self.addLibDir(dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return self;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user