zig build: support single-threaded builds

and fix the zig test suite not setting the --single-threaded flag
This commit is contained in:
Andrew Kelley 2019-04-05 14:54:37 -04:00
parent a5b47bc2c2
commit 846f72b57c
No known key found for this signature in database
GPG Key ID: 7C5F548F728501A9
2 changed files with 8 additions and 1 deletions

View File

@ -943,6 +943,7 @@ pub const LibExeObjStep = struct {
exec_cmd_args: ?[]const ?[]const u8,
name_prefix: []const u8,
filter: ?[]const u8,
single_threaded: bool,
root_src: ?[]const u8,
out_h_filename: []const u8,
@ -1045,6 +1046,7 @@ pub const LibExeObjStep = struct {
.disable_gen_h = false,
.output_dir = null,
.need_system_paths = false,
.single_threaded = false,
};
self.computeOutFileNames();
return self;
@ -1206,7 +1208,7 @@ pub const LibExeObjStep = struct {
pub fn setMainPkgPath(self: *LibExeObjStep, dir_path: []const u8) void {
self.main_pkg_path = dir_path;
}
pub fn setDisableGenH(self: *LibExeObjStep, value: bool) void {
self.disable_gen_h = value;
}
@ -1411,6 +1413,10 @@ pub const LibExeObjStep = struct {
zig_args.append("--strip") catch unreachable;
}
if (self.single_threaded) {
try zig_args.append("--single-threaded");
}
switch (self.build_mode) {
builtin.Mode.Debug => {},
builtin.Mode.ReleaseSafe => zig_args.append("--release-safe") catch unreachable,

View File

@ -186,6 +186,7 @@ pub fn addPkgTests(b: *build.Builder, test_filter: ?[]const u8, root_src: []cons
if (link_libc) "c" else "bare",
if (single_threaded) "single" else "multi",
));
these_tests.single_threaded = single_threaded;
these_tests.setFilter(test_filter);
these_tests.setBuildMode(mode);
if (!is_native) {