@@ -57,12 +57,12 @@ After commenting on the issue, `rm -fr {cache_prefix}` and re-run your command.
57
57
"""
58
58
59
59
def toolchains (
60
- exec_os ,
61
- exec_arch ,
62
60
version = VERSION ,
63
61
url_formats = [],
64
62
host_platform_sha256 = HOST_PLATFORM_SHA256 ,
65
- host_platform_ext = _HOST_PLATFORM_EXT ):
63
+ host_platform_ext = _HOST_PLATFORM_EXT ,
64
+ exec_os = "HOST" ,
65
+ exec_arch = "HOST" ):
66
66
"""
67
67
Download zig toolchain and declare bazel toolchains.
68
68
The platforms are not registered automatically, that should be done by
@@ -75,9 +75,22 @@ def toolchains(
75
75
original_format = URL_FORMAT_NIGHTLY
76
76
else :
77
77
original_format = URL_FORMAT_RELEASE
78
-
79
- mirror_format = original_format .replace ("https://ziglang.org/" , "https://mirror.bazel.build/ziglang.org/" )
80
- url_formats = [mirror_format , original_format ]
78
+ mirror_format = original_format .replace ("https://ziglang.org/" , "https://mirror.bazel.build/ziglang.org/" )
79
+ url_formats = [mirror_format , original_format ]
80
+
81
+ # If these are not specified by user in WORKSPACE, fall back to the old
82
+ # behavior of assuming HOST is the only supported platform.
83
+ if exec_os == "HOST" and exec_arch == "HOST" :
84
+ zig_repository (
85
+ name = "zig_sdk" ,
86
+ version = version ,
87
+ url_formats = url_formats ,
88
+ host_platform_sha256 = host_platform_sha256 ,
89
+ host_platform_ext = host_platform_ext ,
90
+ exec_os = exec_os ,
91
+ exec_arch = exec_arch ,
92
+ )
93
+ return
81
94
82
95
zig_repository (
83
96
name = "zig_sdk-{}-{}" .format (exec_os , exec_arch ),
@@ -97,6 +110,12 @@ def _zig_repository_impl(repository_ctx):
97
110
exec_arch = repository_ctx .attr .exec_arch
98
111
host_os = repository_ctx .os .name
99
112
host_arch = repository_ctx .os .arch
113
+
114
+ if exec_os == "HOST" :
115
+ exec_os = host_os
116
+ if exec_arch == "HOST" :
117
+ exec_arch = host_arch
118
+
100
119
if exec_arch == "amd64" :
101
120
exec_arch = "x86_64"
102
121
if host_arch == "amd64" :
0 commit comments