Skip to content

Commit 7309aba

Browse files
authored
Mark go_sdk module extension as {os,arch}_dependent (#3703)
* Mark `go_sdk` module extension as `{os,arch}_dependent` This ensures that the lockfile maintains separate instances of this extension for each OS/arch combination. * Remove debug print
1 parent 09a206c commit 7309aba

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

MODULE.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module(
55
repo_name = "io_bazel_rules_go",
66
)
77

8+
bazel_dep(name = "bazel_features", version = "1.1.0")
89
bazel_dep(name = "bazel_skylib", version = "1.2.0")
910
bazel_dep(name = "platforms", version = "0.0.4")
1011
bazel_dep(name = "rules_proto", version = "4.0.0")

go/private/extensions.bzl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
load("@bazel_features//:features.bzl", "bazel_features")
1516
load("//go/private:sdk.bzl", "detect_host_platform", "go_download_sdk_rule", "go_host_sdk_rule", "go_multiple_toolchains")
1617
load("//go/private:repositories.bzl", "go_rules_dependencies")
1718

@@ -207,12 +208,20 @@ def _left_pad_zero(index, length):
207208
fail("index must be non-negative")
208209
return ("0" * length + str(index))[-length:]
209210

211+
go_sdk_extra_kwargs = {
212+
# The choice of a host-compatible SDK is expressed in repository rule attribute values and
213+
# depends on host OS and architecture.
214+
"os_dependent": True,
215+
"arch_dependent": True,
216+
} if bazel_features.external_deps.module_extension_has_os_arch_dependent else {}
217+
210218
go_sdk = module_extension(
211219
implementation = _go_sdk_impl,
212220
tag_classes = {
213221
"download": _download_tag,
214222
"host": _host_tag,
215223
},
224+
**go_sdk_extra_kwargs
216225
)
217226

218227
def _non_module_dependencies_impl(_ctx):

0 commit comments

Comments
 (0)