diff --git a/lib/compiler/Maker/ScannedConfig.zig b/lib/compiler/Maker/ScannedConfig.zig index 1e36ff0d515b7c476021b450ebffd35e01fa184c..c1e1ff18a90ba79e2331eae052deb4db61e5d164 100644 --- a/lib/compiler/Maker/ScannedConfig.zig +++ b/lib/compiler/Maker/ScannedConfig.zig @@ -350,6 +350,7 @@ pub fn printUsage(sc: *const ScannedConfig, graph: *Graph, w: *Writer) !void { \\ disallowed Panics when cache would be poisoned \\ ignored A little poison never hurt anybody \\ --print-configuration Render configuration as .zon to stdout + \\ --print-configuration-path Print the path to the binary configuration file to stdout \\ --build-id[=style] At a minor link-time expense, embeds a build ID in binaries \\ fast 8-byte non-cryptographic hash (COFF, ELF, WASM) \\ sha1, tree 20-byte cryptographic hash (ELF, WASM) diff --git a/src/main.zig b/src/main.zig index 49630f637209c97817b6b6151bf8f6507de5365e..29ab8ccf6f2272a1c6647dcf140fd6715499760c 100644 --- a/src/main.zig +++ b/src/main.zig @@ -4951,6 +4951,7 @@ fn cmdBuild( var debug_target: ?[]const u8 = null; var debug_libc_paths_file: ?[]const u8 = null; var cache_poison: std.Build.Graph.CachePoison = .pure; + var print_configuration_path: bool = false; const self_exe_path = try process.executablePathAlloc(io, arena); const default_seed = try std.fmt.allocPrint(arena, "0x{x}", .{randInt(io, u32)}); @@ -5069,6 +5070,9 @@ fn cmdBuild( i += 1; override_global_cache_dir = args[i]; continue; + } else if (mem.eql(u8, arg, "--print-configuration-path")) { + print_configuration_path = true; + continue; } else if (mem.eql(u8, arg, "-freference-trace")) { reference_trace = 256; } else if (mem.eql(u8, arg, "--fetch")) { @@ -5266,7 +5270,7 @@ fn cmdBuild( }; // Kick off an optimized compilation of the make runner. - var make_runner_task = io.async(compileMakeRunner, .{ gpa, arena, io, .{ + var make_runner_task = if (print_configuration_path) undefined else io.async(compileMakeRunner, .{ gpa, arena, io, .{ .dirs = .{ .cwd = dirs.cwd, .zig_lib = dirs.zig_lib, @@ -5283,7 +5287,7 @@ fn cmdBuild( .reference_trace = reference_trace, .optimize_mode = maker_optimize_mode, } }); - defer _ = make_runner_task.cancel(io) catch {}; + defer _ = if (!print_configuration_path) make_runner_task.cancel(io) catch {}; const pkg_root: Path = if (override_pkg_dir) |p| .initCwd(p) @@ -5744,6 +5748,11 @@ fn cmdBuild( var configuration_lock = if (!poisoned) config_man.toOwnedLock() else null; defer if (configuration_lock) |*l| l.release(io); + if (print_configuration_path) { + var stdout_writer = Io.File.stdout().writerStreaming(io, &.{}); + configuration_path.format(&stdout_writer.interface) catch fatal("failed printing cache file path: {t}", .{stdout_writer.err.?}); + return cleanExit(io); + } const make_runner = make_runner_task.await(io) catch |err| fatal("failed compiling maker: {t}", .{err}); make_argv.items[0] = try make_runner.exe_path.toString(arena);