Skip to content

Commit 5b803ae

Browse files
committed
bootstrap.c: allow overriding the host triple
1 parent a65bc8d commit 5b803ae

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

bootstrap.c

+14-3
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ static void print_and_run(const char **argv) {
5454
}
5555

5656
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;
5759
#if defined(__WIN32__)
5860
return "windows";
5961
#elif defined(__APPLE__)
@@ -63,23 +65,32 @@ static const char *get_host_os(void) {
6365
#elif defined(__FreeBSD__)
6466
return "freebsd";
6567
#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");
6769
#endif
6870
}
6971

7072
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;
7175
#if defined(__x86_64__ )
7276
return "x86_64";
7377
#elif defined(__aarch64__)
7478
return "aarch64";
7579
#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");
7781
#endif
7882
}
7983

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+
8089
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;
8192
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());
8394
return global_buffer;
8495
}
8596

0 commit comments

Comments
 (0)