mirror of
https://github.com/ziglang/zig.git
synced 2026-01-20 22:35:24 +00:00
Add include dirs to translate-c (close #5098)
This commit is contained in:
parent
3b4e29f1ad
commit
e9f344dcd4
@ -13,6 +13,7 @@ pub const TranslateCStep = struct {
|
||||
step: Step,
|
||||
builder: *Builder,
|
||||
source: build.FileSource,
|
||||
include_dirs: std.ArrayList([]const u8),
|
||||
output_dir: ?[]const u8,
|
||||
out_basename: []const u8,
|
||||
target: CrossTarget = CrossTarget{},
|
||||
@ -23,6 +24,7 @@ pub const TranslateCStep = struct {
|
||||
.step = Step.init(.TranslateC, "translate-c", builder.allocator, make),
|
||||
.builder = builder,
|
||||
.source = source,
|
||||
.include_dirs = std.ArrayList([]const u8).init(builder.allocator),
|
||||
.output_dir = null,
|
||||
.out_basename = undefined,
|
||||
};
|
||||
@ -49,6 +51,10 @@ pub const TranslateCStep = struct {
|
||||
return self.builder.addExecutableSource("translated_c", @as(build.FileSource, .{ .translate_c = self }));
|
||||
}
|
||||
|
||||
pub fn addIncludeDir(self: *TranslateCStep, include_dir: []const u8) void {
|
||||
self.include_dirs.append(include_dir) catch unreachable;
|
||||
}
|
||||
|
||||
pub fn addCheckFile(self: *TranslateCStep, expected_matches: []const []const u8) *CheckFileStep {
|
||||
return CheckFileStep.create(self.builder, .{ .translate_c = self }, expected_matches);
|
||||
}
|
||||
@ -69,6 +75,11 @@ pub const TranslateCStep = struct {
|
||||
try argv_list.append(try self.target.zigTriple(self.builder.allocator));
|
||||
}
|
||||
|
||||
for (self.include_dirs.items) |include_dir| {
|
||||
try argv_list.append("-I");
|
||||
try argv_list.append(include_dir);
|
||||
}
|
||||
|
||||
try argv_list.append(self.source.getPath(self.builder));
|
||||
|
||||
const output_path_nl = try self.builder.execFromStep(argv_list.span(), &self.step);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user