@@ -21,6 +21,10 @@ pub const Options = struct {
21
21
/// File paths which end in any of these suffixes will be excluded
22
22
/// from being installed.
23
23
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 ,
24
28
/// File paths which end in any of these suffixes will result in
25
29
/// empty files being installed. This is mainly intended for large
26
30
/// test.zig files in order to prevent needless installation bloat.
@@ -34,6 +38,7 @@ pub const Options = struct {
34
38
.install_dir = self .install_dir .dupe (b ),
35
39
.install_subdir = b .dupe (self .install_subdir ),
36
40
.exclude_extensions = b .dupeStrings (self .exclude_extensions ),
41
+ .include_extensions = if (self .include_extensions ) | incs | b .dupeStrings (incs ) else null ,
37
42
.blank_extensions = b .dupeStrings (self .blank_extensions ),
38
43
};
39
44
}
@@ -78,6 +83,16 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
78
83
continue :next_entry ;
79
84
}
80
85
}
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
+ }
81
96
82
97
// relative to src build root
83
98
const src_sub_path = try fs .path .join (arena , &.{ src_dir_path , entry .path });
0 commit comments