| ... | ... | @@ -21,9 +21,9 @@ pub fn detect(arena: Allocator, native_target: *const std.Target) !NativePaths { |
| 21 | 21 | var it = mem.tokenizeScalar(u8, nix_cflags_compile, ' '); |
| 22 | 22 | while (true) { |
| 23 | 23 | const word = it.next() orelse break; |
| 24 | | if (mem.eql(u8, word, "-isystem")) { |
| 24 | if (mem.eql(u8, word, "-isystem") or mem.eql(u8, word, "-idirafter")) { |
| 25 | 25 | const include_path = it.next() orelse { |
| 26 | | try self.addWarning("Expected argument after -isystem in NIX_CFLAGS_COMPILE"); |
| 26 | try self.addWarningFmt("Expected argument after {s} in NIX_CFLAGS_COMPILE", .{word}); |
| 27 | 27 | break; |
| 28 | 28 | }; |
| 29 | 29 | try self.addIncludeDir(include_path); |
| ... | ... | @@ -65,7 +65,7 @@ pub fn detect(arena: Allocator, native_target: *const std.Target) !NativePaths { |
| 65 | 65 | const lib_path = word[2..]; |
| 66 | 66 | try self.addLibDir(lib_path); |
| 67 | 67 | try self.addRPath(lib_path); |
| 68 | | } else if (mem.startsWith(u8, word, "-l")) { |
| 68 | } else if (mem.startsWith(u8, word, "-l") or mem.startsWith(u8, word, "-static")) { |
| 69 | 69 | // Ignore this argument. |
| 70 | 70 | } else { |
| 71 | 71 | try self.addWarningFmt("Unrecognized C flag from NIX_LDFLAGS: {s}", .{word}); |
| ... | ... | @@ -77,6 +77,38 @@ pub fn detect(arena: Allocator, native_target: *const std.Target) !NativePaths { |
| 77 | 77 | error.EnvironmentVariableNotFound => {}, |
| 78 | 78 | error.OutOfMemory => |e| return e, |
| 79 | 79 | } |
| 80 | if (process.getEnvVarOwned(arena, "NIX_CFLAGS_LINK")) |nix_cflags_link| { |
| 81 | is_nix = true; |
| 82 | var it = mem.tokenizeScalar(u8, nix_cflags_link, ' '); |
| 83 | while (true) { |
| 84 | const word = it.next() orelse break; |
| 85 | if (mem.eql(u8, word, "-rpath")) { |
| 86 | const rpath = it.next() orelse { |
| 87 | try self.addWarning("Expected argument after -rpath in NIX_CFLAGS_LINK"); |
| 88 | break; |
| 89 | }; |
| 90 | try self.addRPath(rpath); |
| 91 | } else if (mem.eql(u8, word, "-L") or mem.eql(u8, word, "-l")) { |
| 92 | _ = it.next() orelse { |
| 93 | try self.addWarning("Expected argument after -L or -l in NIX_CFLAGS_LINK"); |
| 94 | break; |
| 95 | }; |
| 96 | } else if (mem.startsWith(u8, word, "-L")) { |
| 97 | const lib_path = word[2..]; |
| 98 | try self.addLibDir(lib_path); |
| 99 | try self.addRPath(lib_path); |
| 100 | } else if (mem.startsWith(u8, word, "-l") or mem.startsWith(u8, word, "-static")) { |
| 101 | // Ignore this argument. |
| 102 | } else { |
| 103 | try self.addWarningFmt("Unrecognized C flag from NIX_CFLAGS_LINK: {s}", .{word}); |
| 104 | break; |
| 105 | } |
| 106 | } |
| 107 | } else |err| switch (err) { |
| 108 | error.InvalidWtf8 => unreachable, |
| 109 | error.EnvironmentVariableNotFound => {}, |
| 110 | error.OutOfMemory => |e| return e, |
| 111 | } |
| 80 | 112 | if (is_nix) { |
| 81 | 113 | return self; |
| 82 | 114 | } |