Commit 19a82ffdba
Changed files (1)
lib
std
Build
Step
lib/std/Build/Step/InstallDir.zig
@@ -21,6 +21,10 @@ pub const Options = struct {
/// File paths which end in any of these suffixes will be excluded
/// from being installed.
exclude_extensions: []const []const u8 = &.{},
+ /// Only file paths which end in any of these suffixes will be included
+ /// in installation. `null` means all suffixes are valid for this option.
+ /// `exclude_extensions` take precedence over `include_extensions`
+ include_extensions: ?[]const []const u8 = null,
/// File paths which end in any of these suffixes will result in
/// empty files being installed. This is mainly intended for large
/// test.zig files in order to prevent needless installation bloat.
@@ -34,6 +38,7 @@ pub const Options = struct {
.install_dir = self.install_dir.dupe(b),
.install_subdir = b.dupe(self.install_subdir),
.exclude_extensions = b.dupeStrings(self.exclude_extensions),
+ .include_extensions = if (self.include_extensions) |incs| b.dupeStrings(incs) else null,
.blank_extensions = b.dupeStrings(self.blank_extensions),
};
}
@@ -78,6 +83,16 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
continue :next_entry;
}
}
+ if (self.options.include_extensions) |incs| {
+ var found = false;
+ for (incs) |inc| {
+ if (mem.endsWith(u8, entry.path, inc)) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) continue :next_entry;
+ }
// relative to src build root
const src_sub_path = try fs.path.join(arena, &.{ src_dir_path, entry.path });