| 1 | //! Shared maker state among all steps. |
| 2 | const Graph = @This(); |
| 3 | |
| 4 | const std = @import("std"); |
| 5 | const Io = std.Io; |
| 6 | const Allocator = std.mem.Allocator; |
| 7 | const Path = std.Build.Cache.Path; |
| 8 | const Directory = std.Build.Cache.Directory; |
| 9 | |
| 10 | io: Io, |
| 11 | /// Process lifetime. |
| 12 | arena: Allocator, |
| 13 | cache: std.Build.Cache, |
| 14 | zig_exe: []const u8, |
| 15 | environ_map: std.process.Environ.Map, |
| 16 | global_cache_root: Directory, |
| 17 | local_cache_root: Directory, |
| 18 | zig_lib_directory: Directory, |
| 19 | build_root_directory: Directory, |
| 20 | |
| 21 | debug_compiler_runtime_libs: ?std.builtin.Optimize = null, |
| 22 | incremental: ?bool = null, |
| 23 | random_seed: u32 = 0, |
| 24 | allow_so_scripts: ?bool = null, |
| 25 | time_report: bool = false, |
| 26 | /// Similar to the `Io.Terminal.Mode` returned by `Io.lockStderr`, but also |
| 27 | /// respects the '--color' flag. |
| 28 | stderr_mode: ?Io.Terminal.Mode = null, |
| 29 | reference_trace: ?u32 = null, |
| 30 | debug_log_scopes: std.ArrayList([]const u8) = .empty, |
| 31 | debug_compile_errors: bool = false, |
| 32 | debug_incremental: bool = false, |
| 33 | fuzzing: bool = false, |
| 34 | verbose: bool = false, |
| 35 | verbose_air: bool = false, |
| 36 | verbose_cc: bool = false, |
| 37 | verbose_link: bool = false, |
| 38 | verbose_llvm_cpu_features: bool = false, |
| 39 | verbose_llvm_ir: bool = false, |
| 40 | libc_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. |
| 47 | sysroot: ?[]const u8 = null, |
| 48 | search_prefixes: std.ArrayList([]const u8) = .empty, |
| 49 | build_id: ?std.zig.BuildId = null, |
| 50 | error_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. |
| 53 | max_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. |
| 60 | libc_runtimes_dir: ?[]const u8 = null, |
| 61 | enable_wine: bool = false, |
| 62 | enable_qemu: bool = false, |
| 63 | enable_wasmtime: bool = false, |
| 64 | enable_darling: bool = false, |
| 65 | enable_rosetta: bool = false, |
| 66 | |
| 67 | /// Intention of verbose is to print all sub-process command lines to stderr |
| 68 | /// before spawning them. |
| 69 | pub 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 | } |