| ... | ... | @@ -13,6 +13,7 @@ pub const TranslateCStep = struct { |
| 13 | 13 | step: Step, |
| 14 | 14 | builder: *Builder, |
| 15 | 15 | source: build.FileSource, |
| 16 | include_dirs: std.ArrayList([]const u8), |
| 16 | 17 | output_dir: ?[]const u8, |
| 17 | 18 | out_basename: []const u8, |
| 18 | 19 | target: CrossTarget = CrossTarget{}, |
| ... | ... | @@ -23,6 +24,7 @@ pub const TranslateCStep = struct { |
| 23 | 24 | .step = Step.init(.TranslateC, "translate-c", builder.allocator, make), |
| 24 | 25 | .builder = builder, |
| 25 | 26 | .source = source, |
| 27 | .include_dirs = std.ArrayList([]const u8).init(builder.allocator), |
| 26 | 28 | .output_dir = null, |
| 27 | 29 | .out_basename = undefined, |
| 28 | 30 | }; |
| ... | ... | @@ -49,6 +51,10 @@ pub const TranslateCStep = struct { |
| 49 | 51 | return self.builder.addExecutableSource("translated_c", @as(build.FileSource, .{ .translate_c = self })); |
| 50 | 52 | } |
| 51 | 53 | |
| 54 | pub fn addIncludeDir(self: *TranslateCStep, include_dir: []const u8) void { |
| 55 | self.include_dirs.append(include_dir) catch unreachable; |
| 56 | } |
| 57 | |
| 52 | 58 | pub fn addCheckFile(self: *TranslateCStep, expected_matches: []const []const u8) *CheckFileStep { |
| 53 | 59 | return CheckFileStep.create(self.builder, .{ .translate_c = self }, expected_matches); |
| 54 | 60 | } |
| ... | ... | @@ -69,6 +75,11 @@ pub const TranslateCStep = struct { |
| 69 | 75 | try argv_list.append(try self.target.zigTriple(self.builder.allocator)); |
| 70 | 76 | } |
| 71 | 77 | |
| 78 | for (self.include_dirs.items) |include_dir| { |
| 79 | try argv_list.append("-I"); |
| 80 | try argv_list.append(include_dir); |
| 81 | } |
| 82 | |
| 72 | 83 | try argv_list.append(self.source.getPath(self.builder)); |
| 73 | 84 | |
| 74 | 85 | const output_path_nl = try self.builder.execFromStep(argv_list.span(), &self.step); |