Skip to content

Commit 19a82ff

Browse files
Add include_extensions to InstallDir Options (#17300)
closes #16687
1 parent e919fbe commit 19a82ff

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

lib/std/Build/Step/InstallDir.zig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ pub const Options = struct {
2121
/// File paths which end in any of these suffixes will be excluded
2222
/// from being installed.
2323
exclude_extensions: []const []const u8 = &.{},
24+
/// Only file paths which end in any of these suffixes will be included
25+
/// in installation. `null` means all suffixes are valid for this option.
26+
/// `exclude_extensions` take precedence over `include_extensions`
27+
include_extensions: ?[]const []const u8 = null,
2428
/// File paths which end in any of these suffixes will result in
2529
/// empty files being installed. This is mainly intended for large
2630
/// test.zig files in order to prevent needless installation bloat.
@@ -34,6 +38,7 @@ pub const Options = struct {
3438
.install_dir = self.install_dir.dupe(b),
3539
.install_subdir = b.dupe(self.install_subdir),
3640
.exclude_extensions = b.dupeStrings(self.exclude_extensions),
41+
.include_extensions = if (self.include_extensions) |incs| b.dupeStrings(incs) else null,
3742
.blank_extensions = b.dupeStrings(self.blank_extensions),
3843
};
3944
}
@@ -78,6 +83,16 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
7883
continue :next_entry;
7984
}
8085
}
86+
if (self.options.include_extensions) |incs| {
87+
var found = false;
88+
for (incs) |inc| {
89+
if (mem.endsWith(u8, entry.path, inc)) {
90+
found = true;
91+
break;
92+
}
93+
}
94+
if (!found) continue :next_entry;
95+
}
8196

8297
// relative to src build root
8398
const src_sub_path = try fs.path.join(arena, &.{ src_dir_path, entry.path });

0 commit comments

Comments
 (0)