mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
build system: fixups to --seed mechanism
* support 0x prefixed hex code for CLI seed arguments * don't change the build summary; the printed CLI on build runner failure is sufficient * use `std.crypto.random` instead of system time for entropy
This commit is contained in:
parent
b87353a17f
commit
10200970bb
@ -202,8 +202,10 @@ pub fn main() !void {
|
||||
std.debug.print("Expected u32 after {s}\n\n", .{arg});
|
||||
usageAndErr(builder, false, stderr_stream);
|
||||
};
|
||||
seed = std.fmt.parseUnsigned(u32, next_arg, 10) catch |err| {
|
||||
std.debug.print("unable to parse seed '{s}' as u32: {s}", .{ next_arg, @errorName(err) });
|
||||
seed = std.fmt.parseUnsigned(u32, next_arg, 0) catch |err| {
|
||||
std.debug.print("unable to parse seed '{s}' as 32-bit integer: {s}", .{
|
||||
next_arg, @errorName(err),
|
||||
});
|
||||
process.exit(1);
|
||||
};
|
||||
} else if (mem.eql(u8, arg, "--debug-log")) {
|
||||
@ -526,9 +528,7 @@ fn runStepNames(
|
||||
stderr.writeAll(" (disable with --summary none)") catch {};
|
||||
ttyconf.setColor(stderr, .reset) catch {};
|
||||
}
|
||||
ttyconf.setColor(stderr, .dim) catch {};
|
||||
stderr.writer().print("\nseed is {}\n", .{seed}) catch {};
|
||||
ttyconf.setColor(stderr, .reset) catch {};
|
||||
stderr.writeAll("\n") catch {};
|
||||
const failures_only = run.summary != Summary.all;
|
||||
|
||||
// Print a fancy tree with build results.
|
||||
|
||||
@ -4906,6 +4906,7 @@ pub const usage_build =
|
||||
\\ --global-cache-dir [path] Override path to global Zig cache directory
|
||||
\\ --zig-lib-dir [arg] Override path to Zig lib directory
|
||||
\\ --build-runner [file] Override path to build runner
|
||||
\\ --seed [integer] For shuffling dependency traversal order (default: random)
|
||||
\\ --fetch Exit after fetching dependency tree
|
||||
\\ -h, --help Print this help and exit
|
||||
\\
|
||||
@ -4930,8 +4931,6 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi
|
||||
var reference_trace: ?u32 = null;
|
||||
var debug_compile_errors = false;
|
||||
var fetch_only = false;
|
||||
const micros: u32 = @truncate(@as(u64, @bitCast(std.time.microTimestamp())));
|
||||
var seed: []const u8 = try std.fmt.allocPrint(arena, "{}", .{micros});
|
||||
|
||||
const argv_index_exe = child_argv.items.len;
|
||||
_ = try child_argv.addOne();
|
||||
@ -4947,7 +4946,10 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi
|
||||
const argv_index_global_cache_dir = child_argv.items.len;
|
||||
_ = try child_argv.addOne();
|
||||
|
||||
try child_argv.appendSlice(&[_][]const u8{ "--seed", seed });
|
||||
try child_argv.appendSlice(&.{
|
||||
"--seed",
|
||||
try std.fmt.allocPrint(arena, "0x{x}", .{std.crypto.random.int(u32)}),
|
||||
});
|
||||
const argv_index_seed = child_argv.items.len - 1;
|
||||
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user