Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI: delete dead option -femit-analysis and update -femit-docs buiild system API #16521

Merged
merged 2 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub fn build(b: *std.Build) !void {
autodoc_test.overrideZigLibDir("lib");
autodoc_test.emit_bin = .no_emit; // https://github.com/ziglang/zig/issues/16351
const install_std_docs = b.addInstallDirectory(.{
.source_dir = autodoc_test.getOutputDocs(),
.source_dir = autodoc_test.getEmittedDocs(),
.install_dir = .prefix,
.install_subdir = "doc/std",
});
Expand Down
6 changes: 2 additions & 4 deletions lib/std/Build/Step/Compile.zig
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ framework_dirs: ArrayList(FileSource),
frameworks: StringHashMap(FrameworkLinkInfo),
verbose_link: bool,
verbose_cc: bool,
emit_analysis: EmitOption = .default,
emit_asm: EmitOption = .default,
emit_bin: EmitOption = .default,
emit_implib: EmitOption = .default,
Expand Down Expand Up @@ -1005,8 +1004,8 @@ pub fn getOutputPdbSource(self: *Compile) FileSource {
return .{ .generated = &self.output_pdb_path_source };
}

pub fn getOutputDocs(self: *Compile) FileSource {
assert(self.generated_docs == null); // This function may only be called once.
pub fn getEmittedDocs(self: *Compile) FileSource {
if (self.generated_docs) |g| return .{ .generated = g };
const arena = self.step.owner.allocator;
const generated_file = arena.create(GeneratedFile) catch @panic("OOM");
generated_file.* = .{ .step = &self.step };
Expand Down Expand Up @@ -1516,7 +1515,6 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
if (b.verbose_cc or self.verbose_cc) try zig_args.append("--verbose-cc");
if (b.verbose_llvm_cpu_features) try zig_args.append("--verbose-llvm-cpu-features");

if (self.emit_analysis.getArg(b, "emit-analysis")) |arg| try zig_args.append(arg);
if (self.emit_asm.getArg(b, "emit-asm")) |arg| try zig_args.append(arg);
if (self.emit_bin.getArg(b, "emit-bin")) |arg| try zig_args.append(arg);
if (self.generated_docs != null) try zig_args.append("-femit-docs");
Expand Down
5 changes: 0 additions & 5 deletions src/Compilation.zig
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ test_name_prefix: ?[]const u8,
emit_asm: ?EmitLoc,
emit_llvm_ir: ?EmitLoc,
emit_llvm_bc: ?EmitLoc,
emit_analysis: ?EmitLoc,

work_queue_wait_group: WaitGroup = .{},
astgen_wait_group: WaitGroup = .{},
Expand Down Expand Up @@ -482,8 +481,6 @@ pub const InitOptions = struct {
emit_llvm_ir: ?EmitLoc = null,
/// `null` means to not emit LLVM module bitcode.
emit_llvm_bc: ?EmitLoc = null,
/// `null` means to not emit semantic analysis JSON.
emit_analysis: ?EmitLoc = null,
/// `null` means to not emit docs.
emit_docs: ?EmitLoc = null,
/// `null` means to not emit an import lib.
Expand Down Expand Up @@ -1589,7 +1586,6 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
.emit_asm = options.emit_asm,
.emit_llvm_ir = options.emit_llvm_ir,
.emit_llvm_bc = options.emit_llvm_bc,
.emit_analysis = options.emit_analysis,
.work_queue = std.fifo.LinearFifo(Job, .Dynamic).init(gpa),
.anon_work_queue = std.fifo.LinearFifo(Job, .Dynamic).init(gpa),
.c_object_work_queue = std.fifo.LinearFifo(*CObject, .Dynamic).init(gpa),
Expand Down Expand Up @@ -2328,7 +2324,6 @@ fn addNonIncrementalStuffToCacheManifest(comp: *Compilation, man: *Cache.Manifes
cache_helpers.addOptionalEmitLoc(&man.hash, comp.emit_asm);
cache_helpers.addOptionalEmitLoc(&man.hash, comp.emit_llvm_ir);
cache_helpers.addOptionalEmitLoc(&man.hash, comp.emit_llvm_bc);
cache_helpers.addOptionalEmitLoc(&man.hash, comp.emit_analysis);

man.hash.addListOfBytes(comp.clang_argv);

Expand Down
28 changes: 0 additions & 28 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,6 @@ const usage_build_generic =
\\ -fno-emit-h (default) Do not generate a C header file (.h)
\\ -femit-docs[=path] Create a docs/ dir with html documentation
\\ -fno-emit-docs (default) Do not produce docs/ dir with html documentation
\\ -femit-analysis[=path] Write analysis JSON file with type information
\\ -fno-emit-analysis (default) Do not write analysis JSON file with type information
\\ -femit-implib[=path] (default) Produce an import .lib when building a Windows DLL
\\ -fno-emit-implib Do not produce an import .lib when building a Windows DLL
\\ --show-builtin Output the source of @import("builtin") then exit
Expand Down Expand Up @@ -755,7 +753,6 @@ fn buildOutputType(
var emit_llvm_ir: Emit = .no;
var emit_llvm_bc: Emit = .no;
var emit_docs: Emit = .no;
var emit_analysis: Emit = .no;
var emit_implib: Emit = .yes_default_path;
var emit_implib_arg_provided = false;
var target_arch_os_abi: []const u8 = "native";
Expand Down Expand Up @@ -1336,12 +1333,6 @@ fn buildOutputType(
emit_docs = .{ .yes = arg["-femit-docs=".len..] };
} else if (mem.eql(u8, arg, "-fno-emit-docs")) {
emit_docs = .no;
} else if (mem.eql(u8, arg, "-femit-analysis")) {
emit_analysis = .yes_default_path;
} else if (mem.startsWith(u8, arg, "-femit-analysis=")) {
emit_analysis = .{ .yes = arg["-femit-analysis=".len..] };
} else if (mem.eql(u8, arg, "-fno-emit-analysis")) {
emit_analysis = .no;
} else if (mem.eql(u8, arg, "-femit-implib")) {
emit_implib = .yes_default_path;
emit_implib_arg_provided = true;
Expand Down Expand Up @@ -2824,24 +2815,6 @@ fn buildOutputType(
};
defer emit_llvm_bc_resolved.deinit();

const default_analysis_basename = try std.fmt.allocPrint(arena, "{s}-analysis.json", .{root_name});
var emit_analysis_resolved = emit_analysis.resolve(default_analysis_basename, output_to_cache) catch |err| {
switch (emit_analysis) {
.yes => |p| {
fatal("unable to open directory from argument '-femit-analysis', '{s}': {s}", .{
p, @errorName(err),
});
},
.yes_default_path => {
fatal("unable to open directory from arguments 'name' or 'soname', '{s}': {s}", .{
default_analysis_basename, @errorName(err),
});
},
.no => unreachable,
}
};
defer emit_analysis_resolved.deinit();

var emit_docs_resolved = emit_docs.resolve("docs", output_to_cache) catch |err| {
switch (emit_docs) {
.yes => |p| {
Expand Down Expand Up @@ -3096,7 +3069,6 @@ fn buildOutputType(
.emit_llvm_ir = emit_llvm_ir_resolved.data,
.emit_llvm_bc = emit_llvm_bc_resolved.data,
.emit_docs = emit_docs_resolved.data,
.emit_analysis = emit_analysis_resolved.data,
.emit_implib = emit_implib_resolved.data,
.link_mode = link_mode,
.dll_export_fns = dll_export_fns,
Expand Down