Zig 0.17.0-dev (Split by item) This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig standard library.
std › Build › standardTargetOptionsQueryOnly Public Function standardTargetOptionsQueryOnly Doc Source 1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349 pub fn standardTargetOptionsQueryOnly (b : *Build , args : StandardTargetOptionsArgs ) Target .Query {
const graph = b .graph ;
const arena = graph .arena ;
const maybe_triple = b .option (
[]const u8 ,
"target" ,
"The CPU architecture, OS, and ABI to build for" ,
);
const mcpu = b .option (
[]const u8 ,
"cpu" ,
"Target CPU features to add or subtract" ,
);
const ofmt = b .option (
[]const u8 ,
"ofmt" ,
"Target object format" ,
);
const dynamic_linker = b .option (
[]const u8 ,
"dynamic-linker" ,
"Path to interpreter on the target system" ,
);
if (maybe_triple == null and mcpu == null and ofmt == null and dynamic_linker == null )
return args .default_target ;
const triple = maybe_triple orelse "native" ;
const selected_target = parseTargetQuery (.{
.arch_os_abi = triple ,
.cpu_features = mcpu ,
.object_format = ofmt ,
.dynamic_linker = dynamic_linker ,
}) catch |err | switch (err ) {
error .ParseFailed => {
b .markInvalidUserInput ();
return args .default_target ;
},
};
const whitelist = args .whitelist orelse return selected_target ;
// Make sure it's a match of one of the list.
for (whitelist ) |q | {
if (q .eql (selected_target ))
return selected_target ;
}
for (whitelist ) |q | {
log .info ("allowed target: -Dtarget={s} -Dcpu={s}" , .{
q .zigTriple (arena ) catch @panic ("OOM" ),
q .serializeCpuAlloc (arena ) catch @panic ("OOM" ),
});
}
log .err ("chosen target {q} does not match one of the allowed targets" , .{
selected_target .zigTriple (arena ) catch @panic ("OOM" ),
});
b .markInvalidUserInput ();
return args .default_target ;
}
Exposes standard
zig buildoptions for choosing a target.