aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Build/Module.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-12-05 16:09:07 -0700
committerAndrew Kelley <andrew@ziglang.org>2024-01-01 17:51:18 -0700
commitb92e30ff0bd2b77a486451b21d17666a311407f3 (patch)
treecd2504c6815b27486e554c2541d4496d7e8f91ab /lib/std/Build/Module.zig
parentf5613a0e3589fcca51411ce379f3c90eace99fa6 (diff)
downloadzig-b92e30ff0bd2b77a486451b21d17666a311407f3.tar.gz
zig-b92e30ff0bd2b77a486451b21d17666a311407f3.zip
std.Build.ResolvedTarget: rename target field to result
This change is seemingly insignificant but I actually agonized over this for three days. Some other things I considered: * (status quo in master branch) make Compile step creation functions accept a Target.Query and delete the ResolvedTarget struct. - downside: redundantly resolve target queries many times * same as before but additionally add a hash map to cache target query resolutions. - downside: now there is a hash map that doesn't actually need to exist, just to make the API more ergonomic. * add is_native_os and is_native_abi fields to std.Target and use it directly as the result of resolving a target query. - downside: they really don't belong there. They would be available as comptime booleans via `@import("builtin")` but they should not be exposed that way. With this change the downsides are: * the option name of addExecutable and friends is `target` instead of `resolved_target` matching the type name. - upside: this does not break compatibility with existing build scripts * you likely end up seeing `target.result.cpu.arch` rather than `target.cpu.arch`. - upside: this is an improvement over `target.target.cpu.arch` which it was before this commit. - downside: `b.host.target` is now `b.host.result`.
Diffstat (limited to 'lib/std/Build/Module.zig')
-rw-r--r--lib/std/Build/Module.zig10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/std/Build/Module.zig b/lib/std/Build/Module.zig
index 9c98dd0a46..81fab2be5e 100644
--- a/lib/std/Build/Module.zig
+++ b/lib/std/Build/Module.zig
@@ -10,7 +10,7 @@ root_source_file: ?LazyPath,
/// maintain step dependency edges.
import_table: std.StringArrayHashMapUnmanaged(*Module),
-target: ?std.Build.ResolvedTarget = null,
+resolved_target: ?std.Build.ResolvedTarget = null,
optimize: ?std.builtin.OptimizeMode = null,
dwarf_format: ?std.dwarf.Format,
@@ -192,7 +192,7 @@ pub fn init(m: *Module, owner: *std.Build, options: CreateOptions, compile: ?*St
.depending_steps = .{},
.root_source_file = if (options.root_source_file) |lp| lp.dupe(owner) else null,
.import_table = .{},
- .target = options.target,
+ .resolved_target = options.target,
.optimize = options.optimize,
.link_libc = options.link_libc,
.link_libcpp = options.link_libcpp,
@@ -627,7 +627,7 @@ pub fn appendZigProcessFlags(
try zig_args.append(@tagName(m.code_model));
}
- if (m.target) |*target| {
+ if (m.resolved_target) |*target| {
// Communicate the query via CLI since it's more compact.
if (!target.query.isNative()) {
try zig_args.appendSlice(&.{
@@ -737,9 +737,9 @@ fn linkLibraryOrObject(m: *Module, other: *Step.Compile) void {
}
fn requireKnownTarget(m: *Module) std.Target {
- const resolved_target = m.target orelse
+ const resolved_target = m.resolved_target orelse
@panic("this API requires the Module to be created with a known 'target' field");
- return resolved_target.target;
+ return resolved_target.result;
}
const Module = @This();