Commit 412d863ba5

Carl Åstholm <carl@astholm.se>
2023-10-01 20:16:00
std.Build: expose `-idirafter` to the build system
1 parent 53775b0
Changed files (1)
lib
std
Build
lib/std/Build/Step/Compile.zig
@@ -289,6 +289,7 @@ const FrameworkLinkInfo = struct {
 pub const IncludeDir = union(enum) {
     path: LazyPath,
     path_system: LazyPath,
+    path_after: LazyPath,
     framework_path: LazyPath,
     framework_path_system: LazyPath,
     other_step: *Compile,
@@ -1062,6 +1063,12 @@ pub fn addObject(self: *Compile, obj: *Compile) void {
     self.linkLibraryOrObject(obj);
 }
 
+pub fn addAfterIncludePath(self: *Compile, path: LazyPath) void {
+    const b = self.step.owner;
+    self.include_dirs.append(IncludeDir{ .path_after = path.dupe(b) }) catch @panic("OOM");
+    path.addStepDependencies(&self.step);
+}
+
 pub fn addSystemIncludePath(self: *Compile, path: LazyPath) void {
     const b = self.step.owner;
     self.include_dirs.append(IncludeDir{ .path_system = path.dupe(b) }) catch @panic("OOM");
@@ -1842,6 +1849,10 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
                 try zig_args.append("-isystem");
                 try zig_args.append(include_path.getPath(b));
             },
+            .path_after => |include_path| {
+                try zig_args.append("-idirafter");
+                try zig_args.append(include_path.getPath(b));
+            },
             .framework_path => |include_path| {
                 try zig_args.append("-F");
                 try zig_args.append(include_path.getPath2(b, step));