diff options
author | nickreid <nickreid@google.com> | 2023-02-14 14:35:47 -0800 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2023-02-14 14:36:27 -0800 |
commit | 247c1d211df109f766b56adbb464c1890357aa6d (patch) | |
tree | 44ab3ba3c243a626392cf9e1b583d72907c6176a | |
parent | d8f98303591f0b4c93531082130a48ed5db2bdae (diff) | |
download | bazelbuild-kotlin-rules-247c1d211df109f766b56adbb464c1890357aa6d.tar.gz |
n/a
PiperOrigin-RevId: 509641261
29 files changed, 44 insertions, 6 deletions
@@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") + licenses(["notice"]) exports_files(["LICENSE"]) diff --git a/bazel/deploy_jar_freshness_golden_test.bzl b/bazel/deploy_jar_freshness_golden_test.bzl index 9e36132..a6524eb 100644 --- a/bazel/deploy_jar_freshness_golden_test.bzl +++ b/bazel/deploy_jar_freshness_golden_test.bzl @@ -14,6 +14,8 @@ """Test on *_deploy.jar freshness""" +load("//:visibility.bzl", "RULES_KOTLIN") + def _deploy_jar_freshness_golden_test_impl(ctx): test_command = """ if ! cmp $1 $2 ; then diff --git a/bazel/stubs.bzl b/bazel/stubs.bzl index 3bd778e..19f0e54 100644 --- a/bazel/stubs.bzl +++ b/bazel/stubs.bzl @@ -15,6 +15,7 @@ """Stubs""" load("@bazel_skylib//lib:sets.bzl", "sets") +load("//:visibility.bzl", "RULES_KOTLIN") def _empty_fn(*_args, **_kwargs): pass diff --git a/kotlin/common.bzl b/kotlin/common.bzl index b094fa8..811d0e9 100644 --- a/kotlin/common.bzl +++ b/kotlin/common.bzl @@ -20,7 +20,7 @@ load("//bazel:stubs.bzl", "lint_actions") load("//bazel:stubs.bzl", "BASE_JVMOPTS") load("//bazel:stubs.bzl", "DEFAULT_BUILTIN_PROCESSORS") load(":file_factory.bzl", "FileFactory") -load(":visibility.bzl", "RULES_DEFS_THAT_COMPILE_KOTLIN") +load("//:visibility.bzl", "RULES_DEFS_THAT_COMPILE_KOTLIN") # TODO: Remove the _ALLOWED_*_RULES lists to determine which rules # are accepted dependencies to Kotlin rules as the approach does not scale diff --git a/kotlin/compiler_opt.bzl b/kotlin/compiler_opt.bzl index 5370066..07f3c86 100644 --- a/kotlin/compiler_opt.bzl +++ b/kotlin/compiler_opt.bzl @@ -24,7 +24,7 @@ be passed to the `custom_kotlincopts` attribute. The set of directories that all `kt_compiler_opt` targets is also limited, to prevent misuse. """ -load(":visibility.bzl", "RULES_DEFS_THAT_COMPILE_KOTLIN") +load("//:visibility.bzl", "RULES_DEFS_THAT_COMPILE_KOTLIN") # Intentionally private to prevent misuse. _KtCompilerOptInfo = provider( diff --git a/kotlin/compiler_plugin.bzl b/kotlin/compiler_plugin.bzl index 3527aee..15ad09a 100644 --- a/kotlin/compiler_plugin.bzl +++ b/kotlin/compiler_plugin.bzl @@ -14,6 +14,8 @@ """A rule for declaring and passing kotlinc plugins.""" +load("//:visibility.bzl", "RULES_KOTLIN") + _KtCompilerPluginInfo = provider( doc = "Info for running a plugin that directly registers itself to kotlinc extension points", fields = dict( diff --git a/kotlin/direct_jdeps.bzl b/kotlin/direct_jdeps.bzl index f242989..c3ab747 100644 --- a/kotlin/direct_jdeps.bzl +++ b/kotlin/direct_jdeps.bzl @@ -14,6 +14,8 @@ """kt_traverse_exports visitor for exposing jdeps files from direct deps.""" +load("//:visibility.bzl", "RULES_KOTLIN") + def _get_jdeps(target, _ctx_rule): return [out.compile_jdeps for out in target[JavaInfo].java_outputs if out.compile_jdeps] diff --git a/kotlin/file_factory.bzl b/kotlin/file_factory.bzl index 25c2837..51e18f9 100644 --- a/kotlin/file_factory.bzl +++ b/kotlin/file_factory.bzl @@ -14,6 +14,8 @@ """FileFactory""" +load("//:visibility.bzl", "RULES_KOTLIN") + def FileFactory(ctx, base, suffix = None): """Creates files with names derived from some base file diff --git a/kotlin/forbidden_deps.bzl b/kotlin/forbidden_deps.bzl index 67a04fb..fa1db86 100644 --- a/kotlin/forbidden_deps.bzl +++ b/kotlin/forbidden_deps.bzl @@ -22,6 +22,7 @@ Currently this system recognizes: load("@bazel_skylib//lib:sets.bzl", "sets") load("//bazel:stubs.bzl", "EXEMPT_DEPS", "FORBIDDEN_DEP_PACKAGES") +load("//:visibility.bzl", "RULES_KOTLIN") def _error(target, msg): return (str(target.label), msg) diff --git a/kotlin/friend_jars.bzl b/kotlin/friend_jars.bzl index 1be3f63..822d9ad 100644 --- a/kotlin/friend_jars.bzl +++ b/kotlin/friend_jars.bzl @@ -14,6 +14,8 @@ """TODO: Write module docstring.""" +load("//:visibility.bzl", "RULES_KOTLIN") + def is_eligible_friend(target, friend): """ Determines if `target` is allowed to use `internal` members of `friend` diff --git a/kotlin/java_plugin.internal.bzl b/kotlin/java_plugin.internal.bzl index 69e7bb5..307af4f 100644 --- a/kotlin/java_plugin.internal.bzl +++ b/kotlin/java_plugin.internal.bzl @@ -19,6 +19,8 @@ Due to cross plugin type processing, the plugin info search processor differs from the way that java targets handles plugins. """ +load("//:visibility.bzl", "RULES_KOTLIN") + def _get_java_plugins(_target, ctx_rule): exported_plugins = getattr(ctx_rule.attr, "exported_plugins", []) return [ diff --git a/kotlin/jvm_compile.bzl b/kotlin/jvm_compile.bzl index 9047d2e..0461060 100644 --- a/kotlin/jvm_compile.bzl +++ b/kotlin/jvm_compile.bzl @@ -17,7 +17,7 @@ load(":common.bzl", "common") load(":compiler_plugin.bzl", "KtCompilerPluginInfo") load(":traverse_exports.bzl", "kt_traverse_exports") -load(":visibility.bzl", "RULES_DEFS_THAT_COMPILE_KOTLIN") +load("//:visibility.bzl", "RULES_DEFS_THAT_COMPILE_KOTLIN") _RULE_FAMILY = common.RULE_FAMILY diff --git a/kotlin/jvm_import.bzl b/kotlin/jvm_import.bzl index c42bb96..0e7a8ea 100644 --- a/kotlin/jvm_import.bzl +++ b/kotlin/jvm_import.bzl @@ -20,6 +20,7 @@ load("//toolchains/kotlin_jvm:kt_jvm_toolchains.bzl", "kt_jvm_toolchains") load("//toolchains/kotlin_jvm:java_toolchains.bzl", "java_toolchains") load("@bazel_skylib//lib:dicts.bzl", "dicts") load(":compiler_plugin.bzl", "KtCompilerPluginInfo") +load("//:visibility.bzl", "RULES_KOTLIN") def _kt_jvm_import_impl(ctx): kt_jvm_toolchain = kt_jvm_toolchains.get(ctx) diff --git a/kotlin/jvm_library.bzl b/kotlin/jvm_library.bzl index c174c91..9485bcf 100644 --- a/kotlin/jvm_library.bzl +++ b/kotlin/jvm_library.bzl @@ -20,6 +20,7 @@ load("@bazel_skylib//lib:dicts.bzl", "dicts") load("//bazel:stubs.bzl", "lint_actions") load("//bazel:stubs.bzl", "LINT_REGISTRY") load("//bazel:stubs.bzl", "registry_checks_for_package") +load("//:visibility.bzl", "RULES_KOTLIN") def kt_jvm_library( name, diff --git a/kotlin/jvm_test.bzl b/kotlin/jvm_test.bzl index 1c19902..2a85a66 100644 --- a/kotlin/jvm_test.bzl +++ b/kotlin/jvm_test.bzl @@ -16,6 +16,7 @@ load(":jvm_library.bzl", "kt_jvm_library") load("//bazel:stubs.bzl", "register_extension_info") +load("//:visibility.bzl", "RULES_KOTLIN") def _lib_name(name): return "%s_DO_NOT_DEPEND_LIB" % name diff --git a/kotlin/traverse_exports.bzl b/kotlin/traverse_exports.bzl index d9fde77..8608b00 100644 --- a/kotlin/traverse_exports.bzl +++ b/kotlin/traverse_exports.bzl @@ -19,7 +19,7 @@ load(":direct_jdeps.bzl", "kt_direct_jdeps_visitor") load(":forbidden_deps.bzl", "kt_forbidden_deps_visitor") load(":friend_jars.bzl", "kt_friend_jars_visitor", "kt_friend_labels_visitor") load(":java_plugin.internal.bzl", "java_plugin_visitor") -load(":visibility.bzl", "RULES_DEFS_THAT_COMPILE_KOTLIN") +load("//:visibility.bzl", "RULES_DEFS_THAT_COMPILE_KOTLIN") # java_xxx_proto_library don't populate java_outputs but we can get them through # required_aspect_providers from their proto_library deps. diff --git a/tests/analysis/assert_failure_test.bzl b/tests/analysis/assert_failure_test.bzl index b266c2a..2a742c3 100644 --- a/tests/analysis/assert_failure_test.bzl +++ b/tests/analysis/assert_failure_test.bzl @@ -15,6 +15,7 @@ """An assertion for analysis failure.""" load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts") +load("//:visibility.bzl", "RULES_KOTLIN") def _assert_failure_test_impl(ctx): env = analysistest.begin(ctx) diff --git a/tests/analysis/compiler_plugin/propagation/assert_propagation_test.bzl b/tests/analysis/compiler_plugin/propagation/assert_propagation_test.bzl index fe8c9dc..0c1b02a 100644 --- a/tests/analysis/compiler_plugin/propagation/assert_propagation_test.bzl +++ b/tests/analysis/compiler_plugin/propagation/assert_propagation_test.bzl @@ -17,6 +17,7 @@ load("@bazel_skylib//lib:sets.bzl", "sets") load("@bazel_skylib//rules:build_test.bzl", "build_test") load("//kotlin:traverse_exports.bzl", "kt_traverse_exports") +load("//:visibility.bzl", "RULES_KOTLIN") def _assert_propagation_impl(ctx): expected_ids = sets.make(ctx.attr.expected_plugin_ids) diff --git a/tests/analysis/compiler_plugin/provider_ctor/fake_compiler_plugin.bzl b/tests/analysis/compiler_plugin/provider_ctor/fake_compiler_plugin.bzl index d4a6bac..194025d 100644 --- a/tests/analysis/compiler_plugin/provider_ctor/fake_compiler_plugin.bzl +++ b/tests/analysis/compiler_plugin/provider_ctor/fake_compiler_plugin.bzl @@ -15,6 +15,7 @@ """A fake impl of kt_compiler_plugin.""" load("//kotlin:compiler_plugin.bzl", "KtCompilerPluginInfo") +load("//:visibility.bzl", "RULES_KOTLIN") def _kt_fake_compiler_plugin_impl(ctx): return [ diff --git a/tests/analysis/compiler_plugin/provider_output/assert_compiler_plugin_test.bzl b/tests/analysis/compiler_plugin/provider_output/assert_compiler_plugin_test.bzl index 9b2951e..f4e1849 100644 --- a/tests/analysis/compiler_plugin/provider_output/assert_compiler_plugin_test.bzl +++ b/tests/analysis/compiler_plugin/provider_output/assert_compiler_plugin_test.bzl @@ -16,6 +16,7 @@ load("//kotlin:compiler_plugin.bzl", "KtCompilerPluginInfo") load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts") +load("//:visibility.bzl", "RULES_KOTLIN") def _test_impl(ctx): env = analysistest.begin(ctx) diff --git a/tests/analysis/for_test.bzl b/tests/analysis/for_test.bzl index 434c1a4..2a75726 100644 --- a/tests/analysis/for_test.bzl +++ b/tests/analysis/for_test.bzl @@ -16,6 +16,7 @@ load("//kotlin:jvm_library.bzl", "kt_jvm_library") load("//tests/analysis:util.bzl", "ONLY_FOR_ANALYSIS_TEST_TAGS") +load("//:visibility.bzl", "RULES_KOTLIN") def _kt_jvm_library_for_test(name, **kwargs): kt_jvm_library( diff --git a/tests/analysis/jvm_compile_test.bzl b/tests/analysis/jvm_compile_test.bzl index b361f5a..a8fd460 100644 --- a/tests/analysis/jvm_compile_test.bzl +++ b/tests/analysis/jvm_compile_test.bzl @@ -22,6 +22,7 @@ load("//toolchains/kotlin_jvm:java_toolchains.bzl", "java_toolchains") load("//toolchains/kotlin_jvm:kt_jvm_toolchains.bzl", "kt_jvm_toolchains") load("@bazel_skylib//rules:build_test.bzl", "build_test") load(":assert_failure_test.bzl", "assert_failure_test") +load("//:visibility.bzl", "RULES_KOTLIN") def _impl(ctx): # As additional capabilites need to be tested, this rule should support diff --git a/tests/analysis/jvm_import_test.bzl b/tests/analysis/jvm_import_test.bzl index a3bfd19..6e56c02 100644 --- a/tests/analysis/jvm_import_test.bzl +++ b/tests/analysis/jvm_import_test.bzl @@ -19,6 +19,7 @@ load("//kotlin:jvm_library.bzl", "kt_jvm_library") load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts") load("//tests/analysis:util.bzl", "ONLY_FOR_ANALYSIS_TEST_TAGS", "create_file") load(":assert_failure_test.bzl", "assert_failure_test") +load("//:visibility.bzl", "RULES_KOTLIN") def _impl(ctx): env = analysistest.begin(ctx) diff --git a/tests/analysis/jvm_library_test.bzl b/tests/analysis/jvm_library_test.bzl index 6435cc5..3053961 100644 --- a/tests/analysis/jvm_library_test.bzl +++ b/tests/analysis/jvm_library_test.bzl @@ -19,6 +19,7 @@ load("//tests/analysis:util.bzl", "ONLY_FOR_ANALYSIS_TEST_TAGS", "create_file", load("@bazel_skylib//lib:sets.bzl", "sets") load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts") load(":assert_failure_test.bzl", "assert_failure_test") +load("//:visibility.bzl", "RULES_KOTLIN") _DEFAULT_LIST = ["__default__"] diff --git a/tests/analysis/util.bzl b/tests/analysis/util.bzl index 28a31f7..1727a64 100644 --- a/tests/analysis/util.bzl +++ b/tests/analysis/util.bzl @@ -14,6 +14,8 @@ """Some utils""" +load("//:visibility.bzl", "RULES_KOTLIN") + # Mark targets that's aren't expected to build, but are needed for analysis test assertions. ONLY_FOR_ANALYSIS_TEST_TAGS = ["manual", "nobuilder", "only_for_analysis_test"] diff --git a/toolchains/kotlin_jvm/androidlint_toolchains.bzl b/toolchains/kotlin_jvm/androidlint_toolchains.bzl index 0c2fbd0..b4c2208 100644 --- a/toolchains/kotlin_jvm/androidlint_toolchains.bzl +++ b/toolchains/kotlin_jvm/androidlint_toolchains.bzl @@ -15,6 +15,7 @@ """Android Lint toolchain for Kotlin.""" load("//bazel:stubs.bzl", "lint_actions") +load("//:visibility.bzl", "RULES_KOTLIN") _ATTRS = dict( _android_lint_baseline_file = attr.label( diff --git a/toolchains/kotlin_jvm/java_toolchains.bzl b/toolchains/kotlin_jvm/java_toolchains.bzl index 63dec4e..74095de 100644 --- a/toolchains/kotlin_jvm/java_toolchains.bzl +++ b/toolchains/kotlin_jvm/java_toolchains.bzl @@ -14,6 +14,8 @@ """Java toolchain for Kotlin.""" +load("//:visibility.bzl", "RULES_DEFS_THAT_COMPILE_KOTLIN") + _ATTRS = dict( _java_toolchain = attr.label( default = Label( diff --git a/toolchains/kotlin_jvm/kt_jvm_toolchains.bzl b/toolchains/kotlin_jvm/kt_jvm_toolchains.bzl index aed882f..d5dc670 100644 --- a/toolchains/kotlin_jvm/kt_jvm_toolchains.bzl +++ b/toolchains/kotlin_jvm/kt_jvm_toolchains.bzl @@ -15,6 +15,7 @@ """Kotlin toolchain.""" load("//bazel:stubs.bzl", "select_java_language_level") +load("//:visibility.bzl", "RULES_DEFS_THAT_COMPILE_KOTLIN") # Work around to toolchains in Google3. KtJvmToolchainInfo = provider() diff --git a/kotlin/visibility.bzl b/visibility.bzl index 3c3cf80..328e2e5 100644 --- a/kotlin/visibility.bzl +++ b/visibility.bzl @@ -12,9 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -"""Bzl visibility lists for JVM""" +"""Bzl visibility lists for rules_kotlin""" + +RULES_KOTLIN = ["//..."] + +TOOLS_KOTLIN = [ +] # bzl files in these packages have access to internal parts of rules_kotlin, so think carefully # before expanding the list. -RULES_DEFS_THAT_COMPILE_KOTLIN = [ +RULES_DEFS_THAT_COMPILE_KOTLIN = RULES_KOTLIN + [ ] |