Skip to content

Commit

Permalink
add bzlmod e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
thesayyn committed Jan 17, 2023
1 parent dee7e24 commit 3eb63c7
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 2 deletions.
3 changes: 2 additions & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ bazel_dep(name = "stardoc", repo_name = "io_bazel_stardoc", version = "0.5.0")
ext = use_extension("@aspect_bazel_lib//lib:extensions.bzl", "ext")

use_repo(ext, "jq_toolchains")

use_repo(ext, "yq_toolchains")
use_repo(ext, "coreutils_toolchains")

register_toolchains(
"@jq_toolchains//:all",
"@yq_toolchains//:all",
"@coreutils_toolchains//:all"
)

1 change: 1 addition & 0 deletions e2e/bzlmod_coreutils/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
common --enable_bzlmod
1 change: 1 addition & 0 deletions e2e/bzlmod_coreutils/.bazelversion
18 changes: 18 additions & 0 deletions e2e/bzlmod_coreutils/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")

genrule(
name = "ls",
outs = ["ls.txt"],
cmd = "$(COREUTILS_BIN) ls > $@",
toolchains = ["@coreutils_toolchains//:resolved_toolchain"],
)

# This tests that the "in" file to write_source_files can be a
# label to an external repository target when bzlmod is enabled.
write_source_files(
name = "write_ls",
files = {
"ls.txt.expected": ":ls.txt",
},
)

15 changes: 15 additions & 0 deletions e2e/bzlmod_coreutils/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module(
name = "bzlmod_coreutils",
compatibility_level = 1,
version = "0.0.0",
)

bazel_dep(name = "aspect_bazel_lib", version = "0.0.0")

local_path_override(
module_name = "aspect_bazel_lib",
path = "../..",
)

ext = use_extension("@aspect_bazel_lib//lib:extensions.bzl", "ext")
use_repo(ext, "coreutils_toolchains")
Empty file added e2e/bzlmod_coreutils/WORKSPACE
Empty file.
2 changes: 2 additions & 0 deletions e2e/bzlmod_coreutils/ls.txt.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bazel-out
external
4 changes: 3 additions & 1 deletion lib/extensions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ load(
"register_copy_to_directory_toolchains",
"register_jq_toolchains",
"register_yq_toolchains",
"register_coreutils_toolchains"
)

def _toolchain_extension(_):
register_yq_toolchains(register = False)
register_jq_toolchains(register = False)
register_copy_to_directory_toolchains(register = False)
register_coreutils_toolchains(register = False)

# TODO: some way for users to control repo name/version of the tools installed
ext = module_extension(
implementation = _toolchain_extension,
)
)
3 changes: 3 additions & 0 deletions lib/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ def aspect_bazel_lib_dependencies(override_local_config_platform = False):
# Always register the copy_to_directory toolchain
register_copy_to_directory_toolchains()

# Always register the coreutils toolchain
register_coreutils_toolchains()

# Re-export the default versions
DEFAULT_JQ_VERSION = _DEFAULT_JQ_VERSION
DEFAULT_YQ_VERSION = _DEFAULT_YQ_VERSION
Expand Down

0 comments on commit 3eb63c7

Please sign in to comment.