Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes needed for rules_js bzlmod support #375

Merged
merged 2 commits into from
Feb 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/docs.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions e2e/bzlmod/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ load("@aspect_bazel_lib//lib:diff_test.bzl", "diff_test")
load("@aspect_bazel_lib//lib:jq.bzl", "jq")
load("@aspect_bazel_lib//lib:yq.bzl", "yq")
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@aspect_bazel_lib_host//:defs.bzl", "host")

bzl_library(
name = "defs",
Expand Down Expand Up @@ -86,3 +87,9 @@ diff_test(
# Source directories are not support on remote execution.
tags = ["no-remote-exec"],
)

genrule(
name = "host_bazel_version",
outs = ["host_bazel_version.txt"],
cmd = "echo '%s' > $@" % host.bazel_version,
)
6 changes: 6 additions & 0 deletions e2e/bzlmod/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@ local_path_override(
module_name = "aspect_bazel_lib",
path = "../..",
)

ext = use_extension("@aspect_bazel_lib//lib:extensions.bzl", "ext")

ext.host()

use_repo(ext, "aspect_bazel_lib_host")
12 changes: 11 additions & 1 deletion lib/extensions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,24 @@ load(
"register_jq_toolchains",
"register_yq_toolchains",
)
load("//lib/private:host_repo.bzl", "host_repo")

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

create_host_repo = False
for module in mctx.modules:
if len(module.tags.host) > 0:
create_host_repo = True

if create_host_repo:
host_repo(name = "aspect_bazel_lib_host")

# TODO: some way for users to control repo name/version of the tools installed
ext = module_extension(
implementation = _toolchain_extension,
tag_classes = {"host": tag_class(attrs = {})},
)
4 changes: 3 additions & 1 deletion lib/private/docs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def stardoc_with_diff_test(
**kwargs
)

def update_docs(name = "update"):
def update_docs(name = "update", **kwargs):
gregmagolan marked this conversation as resolved.
Show resolved Hide resolved
"""Stamps an executable run for writing all stardocs declared with stardoc_with_diff_test to the source tree.

This is to be used in tandem with `stardoc_with_diff_test()` to produce a convenient workflow
Expand All @@ -45,6 +45,7 @@ def update_docs(name = "update"):

Args:
name: the name of executable target
**kwargs: Other common named parameters such as `tags` or `visibility`
"""

update_files = {}
Expand All @@ -60,4 +61,5 @@ def update_docs(name = "update"):
write_source_files(
name = name,
files = update_files,
**kwargs
)