ziglang/zig

take away EmitOption.emit_to option and make it give a FileSource

andrewrk opened this issue · 1 comments

Extracted from #14647.

emit_analysis: EmitOption = .default,
emit_asm: EmitOption = .default,
emit_bin: EmitOption = .default,
emit_docs: EmitOption = .default,
emit_implib: EmitOption = .default,
emit_llvm_bc: EmitOption = .default,
emit_llvm_ir: EmitOption = .default,
// Lots of things depend on emit_h having a consistent path,
// so it is not an EmitOption for now.
emit_h: bool = false,

pub const EmitOption = union(enum) {
default: void,
no_emit: void,
emit: void,
emit_to: []const u8,
fn getArg(self: @This(), b: *std.Build, arg_name: []const u8) ?[]const u8 {
return switch (self) {
.no_emit => b.fmt("-fno-{s}", .{arg_name}),
.default => null,
.emit => b.fmt("-f{s}", .{arg_name}),
.emit_to => |path| b.fmt("-f{s}={s}", .{ arg_name, path }),
};
}
};

All of these, including emit_h, will no longer have the option to specify an output path, same as #14951. Instead, the two choices will be null, or providing a FileSource to interact with the rest of the build system. The zig compiler itself will only ever see -femit-foo or -fno-emit-foo. It will always put the artifact in the cache directory, and the build script must rely on other steps that interact with FileSource to do anything with the artifacts.

Is there anything blocking this? If not, I'm willing to implement this in the same PR I am working on for #15156.