authorgravatar for jhc@dismail.deJimmi Holst Christensen <jhc@dismail.de> 2018-12-05 14:10:09+01:00
committergravatar for jhc@dismail.deJimmi Holst Christensen <jhc@dismail.de> 2018-12-05 14:10:09+01:00
log518ff33e64f3970e6fc053d2cffe0751e21b0700
treebb080003c4f00b41863220845511f2510c1ccbb8
parent9ac838c8e3f5c3e77533e30f72bac30487b9ae23

Allow packages in TestStep


1 files changed, 21 insertions(+), 5 deletions(-)

std/build.zig+21-5
......@@ -811,6 +811,11 @@ pub const Target = union(enum) {
811811 }
812812};
813813
814const Pkg = struct {
815 name: []const u8,
816 path: []const u8,
817};
818
814819pub const LibExeObjStep = struct {
815820 step: Step,
816821 builder: *Builder,
......@@ -853,11 +858,6 @@ pub const LibExeObjStep = struct {
853858 source_files: ArrayList([]const u8),
854859 object_src: []const u8,
855860
856 const Pkg = struct {
857 name: []const u8,
858 path: []const u8,
859 };
860
861861 const Kind = enum {
862862 Exe,
863863 Lib,
......@@ -1667,6 +1667,7 @@ pub const TestStep = struct {
16671667 exec_cmd_args: ?[]const ?[]const u8,
16681668 include_dirs: ArrayList([]const u8),
16691669 lib_paths: ArrayList([]const u8),
1670 packages: ArrayList(Pkg),
16701671 object_files: ArrayList([]const u8),
16711672 no_rosegment: bool,
16721673 output_path: ?[]const u8,
......@@ -1687,6 +1688,7 @@ pub const TestStep = struct {
16871688 .exec_cmd_args = null,
16881689 .include_dirs = ArrayList([]const u8).init(builder.allocator),
16891690 .lib_paths = ArrayList([]const u8).init(builder.allocator),
1691 .packages = ArrayList(Pkg).init(builder.allocator),
16901692 .object_files = ArrayList([]const u8).init(builder.allocator),
16911693 .no_rosegment = false,
16921694 .output_path = null,
......@@ -1702,6 +1704,13 @@ pub const TestStep = struct {
17021704 self.lib_paths.append(path) catch unreachable;
17031705 }
17041706
1707 pub fn addPackagePath(self: *TestStep, name: []const u8, pkg_index_path: []const u8) void {
1708 self.packages.append(Pkg{
1709 .name = name,
1710 .path = pkg_index_path,
1711 }) catch unreachable;
1712 }
1713
17051714 pub fn setVerbose(self: *TestStep, value: bool) void {
17061715 self.verbose = value;
17071716 }
......@@ -1878,6 +1887,13 @@ pub const TestStep = struct {
18781887 try zig_args.append(lib_path);
18791888 }
18801889
1890 for (self.packages.toSliceConst()) |pkg| {
1891 zig_args.append("--pkg-begin") catch unreachable;
1892 zig_args.append(pkg.name) catch unreachable;
1893 zig_args.append(builder.pathFromRoot(pkg.path)) catch unreachable;
1894 zig_args.append("--pkg-end") catch unreachable;
1895 }
1896
18811897 if (self.no_rosegment) {
18821898 try zig_args.append("--no-rosegment");
18831899 }