| ... | ... | @@ -1,21 +1,23 @@ |
| 1 | 1 | const builtin = @import("builtin"); |
| 2 | 2 | |
| 3 | 3 | const std = @import("std"); |
| 4 | const Allocator = std.mem.Allocator; |
| 5 | const Cache = std.Build.Cache; |
| 6 | const Configuration = std.Build.Configuration; |
| 7 | const File = std.Io.File; |
| 4 | 8 | const Io = std.Io; |
| 9 | const Path = std.Build.Cache.Path; |
| 10 | const Writer = std.Io.Writer; |
| 5 | 11 | const assert = std.debug.assert; |
| 12 | const fatal = std.process.fatal; |
| 6 | 13 | const fmt = std.fmt; |
| 14 | const log = std.log; |
| 7 | 15 | const mem = std.mem; |
| 8 | 16 | const process = std.process; |
| 9 | | const File = std.Io.File; |
| 10 | | const Allocator = std.mem.Allocator; |
| 11 | | const fatal = std.process.fatal; |
| 12 | | const Writer = std.Io.Writer; |
| 13 | | const Cache = std.Build.Cache; |
| 14 | | const Configuration = std.Build.Configuration; |
| 15 | 17 | |
| 16 | 18 | const Fuzz = @import("maker/Fuzz.zig"); |
| 17 | 19 | const Graph = @import("maker/Graph.zig"); |
| 18 | | const Step = @import("maker/Step.zig"); |
| 20 | const Step = void; // @import("maker/Step.zig"); |
| 19 | 21 | const Watch = @import("maker/Watch.zig"); |
| 20 | 22 | const WebServer = @import("maker/WebServer.zig"); |
| 21 | 23 | |
| ... | ... | @@ -48,12 +50,12 @@ pub fn main(init: process.Init.Minimal) !void { |
| 48 | 50 | // skip my own exe name |
| 49 | 51 | var arg_idx: usize = 1; |
| 50 | 52 | |
| 51 | | const zig_exe = cutArgPrefixOrFatal(args, &arg_idx, "--zig="); |
| 52 | | const zig_lib_dir = cutArgPrefixOrFatal(args, &arg_idx, "--lib="); |
| 53 | | const build_root = cutArgPrefixOrFatal(args, &arg_idx, "--build-root="); |
| 54 | | const local_cache_root = cutArgPrefixOrFatal(args, &arg_idx, "--local-cache="); |
| 55 | | const global_cache_root = cutArgPrefixOrFatal(args, &arg_idx, "--global-cache="); |
| 56 | | const configure_path = cutArgPrefixOrFatal(args, &arg_idx, "--configure="); |
| 53 | const zig_exe = expectArgOrFatal(args, &arg_idx, "--zig"); |
| 54 | const zig_lib_dir = expectArgOrFatal(args, &arg_idx, "--zig-lib-dir"); |
| 55 | const build_root = expectArgOrFatal(args, &arg_idx, "--build-root"); |
| 56 | const local_cache_root = expectArgOrFatal(args, &arg_idx, "--local-cache"); |
| 57 | const global_cache_root = expectArgOrFatal(args, &arg_idx, "--global-cache"); |
| 58 | const configure_path = expectArgOrFatal(args, &arg_idx, "--configuration"); |
| 57 | 59 | |
| 58 | 60 | const cwd: Io.Dir = .cwd(); |
| 59 | 61 | |
| ... | ... | @@ -90,11 +92,6 @@ pub fn main(init: process.Init.Minimal) !void { |
| 90 | 92 | .environ_map = try init.environ.createMap(arena), |
| 91 | 93 | .global_cache_root = global_cache_directory, |
| 92 | 94 | .zig_lib_directory = zig_lib_directory, |
| 93 | | .host = .{ |
| 94 | | .query = .{}, |
| 95 | | .result = try std.zig.system.resolveTargetQuery(io, .{}), |
| 96 | | }, |
| 97 | | .time_report = false, |
| 98 | 95 | }; |
| 99 | 96 | |
| 100 | 97 | graph.cache.addPrefix(.{ .path = null, .handle = cwd }); |
| ... | ... | @@ -105,9 +102,13 @@ pub fn main(init: process.Init.Minimal) !void { |
| 105 | 102 | |
| 106 | 103 | var targets = std.array_list.Managed([]const u8).init(arena); |
| 107 | 104 | var debug_log_scopes = std.array_list.Managed([]const u8).init(arena); |
| 108 | | |
| 109 | | var install_prefix: ?[]const u8 = null; |
| 110 | | var dir_list: std.Build.DirList = .{}; |
| 105 | var help_menu = false; |
| 106 | var steps_menu = false; |
| 107 | var print_configuration = false; |
| 108 | var override_install_prefix: ?[]const u8 = null; |
| 109 | var override_lib_dir: ?[]const u8 = null; |
| 110 | var override_bin_dir: ?[]const u8 = null; |
| 111 | var override_include_dir: ?[]const u8 = null; |
| 111 | 112 | var error_style: ErrorStyle = .verbose; |
| 112 | 113 | var multiline_errors: MultilineErrors = .indent; |
| 113 | 114 | var summary: ?Summary = null; |
| ... | ... | @@ -115,8 +116,6 @@ pub fn main(init: process.Init.Minimal) !void { |
| 115 | 116 | var skip_oom_steps = false; |
| 116 | 117 | var test_timeout_ns: ?u64 = null; |
| 117 | 118 | var color: Color = .auto; |
| 118 | | var help_menu = false; |
| 119 | | var steps_menu = false; |
| 120 | 119 | var watch = false; |
| 121 | 120 | var fuzz: ?Fuzz.Mode = null; |
| 122 | 121 | var debounce_interval_ms: u16 = 50; |
| ... | ... | @@ -152,51 +151,53 @@ pub fn main(init: process.Init.Minimal) !void { |
| 152 | 151 | } |
| 153 | 152 | } |
| 154 | 153 | |
| 155 | | var configuration: Configuration = undefined; |
| 156 | | { |
| 157 | | var file = cwd.openFile(io, configure_path, .{}) catch |err| |
| 158 | | fatal("failed to open configuration file {f}: {t}", .{ configure_path, err }); |
| 159 | | defer file.close(io); |
| 160 | | configuration = Configuration.load(arena, io, file) catch |err| |
| 161 | | fatal("failed to load configuration file {f}: {t}", .{ configure_path, err }); |
| 162 | | } |
| 163 | | graph.configuration = &configuration; |
| 164 | | graph.scanConfiguration(); |
| 154 | const scanned_config: ScannedConfig = sc: { |
| 155 | const configuration = c: { |
| 156 | var file = cwd.openFile(io, configure_path, .{}) catch |err| |
| 157 | fatal("failed to open configuration file {s}: {t}", .{ configure_path, err }); |
| 158 | defer file.close(io); |
| 159 | break :c Configuration.loadFile(arena, io, file) catch |err| |
| 160 | fatal("failed to load configuration file {s}: {t}", .{ configure_path, err }); |
| 161 | }; |
| 162 | var top_level_steps: std.ArrayList(Configuration.Step.Index) = .empty; |
| 163 | for (configuration.steps, 0..) |*conf_step, step_index| { |
| 164 | const flags: Configuration.Step.Flags = @bitCast(configuration.extra[conf_step.extra_index]); |
| 165 | if (flags.tag == .top_level) { |
| 166 | try top_level_steps.append(arena, @enumFromInt(step_index)); |
| 167 | } |
| 168 | } |
| 169 | break :sc .{ |
| 170 | .configuration = configuration, |
| 171 | .top_level_steps = top_level_steps.items, |
| 172 | }; |
| 173 | }; |
| 165 | 174 | |
| 166 | | std.log.err("TODO handle user -D options", .{}); |
| 175 | log.err("TODO handle user -D options", .{}); |
| 167 | 176 | |
| 168 | 177 | while (nextArg(args, &arg_idx)) |arg| { |
| 169 | 178 | if (mem.startsWith(u8, arg, "-")) { |
| 170 | | if (mem.eql(u8, arg, "--verbose")) { |
| 171 | | verbose = true; |
| 172 | | } else if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) { |
| 179 | if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) { |
| 173 | 180 | help_menu = true; |
| 174 | | } else if (mem.eql(u8, arg, "-p") or mem.eql(u8, arg, "--prefix")) { |
| 175 | | install_prefix = nextArgOrFatal(args, &arg_idx); |
| 176 | 181 | } else if (mem.eql(u8, arg, "-l") or mem.eql(u8, arg, "--list-steps")) { |
| 177 | 182 | steps_menu = true; |
| 178 | | } else if (mem.startsWith(u8, arg, "-fsys=")) { |
| 179 | | const name = arg["-fsys=".len..]; |
| 180 | | graph.system_library_options.put(arena, name, .user_enabled) catch @panic("OOM"); |
| 181 | | } else if (mem.startsWith(u8, arg, "-fno-sys=")) { |
| 182 | | const name = arg["-fno-sys=".len..]; |
| 183 | | graph.system_library_options.put(arena, name, .user_disabled) catch @panic("OOM"); |
| 183 | } else if (mem.eql(u8, arg, "--print-configuration")) { |
| 184 | print_configuration = true; |
| 185 | } else if (mem.eql(u8, arg, "--verbose")) { |
| 186 | verbose = true; |
| 187 | } else if (mem.eql(u8, arg, "-p") or mem.eql(u8, arg, "--prefix")) { |
| 188 | override_install_prefix = nextArgOrFatal(args, &arg_idx); |
| 184 | 189 | } else if (mem.eql(u8, arg, "--prefix-lib-dir")) { |
| 185 | | dir_list.lib_dir = nextArgOrFatal(args, &arg_idx); |
| 190 | override_lib_dir = nextArgOrFatal(args, &arg_idx); |
| 186 | 191 | } else if (mem.eql(u8, arg, "--prefix-exe-dir")) { |
| 187 | | dir_list.exe_dir = nextArgOrFatal(args, &arg_idx); |
| 192 | override_bin_dir = nextArgOrFatal(args, &arg_idx); |
| 188 | 193 | } else if (mem.eql(u8, arg, "--prefix-include-dir")) { |
| 189 | | dir_list.include_dir = nextArgOrFatal(args, &arg_idx); |
| 194 | override_include_dir = nextArgOrFatal(args, &arg_idx); |
| 190 | 195 | } else if (mem.eql(u8, arg, "--sysroot")) { |
| 191 | 196 | sysroot = nextArgOrFatal(args, &arg_idx); |
| 192 | 197 | } else if (mem.eql(u8, arg, "--maxrss")) { |
| 193 | 198 | const max_rss_text = nextArgOrFatal(args, &arg_idx); |
| 194 | | max_rss = std.fmt.parseIntSizeSuffix(max_rss_text, 10) catch |err| { |
| 195 | | std.debug.print("invalid byte size: '{s}': {s}\n", .{ |
| 196 | | max_rss_text, @errorName(err), |
| 197 | | }); |
| 198 | | process.exit(1); |
| 199 | | }; |
| 199 | max_rss = std.fmt.parseIntSizeSuffix(max_rss_text, 10) catch |err| |
| 200 | fatal("invalid byte size: '{s}': {t}", .{ max_rss_text, err }); |
| 200 | 201 | } else if (mem.eql(u8, arg, "--skip-oom-steps")) { |
| 201 | 202 | skip_oom_steps = true; |
| 202 | 203 | } else if (mem.eql(u8, arg, "--test-timeout")) { |
| ... | ... | @@ -270,9 +271,7 @@ pub fn main(init: process.Init.Minimal) !void { |
| 270 | 271 | const next_arg = nextArg(args, &arg_idx) orelse |
| 271 | 272 | fatalWithHint("expected u32 after '{s}'", .{arg}); |
| 272 | 273 | graph.random_seed = std.fmt.parseUnsigned(u32, next_arg, 0) catch |err| { |
| 273 | | fatal("unable to parse seed '{s}' as unsigned 32-bit integer: {s}\n", .{ |
| 274 | | next_arg, @errorName(err), |
| 275 | | }); |
| 274 | fatal("unable to parse seed '{s}' as unsigned 32-bit integer: {t}", .{ next_arg, err }); |
| 276 | 275 | }; |
| 277 | 276 | } else if (mem.eql(u8, arg, "--debounce")) { |
| 278 | 277 | const next_arg = nextArg(args, &arg_idx) orelse |
| ... | ... | @@ -288,7 +287,7 @@ pub fn main(init: process.Init.Minimal) !void { |
| 288 | 287 | const addr_str = arg["--webui=".len..]; |
| 289 | 288 | if (std.mem.eql(u8, addr_str, "-")) fatal("web interface cannot listen on stdio", .{}); |
| 290 | 289 | webui_listen = Io.net.IpAddress.parseLiteral(addr_str) catch |err| { |
| 291 | | fatal("invalid web UI address '{s}': {s}", .{ addr_str, @errorName(err) }); |
| 290 | fatal("invalid web UI address '{s}': {t}", .{ addr_str, err }); |
| 292 | 291 | }; |
| 293 | 292 | } else if (mem.eql(u8, arg, "--debug-log")) { |
| 294 | 293 | const next_arg = nextArgOrFatal(args, &arg_idx); |
| ... | ... | @@ -300,11 +299,6 @@ pub fn main(init: process.Init.Minimal) !void { |
| 300 | 299 | } else if (mem.cutPrefix(u8, arg, "--debug-rt=")) |rest| { |
| 301 | 300 | graph.debug_compiler_runtime_libs = std.meta.stringToEnum(std.builtin.OptimizeMode, rest) orelse |
| 302 | 301 | fatal("unrecognized optimization mode: {s}", .{rest}); |
| 303 | | } else if (mem.eql(u8, arg, "--system")) { |
| 304 | | // The usage text shows another argument after this parameter |
| 305 | | // but it is handled by the parent process. The build runner |
| 306 | | // only sees this flag. |
| 307 | | graph.system_package_mode = true; |
| 308 | 302 | } else if (mem.eql(u8, arg, "--libc-runtimes") or mem.eql(u8, arg, "--glibc-runtimes")) { |
| 309 | 303 | // --glibc-runtimes was the old name of the flag; kept for compatibility for now. |
| 310 | 304 | libc_runtimes_dir = nextArgOrFatal(args, &arg_idx); |
| ... | ... | @@ -383,7 +377,7 @@ pub fn main(init: process.Init.Minimal) !void { |
| 383 | 377 | } else if (mem.startsWith(u8, arg, "-freference-trace=")) { |
| 384 | 378 | const num = arg["-freference-trace=".len..]; |
| 385 | 379 | reference_trace = std.fmt.parseUnsigned(u32, num, 10) catch |err| { |
| 386 | | std.debug.print("unable to parse reference_trace count '{s}': {s}", .{ num, @errorName(err) }); |
| 380 | std.debug.print("unable to parse reference_trace count '{s}': {t}", .{ num, err }); |
| 387 | 381 | process.exit(1); |
| 388 | 382 | }; |
| 389 | 383 | } else if (mem.eql(u8, arg, "-fno-reference-trace")) { |
| ... | ... | @@ -414,6 +408,29 @@ pub fn main(init: process.Init.Minimal) !void { |
| 414 | 408 | .off => .no_color, |
| 415 | 409 | }; |
| 416 | 410 | |
| 411 | if (help_menu) { |
| 412 | var w = initStdoutWriter(io); |
| 413 | scanned_config.printUsage(&graph, w) catch |err| switch (err) { |
| 414 | error.WriteFailed => return stdout_writer_allocation.err.?, |
| 415 | else => |e| return e, |
| 416 | }; |
| 417 | w.flush() catch return stdout_writer_allocation.err.?; |
| 418 | return; |
| 419 | } else if (steps_menu) { |
| 420 | var w = initStdoutWriter(io); |
| 421 | scanned_config.printSteps(&graph, w) catch |err| switch (err) { |
| 422 | error.WriteFailed => return stdout_writer_allocation.err.?, |
| 423 | else => |e| return e, |
| 424 | }; |
| 425 | w.flush() catch return stdout_writer_allocation.err.?; |
| 426 | return; |
| 427 | } else if (print_configuration) { |
| 428 | var w = initStdoutWriter(io); |
| 429 | scanned_config.print(w) catch return stdout_writer_allocation.err.?; |
| 430 | w.flush() catch return stdout_writer_allocation.err.?; |
| 431 | return; |
| 432 | } |
| 433 | |
| 417 | 434 | if (webui_listen != null) { |
| 418 | 435 | if (watch) fatal("using '--webui' and '--watch' together is not yet supported; consider omitting '--watch' in favour of the web UI \"Rebuild\" button", .{}); |
| 419 | 436 | if (builtin.single_threaded) fatal("'--webui' is not yet supported on single-threaded hosts", .{}); |
| ... | ... | @@ -424,27 +441,33 @@ pub fn main(init: process.Init.Minimal) !void { |
| 424 | 441 | }); |
| 425 | 442 | defer main_progress_node.end(); |
| 426 | 443 | |
| 427 | | graph.resolveInstallPrefix(install_prefix, dir_list); |
| 444 | const install_prefix_path: Path = if (graph.environ_map.get("DESTDIR")) |dest_dir| .{ |
| 445 | .root_dir = .cwd(), |
| 446 | .sub_path = try Io.Dir.path.join(arena, &.{ dest_dir, override_install_prefix orelse "/usr" }), |
| 447 | } else if (override_install_prefix) |cwd_relative| .{ |
| 448 | .root_dir = .cwd(), |
| 449 | .sub_path = cwd_relative, |
| 450 | } else .{ |
| 451 | .root_dir = build_root_directory, |
| 452 | .sub_path = "zig-out", |
| 453 | }; |
| 428 | 454 | |
| 429 | | if (graph.validateUserInputDidItFail()) { |
| 430 | | fatal(" access the help menu with 'zig build -h'", .{}); |
| 431 | | } |
| 455 | const install_lib_path: Path = if (override_lib_dir) |cwd_relative| .{ |
| 456 | .root_dir = .cwd(), |
| 457 | .sub_path = cwd_relative, |
| 458 | } else try install_prefix_path.join(arena, "lib"); |
| 432 | 459 | |
| 433 | | validateSystemLibraryOptions(&graph); |
| 460 | const install_bin_path: Path = if (override_bin_dir) |cwd_relative| .{ |
| 461 | .root_dir = .cwd(), |
| 462 | .sub_path = cwd_relative, |
| 463 | } else try install_prefix_path.join(arena, "bin"); |
| 434 | 464 | |
| 435 | | if (help_menu) { |
| 436 | | var w = initStdoutWriter(io); |
| 437 | | printUsage(&graph, w) catch return stdout_writer_allocation.err.?; |
| 438 | | w.flush() catch return stdout_writer_allocation.err.?; |
| 439 | | return; |
| 440 | | } |
| 465 | const install_include_path: Path = if (override_include_dir) |cwd_relative| .{ |
| 466 | .root_dir = .cwd(), |
| 467 | .sub_path = cwd_relative, |
| 468 | } else try install_prefix_path.join(arena, "include"); |
| 441 | 469 | |
| 442 | | if (steps_menu) { |
| 443 | | var w = initStdoutWriter(io); |
| 444 | | printSteps(&graph, w) catch return stdout_writer_allocation.err.?; |
| 445 | | w.flush() catch return stdout_writer_allocation.err.?; |
| 446 | | return; |
| 447 | | } |
| 470 | if (true) @panic("TODO"); |
| 448 | 471 | |
| 449 | 472 | var run: Run = .{ |
| 450 | 473 | .gpa = gpa, |
| ... | ... | @@ -463,6 +486,13 @@ pub fn main(init: process.Init.Minimal) !void { |
| 463 | 486 | .error_style = error_style, |
| 464 | 487 | .multiline_errors = multiline_errors, |
| 465 | 488 | .summary = summary orelse if (watch or webui_listen != null) .line else .failures, |
| 489 | |
| 490 | .install_paths = .{ |
| 491 | .prefix = install_prefix_path, |
| 492 | .lib = install_lib_path, |
| 493 | .bin = install_bin_path, |
| 494 | .include = install_include_path, |
| 495 | }, |
| 466 | 496 | }; |
| 467 | 497 | defer { |
| 468 | 498 | run.memory_blocked_steps.deinit(gpa); |
| ... | ... | @@ -628,9 +658,9 @@ fn prepare(graph: *Graph, step_names: []const []const u8, run: *Run) !void { |
| 628 | 658 | try step_stack.ensureUnusedCapacity(gpa, step_names.len); |
| 629 | 659 | for (0..step_names.len) |i| { |
| 630 | 660 | const step_name = step_names[step_names.len - i - 1]; |
| 631 | | const s = graph.top_level_steps.get(step_name) orelse { |
| 632 | | std.log.info("access the help menu with \"zig build -h\"", .{}); |
| 633 | | fatal("no step named '{s}'", .{step_name}); |
| 661 | const s = run.top_level_steps.get(step_name) orelse { |
| 662 | log.info("access the help menu with 'zig build -h'", .{}); |
| 663 | fatal("no such step: {s}", .{step_name}); |
| 634 | 664 | }; |
| 635 | 665 | step_stack.putAssumeCapacity(&s.step, {}); |
| 636 | 666 | } |
| ... | ... | @@ -873,11 +903,11 @@ fn runStepNames( |
| 873 | 903 | print_node.last = true; |
| 874 | 904 | printTreeStep(graph, graph.default_step, run, t, &print_node, &step_stack_copy) catch {}; |
| 875 | 905 | } else { |
| 876 | | const last_index = if (run.summary == .all) graph.top_level_steps.count() else blk: { |
| 906 | const last_index = if (run.summary == .all) run.top_level_steps.count() else blk: { |
| 877 | 907 | var i: usize = step_names.len; |
| 878 | 908 | while (i > 0) { |
| 879 | 909 | i -= 1; |
| 880 | | const step = graph.top_level_steps.get(step_names[i]).?.step; |
| 910 | const step = run.top_level_steps.get(step_names[i]).?.step; |
| 881 | 911 | const found = switch (run.summary) { |
| 882 | 912 | .all, .line, .none => unreachable, |
| 883 | 913 | .failures => step.state != .success, |
| ... | ... | @@ -885,10 +915,10 @@ fn runStepNames( |
| 885 | 915 | }; |
| 886 | 916 | if (found) break :blk i; |
| 887 | 917 | } |
| 888 | | break :blk graph.top_level_steps.count(); |
| 918 | break :blk run.top_level_steps.count(); |
| 889 | 919 | }; |
| 890 | 920 | for (step_names, 0..) |step_name, i| { |
| 891 | | const tls = graph.top_level_steps.get(step_name).?; |
| 921 | const tls = run.top_level_steps.get(step_name).?; |
| 892 | 922 | print_node.last = i + 1 == last_index; |
| 893 | 923 | printTreeStep(graph, &tls.step, run, t, &print_node, &step_stack_copy) catch {}; |
| 894 | 924 | } |
| ... | ... | @@ -1207,7 +1237,7 @@ fn constructGraphAndCheckForDependencyLoop( |
| 1207 | 1237 | |
| 1208 | 1238 | // We dupe to avoid shuffling the steps in the summary, it depends |
| 1209 | 1239 | // on s.dependencies' order. |
| 1210 | | const deps = gpa.dupe(*Step, s.dependencies.items) catch @panic("OOM"); |
| 1240 | const deps = try gpa.dupe(*Step, s.dependencies.items); |
| 1211 | 1241 | defer gpa.free(deps); |
| 1212 | 1242 | |
| 1213 | 1243 | rand.shuffle(*Step, deps); |
| ... | ... | @@ -1327,7 +1357,7 @@ fn makeStep( |
| 1327 | 1357 | try run.max_rss_mutex.lock(io); |
| 1328 | 1358 | defer run.max_rss_mutex.unlock(io); |
| 1329 | 1359 | run.available_rss += s.max_rss; |
| 1330 | | dispatch_set.ensureUnusedCapacity(gpa, run.memory_blocked_steps.items.len) catch @panic("OOM"); |
| 1360 | try dispatch_set.ensureUnusedCapacity(gpa, run.memory_blocked_steps.items.len); |
| 1331 | 1361 | while (run.memory_blocked_steps.getLast()) |candidate| { |
| 1332 | 1362 | if (run.available_rss < candidate.max_rss) break; |
| 1333 | 1363 | assert(run.memory_blocked_steps.pop() == candidate); |
| ... | ... | @@ -1360,7 +1390,7 @@ fn stepReady( |
| 1360 | 1390 | defer run.max_rss_mutex.unlock(io); |
| 1361 | 1391 | if (run.available_rss < s.max_rss) { |
| 1362 | 1392 | // Running this step right now could possibly exceed the allotted RSS. |
| 1363 | | run.memory_blocked_steps.append(run.gpa, s) catch @panic("OOM"); |
| 1393 | try run.memory_blocked_steps.append(run.gpa, s); |
| 1364 | 1394 | return; |
| 1365 | 1395 | } |
| 1366 | 1396 | run.available_rss -= s.max_rss; |
| ... | ... | @@ -1454,178 +1484,6 @@ pub fn printErrorMessages( |
| 1454 | 1484 | try writer.writeByte('\n'); |
| 1455 | 1485 | } |
| 1456 | 1486 | |
| 1457 | | fn printSteps(graph: *Graph, w: *Writer) !void { |
| 1458 | | const arena = graph.arena; |
| 1459 | | for (graph.top_level_steps.values()) |top_level_step| { |
| 1460 | | const name = if (&top_level_step.step == graph.default_step) |
| 1461 | | try fmt.allocPrint(arena, "{s} (default)", .{top_level_step.step.name}) |
| 1462 | | else |
| 1463 | | top_level_step.step.name; |
| 1464 | | try w.print(" {s:<28} {s}\n", .{ name, top_level_step.description }); |
| 1465 | | } |
| 1466 | | } |
| 1467 | | |
| 1468 | | fn printUsage(graph: *Graph, w: *Writer) !void { |
| 1469 | | const arena = graph.arena; |
| 1470 | | |
| 1471 | | try w.print( |
| 1472 | | \\Usage: {s} build [steps] [options] |
| 1473 | | \\ |
| 1474 | | \\Steps: |
| 1475 | | \\ |
| 1476 | | , .{graph.zig_exe}); |
| 1477 | | try printSteps(graph, w); |
| 1478 | | try w.writeAll( |
| 1479 | | \\ |
| 1480 | | \\Project-Specific Options: |
| 1481 | | \\ |
| 1482 | | ); |
| 1483 | | |
| 1484 | | if (graph.available_options_list.items.len == 0) { |
| 1485 | | try w.print(" (none)\n", .{}); |
| 1486 | | } else { |
| 1487 | | for (graph.available_options_list.items) |option| { |
| 1488 | | const name = try fmt.allocPrint(arena, " -D{s}=[{t}]", .{ option.name, option.type_id }); |
| 1489 | | try w.print("{s:<30} {s}\n", .{ name, option.description }); |
| 1490 | | if (option.enum_options) |enum_options| { |
| 1491 | | const padding: [33]u8 = @splat(' '); |
| 1492 | | try w.writeAll(padding ++ "Supported Values:\n"); |
| 1493 | | for (enum_options) |enum_option| { |
| 1494 | | try w.print(padding ++ " {s}\n", .{enum_option}); |
| 1495 | | } |
| 1496 | | } |
| 1497 | | } |
| 1498 | | } |
| 1499 | | |
| 1500 | | try w.writeAll( |
| 1501 | | \\ |
| 1502 | | \\System Integration Options: |
| 1503 | | \\ --search-prefix [path] Add a path to look for binaries, libraries, headers |
| 1504 | | \\ --sysroot [path] Set the system root directory (usually /) |
| 1505 | | \\ --libc [file] Provide a file which specifies libc paths |
| 1506 | | \\ |
| 1507 | | \\ --system [pkgdir] Disable package fetching; enable all integrations |
| 1508 | | \\ -fsys=[name] Enable a system integration |
| 1509 | | \\ -fno-sys=[name] Disable a system integration |
| 1510 | | \\ |
| 1511 | | \\ -fdarling, -fno-darling Integration with system-installed Darling to |
| 1512 | | \\ execute macOS programs on Linux hosts |
| 1513 | | \\ (default: no) |
| 1514 | | \\ -fqemu, -fno-qemu Integration with system-installed QEMU to execute |
| 1515 | | \\ foreign-architecture programs on Linux hosts |
| 1516 | | \\ (default: no) |
| 1517 | | \\ --libc-runtimes [path] Enhances QEMU integration by providing dynamic libc |
| 1518 | | \\ (e.g. glibc or musl) built for multiple foreign |
| 1519 | | \\ architectures, allowing execution of non-native |
| 1520 | | \\ programs that link with libc. |
| 1521 | | \\ -frosetta, -fno-rosetta Rely on Rosetta to execute x86_64 programs on |
| 1522 | | \\ ARM64 macOS hosts. (default: no) |
| 1523 | | \\ -fwasmtime, -fno-wasmtime Integration with system-installed wasmtime to |
| 1524 | | \\ execute WASI binaries. (default: no) |
| 1525 | | \\ -fwine, -fno-wine Integration with system-installed Wine to execute |
| 1526 | | \\ Windows programs on Linux hosts. (default: no) |
| 1527 | | \\ |
| 1528 | | \\ Available System Integrations: Enabled: |
| 1529 | | \\ |
| 1530 | | ); |
| 1531 | | if (graph.system_library_options.entries.len == 0) { |
| 1532 | | try w.writeAll(" (none) -\n"); |
| 1533 | | } else { |
| 1534 | | for (graph.system_library_options.keys(), graph.system_library_options.values()) |k, v| { |
| 1535 | | const status = switch (v) { |
| 1536 | | .declared_enabled => "yes", |
| 1537 | | .declared_disabled => "no", |
| 1538 | | .user_enabled, .user_disabled => unreachable, // already emitted error |
| 1539 | | }; |
| 1540 | | try w.print(" {s:<43} {s}\n", .{ k, status }); |
| 1541 | | } |
| 1542 | | } |
| 1543 | | |
| 1544 | | try w.writeAll( |
| 1545 | | \\ |
| 1546 | | \\General Options: |
| 1547 | | \\ -h, --help Print this help and exit |
| 1548 | | \\ -l, --list-steps Print available steps |
| 1549 | | \\ |
| 1550 | | \\ -p, --prefix [path] Where to install files (default: zig-out) |
| 1551 | | \\ --prefix-lib-dir [path] Where to install libraries |
| 1552 | | \\ --prefix-exe-dir [path] Where to install executables |
| 1553 | | \\ --prefix-include-dir [path] Where to install C header files |
| 1554 | | \\ --release[=mode] Request release mode, optionally specifying a |
| 1555 | | \\ preferred optimization mode: fast, safe, small |
| 1556 | | \\ |
| 1557 | | \\ --verbose Print commands before executing them |
| 1558 | | \\ --color [auto|off|on] Enable or disable colored error messages |
| 1559 | | \\ --error-style [style] Control how build errors are printed |
| 1560 | | \\ verbose (Default) Report errors with full context |
| 1561 | | \\ minimal Report errors after summary, excluding context like command lines |
| 1562 | | \\ verbose_clear Like 'verbose', but clear the terminal at the start of each update |
| 1563 | | \\ minimal_clear Like 'minimal', but clear the terminal at the start of each update |
| 1564 | | \\ --multiline-errors [style] Control how multi-line error messages are printed |
| 1565 | | \\ indent (Default) Indent non-initial lines to align with initial line |
| 1566 | | \\ newline Include a leading newline so that the error message is on its own lines |
| 1567 | | \\ none Print as usual so the first line is misaligned |
| 1568 | | \\ --summary [mode] Control the printing of the build summary |
| 1569 | | \\ all Print the build summary in its entirety |
| 1570 | | \\ new Omit cached steps |
| 1571 | | \\ failures (Default if short-lived) Only print failed steps |
| 1572 | | \\ line (Default if long-lived) Only print the single-line summary |
| 1573 | | \\ none Do not print the build summary |
| 1574 | | \\ -j<N> Limit concurrent jobs (default is to use all CPU cores) |
| 1575 | | \\ --maxrss <bytes> Limit memory usage (default is to use available memory) |
| 1576 | | \\ --skip-oom-steps Instead of failing, skip steps that would exceed --maxrss |
| 1577 | | \\ --test-timeout <timeout> Limit execution time of unit tests, terminating if exceeded. |
| 1578 | | \\ The timeout must include a unit: ns, us, ms, s, m, h |
| 1579 | | \\ --watch Continuously rebuild when source files are modified |
| 1580 | | \\ --debounce <ms> Delay before rebuilding after changed file detected |
| 1581 | | \\ --webui[=ip] Enable the web interface on the given IP address |
| 1582 | | \\ --fuzz[=limit] Continuously search for unit test failures with an optional |
| 1583 | | \\ limit to the max number of iterations. The argument supports |
| 1584 | | \\ an optional 'K', 'M', or 'G' suffix (e.g. '10K'). Implies |
| 1585 | | \\ '--webui' when no limit is specified. |
| 1586 | | \\ --time-report Force full rebuild and provide detailed information on |
| 1587 | | \\ compilation time of Zig source code (implies '--webui') |
| 1588 | | \\ -fincremental Enable incremental compilation |
| 1589 | | \\ -fno-incremental Disable incremental compilation |
| 1590 | | \\ |
| 1591 | | \\Package Management Options: |
| 1592 | | \\ --fetch[=mode] Fetch dependency tree (optionally choose laziness) and exit |
| 1593 | | \\ needed (Default) Lazy dependencies are fetched as needed |
| 1594 | | \\ all Lazy dependencies are always fetched |
| 1595 | | \\ --fork=[path] Override one or more projects from dependency tree |
| 1596 | | \\ |
| 1597 | | \\Advanced Options: |
| 1598 | | \\ -freference-trace[=num] How many lines of reference trace should be shown per compile error |
| 1599 | | \\ -fno-reference-trace Disable reference trace |
| 1600 | | \\ -fallow-so-scripts Allows .so files to be GNU ld scripts |
| 1601 | | \\ -fno-allow-so-scripts (default) .so files must be ELF files |
| 1602 | | \\ --build-file [file] Override path to build.zig |
| 1603 | | \\ --cache-dir [path] Override path to local Zig cache directory |
| 1604 | | \\ --global-cache-dir [path] Override path to global Zig cache directory |
| 1605 | | \\ --zig-lib-dir [arg] Override path to Zig lib directory |
| 1606 | | \\ --build-runner [file] Override path to build runner |
| 1607 | | \\ --seed [integer] For shuffling dependency traversal order (default: random) |
| 1608 | | \\ --build-id[=style] At a minor link-time expense, embeds a build ID in binaries |
| 1609 | | \\ fast 8-byte non-cryptographic hash (COFF, ELF, WASM) |
| 1610 | | \\ sha1, tree 20-byte cryptographic hash (ELF, WASM) |
| 1611 | | \\ md5 16-byte cryptographic hash (ELF) |
| 1612 | | \\ uuid 16-byte random UUID (ELF, WASM) |
| 1613 | | \\ 0x[hexstring] Constant ID, maximum 32 bytes (ELF, WASM) |
| 1614 | | \\ none (default) No build ID |
| 1615 | | \\ --debug-log [scope] Enable debugging the compiler |
| 1616 | | \\ --debug-pkg-config Fail if unknown pkg-config flags encountered |
| 1617 | | \\ --debug-rt Debug compiler runtime libraries |
| 1618 | | \\ --verbose-link Enable compiler debug output for linking |
| 1619 | | \\ --verbose-air Enable compiler debug output for Zig AIR |
| 1620 | | \\ --verbose-llvm-ir[=file] Enable compiler debug output for LLVM IR |
| 1621 | | \\ --verbose-llvm-bc=[file] Enable compiler debug output for LLVM BC |
| 1622 | | \\ --verbose-cimport Enable compiler debug output for C imports |
| 1623 | | \\ --verbose-cc Enable compiler debug output for C compilation |
| 1624 | | \\ --verbose-llvm-cpu-features Enable compiler debug output for LLVM CPU features |
| 1625 | | \\ |
| 1626 | | ); |
| 1627 | | } |
| 1628 | | |
| 1629 | 1487 | fn nextArg(args: []const [:0]const u8, idx: *usize) ?[:0]const u8 { |
| 1630 | 1488 | if (idx.* >= args.len) return null; |
| 1631 | 1489 | defer idx.* += 1; |
| ... | ... | @@ -1633,17 +1491,17 @@ fn nextArg(args: []const [:0]const u8, idx: *usize) ?[:0]const u8 { |
| 1633 | 1491 | } |
| 1634 | 1492 | |
| 1635 | 1493 | fn nextArgOrFatal(args: []const [:0]const u8, idx: *usize) [:0]const u8 { |
| 1636 | | return nextArg(args, idx) orelse |
| 1637 | | fatal("expected argument after {q}\n access the help menu with \"zig build -h\"", .{args[idx.* - 1]}); |
| 1494 | return nextArg(args, idx) orelse { |
| 1495 | log.info("access the help menu with \"zig build -h\"", .{}); |
| 1496 | fatal("expected argument after {q}", .{args[idx.* - 1]}); |
| 1497 | }; |
| 1638 | 1498 | } |
| 1639 | 1499 | |
| 1640 | | fn cutArgPrefixOrFatal(args: []const [:0]const u8, idx: *usize, prefix: []const u8) []const u8 { |
| 1641 | | if (nextArg(args, idx)) |next_arg| { |
| 1642 | | if (mem.cutPrefix(u8, next_arg, prefix)) |arg| { |
| 1643 | | return arg; |
| 1644 | | } |
| 1645 | | } |
| 1646 | | fatal("expected argument after {q} to start with {q}", .{ args[idx.* - 1], prefix }); |
| 1500 | fn expectArgOrFatal(args: []const [:0]const u8, index_ptr: *usize, first: []const u8) []const u8 { |
| 1501 | const next_arg = nextArg(args, index_ptr) orelse fatal("missing {q} argument", .{first}); |
| 1502 | if (!mem.eql(u8, first, next_arg)) fatal("expected {q} instead of {q}", .{ first, next_arg }); |
| 1503 | const arg = nextArg(args, index_ptr) orelse fatal("expected argument after {q}", .{first}); |
| 1504 | return arg; |
| 1647 | 1505 | } |
| 1648 | 1506 | |
| 1649 | 1507 | fn argsRest(args: []const [:0]const u8, idx: usize) ?[]const [:0]const u8 { |
| ... | ... | @@ -1674,29 +1532,28 @@ const MultilineErrors = enum { indent, newline, none }; |
| 1674 | 1532 | const Summary = enum { all, new, failures, line, none }; |
| 1675 | 1533 | |
| 1676 | 1534 | fn fatalWithHint(comptime f: []const u8, args: anytype) noreturn { |
| 1677 | | std.debug.print(f ++ "\n access the help menu with 'zig build -h'\n", args); |
| 1678 | | process.exit(1); |
| 1535 | log.info("access the help menu with 'zig build -h'", .{}); |
| 1536 | fatal(f, args); |
| 1679 | 1537 | } |
| 1680 | 1538 | |
| 1681 | | fn validateSystemLibraryOptions(graph: *Graph) void { |
| 1682 | | var bad = false; |
| 1683 | | for (graph.system_library_options.keys(), graph.system_library_options.values()) |k, v| { |
| 1684 | | switch (v) { |
| 1685 | | .user_disabled, .user_enabled => { |
| 1686 | | // The user tried to enable or disable a system library integration, but |
| 1687 | | // the build script did not recognize that option. |
| 1688 | | std.debug.print("system library name not recognized by build script: '{s}'\n", .{k}); |
| 1689 | | bad = true; |
| 1690 | | }, |
| 1691 | | .declared_disabled, .declared_enabled => {}, |
| 1692 | | } |
| 1693 | | } |
| 1694 | | if (bad) { |
| 1695 | | std.debug.print(" access the help menu with 'zig build -h'\n", .{}); |
| 1696 | | process.exit(1); |
| 1539 | fn cleanTmpFiles(io: Io, steps: []const *Step) void { |
| 1540 | for (steps) |step| { |
| 1541 | const wf = step.cast(Step.WriteFile) orelse continue; |
| 1542 | if (wf.mode != .tmp) continue; |
| 1543 | const path = wf.generated_directory.path orelse continue; |
| 1544 | Io.Dir.cwd().deleteTree(io, path) catch |err| { |
| 1545 | log.warn("failed to delete {s}: {t}", .{ path, err }); |
| 1546 | }; |
| 1697 | 1547 | } |
| 1698 | 1548 | } |
| 1699 | 1549 | |
| 1550 | const InstallPaths = struct { |
| 1551 | prefix: Path, |
| 1552 | lib: Path, |
| 1553 | bin: Path, |
| 1554 | include: Path, |
| 1555 | }; |
| 1556 | |
| 1700 | 1557 | var stdio_buffer_allocation: [256]u8 = undefined; |
| 1701 | 1558 | var stdout_writer_allocation: Io.File.Writer = undefined; |
| 1702 | 1559 | |
| ... | ... | @@ -1705,13 +1562,202 @@ fn initStdoutWriter(io: Io) *Writer { |
| 1705 | 1562 | return &stdout_writer_allocation.interface; |
| 1706 | 1563 | } |
| 1707 | 1564 | |
| 1708 | | fn cleanTmpFiles(io: Io, steps: []const *Step) void { |
| 1709 | | for (steps) |step| { |
| 1710 | | const wf = step.cast(Step.WriteFile) orelse continue; |
| 1711 | | if (wf.mode != .tmp) continue; |
| 1712 | | const path = wf.generated_directory.path orelse continue; |
| 1713 | | Io.Dir.cwd().deleteTree(io, path) catch |err| { |
| 1714 | | std.log.warn("failed to delete {s}: {t}", .{ path, err }); |
| 1715 | | }; |
| 1565 | const ScannedConfig = struct { |
| 1566 | configuration: Configuration, |
| 1567 | top_level_steps: []const Configuration.Step.Index, |
| 1568 | |
| 1569 | fn print(sc: *const ScannedConfig, w: *Writer) Writer.Error!void { |
| 1570 | var serializer: std.zon.Serializer = .{ .writer = w }; |
| 1571 | var s = try serializer.beginStruct(.{}); |
| 1572 | |
| 1573 | try s.field("default_step", @intFromEnum(sc.configuration.default_step), .{}); |
| 1574 | { |
| 1575 | var tuple = try s.beginTupleField("top_level_steps", .{}); |
| 1576 | for (sc.top_level_steps) |step| try tuple.field(@intFromEnum(step), .{}); |
| 1577 | try tuple.end(); |
| 1578 | } |
| 1579 | |
| 1580 | try s.end(); |
| 1716 | 1581 | } |
| 1717 | | } |
| 1582 | |
| 1583 | fn printSteps(sc: *const ScannedConfig, graph: *Graph, w: *Writer) !void { |
| 1584 | const arena = graph.arena; |
| 1585 | const c = &sc.configuration; |
| 1586 | for (sc.top_level_steps) |step_index| { |
| 1587 | const step = step_index.ptr(c); |
| 1588 | const name = step.name.slice(c); |
| 1589 | const decorated_name = if (step_index == c.default_step) |
| 1590 | try fmt.allocPrint(arena, "{s} (default)", .{name}) |
| 1591 | else |
| 1592 | name; |
| 1593 | const top_level = c.extraData(Configuration.Step.TopLevel, step.extra_index); |
| 1594 | const description = top_level.description.slice(c); |
| 1595 | try w.print(" {s:<28} {s}\n", .{ decorated_name, description }); |
| 1596 | } |
| 1597 | } |
| 1598 | |
| 1599 | fn printUsage(sc: *const ScannedConfig, graph: *Graph, w: *Writer) !void { |
| 1600 | const arena = graph.arena; |
| 1601 | |
| 1602 | try w.print( |
| 1603 | \\Usage: {s} build [steps] [options] |
| 1604 | \\ |
| 1605 | \\Steps: |
| 1606 | \\ |
| 1607 | , .{graph.zig_exe}); |
| 1608 | try printSteps(sc, graph, w); |
| 1609 | try w.writeAll( |
| 1610 | \\ |
| 1611 | \\Project-Specific Options: |
| 1612 | \\ |
| 1613 | ); |
| 1614 | |
| 1615 | const available_options = sc.configuration.available_options; |
| 1616 | if (available_options.len == 0) { |
| 1617 | try w.print(" (none)\n", .{}); |
| 1618 | } else { |
| 1619 | for (available_options) |option| { |
| 1620 | const name = option.name.slice(&sc.configuration); |
| 1621 | const description = option.description.slice(&sc.configuration); |
| 1622 | const help = try fmt.allocPrint(arena, " -D{s}=[{t}]", .{ name, option.type }); |
| 1623 | try w.print("{s:<30} {s}\n", .{ help, description }); |
| 1624 | if (option.enum_options.slice(&sc.configuration)) |enum_options| { |
| 1625 | const padding: [33]u8 = @splat(' '); |
| 1626 | try w.writeAll(padding ++ "Supported Values:\n"); |
| 1627 | for (enum_options) |enum_option_index| { |
| 1628 | const enum_option = enum_option_index.slice(&sc.configuration); |
| 1629 | try w.print(padding ++ " {s}\n", .{enum_option}); |
| 1630 | } |
| 1631 | } |
| 1632 | } |
| 1633 | } |
| 1634 | |
| 1635 | try w.writeAll( |
| 1636 | \\ |
| 1637 | \\System Integration Options: |
| 1638 | \\ --search-prefix [path] Add a path to look for binaries, libraries, headers |
| 1639 | \\ --sysroot [path] Set the system root directory (usually /) |
| 1640 | \\ --libc [file] Provide a file which specifies libc paths |
| 1641 | \\ |
| 1642 | \\ --system [pkgdir] Disable package fetching; enable all integrations |
| 1643 | \\ -fsys=[name] Enable a system integration |
| 1644 | \\ -fno-sys=[name] Disable a system integration |
| 1645 | \\ |
| 1646 | \\ -fdarling, -fno-darling Integration with system-installed Darling to |
| 1647 | \\ execute macOS programs on Linux hosts |
| 1648 | \\ (default: no) |
| 1649 | \\ -fqemu, -fno-qemu Integration with system-installed QEMU to execute |
| 1650 | \\ foreign-architecture programs on Linux hosts |
| 1651 | \\ (default: no) |
| 1652 | \\ --libc-runtimes [path] Enhances QEMU integration by providing dynamic libc |
| 1653 | \\ (e.g. glibc or musl) built for multiple foreign |
| 1654 | \\ architectures, allowing execution of non-native |
| 1655 | \\ programs that link with libc. |
| 1656 | \\ -frosetta, -fno-rosetta Rely on Rosetta to execute x86_64 programs on |
| 1657 | \\ ARM64 macOS hosts. (default: no) |
| 1658 | \\ -fwasmtime, -fno-wasmtime Integration with system-installed wasmtime to |
| 1659 | \\ execute WASI binaries. (default: no) |
| 1660 | \\ -fwine, -fno-wine Integration with system-installed Wine to execute |
| 1661 | \\ Windows programs on Linux hosts. (default: no) |
| 1662 | \\ |
| 1663 | \\ Available System Integrations: Enabled: |
| 1664 | \\ |
| 1665 | ); |
| 1666 | if (sc.configuration.system_integrations.len == 0) { |
| 1667 | try w.writeAll(" (none) -\n"); |
| 1668 | } else { |
| 1669 | for (sc.configuration.system_integrations) |system_integration| { |
| 1670 | const name = system_integration.name.slice(&sc.configuration); |
| 1671 | const status = switch (system_integration.status) { |
| 1672 | .disabled => "no", |
| 1673 | .enabled => "yes", |
| 1674 | }; |
| 1675 | try w.print(" {s:<43} {s}\n", .{ name, status }); |
| 1676 | } |
| 1677 | } |
| 1678 | |
| 1679 | try w.writeAll( |
| 1680 | \\ |
| 1681 | \\General Options: |
| 1682 | \\ -h, --help Print this help and exit |
| 1683 | \\ -l, --list-steps Print available steps |
| 1684 | \\ |
| 1685 | \\ -p, --prefix [path] Where to install files (default: zig-out) |
| 1686 | \\ --prefix-lib-dir [path] Where to install libraries |
| 1687 | \\ --prefix-exe-dir [path] Where to install executables |
| 1688 | \\ --prefix-include-dir [path] Where to install C header files |
| 1689 | \\ --release[=mode] Request release mode, optionally specifying a |
| 1690 | \\ preferred optimization mode: fast, safe, small |
| 1691 | \\ |
| 1692 | \\ --verbose Print commands before executing them |
| 1693 | \\ --color [auto|off|on] Enable or disable colored error messages |
| 1694 | \\ --error-style [style] Control how build errors are printed |
| 1695 | \\ verbose (Default) Report errors with full context |
| 1696 | \\ minimal Report errors after summary, excluding context like command lines |
| 1697 | \\ verbose_clear Like 'verbose', but clear the terminal at the start of each update |
| 1698 | \\ minimal_clear Like 'minimal', but clear the terminal at the start of each update |
| 1699 | \\ --multiline-errors [style] Control how multi-line error messages are printed |
| 1700 | \\ indent (Default) Indent non-initial lines to align with initial line |
| 1701 | \\ newline Include a leading newline so that the error message is on its own lines |
| 1702 | \\ none Print as usual so the first line is misaligned |
| 1703 | \\ --summary [mode] Control the printing of the build summary |
| 1704 | \\ all Print the build summary in its entirety |
| 1705 | \\ new Omit cached steps |
| 1706 | \\ failures (Default if short-lived) Only print failed steps |
| 1707 | \\ line (Default if long-lived) Only print the single-line summary |
| 1708 | \\ none Do not print the build summary |
| 1709 | \\ -j<N> Limit concurrent jobs (default is to use all CPU cores) |
| 1710 | \\ --maxrss <bytes> Limit memory usage (default is to use available memory) |
| 1711 | \\ --skip-oom-steps Instead of failing, skip steps that would exceed --maxrss |
| 1712 | \\ --test-timeout <timeout> Limit execution time of unit tests, terminating if exceeded. |
| 1713 | \\ The timeout must include a unit: ns, us, ms, s, m, h |
| 1714 | \\ --watch Continuously rebuild when source files are modified |
| 1715 | \\ --debounce <ms> Delay before rebuilding after changed file detected |
| 1716 | \\ --webui[=ip] Enable the web interface on the given IP address |
| 1717 | \\ --fuzz[=limit] Continuously search for unit test failures with an optional |
| 1718 | \\ limit to the max number of iterations. The argument supports |
| 1719 | \\ an optional 'K', 'M', or 'G' suffix (e.g. '10K'). Implies |
| 1720 | \\ '--webui' when no limit is specified. |
| 1721 | \\ --time-report Force full rebuild and provide detailed information on |
| 1722 | \\ compilation time of Zig source code (implies '--webui') |
| 1723 | \\ -fincremental Enable incremental compilation |
| 1724 | \\ -fno-incremental Disable incremental compilation |
| 1725 | \\ |
| 1726 | \\Package Management Options: |
| 1727 | \\ --fetch[=mode] Fetch dependency tree (optionally choose laziness) and exit |
| 1728 | \\ needed (Default) Lazy dependencies are fetched as needed |
| 1729 | \\ all Lazy dependencies are always fetched |
| 1730 | \\ --fork=[path] Override one or more projects from dependency tree |
| 1731 | \\ |
| 1732 | \\Advanced Options: |
| 1733 | \\ -freference-trace[=num] How many lines of reference trace should be shown per compile error |
| 1734 | \\ -fno-reference-trace Disable reference trace |
| 1735 | \\ -fallow-so-scripts Allows .so files to be GNU ld scripts |
| 1736 | \\ -fno-allow-so-scripts (default) .so files must be ELF files |
| 1737 | \\ --build-file [file] Override path to build.zig |
| 1738 | \\ --cache-dir [path] Override path to local Zig cache directory |
| 1739 | \\ --global-cache-dir [path] Override path to global Zig cache directory |
| 1740 | \\ --zig-lib-dir [arg] Override path to Zig lib directory |
| 1741 | \\ --build-runner [file] Override path to build runner |
| 1742 | \\ --seed [integer] For shuffling dependency traversal order (default: random) |
| 1743 | \\ --build-id[=style] At a minor link-time expense, embeds a build ID in binaries |
| 1744 | \\ fast 8-byte non-cryptographic hash (COFF, ELF, WASM) |
| 1745 | \\ sha1, tree 20-byte cryptographic hash (ELF, WASM) |
| 1746 | \\ md5 16-byte cryptographic hash (ELF) |
| 1747 | \\ uuid 16-byte random UUID (ELF, WASM) |
| 1748 | \\ 0x[hexstring] Constant ID, maximum 32 bytes (ELF, WASM) |
| 1749 | \\ none (default) No build ID |
| 1750 | \\ --debug-log [scope] Enable debugging the compiler |
| 1751 | \\ --debug-pkg-config Fail if unknown pkg-config flags encountered |
| 1752 | \\ --debug-rt Debug compiler runtime libraries |
| 1753 | \\ --verbose-link Enable compiler debug output for linking |
| 1754 | \\ --verbose-air Enable compiler debug output for Zig AIR |
| 1755 | \\ --verbose-llvm-ir[=file] Enable compiler debug output for LLVM IR |
| 1756 | \\ --verbose-llvm-bc=[file] Enable compiler debug output for LLVM BC |
| 1757 | \\ --verbose-cimport Enable compiler debug output for C imports |
| 1758 | \\ --verbose-cc Enable compiler debug output for C compilation |
| 1759 | \\ --verbose-llvm-cpu-features Enable compiler debug output for LLVM CPU features |
| 1760 | \\ |
| 1761 | ); |
| 1762 | } |
| 1763 | }; |