Skip to content
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
8 changes: 4 additions & 4 deletions kotlin/internal/jvm/impl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,13 @@ def kt_jvm_library_impl(ctx):
)
return _make_providers(
ctx,
_compile.kt_jvm_produce_jar_actions(ctx, "kt_jvm_library") if ctx.attr.srcs or ctx.attr.resources else _compile.export_only_providers(
providers = _compile.kt_jvm_produce_jar_actions(ctx, "kt_jvm_library") if ctx.attr.srcs or ctx.attr.resources else _compile.export_only_providers(
ctx = ctx,
actions = ctx.actions,
outputs = ctx.outputs,
attr = ctx.attr,
),
runfiles_targets = ctx.attr.deps + ctx.attr.exports,
runfiles_targets = ctx.attr.deps + ctx.attr.exports + ctx.attr.runtime_deps + ctx.attr.data,
)

def kt_jvm_binary_impl(ctx):
Expand All @@ -251,12 +251,12 @@ def kt_jvm_binary_impl(ctx):
return _make_providers(
ctx,
providers,
runfiles_targets = ctx.attr.deps,
transitive_files = depset(
order = "default",
transitive = [providers.java.transitive_runtime_jars],
direct = ctx.files._java_runtime,
),
runfiles_targets = ctx.attr.deps + ctx.attr.runtime_deps + ctx.attr.data,
)

_SPLIT_STRINGS = [
Expand Down Expand Up @@ -308,7 +308,7 @@ def kt_jvm_junit_test_impl(ctx):
return _make_providers(
ctx,
providers,
ctx.attr.deps,
ctx.attr.deps + ctx.attr.runtime_deps + ctx.attr.data,
depset(
order = "default",
transitive = [runtime_jars, depset(coverage_runfiles), depset(coverage_metadata)],
Expand Down
4 changes: 2 additions & 2 deletions src/main/starlark/core/compile/rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def _kt_jvm_library_impl(ctx):
files = ctx.files.data,
).merge_all([
d[DefaultInfo].default_runfiles
for d in ctx.attr.deps + ctx.attr.exports
for d in ctx.attr.deps + ctx.attr.exports + ctx.attr.data + ctx.attr.runtime_deps
if DefaultInfo in d
]),
),
Expand Down Expand Up @@ -166,7 +166,7 @@ def _kt_jvm_binary_impl(ctx):
transitive_files = launch_runfiles,
).merge_all([
d[DefaultInfo].default_runfiles
for d in ctx.attr.deps
for d in ctx.attr.deps + ctx.attr.data + ctx.attr.runtime_deps
if DefaultInfo in d
]),
executable = executable,
Expand Down
95 changes: 90 additions & 5 deletions src/test/starlark/compile/rule_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,91 @@ def _test_neverlink_deps(

return _case

def _test_deps_core(
def _test_runfiles(
rule_under_test,
compile_mnemonic,
srcjar_ext = ".srcjar",
additional_compile_libs = [],
**kwargs):
def _case(test):
transitive_data_file = test.artifact("transitive_data.file")
transitive_data = test.have(
rule_under_test,
name = "transitive_data",
srcs = [],
deps = [],
data = [transitive_data_file],
**kwargs
)
data_file = test.artifact("data.file")
data = test.have(
rule_under_test,
name = "data",
srcs = [],
runtime_deps = [transitive_data],
data = [data_file],
**kwargs
)

got = test.got(
rule_under_test,
name = "got",
srcs = [
test.artifact("gave.kt"),
],
deps = [
data,
],
**kwargs
)
test.claim(
got = got,
what = _outputs,
wants = {
"class_jar": Want(
attr = attr.label(allow_single_file = True),
value = got + ".jar",
),
"source_jar": Want(
attr = attr.label(allow_single_file = True),
value = got + srcjar_ext,
),
"inputs": Want(
attr = attr.label_list(allow_empty = True, allow_files = True),
value = [data],
),
"transitive_compile_deps": Want(
attr = attr.label_list(providers = [[JavaInfo], [KtJvmInfo]]),
value = [data, got] + additional_compile_libs,
),
"transitive_runtime_deps": Want(
attr = attr.label_list(providers = [[JavaInfo], [KtJvmInfo]]),
value = [got],
),
"compile_mnemonic": Want(
attr = attr.string(),
value = compile_mnemonic,
),
"runfiles": Want(
attr = attr.label_list(allow_empty = True, allow_files = True),
value = [
data_file,
transitive_data_file,
],
),
},
)

return _case

def _test_deps(
rule_under_test,
compile_mnemonic,
srcjar_ext = ".srcjar",
additional_compile_libs = [],
**kwargs):
def _case(test):
have_data = test.artifact("some.file")
have = test.have(
rule_under_test,
name = "have",
Expand All @@ -137,6 +215,9 @@ def _test_deps_core(
],
deps = [
],
data = [
have_data,
],
**kwargs
)

Expand Down Expand Up @@ -181,7 +262,9 @@ def _test_deps_core(
),
"runfiles": Want(
attr = attr.label_list(allow_empty = True, allow_files = True),
value = [],
value = [
have_data,
],
),
},
)
Expand Down Expand Up @@ -338,13 +421,14 @@ def test_core():
compile_mnemonic = COMPILE_MNEMONIC,
)
return dict(
test_deps_core_kt_jvm_binary = _test_deps_core(**binary),
test_deps_core_kt_jvm_binary = _test_deps(**binary),
test_neverlink_deps_core_kt_jvm_binary = _test_neverlink_deps(**binary),
test_no_deps_core_kt_jvm_binary = _test_no_deps(**binary),
test_deps_core_kt_jvm_library = _test_deps_core(**library),
test_deps_core_kt_jvm_library = _test_deps(**library),
test_neverlink_deps_core_kt_jvm_library = _test_neverlink_deps(**library),
test_no_deps_core_kt_jvm_library = _test_no_deps(**library),
test_exports_core_kt_jvm_library = _test_exports(**library),
test_runfiles_core = _test_runfiles(**library),
)

def test_jvm():
Expand All @@ -360,10 +444,11 @@ def test_jvm():
],
)
return dict(
test_deps_kt_jvm_library = _test_deps_core(**library),
test_deps_kt_jvm_library = _test_deps(**library),
test_neverlink_deps_kt_jvm_library = _test_neverlink_deps(**library),
test_no_deps_kt_jvm_library = _test_no_deps(**library),
test_exports_kt_jvm_library = _test_exports(**library),
test_runfiles = _test_runfiles(**library),
)

def test_suite(name):
Expand Down