aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Build/Module.zig
diff options
context:
space:
mode:
authorRyan Liptak <squeek502@hotmail.com>2024-05-02 18:57:34 -0700
committerAndrew Kelley <andrew@ziglang.org>2024-05-02 22:08:00 -0700
commitea9d817a905ae19dcf27db4f380270485f9e26d2 (patch)
treee8edc32b14154ca7f0e833953a8d18a787bf194d /lib/std/Build/Module.zig
parent8ea4283d83a23b2956a1894eeb64793335de82b9 (diff)
downloadzig-ea9d817a905ae19dcf27db4f380270485f9e26d2.tar.gz
zig-ea9d817a905ae19dcf27db4f380270485f9e26d2.zip
Build system: Allow specifying Win32 resource include paths using LazyPath
Adds an `include_paths` field to RcSourceFile that takes a slice of LazyPaths. The paths are resolved and subsequently appended to the -rcflags as `/I <resolved path>`. This fixes an accidental regression from https://github.com/ziglang/zig/pull/19174. Before that PR, all Win32 resource compilation would inherit the CC flags (via `addCCArgs`), which included things like include directories. After that PR, though, that is no longer the case. However, this commit intentionally does not restore the previous behavior (inheriting the C include paths). Instead, each .rc file will need to have its include paths specified directly and the include paths only apply to one particular resource script. This allows more fine-grained control and has less potentially surprising behavior (at the cost of some convenience). Closes #19605
Diffstat (limited to 'lib/std/Build/Module.zig')
-rw-r--r--lib/std/Build/Module.zig10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/std/Build/Module.zig b/lib/std/Build/Module.zig
index d19f0a781e..a142bbd405 100644
--- a/lib/std/Build/Module.zig
+++ b/lib/std/Build/Module.zig
@@ -110,11 +110,18 @@ pub const RcSourceFile = struct {
/// /x (ignore the INCLUDE environment variable)
/// /D_DEBUG or /DNDEBUG depending on the optimization mode
flags: []const []const u8 = &.{},
+ /// Include paths that may or may not exist yet and therefore need to be
+ /// specified as a LazyPath. Each path will be appended to the flags
+ /// as `/I <resolved path>`.
+ include_paths: []const LazyPath = &.{},
pub fn dupe(self: RcSourceFile, b: *std.Build) RcSourceFile {
+ const include_paths = b.allocator.alloc(LazyPath, self.include_paths.len) catch @panic("OOM");
+ for (include_paths, self.include_paths) |*dest, lazy_path| dest.* = lazy_path.dupe(b);
return .{
.file = self.file.dupe(b),
.flags = b.dupeStrings(self.flags),
+ .include_paths = include_paths,
};
}
};
@@ -503,6 +510,9 @@ pub fn addWin32ResourceFile(m: *Module, source: RcSourceFile) void {
rc_source_file.* = source.dupe(b);
m.link_objects.append(allocator, .{ .win32_resource_file = rc_source_file }) catch @panic("OOM");
addLazyPathDependenciesOnly(m, source.file);
+ for (source.include_paths) |include_path| {
+ addLazyPathDependenciesOnly(m, include_path);
+ }
}
pub fn addAssemblyFile(m: *Module, source: LazyPath) void {