Skip to content

Commit

Permalink
Cleanup lint, etc
Browse files Browse the repository at this point in the history
  • Loading branch information
restingbull committed Mar 27, 2024
1 parent 750b660 commit 904776b
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 28 deletions.
27 changes: 26 additions & 1 deletion docs/kotlin.md
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ kt_compiler_plugin(<a href="#kt_compiler_plugin-name">name</a>, <a href="#kt_com
|<a id="kt_compiler_plugin-compile_phase"></a>compile_phase | Runs the compiler plugin during kotlin compilation. Known examples: <code>allopen</code>, <code>sam_with_reciever</code> | Boolean | optional | True |
|<a id="kt_compiler_plugin-deps"></a>deps | The list of libraries to be added to the compiler's plugin classpath | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | [] |
|<a id="kt_compiler_plugin-id"></a>id | The ID of the plugin | String | required | |
|<a id="kt_compiler_plugin-options"></a>options | Dictionary of options to be passed to the plugin. Supports the following template values:<br><br>- <code>{generatedClasses}</code>: directory for generated class output - <code>{temp}</code>: temporary directory, discarded between invocations - <code>{generatedSources}</code>: directory for generated source output | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional | {} |
|<a id="kt_compiler_plugin-options"></a>options | Dictionary of options to be passed to the plugin. Supports the following template values:<br><br>- <code>{generatedClasses}</code>: directory for generated class output - <code>{temp}</code>: temporary directory, discarded between invocations - <code>{generatedSources}</code>: directory for generated source output - <code>{classpath}</code> : replaced with a list of jars separated by the filesystem appropriate separator. | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional | {} |
|<a id="kt_compiler_plugin-stubs_phase"></a>stubs_phase | Runs the compiler plugin in kapt stub generation. | Boolean | optional | True |
|<a id="kt_compiler_plugin-target_embedded_compiler"></a>target_embedded_compiler | Plugin was compiled against the embeddable kotlin compiler. These plugins expect shaded kotlinc dependencies, and will fail when running against a non-embeddable compiler. | Boolean | optional | False |

Expand Down Expand Up @@ -482,6 +482,31 @@ kt_ksp_plugin(<a href="#kt_ksp_plugin-name">name</a>, <a href="#kt_ksp_plugin-de
|<a id="kt_ksp_plugin-processor_class"></a>processor_class | The fully qualified class name that the Java compiler uses as an entry point to the annotation processor. | String | required | |


<a id="#kt_plugin_cfg"></a>

## kt_plugin_cfg

kt_plugin_cfg(<a href="#kt_plugin_cfg-name">name</a>, <a href="#kt_plugin_cfg-deps">deps</a>, <a href="#kt_plugin_cfg-options">options</a>, <a href="#kt_plugin_cfg-plugin">plugin</a>)

Configurations for kt_compiler_plugin, ksp_plugin, and java_plugin.
This allows setting options and dependencies independently from the initial plugin definition.


**ATTRIBUTES**


| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
|<a id="kt_plugin_cfg-name"></a>name | A unique name for this target. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | |
|<a id="kt_plugin_cfg-deps"></a>deps | Dependencies for this configuration. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | [] |
|<a id="kt_plugin_cfg-options"></a>options | A dictionary of flag to values to be used as plugin configuration options. | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> List of strings</a> | optional | {} |
|<a id="kt_plugin_cfg-plugin"></a>plugin | The plugin to associate with this configuration | <a href="https://bazel.build/concepts/labels">Label</a> | required | |


<a id="define_kt_toolchain"></a>

## define_kt_toolchain
Expand Down
1 change: 1 addition & 0 deletions kotlin/internal/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ bzl_library(
"//kotlin/internal/lint",
"//kotlin/internal/utils",
"//src/main/starlark",
"//src/main/starlark/core/options",
"@rules_java//java:rules",
],
)
5 changes: 3 additions & 2 deletions kotlin/internal/jvm/jvm.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,9 @@ _common_attr = utils.add_dicts(
cfg = "exec",
providers = [
[JavaPluginInfo],
[_KtJvmInfo],
[KtPluginConfiguration],
[_KspPluginInfo],
[_KtCompilerPluginInfo],
[_KtCompilerPluginInfo],
],
),
Expand Down Expand Up @@ -461,7 +462,7 @@ Compiler plugins listed here will be treated as if they were added in the plugin
attribute of any targets that directly depend on this target. Unlike java_plugins'
exported_plugins, this is not transitive""",
default = [],
providers = [[_KtCompilerPluginInfo], [KtPluginConfiguration]],
providers = [[_KtCompilerPluginInfo], [KtPluginConfiguration], [_KspPluginInfo]],
),
"neverlink": attr.bool(
doc = """If true only use this library for compilation and not at runtime.""",
Expand Down
2 changes: 1 addition & 1 deletion scripts/install_android_sdk
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if which brew; then
brew install --cask android-commandlinetools
sudo mkdir /usr/local/android-sdk
sudo chown "$USER" /usr/local/android-sdk
sdkmanager --sdk_root=/usr/local/android-sdk "platform-tools" "platforms;android-33" "platforms;android-31" "build-tools;33.0.0" "emulator" "build-tools;30.0.3"
sdkmanager --sdk_root=/usr/local/android-sdk "platform-tools" "platforms;android-33" "platforms;android-31" "build-tools;33.0.0" "emulator" "build-tools;30.0.3" "ndk-bundle"
else
echo "home brew not installed, unsupported. Here is a chance to improve the script!"
fi
9 changes: 5 additions & 4 deletions scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ if test ! -d examples; then
fail "unable to find example directory: $PWD"
fi

# generate stardoc
bazel build //kotlin:stardoc || fail "docs did not generate"

cp -f bazel-bin/kotlin/kotlin.md docs/ || fail "couldn't copy"

bazel test //...:all || fail "tests failed"

# build release
Expand Down Expand Up @@ -74,10 +79,6 @@ done
# clean up
rm -rf $ARCHIVE_DIR

# generate stardoc
bazel build //kotlin:stardoc || fail "docs did not generate"

cp -f bazel-bin/kotlin/kotlin.md docs/ || fail "couldn't copy"

echo "Release artifact is good:"
echo " bazel-bin/rules_kotlin_release.tgz"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ internal fun JvmCompilationTask.plugins(
"{stubs}" to directories.stubs,
"{temp}" to directories.temp,
"{generatedSources}" to directories.generatedSources,
"{classpath}" to classpath.joinToString(File.pathSeparator)
"{classpath}" to classpath.joinToString(File.pathSeparator),
)
options.forEach { opt ->
val formatted = optionTokens.entries.fold(opt) { formatting, (token, value) ->
Expand Down
16 changes: 8 additions & 8 deletions src/main/starlark/core/options/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ release_archive(
},
)

#bzl_library(
# name = "options",
# srcs = glob(["*.bzl"]),
# visibility = ["//:__subpackages__"],
# deps = [
# "@com_github_jetbrains_kotlin//:capabilities",
# ],
#)
bzl_library(
name = "options",
srcs = glob(["*.bzl"]),
visibility = ["//:__subpackages__"],
deps = [
"@com_github_jetbrains_kotlin//:capabilities",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
package(default_visibility = ["//visibility:public"])

load("@bazel_skylib//:bzl_library.bzl", "bzl_library")

package(default_visibility = ["//visibility:public"])

# Kotlin home filegroup containing everything that is needed.
filegroup(
name = "home",
Expand Down
1 change: 0 additions & 1 deletion src/test/starlark/case.bzl
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
load("@rules_testing//lib:util.bzl", "util")
load("@rules_testing//lib:test_suite.bzl", "test_suite")

def _prepend(rule, name, **kwargs):
util.helper_target(
Expand Down
14 changes: 6 additions & 8 deletions src/test/starlark/core/plugin/test.bzl
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
load("//src/main/starlark/core/plugin:providers.bzl", "KspPluginInfo", "KtCompilerPluginInfo", "KtPluginConfiguration")
load("@rules_testing//lib:analysis_test.bzl", "analysis_test")
load("@rules_testing//lib:util.bzl", "util")
load("//kotlin:core.bzl", "kt_compiler_plugin", "kt_plugin_cfg")
load("//kotlin:jvm.bzl", "kt_jvm_import", "kt_jvm_library")
load("@rules_testing//lib:truth.bzl", "subjects")
load("//src/main/starlark/core/plugin:providers.bzl", "KtCompilerPluginInfo", "KtPluginConfiguration")
load("//src/test/starlark:case.bzl", "suite")
load("//src/test/starlark:truth.bzl", "fail_messages_in", "flags_and_values_of")
load(":subjects.bzl", "plugin_configuration_subject_factory")
Expand Down Expand Up @@ -83,7 +81,7 @@ def _test_kt_plugin_cfg(test):
name = "got",
plugin = plugin,
options = {
"extra": "annotation",
"extra": ["annotation"],
},
deps = [
cfg_dep,
Expand Down Expand Up @@ -140,7 +138,7 @@ def _test_compile_configuration(test):
name = "cfg",
plugin = plugin,
options = {
"-Dop": "koo",
"-Dop": ["koo"],
},
deps = [
test.have(
Expand Down Expand Up @@ -211,7 +209,7 @@ def _test_compile_configuration_single_phase(test):
name = "stub_cfg",
plugin = stub,
options = {
"-Dop": "stub_only",
"-Dop": ["stub_only"],
},
)

Expand All @@ -220,7 +218,7 @@ def _test_compile_configuration_single_phase(test):
name = "compile_cfg",
plugin = compile,
options = {
"-Dop": "compile_only",
"-Dop": ["compile_only"],
},
)

Expand Down Expand Up @@ -339,7 +337,7 @@ def _test_cfg_without_plugin(test):
name = "adee_cfg",
plugin = adee,
options = {
"-Dop": "compile_only",
"-Dop": ["compile_only"],
},
)

Expand Down

0 comments on commit 904776b

Please sign in to comment.