authorgravatar for der.teufel.mail@gmail.comKrzysztof Wolicki <der.teufel.mail@gmail.com> 2023-09-30 00:50:37+02:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2023-09-29 18:50:37-04:00
log19a82ffdba15c9082b5cd854c2c15f7e9c8ecd05
tree9046fcd3c405cc2d8049fd8397df2c96418f52c1
parente919fbea9fd62e55ebbfb0739a2a468c93673e93
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Add include_extensions to InstallDir Options (#17300)

closes #16687

1 files changed, 15 insertions(+), 0 deletions(-)

lib/std/Build/Step/InstallDir.zig+15
......@@ -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 });