Skip to content

Commit

Permalink
Make coverage collection work for Buck2 + Kotlin
Browse files Browse the repository at this point in the history
Summary: Kotlin tests weren't generating the `class_to_src_map` data needed to support coverage.

Reviewed By: IanChilds

Differential Revision: D44811189

fbshipit-source-id: 3bf76c4c72abcfda295a6653b5535c857cb7c9e2
  • Loading branch information
loganwendholt authored and facebook-github-bot committed Apr 13, 2023
1 parent 8fb6742 commit c341dea
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions kotlin/kotlin_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ load(
)
load("@prelude//java/plugins:java_annotation_processor.bzl", "create_ap_params", "create_ksp_ap_params")
load("@prelude//java/plugins:java_plugin.bzl", "create_plugin_params")
load("@prelude//java/utils:java_utils.bzl", "derive_javac", "get_abi_generation_mode", "get_default_info", "get_java_version_attributes", "get_path_separator")
load("@prelude//java/utils:java_utils.bzl", "derive_javac", "get_abi_generation_mode", "get_class_to_source_map_info", "get_default_info", "get_java_version_attributes", "get_path_separator")
load(
"@prelude//kotlin:kotlin_toolchain.bzl",
"KotlinToolchainInfo",
Expand Down Expand Up @@ -374,6 +374,13 @@ def build_kotlin_library(
has_srcs = bool(srcs),
)

class_to_src_map, class_to_src_map_sub_targets = get_class_to_source_map_info(
ctx,
outputs = outputs,
deps = ctx.attrs.deps + deps_query + ctx.attrs.exported_deps,
)
extra_sub_targets = extra_sub_targets | class_to_src_map_sub_targets

default_info = get_default_info(outputs, extra_sub_targets = extra_sub_targets)
return JavaProviders(
java_library_info = java_library_info,
Expand All @@ -383,7 +390,7 @@ def build_kotlin_library(
cxx_resource_info = cxx_resource_info,
template_placeholder_info = template_placeholder_info,
default_info = default_info,
class_to_src_map = None,
class_to_src_map = class_to_src_map,
)
else:
fail("unrecognized kotlinc protocol `{}`".format(kotlin_toolchain.kotlinc_protocol))

0 comments on commit c341dea

Please sign in to comment.