1//! Shared maker state among all steps.
2const Graph = @This();
3
4const std = @import("std");
5const Io = std.Io;
6const Allocator = std.mem.Allocator;
7const Path = std.Build.Cache.Path;
8const Directory = std.Build.Cache.Directory;
9
10io: Io,
11/// Process lifetime.
12arena: Allocator,
13cache: std.Build.Cache,
14zig_exe: []const u8,
15environ_map: std.process.Environ.Map,
16global_cache_root: Directory,
17local_cache_root: Directory,
18zig_lib_directory: Directory,
19build_root_directory: Directory,
20
21debug_compiler_runtime_libs: ?std.builtin.Optimize = null,
22incremental: ?bool = null,
23random_seed: u32 = 0,
24allow_so_scripts: ?bool = null,
25time_report: bool = false,
26/// Similar to the `Io.Terminal.Mode` returned by `Io.lockStderr`, but also
27/// respects the '--color' flag.
28stderr_mode: ?Io.Terminal.Mode = null,
29reference_trace: ?u32 = null,
30debug_log_scopes: std.ArrayList([]const u8) = .empty,
31debug_compile_errors: bool = false,
32debug_incremental: bool = false,
33fuzzing: bool = false,
34verbose: bool = false,
35verbose_air: bool = false,
36verbose_cc: bool = false,
37verbose_link: bool = false,
38verbose_llvm_cpu_features: bool = false,
39verbose_llvm_ir: bool = false,
40libc_file: ?[]const u8 = null,
41/// What does this do? Nobody bothered to document it, and I think it's a
42/// smelly option. So unless somebody deletes these passive aggressive comments
43/// and replaces them with actual documentation, I'm going to delete this
44/// option from the build system in a future release. In other words, this is
45/// deprecated due to lack of test coverage, lack of documentation, and a hunch
46/// that it's a bad option that should be avoided.
47sysroot: ?[]const u8 = null,
48search_prefixes: std.ArrayList([]const u8) = .empty,
49build_id: ?std.zig.BuildId = null,
50error_limit: ?u32 = null,
51/// Steps should use `io` to limit the number of jobs, however in the case of
52/// a single step spawning a fixed number of processes this can be used.
53max_jobs: ?u32 = null,
54
55/// After following the steps in https://codeberg.org/ziglang/infra/src/branch/master/libc-update/glibc.md,
56/// this will be the directory $glibc-build-dir/install/glibcs
57/// Given the example of the aarch64 target, this is the directory
58/// that contains the path `aarch64-linux-gnu/lib/ld-linux-aarch64.so.1`.
59/// Also works for dynamic musl.
60libc_runtimes_dir: ?[]const u8 = null,
61enable_wine: bool = false,
62enable_qemu: bool = false,
63enable_wasmtime: bool = false,
64enable_darling: bool = false,
65enable_rosetta: bool = false,
66
67/// Intention of verbose is to print all sub-process command lines to stderr
68/// before spawning them.
69pub fn handleVerbose(
70 graph: *const Graph,
71 cwd: ?[]const u8,
72 opt_env: ?*const std.process.Environ.Map,
73 argv: []const []const u8,
74) error{OutOfMemory}!void {
75 if (!graph.verbose) return;
76 const arena = graph.arena;
77 const text = try std.zig.allocPrintCmd(arena, argv, .{
78 .cwd = cwd,
79 .parent_env = &graph.environ_map,
80 .child_env = opt_env,
81 });
82 defer arena.free(text);
83 std.log.scoped(.verbose).info("{s}", .{text});
84}