Skip to content

Commit

Permalink
register toolchains for go optional
Browse files Browse the repository at this point in the history
  • Loading branch information
gleyba committed Mar 31, 2022
1 parent b39b20e commit 50af1f7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion nixpkgs/nixpkgs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ def nixpkgs_cc_configure(
# Generate the `cc_toolchain_config` workspace.
_nixpkgs_cc_toolchain_config(
name = "{}".format(name),
cc_toolchain_info = "@{}_info//:CC_TOOLCHAIN_INFO".format(name),
cc_toolchain_info = Label("@{}{}_info//:CC_TOOLCHAIN_INFO".format(prefix, name)),
fail_not_supported = fail_not_supported,
)

Expand Down
14 changes: 8 additions & 6 deletions nixpkgs/toolchains/foreign_cc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ def nixpkgs_foreign_cc_configure(
fail_not_supported = True,
quiet = False,
exec_constraints = None,
target_constraints = None):
target_constraints = None,
register = True):
if not nix_file and not nix_file_content:
nix_file_content = """
with import <nixpkgs> { config = {}; overlays = []; }; buildEnv {
Expand All @@ -107,8 +108,9 @@ def nixpkgs_foreign_cc_configure(
exec_constraints = exec_constraints,
target_constraints = target_constraints,
)
native.register_toolchains(
str(Label("@{}_toolchain//:cmake_nix_toolchain".format(name))),
str(Label("@{}_toolchain//:make_nix_toolchain".format(name))),
str(Label("@{}_toolchain//:ninja_nix_toolchain".format(name))),
)
if register:
native.register_toolchains(
str(Label("@{}_toolchain//:cmake_nix_toolchain".format(name))),
str(Label("@{}_toolchain//:make_nix_toolchain".format(name))),
str(Label("@{}_toolchain//:ninja_nix_toolchain".format(name))),
)
7 changes: 4 additions & 3 deletions nixpkgs/toolchains/go.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def nixpkgs_go_configure(
nixopts = [],
fail_not_supported = True,
quiet = False,
):
register = True):
"""Use go toolchain from Nixpkgs.
By default rules_go configures the go toolchain to be downloaded as binaries (which doesn't work on NixOS),
Expand Down Expand Up @@ -362,5 +362,6 @@ def nixpkgs_go_configure(
name = toolchains_repo,
sdk_repo = sdk_name,
)
for p in [p for p in PLATFORMS if not p.cgo]:
native.register_toolchains("@{}//:toolchain_go_{}".format(toolchains_repo, p.name))
if register:
for p in [p for p in PLATFORMS if not p.cgo]:
native.register_toolchains("@{}//:toolchain_go_{}".format(toolchains_repo, p.name))

0 comments on commit 50af1f7

Please sign in to comment.