authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2024-02-03 22:10:50+01:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2024-02-03 22:34:59-05:00
log5b803aecfb302718b67c465adfdaaef500ab8c68
tree747baf4610f945c1cf777729888804a29f0ff709
parenta65bc8d0712d14580a7d1b8bfdd2d7beb4b247d5

bootstrap.c: allow overriding the host triple


1 files changed, 14 insertions(+), 3 deletions(-)

bootstrap.c+14-3
...@@ -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}
5555
56static const char *get_host_os(void) {56static 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#else67#else
66#error TODO implement get_host_os in this build script for this target68 panic("unknown host os, specify with ZIG_HOST_TARGET_OS");
67#endif69#endif
68}70}
6971
70static const char *get_host_arch(void) {72static 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#else79#else
76#error TODO implement get_host_arch in this build script for this target80 panic("unknown host arch, specify with ZIG_HOST_TARGET_ARCH");
77#endif81#endif
78}82}
7983
84static 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
80static const char *get_host_triple(void) {89static 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}
8596