fix: disable stardoc under bzlmod and windows by default
We've been making these exceptions in downstream repos
This commit is contained in:
parent
5faf59e8a6
commit
035473873a
|
@ -1,4 +1,5 @@
|
|||
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
|
||||
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
|
||||
load("//lib/private:stamping.bzl", "stamp_build_setting")
|
||||
|
||||
# Ensure that users building their own rules can dep on our bzl_library targets for their stardoc
|
||||
|
@ -15,6 +16,23 @@ exports_files(
|
|||
# Macro that creates targets enabling the use of `--stamp` in Starlark rules
|
||||
stamp_build_setting(name = "stamp")
|
||||
|
||||
# Add a flag indicating that bzlmod is enabled so that we can use select()
|
||||
# to skip bzlmod-incompatible targets. Note that Bazel does not currently
|
||||
# support declaring a config_setting directly on --enable_bzlmod, so we
|
||||
# must use set this flag instead.
|
||||
|
||||
config_setting(
|
||||
name = "bzlmod",
|
||||
flag_values = {
|
||||
":flag_bzlmod": "true",
|
||||
},
|
||||
)
|
||||
|
||||
bool_flag(
|
||||
name = "flag_bzlmod",
|
||||
build_setting_default = False,
|
||||
)
|
||||
|
||||
toolchain_type(
|
||||
name = "jq_toolchain_type",
|
||||
)
|
||||
|
|
|
@ -17,6 +17,16 @@ def stardoc_with_diff_test(
|
|||
**kwargs: additional attributes passed to the stardoc() rule, such as for overriding the templates
|
||||
"""
|
||||
|
||||
target_compatible_with = kwargs.pop("target_compatible_with", select({
|
||||
# stardoc doesn't work under bzlmod:
|
||||
# https://github.com/bazelbuild/bazel/issues/14140
|
||||
"@aspect_bazel_lib//lib:bzlmod": ["@platforms//:incompatible"],
|
||||
# stardoc produces different line endings on Windows
|
||||
# which makes the diff_test fail
|
||||
"@platforms//os:windows": ["@platforms//:incompatible"],
|
||||
"//conditions:default": [],
|
||||
}))
|
||||
|
||||
# Generate MD from .bzl
|
||||
_stardoc(
|
||||
name = name,
|
||||
|
@ -24,6 +34,7 @@ def stardoc_with_diff_test(
|
|||
input = bzl_library_target + ".bzl",
|
||||
deps = [bzl_library_target],
|
||||
tags = ["package:" + native.package_name()], # Tag the package name which will help us reconstruct the write_source_files label in update_docs
|
||||
target_compatible_with = target_compatible_with,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue