authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-02-29 12:27:13-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-02-29 12:27:13-05:00
log3c7f030a60b038045334788837f40bee0226109c
tree6de3d50011ed7bf4c7ebe84d1aa8006bc25f1226
parent7e6b68a534f840d2d08770a5a77896707271e8ea
signaturelock-open Commit is signed but in an unrecognized format.

add CrossTarget.getObjectFormat

closes #4588 thanks Michaël Larouche for the suggested fix

2 files changed, 12 insertions(+), 4 deletions(-)

lib/std/target.zig+8-4
...@@ -1014,18 +1014,22 @@ pub const Target = struct {...@@ -1014,18 +1014,22 @@ pub const Target = struct {
1014 return libPrefix_cpu_arch_abi(self.cpu.arch, self.abi);1014 return libPrefix_cpu_arch_abi(self.cpu.arch, self.abi);
1015 }1015 }
10161016
1017 pub fn getObjectFormat(self: Target) ObjectFormat {1017 pub fn getObjectFormatSimple(os_tag: Os.Tag, cpu_arch: Cpu.Arch) ObjectFormat {
1018 if (self.os.tag == .windows or self.os.tag == .uefi) {1018 if (os_tag == .windows or os_tag == .uefi) {
1019 return .coff;1019 return .coff;
1020 } else if (self.isDarwin()) {1020 } else if (os_tag.isDarwin()) {
1021 return .macho;1021 return .macho;
1022 }1022 }
1023 if (self.cpu.arch.isWasm()) {1023 if (cpu_arch.isWasm()) {
1024 return .wasm;1024 return .wasm;
1025 }1025 }
1026 return .elf;1026 return .elf;
1027 }1027 }
10281028
1029 pub fn getObjectFormat(self: Target) ObjectFormat {
1030 return getObjectFormatSimple(self.os.tag, self.cpu.arch);
1031 }
1032
1029 pub fn isMinGW(self: Target) bool {1033 pub fn isMinGW(self: Target) bool {
1030 return self.os.tag == .windows and self.isGnu();1034 return self.os.tag == .windows and self.isGnu();
1031 }1035 }
lib/std/zig/cross_target.zig+4
...@@ -645,6 +645,10 @@ pub const CrossTarget = struct {...@@ -645,6 +645,10 @@ pub const CrossTarget = struct {
645 self.glibc_version = SemVer{ .major = major, .minor = minor, .patch = patch };645 self.glibc_version = SemVer{ .major = major, .minor = minor, .patch = patch };
646 }646 }
647647
648 pub fn getObjectFormat(self: CrossTarget) ObjectFormat {
649 return Target.getObjectFormatSimple(self.getOsTag(), self.getCpuArch());
650 }
651
648 fn updateCpuFeatures(self: CrossTarget, set: *Target.Cpu.Feature.Set) void {652 fn updateCpuFeatures(self: CrossTarget, set: *Target.Cpu.Feature.Set) void {
649 set.removeFeatureSet(self.cpu_features_sub);653 set.removeFeatureSet(self.cpu_features_sub);
650 set.addFeatureSet(self.cpu_features_add);654 set.addFeatureSet(self.cpu_features_add);