@@ -46,11 +46,6 @@ pub fn main() !void {
46
46
return error .InvalidArgs ;
47
47
};
48
48
49
- const host : std.Build.ResolvedTarget = .{
50
- .query = .{},
51
- .result = try std .zig .system .resolveTargetQuery (.{}),
52
- };
53
-
54
49
const build_root_directory : std.Build.Cache.Directory = .{
55
50
.path = build_root ,
56
51
.handle = try std .fs .cwd ().openDir (build_root , .{}),
@@ -66,28 +61,28 @@ pub fn main() !void {
66
61
.handle = try std .fs .cwd ().makeOpenPath (global_cache_root , .{}),
67
62
};
68
63
69
- var cache : std.Build.Cache = .{
70
- .gpa = arena ,
71
- .manifest_dir = try local_cache_directory .handle .makeOpenPath ("h" , .{}),
64
+ var graph : std.Build.Graph = .{
65
+ .arena = arena ,
66
+ .cache = .{
67
+ .gpa = arena ,
68
+ .manifest_dir = try local_cache_directory .handle .makeOpenPath ("h" , .{}),
69
+ },
70
+ .zig_exe = zig_exe ,
71
+ .env_map = try process .getEnvMap (arena ),
72
+ .global_cache_root = global_cache_directory ,
72
73
};
73
- cache .addPrefix (.{ .path = null , .handle = std .fs .cwd () });
74
- cache .addPrefix (build_root_directory );
75
- cache .addPrefix (local_cache_directory );
76
- cache .addPrefix (global_cache_directory );
77
- cache .hash .addBytes (builtin .zig_version_string );
78
74
79
- var system_library_options : std .StringArrayHashMapUnmanaged (std .Build .SystemLibraryMode ) = .{};
75
+ graph .cache .addPrefix (.{ .path = null , .handle = std .fs .cwd () });
76
+ graph .cache .addPrefix (build_root_directory );
77
+ graph .cache .addPrefix (local_cache_directory );
78
+ graph .cache .addPrefix (global_cache_directory );
79
+ graph .cache .hash .addBytes (builtin .zig_version_string );
80
80
81
81
const builder = try std .Build .create (
82
- arena ,
83
- zig_exe ,
82
+ & graph ,
84
83
build_root_directory ,
85
84
local_cache_directory ,
86
- global_cache_directory ,
87
- host ,
88
- & cache ,
89
85
dependencies .root_deps ,
90
- & system_library_options ,
91
86
);
92
87
93
88
var targets = ArrayList ([]const u8 ).init (arena );
@@ -132,10 +127,16 @@ pub fn main() !void {
132
127
steps_menu = true ;
133
128
} else if (mem .eql (u8 , arg , "--system-lib" )) {
134
129
const name = nextArgOrFatal (args , & arg_idx );
135
- builder .system_library_options .put (arena , name , .user_enabled ) catch @panic ("OOM" );
130
+ graph .system_library_options .put (arena , name , .user_enabled ) catch @panic ("OOM" );
136
131
} else if (mem .eql (u8 , arg , "--no-system-lib" )) {
137
132
const name = nextArgOrFatal (args , & arg_idx );
138
- builder .system_library_options .put (arena , name , .user_disabled ) catch @panic ("OOM" );
133
+ graph .system_library_options .put (arena , name , .user_disabled ) catch @panic ("OOM" );
134
+ } else if (mem .eql (u8 , arg , "--host-target" )) {
135
+ graph .host_query_options .arch_os_abi = nextArgOrFatal (args , & arg_idx );
136
+ } else if (mem .eql (u8 , arg , "--host-cpu" )) {
137
+ graph .host_query_options .cpu_features = nextArgOrFatal (args , & arg_idx );
138
+ } else if (mem .eql (u8 , arg , "--host-dynamic-linker" )) {
139
+ graph .host_query_options .dynamic_linker = nextArgOrFatal (args , & arg_idx );
139
140
} else if (mem .eql (u8 , arg , "--prefix-lib-dir" )) {
140
141
dir_list .lib_dir = nextArgOrFatal (args , & arg_idx );
141
142
} else if (mem .eql (u8 , arg , "--prefix-exe-dir" )) {
@@ -193,7 +194,7 @@ pub fn main() !void {
193
194
} else if (mem .eql (u8 , arg , "--debug-compile-errors" )) {
194
195
builder .debug_compile_errors = true ;
195
196
} else if (mem .eql (u8 , arg , "--glibc-runtimes" )) {
196
- builder .glibc_runtimes_dir = nextArgOrFatal (args , & arg_idx );
197
+ graph .glibc_runtimes_dir = nextArgOrFatal (args , & arg_idx );
197
198
} else if (mem .eql (u8 , arg , "--verbose-link" )) {
198
199
builder .verbose_link = true ;
199
200
} else if (mem .eql (u8 , arg , "--verbose-air" )) {
@@ -213,25 +214,25 @@ pub fn main() !void {
213
214
} else if (mem .eql (u8 , arg , "--prominent-compile-errors" )) {
214
215
prominent_compile_errors = true ;
215
216
} else if (mem .eql (u8 , arg , "-fwine" )) {
216
- builder .enable_wine = true ;
217
+ graph .enable_wine = true ;
217
218
} else if (mem .eql (u8 , arg , "-fno-wine" )) {
218
- builder .enable_wine = false ;
219
+ graph .enable_wine = false ;
219
220
} else if (mem .eql (u8 , arg , "-fqemu" )) {
220
- builder .enable_qemu = true ;
221
+ graph .enable_qemu = true ;
221
222
} else if (mem .eql (u8 , arg , "-fno-qemu" )) {
222
- builder .enable_qemu = false ;
223
+ graph .enable_qemu = false ;
223
224
} else if (mem .eql (u8 , arg , "-fwasmtime" )) {
224
- builder .enable_wasmtime = true ;
225
+ graph .enable_wasmtime = true ;
225
226
} else if (mem .eql (u8 , arg , "-fno-wasmtime" )) {
226
- builder .enable_wasmtime = false ;
227
+ graph .enable_wasmtime = false ;
227
228
} else if (mem .eql (u8 , arg , "-frosetta" )) {
228
- builder .enable_rosetta = true ;
229
+ graph .enable_rosetta = true ;
229
230
} else if (mem .eql (u8 , arg , "-fno-rosetta" )) {
230
- builder .enable_rosetta = false ;
231
+ graph .enable_rosetta = false ;
231
232
} else if (mem .eql (u8 , arg , "-fdarling" )) {
232
- builder .enable_darling = true ;
233
+ graph .enable_darling = true ;
233
234
} else if (mem .eql (u8 , arg , "-fno-darling" )) {
234
- builder .enable_darling = false ;
235
+ graph .enable_darling = false ;
235
236
} else if (mem .eql (u8 , arg , "-freference-trace" )) {
236
237
builder .reference_trace = 256 ;
237
238
} else if (mem .startsWith (u8 , arg , "-freference-trace=" )) {
@@ -266,11 +267,19 @@ pub fn main() !void {
266
267
}
267
268
}
268
269
270
+ const host_query = std .Build .parseTargetQuery (graph .host_query_options ) catch | err | switch (err ) {
271
+ error .ParseFailed = > process .exit (1 ),
272
+ };
273
+ builder .host = .{
274
+ .query = .{},
275
+ .result = try std .zig .system .resolveTargetQuery (host_query ),
276
+ };
277
+
269
278
const stderr = std .io .getStdErr ();
270
279
const ttyconf = get_tty_conf (color , stderr );
271
280
switch (ttyconf ) {
272
- .no_color = > try builder .env_map .put ("NO_COLOR" , "1" ),
273
- .escape_codes = > try builder .env_map .put ("YES_COLOR" , "1" ),
281
+ .no_color = > try graph .env_map .put ("NO_COLOR" , "1" ),
282
+ .escape_codes = > try graph .env_map .put ("YES_COLOR" , "1" ),
274
283
.windows_api = > {},
275
284
}
276
285
@@ -1029,7 +1038,7 @@ fn usage(b: *std.Build, out_stream: anytype) !void {
1029
1038
\\
1030
1039
\\Steps:
1031
1040
\\
1032
- , .{b .zig_exe });
1041
+ , .{b .graph . zig_exe });
1033
1042
try steps (b , out_stream );
1034
1043
1035
1044
try out_stream .writeAll (
@@ -1104,22 +1113,23 @@ fn usage(b: *std.Build, out_stream: anytype) !void {
1104
1113
\\ --system [dir] System Package Mode. Disable fetching; prefer system libs
1105
1114
\\ --host-target [triple] Use the provided target as the host
1106
1115
\\ --host-cpu [cpu] Use the provided CPU as the host
1116
+ \\ --host-dynamic-linker [path] Use the provided dynamic linker as the host
1107
1117
\\ --system-lib [name] Use the system-provided library
1108
1118
\\ --no-system-lib [name] Do not use the system-provided library
1109
1119
\\
1110
1120
\\ Available System Library Integrations: Enabled:
1111
1121
\\
1112
1122
);
1113
- if (b .system_library_options .entries .len == 0 ) {
1123
+ if (b .graph . system_library_options .entries .len == 0 ) {
1114
1124
try out_stream .writeAll (" (none) -\n " );
1115
1125
} else {
1116
- for (b .system_library_options .keys (), b .system_library_options .values ()) | name , v | {
1126
+ for (b .graph . system_library_options .keys (), b .graph . system_library_options .values ()) | k , v | {
1117
1127
const status = switch (v ) {
1118
1128
.declared_enabled = > "yes" ,
1119
1129
.declared_disabled = > "no" ,
1120
1130
.user_enabled , .user_disabled = > unreachable , // already emitted error
1121
1131
};
1122
- try out_stream .print (" {s:<43} {s}\n " , .{ name , status });
1132
+ try out_stream .print (" {s:<43} {s}\n " , .{ k , status });
1123
1133
}
1124
1134
}
1125
1135
@@ -1203,7 +1213,7 @@ fn fatal(comptime f: []const u8, args: anytype) noreturn {
1203
1213
1204
1214
fn validateSystemLibraryOptions (b : * std.Build ) void {
1205
1215
var bad = false ;
1206
- for (b .system_library_options .keys (), b .system_library_options .values ()) | k , v | {
1216
+ for (b .graph . system_library_options .keys (), b . graph .system_library_options .values ()) | k , v | {
1207
1217
switch (v ) {
1208
1218
.user_disabled , .user_enabled = > {
1209
1219
// The user tried to enable or disable a system library integration, but
0 commit comments