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 {...@@ -1454,10 +1454,15 @@ pub const LibExeObjStep = struct {
1454 frameworks: BufSet,1454 frameworks: BufSet,
1455 verbose_link: bool,1455 verbose_link: bool,
1456 verbose_cc: bool,1456 verbose_cc: bool,
1457 emit_llvm_ir: bool = false,1457 emit_analysis: EmitOption = .default,
1458 emit_asm: bool = false,1458 emit_asm: EmitOption = .default,
1459 emit_bin: bool = true,1459 emit_bin: EmitOption = .default,
1460 emit_docs: bool = false,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.
1461 emit_h: bool = false,1466 emit_h: bool = false,
1462 bundle_compiler_rt: ?bool = null,1467 bundle_compiler_rt: ?bool = null,
1463 single_threaded: ?bool = null,1468 single_threaded: ?bool = null,
...@@ -1544,7 +1549,7 @@ pub const LibExeObjStep = struct {...@@ -1544,7 +1549,7 @@ pub const LibExeObjStep = struct {
1544 output_h_path_source: GeneratedFile,1549 output_h_path_source: GeneratedFile,
1545 output_pdb_path_source: GeneratedFile,1550 output_pdb_path_source: GeneratedFile,
15461551
1547 const LinkObject = union(enum) {1552 pub const LinkObject = union(enum) {
1548 static_path: FileSource,1553 static_path: FileSource,
1549 other_step: *LibExeObjStep,1554 other_step: *LibExeObjStep,
1550 system_lib: []const u8,1555 system_lib: []const u8,
...@@ -1553,26 +1558,42 @@ pub const LibExeObjStep = struct {...@@ -1553,26 +1558,42 @@ pub const LibExeObjStep = struct {
1553 c_source_files: *CSourceFiles,1558 c_source_files: *CSourceFiles,
1554 };1559 };
15551560
1556 const IncludeDir = union(enum) {1561 pub const IncludeDir = union(enum) {
1557 raw_path: []const u8,1562 raw_path: []const u8,
1558 raw_path_system: []const u8,1563 raw_path_system: []const u8,
1559 other_step: *LibExeObjStep,1564 other_step: *LibExeObjStep,
1560 };1565 };
15611566
1562 const Kind = enum {1567 pub const Kind = enum {
1563 exe,1568 exe,
1564 lib,1569 lib,
1565 obj,1570 obj,
1566 @"test",1571 @"test",
1567 };1572 };
15681573
1569 const SharedLibKind = union(enum) {1574 pub const SharedLibKind = union(enum) {
1570 versioned: std.builtin.Version,1575 versioned: std.builtin.Version,
1571 unversioned: void,1576 unversioned: void,
1572 };1577 };
15731578
1574 pub const Linkage = enum { dynamic, static };1579 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
1576 pub fn createSharedLibrary(builder: *Builder, name: []const u8, root_src: ?FileSource, kind: SharedLibKind) *LibExeObjStep {1597 pub fn createSharedLibrary(builder: *Builder, name: []const u8, root_src: ?FileSource, kind: SharedLibKind) *LibExeObjStep {
1577 return initExtraArgs(builder, name, root_src, .lib, .dynamic, switch (kind) {1598 return initExtraArgs(builder, name, root_src, .lib, .dynamic, switch (kind) {
1578 .versioned => |ver| ver,1599 .versioned => |ver| ver,
...@@ -2348,10 +2369,14 @@ pub const LibExeObjStep = struct {...@@ -2348,10 +2369,14 @@ pub const LibExeObjStep = struct {
2348 if (builder.verbose_cc or self.verbose_cc) zig_args.append("--verbose-cc") catch unreachable;2369 if (builder.verbose_cc or self.verbose_cc) zig_args.append("--verbose-cc") catch unreachable;
2349 if (builder.verbose_llvm_cpu_features) zig_args.append("--verbose-llvm-cpu-features") catch unreachable;2370 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");2372 if (self.emit_analysis.getArg(builder, "emit-analysis")) |arg| try zig_args.append(arg);
2352 if (self.emit_asm) try zig_args.append("-femit-asm");2373 if (self.emit_asm.getArg(builder, "emit-asm")) |arg| try zig_args.append(arg);
2353 if (!self.emit_bin) try zig_args.append("-fno-emit-bin");2374 if (self.emit_bin.getArg(builder, "emit-bin")) |arg| try zig_args.append(arg);
2354 if (self.emit_docs) try zig_args.append("-femit-docs");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
2355 if (self.emit_h) try zig_args.append("-femit-h");2380 if (self.emit_h) try zig_args.append("-femit-h");
23562381
2357 if (self.strip) {2382 if (self.strip) {