Skip to content

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

@andrewrk

Description

@andrewrk

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    breakingImplementing this issue could cause existing code to no longer compile or have different behavior.contributor friendlyThis issue is limited in scope and/or knowledge of Zig internals.enhancementSolving this issue will likely involve adding new logic or components to the codebase.zig build systemstd.Build, the build runner, `zig build` subcommand, package management

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions