static int print_target_list(FILE *f) { ZigTarget native; get_native_target(&native); fprintf(f, "Architectures:\n"); int arch_count = target_arch_count(); for (int arch_i = 0; arch_i < arch_count; arch_i += 1) { const ArchType *arch = get_target_arch(arch_i); char arch_name[50]; get_arch_name(arch_name, arch); const char *native_str = (native.arch.arch == arch->arch && native.arch.sub_arch == arch->sub_arch) ? " (native)" : ""; fprintf(f, " %s%s\n", arch_name, native_str); } fprintf(f, "\nOperating Systems:\n"); int os_count = target_os_count(); for (int i = 0; i < os_count; i += 1) { ZigLLVM_OSType os_type = get_target_os(i); const char *native_str = (native.os == os_type) ? " (native)" : ""; fprintf(f, " %s%s\n", get_target_os_name(os_type), native_str); } fprintf(f, "\nEnvironments:\n"); int environ_count = target_environ_count(); for (int i = 0; i < environ_count; i += 1) { ZigLLVM_EnvironmentType environ_type = get_target_environ(i); const char *native_str = (native.env_type == environ_type) ? " (native)" : ""; fprintf(f, " %s%s\n", ZigLLVMGetEnvironmentTypeName(environ_type), native_str); } return EXIT_SUCCESS; }
int parse_target_environ(const char *str, ZigLLVM_EnvironmentType *out_environ) { for (int i = 0; i < array_length(environ_list); i += 1) { ZigLLVM_EnvironmentType env_type = environ_list[i]; const char *environ_name = ZigLLVMGetEnvironmentTypeName(env_type); if (strcmp(environ_name, str) == 0) { *out_environ = env_type; return 0; } } return ErrorFileNotFound; }