| ... | ... | @@ -2144,6 +2144,33 @@ pub const ResolvedTarget = struct { |
| 2144 | 2144 | return (unwrap(this) orelse return null).get(c); |
| 2145 | 2145 | } |
| 2146 | 2146 | }; |
| 2147 | |
| 2148 | pub fn unwrapQuery(rt: *const ResolvedTarget, c: *const Configuration) ?std.Target.Query { |
| 2149 | const tq = rt.query.get(c) orelse return null; |
| 2150 | const cpu_arch = tq.flags.cpu_arch.unwrap() orelse rt.result.get(c).flags.cpu_arch.unwrap().?; |
| 2151 | return .{ |
| 2152 | .cpu_arch = cpu_arch, |
| 2153 | .cpu_model = switch (tq.flags.cpu_model) { |
| 2154 | .native => .native, |
| 2155 | .baseline => .baseline, |
| 2156 | .determined_by_arch_os => .determined_by_arch_os, |
| 2157 | .explicit => .{ .explicit = cpu_arch.parseCpuModel(tq.cpu_name.value.?.slice(c)).? }, |
| 2158 | }, |
| 2159 | .cpu_features_add = tq.cpu_features_add.value orelse .empty, |
| 2160 | .cpu_features_sub = tq.cpu_features_sub.value orelse .empty, |
| 2161 | .os_tag = tq.flags.os_tag.unwrap(), |
| 2162 | .os_version_min = tq.os_version_min.u.unwrap(c), |
| 2163 | .os_version_max = tq.os_version_max.u.unwrap(c), |
| 2164 | .glibc_version = if (tq.glibc_version.value) |s| |
| 2165 | std.SemanticVersion.parse(s.slice(c)) catch unreachable |
| 2166 | else |
| 2167 | null, |
| 2168 | .android_api_level = tq.android_api_level.value, |
| 2169 | .abi = tq.flags.abi.unwrap(), |
| 2170 | .dynamic_linker = if (tq.dynamic_linker.value) |s| .init(s.slice(c)) else null, |
| 2171 | .ofmt = tq.flags.object_format.unwrap(), |
| 2172 | }; |
| 2173 | } |
| 2147 | 2174 | }; |
| 2148 | 2175 | |
| 2149 | 2176 | pub const TargetQuery = struct { |
| ... | ... | @@ -2731,29 +2758,50 @@ pub const TargetQuery = struct { |
| 2731 | 2758 | dynamic_linker: bool, |
| 2732 | 2759 | }; |
| 2733 | 2760 | |
| 2734 | | pub fn unwrap(tq: *const TargetQuery, c: *const Configuration) std.Target.Query { |
| 2735 | | const cpu_arch = tq.flags.cpu_arch.unwrap(); |
| 2761 | pub fn unwrapTarget(tq: *const TargetQuery, c: *const Configuration) std.Target { |
| 2762 | const cpu_arch = tq.flags.cpu_arch.unwrap().?; |
| 2763 | const os_tag = tq.flags.os_tag.unwrap().?; |
| 2736 | 2764 | return .{ |
| 2737 | | .cpu_arch = cpu_arch, |
| 2738 | | .cpu_model = switch (tq.flags.cpu_model) { |
| 2739 | | .native => .native, |
| 2740 | | .baseline => .baseline, |
| 2741 | | .determined_by_arch_os => .determined_by_arch_os, |
| 2742 | | .explicit => .{ .explicit = cpu_arch.?.parseCpuModel(tq.cpu_name.value.?.slice(c)).? }, |
| 2765 | .cpu = .{ |
| 2766 | .arch = cpu_arch, |
| 2767 | .model = cpu_arch.parseCpuModel(tq.cpu_name.value.?.slice(c)).?, |
| 2768 | .features = tq.cpu_features_add.value.?, |
| 2743 | 2769 | }, |
| 2744 | | .cpu_features_add = tq.cpu_features_add.value orelse .empty, |
| 2745 | | .cpu_features_sub = tq.cpu_features_sub.value orelse .empty, |
| 2746 | | .os_tag = tq.flags.os_tag.unwrap(), |
| 2747 | | .os_version_min = tq.os_version_min.u.unwrap(c), |
| 2748 | | .os_version_max = tq.os_version_max.u.unwrap(c), |
| 2749 | | .glibc_version = if (tq.glibc_version.value) |s| |
| 2750 | | std.SemanticVersion.parse(s.slice(c)) catch unreachable |
| 2751 | | else |
| 2752 | | null, |
| 2753 | | .android_api_level = tq.android_api_level.value, |
| 2754 | | .abi = tq.flags.abi.unwrap(), |
| 2755 | | .dynamic_linker = if (tq.dynamic_linker.value) |s| .init(s.slice(c)) else null, |
| 2756 | | .ofmt = tq.flags.object_format.unwrap(), |
| 2770 | .os = .{ |
| 2771 | .tag = os_tag, |
| 2772 | .version_range = switch (os_tag) { |
| 2773 | .linux => .{ .linux = .{ |
| 2774 | .range = .{ |
| 2775 | .min = tq.os_version_min.u.unwrap(c).?.semver, |
| 2776 | .max = tq.os_version_max.u.unwrap(c).?.semver, |
| 2777 | }, |
| 2778 | .glibc = std.SemanticVersion.parse(tq.glibc_version.value.?.slice(c)) catch unreachable, |
| 2779 | .android = tq.android_api_level.value.?, |
| 2780 | } }, |
| 2781 | .hurd => .{ .hurd = .{ |
| 2782 | .range = .{ |
| 2783 | .min = tq.os_version_min.u.unwrap(c).?.semver, |
| 2784 | .max = tq.os_version_max.u.unwrap(c).?.semver, |
| 2785 | }, |
| 2786 | .glibc = std.SemanticVersion.parse(tq.glibc_version.value.?.slice(c)) catch unreachable, |
| 2787 | } }, |
| 2788 | .windows => .{ .windows = .{ |
| 2789 | .min = tq.os_version_min.u.unwrap(c).?.windows, |
| 2790 | .max = tq.os_version_max.u.unwrap(c).?.windows, |
| 2791 | } }, |
| 2792 | else => switch (tq.os_version_min.u.unwrap(c).?) { |
| 2793 | .none => .{ .none = {} }, |
| 2794 | .semver => |min| .{ .semver = .{ |
| 2795 | .min = min, |
| 2796 | .max = tq.os_version_max.u.unwrap(c).?.semver, |
| 2797 | } }, |
| 2798 | .windows => unreachable, |
| 2799 | }, |
| 2800 | }, |
| 2801 | }, |
| 2802 | .abi = tq.flags.abi.unwrap().?, |
| 2803 | .ofmt = tq.flags.object_format.unwrap().?, |
| 2804 | .dynamic_linker = .init(if (tq.dynamic_linker.value) |s| s.slice(c) else null), |
| 2757 | 2805 | }; |
| 2758 | 2806 | } |
| 2759 | 2807 | }; |