From bea9e9c7f8abc1e270dd2ea0065934b32627288c Mon Sep 17 00:00:00 2001 From: Marc Tiehuis Date: Wed, 14 Mar 2018 22:19:51 +1300 Subject: [PATCH] Add addIncludeDir to TestStep + fix build template Closes #794. --- std/build.zig | 11 +++++++++++ std/special/build_file_template.zig | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/std/build.zig b/std/build.zig index e6b6676261..a4d745e450 100644 --- a/std/build.zig +++ b/std/build.zig @@ -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)); diff --git a/std/special/build_file_template.zig b/std/special/build_file_template.zig index 2edfdadf50..1c06c93cdc 100644 --- a/std/special/build_file_template.zig +++ b/std/special/build_file_template.zig @@ -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);