| ... | @@ -13,6 +13,7 @@ pub const TranslateCStep = struct { | ... | @@ -13,6 +13,7 @@ pub const TranslateCStep = struct { |
| 13 | step: Step, | 13 | step: Step, |
| 14 | builder: *Builder, | 14 | builder: *Builder, |
| 15 | source: build.FileSource, | 15 | source: build.FileSource, |
| | 16 | include_dirs: std.ArrayList([]const u8), |
| 16 | output_dir: ?[]const u8, | 17 | output_dir: ?[]const u8, |
| 17 | out_basename: []const u8, | 18 | out_basename: []const u8, |
| 18 | target: CrossTarget = CrossTarget{}, | 19 | target: CrossTarget = CrossTarget{}, |
| ... | @@ -23,6 +24,7 @@ pub const TranslateCStep = struct { | ... | @@ -23,6 +24,7 @@ pub const TranslateCStep = struct { |
| 23 | .step = Step.init(.TranslateC, "translate-c", builder.allocator, make), | 24 | .step = Step.init(.TranslateC, "translate-c", builder.allocator, make), |
| 24 | .builder = builder, | 25 | .builder = builder, |
| 25 | .source = source, | 26 | .source = source, |
| | 27 | .include_dirs = std.ArrayList([]const u8).init(builder.allocator), |
| 26 | .output_dir = null, | 28 | .output_dir = null, |
| 27 | .out_basename = undefined, | 29 | .out_basename = undefined, |
| 28 | }; | 30 | }; |
| ... | @@ -49,6 +51,10 @@ pub const TranslateCStep = struct { | ... | @@ -49,6 +51,10 @@ pub const TranslateCStep = struct { |
| 49 | return self.builder.addExecutableSource("translated_c", @as(build.FileSource, .{ .translate_c = self })); | 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 | pub fn addCheckFile(self: *TranslateCStep, expected_matches: []const []const u8) *CheckFileStep { | 58 | pub fn addCheckFile(self: *TranslateCStep, expected_matches: []const []const u8) *CheckFileStep { |
| 53 | return CheckFileStep.create(self.builder, .{ .translate_c = self }, expected_matches); | 59 | return CheckFileStep.create(self.builder, .{ .translate_c = self }, expected_matches); |
| 54 | } | 60 | } |
| ... | @@ -69,6 +75,11 @@ pub const TranslateCStep = struct { | ... | @@ -69,6 +75,11 @@ pub const TranslateCStep = struct { |
| 69 | try argv_list.append(try self.target.zigTriple(self.builder.allocator)); | 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 | try argv_list.append(self.source.getPath(self.builder)); | 83 | try argv_list.append(self.source.getPath(self.builder)); |
| 73 | | 84 | |
| 74 | const output_path_nl = try self.builder.execFromStep(argv_list.span(), &self.step); | 85 | const output_path_nl = try self.builder.execFromStep(argv_list.span(), &self.step); |