Skip to content

Commit

Permalink
Mark go_sdk module extension as {os,arch}_dependent (#3703)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
fmeum authored Sep 20, 2023
1 parent 09a206c commit 7309aba
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module(
repo_name = "io_bazel_rules_go",
)

bazel_dep(name = "bazel_features", version = "1.1.0")
bazel_dep(name = "bazel_skylib", version = "1.2.0")
bazel_dep(name = "platforms", version = "0.0.4")
bazel_dep(name = "rules_proto", version = "4.0.0")
Expand Down
9 changes: 9 additions & 0 deletions go/private/extensions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

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

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

go_sdk_extra_kwargs = {
# The choice of a host-compatible SDK is expressed in repository rule attribute values and
# depends on host OS and architecture.
"os_dependent": True,
"arch_dependent": True,
} if bazel_features.external_deps.module_extension_has_os_arch_dependent else {}

go_sdk = module_extension(
implementation = _go_sdk_impl,
tag_classes = {
"download": _download_tag,
"host": _host_tag,
},
**go_sdk_extra_kwargs
)

def _non_module_dependencies_impl(_ctx):
Expand Down

0 comments on commit 7309aba

Please sign in to comment.