authorgravatar for spexguy070@gmail.comMartin Wickham <spexguy070@gmail.com> 2021-12-05 18:54:33-06:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2021-12-05 19:54:33-05:00
log2af94e76a3d3fb8ddfa4bba698c13e51c7ef2b1b
tree72726febea863ba0bc74446fb11ab0c82bdf7ef1
parenta7828c261a0909a1ed672761adf332c978d492c7
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Add emit path options to emit args in build.zig (#10278)


1 files changed, 37 insertions(+), 12 deletions(-)

lib/std/build.zig+37-12
......@@ -1454,10 +1454,15 @@ pub const LibExeObjStep = struct {
14541454 frameworks: BufSet,
14551455 verbose_link: bool,
14561456 verbose_cc: bool,
1457 emit_llvm_ir: bool = false,
1458 emit_asm: bool = false,
1459 emit_bin: bool = true,
1460 emit_docs: bool = false,
1457 emit_analysis: EmitOption = .default,
1458 emit_asm: EmitOption = .default,
1459 emit_bin: EmitOption = .default,
1460 emit_docs: EmitOption = .default,
1461 emit_implib: EmitOption = .default,
1462 emit_llvm_bc: EmitOption = .default,
1463 emit_llvm_ir: EmitOption = .default,
1464 // Lots of things depend on emit_h having a consistent path,
1465 // so it is not an EmitOption for now.
14611466 emit_h: bool = false,
14621467 bundle_compiler_rt: ?bool = null,
14631468 single_threaded: ?bool = null,
......@@ -1544,7 +1549,7 @@ pub const LibExeObjStep = struct {
15441549 output_h_path_source: GeneratedFile,
15451550 output_pdb_path_source: GeneratedFile,
15461551
1547 const LinkObject = union(enum) {
1552 pub const LinkObject = union(enum) {
15481553 static_path: FileSource,
15491554 other_step: *LibExeObjStep,
15501555 system_lib: []const u8,
......@@ -1553,26 +1558,42 @@ pub const LibExeObjStep = struct {
15531558 c_source_files: *CSourceFiles,
15541559 };
15551560
1556 const IncludeDir = union(enum) {
1561 pub const IncludeDir = union(enum) {
15571562 raw_path: []const u8,
15581563 raw_path_system: []const u8,
15591564 other_step: *LibExeObjStep,
15601565 };
15611566
1562 const Kind = enum {
1567 pub const Kind = enum {
15631568 exe,
15641569 lib,
15651570 obj,
15661571 @"test",
15671572 };
15681573
1569 const SharedLibKind = union(enum) {
1574 pub const SharedLibKind = union(enum) {
15701575 versioned: std.builtin.Version,
15711576 unversioned: void,
15721577 };
15731578
15741579 pub const Linkage = enum { dynamic, static };
15751580
1581 pub const EmitOption = union(enum) {
1582 default: void,
1583 no_emit: void,
1584 emit: void,
1585 emit_to: []const u8,
1586
1587 fn getArg(self: @This(), b: *Builder, arg_name: []const u8) ?[]const u8 {
1588 return switch (self) {
1589 .no_emit => b.fmt("-fno-{s}", .{arg_name}),
1590 .default => null,
1591 .emit => b.fmt("-f{s}", .{arg_name}),
1592 .emit_to => |path| b.fmt("-f{s}={s}", .{ arg_name, path }),
1593 };
1594 }
1595 };
1596
15761597 pub fn createSharedLibrary(builder: *Builder, name: []const u8, root_src: ?FileSource, kind: SharedLibKind) *LibExeObjStep {
15771598 return initExtraArgs(builder, name, root_src, .lib, .dynamic, switch (kind) {
15781599 .versioned => |ver| ver,
......@@ -2348,10 +2369,14 @@ pub const LibExeObjStep = struct {
23482369 if (builder.verbose_cc or self.verbose_cc) zig_args.append("--verbose-cc") catch unreachable;
23492370 if (builder.verbose_llvm_cpu_features) zig_args.append("--verbose-llvm-cpu-features") catch unreachable;
23502371
2351 if (self.emit_llvm_ir) try zig_args.append("-femit-llvm-ir");
2352 if (self.emit_asm) try zig_args.append("-femit-asm");
2353 if (!self.emit_bin) try zig_args.append("-fno-emit-bin");
2354 if (self.emit_docs) try zig_args.append("-femit-docs");
2372 if (self.emit_analysis.getArg(builder, "emit-analysis")) |arg| try zig_args.append(arg);
2373 if (self.emit_asm.getArg(builder, "emit-asm")) |arg| try zig_args.append(arg);
2374 if (self.emit_bin.getArg(builder, "emit-bin")) |arg| try zig_args.append(arg);
2375 if (self.emit_docs.getArg(builder, "emit-docs")) |arg| try zig_args.append(arg);
2376 if (self.emit_implib.getArg(builder, "emit-implib")) |arg| try zig_args.append(arg);
2377 if (self.emit_llvm_bc.getArg(builder, "emit-llvm-bc")) |arg| try zig_args.append(arg);
2378 if (self.emit_llvm_ir.getArg(builder, "emit-llvm-ir")) |arg| try zig_args.append(arg);
2379
23552380 if (self.emit_h) try zig_args.append("-femit-h");
23562381
23572382 if (self.strip) {