| ... | @@ -54,6 +54,8 @@ static void print_and_run(const char **argv) { | ... | @@ -54,6 +54,8 @@ static void print_and_run(const char **argv) { |
| 54 | } | 54 | } |
| 55 | | 55 | |
| 56 | static const char *get_host_os(void) { | 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 | #if defined(__WIN32__) | 59 | #if defined(__WIN32__) |
| 58 | return "windows"; | 60 | return "windows"; |
| 59 | #elif defined(__APPLE__) | 61 | #elif defined(__APPLE__) |
| ... | @@ -63,23 +65,32 @@ static const char *get_host_os(void) { | ... | @@ -63,23 +65,32 @@ static const char *get_host_os(void) { |
| 63 | #elif defined(__FreeBSD__) | 65 | #elif defined(__FreeBSD__) |
| 64 | return "freebsd"; | 66 | return "freebsd"; |
| 65 | #else | 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 | #endif | 69 | #endif |
| 68 | } | 70 | } |
| 69 | | 71 | |
| 70 | static const char *get_host_arch(void) { | 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 | #if defined(__x86_64__ ) | 75 | #if defined(__x86_64__ ) |
| 72 | return "x86_64"; | 76 | return "x86_64"; |
| 73 | #elif defined(__aarch64__) | 77 | #elif defined(__aarch64__) |
| 74 | return "aarch64"; | 78 | return "aarch64"; |
| 75 | #else | 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 | #endif | 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 | static const char *get_host_triple(void) { | 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 | static char global_buffer[100]; | 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 | return global_buffer; | 94 | return global_buffer; |
| 84 | } | 95 | } |
| 85 | | 96 | |