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