pub const ResolvedTarget = struct query: TargetQuery.OptionalIndexnone indicates host.
result: TargetQuery.Indexdefaults will be resolved.
pub fn unwrapQuery(rt: *const ResolvedTarget, c: *const Configuration) ?std.Target.Query2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166pub const ResolvedTarget = struct {
/// none indicates host.
query: TargetQuery.OptionalIndex,
/// defaults will be resolved.
result: TargetQuery.Index,
pub const Index = IndexType(@This());
pub const OptionalIndex = enum(u32) {
none = max_u32,
_,
pub fn init(i: Index) OptionalIndex {
const result: OptionalIndex = @fromBackingInt(@intCast(@backingInt(i)));
assert(result != .none);
return result;
}
pub fn unwrap(this: @This()) ?Index {
return switch (this) {
.none => null,
_ => @fromBackingInt(@intCast(@backingInt(this))),
};
}
pub fn get(this: @This(), c: *const Configuration) ?ResolvedTarget {
return (unwrap(this) orelse return null).get(c);
}
};
pub fn unwrapQuery(rt: *const ResolvedTarget, c: *const Configuration) ?std.Target.Query {
const tq = rt.query.get(c) orelse return null;
const cpu_arch = tq.flags.cpu_arch.unwrap() orelse rt.result.get(c).flags.cpu_arch.unwrap().?;
return .{
.cpu_arch = cpu_arch,
.cpu_model = switch (tq.flags.cpu_model) {
.native => .native,
.baseline => .baseline,
.determined_by_arch_os => .determined_by_arch_os,
.explicit => .{ .explicit = cpu_arch.parseCpuModel(tq.cpu_name.value.?.slice(c)).? },
},
.cpu_features_add = tq.cpu_features_add.value orelse .empty,
.cpu_features_sub = tq.cpu_features_sub.value orelse .empty,
.os_tag = tq.flags.os_tag.unwrap(),
.os_version_min = tq.os_version_min.u.unwrap(c),
.os_version_max = tq.os_version_max.u.unwrap(c),
.glibc_version = if (tq.glibc_version.value) |s|
std.SemanticVersion.parse(s.slice(c)) catch unreachable
else
null,
.android_api_level = tq.android_api_level.value,
.abi = tq.flags.abi.unwrap(),
.dynamic_linker = if (tq.dynamic_linker.value) |s| .init(s.slice(c)) else null,
.ofmt = tq.flags.object_format.unwrap(),
};
}
}