╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ dev.zig ──────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭ find file ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ ╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │ │ │http│ ssh │ │ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
239 .stdio_listen, 240 .incremental, 241 .legalize, 242 .loongarch_backend, 243 .elf2_linker, 244 => true, 245 else => Env.sema.supports(feature), 246 }, 247 .spork8 => switch (feature) { 248 .stdio_listen, 249 .incremental, 250 .legalize, 251 .spork8_backend, 252 .spork8_linker, 253 => true, 254 else => Env.sema.supports(feature), 255 }, 256 }; 257 } 258 259 pub inline fn supportsAny(comptime dev_env: Env, comptime features: []const Feature) bool { 260 inline for (features) |feature| if (dev_env.supports(feature)) return true; 261 return false; 262 } 263 264 pub inline fn supportsAll(comptime dev_env: Env, comptime features: []const Feature) bool { 265 inline for (features) |feature| if (!dev_env.supports(feature)) return false; 266 return true; 267 } 268 }; 269 270 pub const Feature = enum { 271 build_exe_command, 272 build_lib_command, 273 build_obj_command, 274 test_command, 275 run_command, 276 ar_command, 277 clang_command, 278 cc_command, 279 translate_c_command, 280 fmt_command, 281 jit_command, 282 init_command, 283 targets_command, 284 version_command, 285 env_command, 286 zen_command, 287 help_command, 288 ast_check_command, 289 detect_cpu_command, 290 changelist_command, 291 dump_zir_command, 292 llvm_ints_command, 293 294 docs_emit, 295 stdio_listen, 296 network_listen, 297 build_import_lib, 298 win32_resource, 299 make_executable, 300 make_writable, 301 incremental, 302 ast_gen, 303 sema, 304 legalize, 305 306 c_compiler, 307 308 llvm_backend, 309 c_backend, 310 wasm_backend, 311 arm_backend, 312 x86_64_backend, 313 aarch64_backend, 314 x86_backend, 315 powerpc_backend, 316 riscv64_backend, 317 sparc64_backend, 318 spirv_backend, 319 loongarch_backend, 320 spork8_backend, 321 322 lld_linker, 323 coff_linker, 324 coff2_linker, 325 elf_linker, 326 elf2_linker, 327 macho_linker, 328 c_linker, 329 wasm_linker, 330 spirv_linker, 331 plan9_linker, 332 spork8_linker, 333 }; 334 335 /// Makes the code following the call to this function unreachable if `feature` is disabled. 336 pub fn check(comptime feature: Feature) if (env.supports(feature)) void else noreturn { 337 if (env.supports(feature)) return; 338 @panic("development environment " ++ @tagName(env) ++ " does not support feature " ++ @tagName(feature)); 339 } 340 341 /// Makes the code following the call to this function unreachable if all of `features` are disabled. 342 pub fn checkAny(comptime features: []const Feature) if (env.supportsAny(features)) void else noreturn { 343 if (env.supportsAny(features)) return; 344 comptime var feature_tags: []const u8 = ""; 345 inline for (features[0 .. features.len - 1]) |feature| feature_tags = feature_tags ++ @tagName(feature) ++ ", "; 346 feature_tags = feature_tags ++ "or " ++ @tagName(features[features.len - 1]); 347 @panic("development environment " ++ @tagName(env) ++ " does not support feature " ++ feature_tags); 348 } 349 350 /// Makes the code following the call to this function unreachable if any of `features` are disabled. 351 pub fn checkAll(comptime features: []const Feature) if (env.supportsAll(features)) void else noreturn { 352 if (env.supportsAll(features)) return; 353 inline for (features) |feature| if (!env.supports(feature)) 354 @panic("development environment " ++ @tagName(env) ++ " does not support feature " ++ @tagName(feature)); 355 } 356 357 const build_options = @import("build_options"); 358 359 pub const env: Env = if (@hasDecl(build_options, "dev")) 360 @field(Env, @tagName(build_options.dev)) 361 else if (@hasDecl(build_options, "only_c") and build_options.only_c) 362 .bootstrap 363 else if (@hasDecl(build_options, "only_core_functionality") and build_options.only_core_functionality) 364 .core 365 else 366 .full; 367