Add addIncludeDir to TestStep + fix build template

Closes #794.
This commit is contained in:
Marc Tiehuis 2018-03-14 22:19:51 +13:00 committed by Andrew Kelley
parent bbad0fa411
commit bea9e9c7f8
2 changed files with 12 additions and 1 deletions

View File

@ -1627,6 +1627,7 @@ pub const TestStep = struct {
filter: ?[]const u8,
target: Target,
exec_cmd_args: ?[]const ?[]const u8,
include_dirs: ArrayList([]const u8),
pub fn init(builder: &Builder, root_src: []const u8) TestStep {
const step_name = builder.fmt("test {}", root_src);
@ -1641,6 +1642,7 @@ pub const TestStep = struct {
.link_libs = BufSet.init(builder.allocator),
.target = Target { .Native = {} },
.exec_cmd_args = null,
.include_dirs = ArrayList([]const u8).init(builder.allocator),
};
}
@ -1648,6 +1650,10 @@ pub const TestStep = struct {
self.verbose = value;
}
pub fn addIncludeDir(self: &TestStep, path: []const u8) void {
self.include_dirs.append(path) catch unreachable;
}
pub fn setBuildMode(self: &TestStep, mode: builtin.Mode) void {
self.build_mode = mode;
}
@ -1746,6 +1752,11 @@ pub const TestStep = struct {
}
}
for (self.include_dirs.toSliceConst()) |include_path| {
try zig_args.append("-isystem");
try zig_args.append(builder.pathFromRoot(include_path));
}
for (builder.include_paths.toSliceConst()) |include_path| {
try zig_args.append("-isystem");
try zig_args.append(builder.pathFromRoot(include_path));

View File

@ -1,6 +1,6 @@
const Builder = @import("std").build.Builder;
pub fn build(b: &Builder) !void {
pub fn build(b: &Builder) void {
const mode = b.standardReleaseOptions();
const exe = b.addExecutable("YOUR_NAME_HERE", "src/main.zig");
exe.setBuildMode(mode);