Skip to content

Commit

Permalink
Remove unnecessary Java runtime dependencies
Browse files Browse the repository at this point in the history
`kt_jvm_library` no longer depends on a Java runtime for the target
platform, which ensures that cross-platform builds targeting platforms
without standalone Java runtimes (e.g. Android) can succeed without
hacks (currently, Bazel's local_jdk is marked as compatible with any
target platform, but that will change in the future).
  • Loading branch information
fmeum committed Aug 10, 2023
1 parent d584c43 commit c57a3c8
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions kotlin/internal/jvm/jvm.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ _implicit_deps = {
default = Label("@bazel_tools//tools/jdk:current_java_runtime"),
cfg = "exec",
),
}

_runnable_implicit_deps = {
"_java_runtime": attr.label(
default = Label("@bazel_tools//tools/jdk:current_java_runtime"),
),
Expand Down Expand Up @@ -269,7 +272,7 @@ this is not transitive""",
),
})

_runnable_common_attr = utils.add_dicts(_common_attr, {
_runnable_common_attr = utils.add_dicts(_common_attr, _runnable_implicit_deps, {
"jvm_flags": attr.string_list(
doc = """A list of flags to embed in the wrapper script generated for running this binary. Note: does not yet
support make variable substitution.""",
Expand All @@ -287,6 +290,9 @@ _common_outputs = dict(
_common_toolchains = [
_TOOLCHAIN_TYPE,
_JAVA_TOOLCHAIN_TYPE,
]

_runnable_common_toolchains = [
_JAVA_RUNTIME_TOOLCHAIN_TYPE,
]

Expand Down Expand Up @@ -318,7 +324,7 @@ It is appropriate for building workspace utilities. `java_binary` should be pref
}.items()),
executable = True,
outputs = _common_outputs,
toolchains = _common_toolchains,
toolchains = _common_toolchains + _runnable_common_toolchains,
fragments = ["java"], # Required fragments of the target configuration
host_fragments = ["java"], # Required fragments of the host configuration
implementation = _kt_jvm_binary_impl,
Expand Down Expand Up @@ -353,7 +359,7 @@ Setup a simple kotlin_test.
executable = True,
outputs = _common_outputs,
test = True,
toolchains = _common_toolchains,
toolchains = _common_toolchains + _runnable_common_toolchains,
implementation = _kt_jvm_junit_test_impl,
fragments = ["java"], # Required fragments of the target configuration
host_fragments = ["java"], # Required fragments of the host configuration
Expand Down

0 comments on commit c57a3c8

Please sign in to comment.