| ... | @@ -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, |
| 1546 | | 1551 | |
| 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 | }; |
| 1555 | | 1560 | |
| 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 | }; |
| 1561 | | 1566 | |
| 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 | }; |
| 1568 | | 1573 | |
| 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 | }; |
| 1573 | | 1578 | |
| 1574 | pub const Linkage = enum { dynamic, static }; | 1579 | pub const Linkage = enum { dynamic, static }; |
| 1575 | | 1580 | |
| | 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; |
| 2350 | | 2371 | |
| 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"); |
| 2356 | | 2381 | |
| 2357 | if (self.strip) { | 2382 | if (self.strip) { |