| ... | ... | @@ -54,6 +54,8 @@ static void print_and_run(const char **argv) { |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | static const char *get_host_os(void) { |
| 57 | const char *host_os = getenv("ZIG_HOST_TARGET_OS"); |
| 58 | if (host_os != NULL) return host_os; |
| 57 | 59 | #if defined(__WIN32__) |
| 58 | 60 | return "windows"; |
| 59 | 61 | #elif defined(__APPLE__) |
| ... | ... | @@ -63,23 +65,32 @@ static const char *get_host_os(void) { |
| 63 | 65 | #elif defined(__FreeBSD__) |
| 64 | 66 | return "freebsd"; |
| 65 | 67 | #else |
| 66 | | #error TODO implement get_host_os in this build script for this target |
| 68 | panic("unknown host os, specify with ZIG_HOST_TARGET_OS"); |
| 67 | 69 | #endif |
| 68 | 70 | } |
| 69 | 71 | |
| 70 | 72 | static const char *get_host_arch(void) { |
| 73 | const char *host_arch = getenv("ZIG_HOST_TARGET_ARCH"); |
| 74 | if (host_arch != NULL) return host_arch; |
| 71 | 75 | #if defined(__x86_64__ ) |
| 72 | 76 | return "x86_64"; |
| 73 | 77 | #elif defined(__aarch64__) |
| 74 | 78 | return "aarch64"; |
| 75 | 79 | #else |
| 76 | | #error TODO implement get_host_arch in this build script for this target |
| 80 | panic("unknown host arch, specify with ZIG_HOST_TARGET_ARCH"); |
| 77 | 81 | #endif |
| 78 | 82 | } |
| 79 | 83 | |
| 84 | static const char *get_host_abi(void) { |
| 85 | const char *host_abi = getenv("ZIG_HOST_TARGET_ABI"); |
| 86 | return (host_abi == NULL) ? "" : host_abi; |
| 87 | } |
| 88 | |
| 80 | 89 | static const char *get_host_triple(void) { |
| 90 | const char *host_triple = getenv("ZIG_HOST_TARGET_TRIPLE"); |
| 91 | if (host_triple != NULL) return host_triple; |
| 81 | 92 | static char global_buffer[100]; |
| 82 | | sprintf(global_buffer, "%s-%s", get_host_arch(), get_host_os()); |
| 93 | sprintf(global_buffer, "%s-%s%s", get_host_arch(), get_host_os(), get_host_abi()); |
| 83 | 94 | return global_buffer; |
| 84 | 95 | } |
| 85 | 96 | |