Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return providers array instead of legacy struct #916

Merged
merged 8 commits into from
Jan 16, 2020
18 changes: 6 additions & 12 deletions scala/private/phases/phase_final.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,26 @@
# DOCUMENT THIS
#
def phase_binary_final(ctx, p):
return struct(
defaultInfo = DefaultInfo(
executable = p.declare_executable,
coverage = p.compile.coverage,
files = depset([p.declare_executable, ctx.outputs.jar]),
instrumented_files = p.compile.coverage.instrumented_files,
providers = [p.compile.merged_provider, p.collect_jars.jars2labels] + p.compile.coverage.providers,
runfiles = p.runfiles.runfiles,
transitive_rjars = p.compile.rjars, #calling rules need this for the classpath in the launcher
)
return [defaultInfo, p.compile.merged_provider, p.collect_jars.jars2labels] + p.compile.coverage.providers

def phase_library_final(ctx, p):
return struct(
defaultInfo = DefaultInfo(
files = depset([ctx.outputs.jar] + p.compile.full_jars), # Here is the default output
instrumented_files = p.compile.coverage.instrumented_files,
jars_to_labels = p.collect_jars.jars2labels,
providers = [p.compile.merged_provider, p.collect_jars.jars2labels] + p.compile.coverage.providers,
runfiles = p.runfiles.runfiles,
)
return [defaultInfo, p.compile.merged_provider, p.collect_jars.jars2labels] + p.compile.coverage.providers

def phase_scalatest_final(ctx, p):
coverage_runfiles = p.coverage_runfiles.coverage_runfiles
coverage_runfiles.extend(p.write_executable)
return struct(
defaultInfo = DefaultInfo(
executable = p.declare_executable,
files = depset([p.declare_executable, ctx.outputs.jar]),
instrumented_files = p.compile.coverage.instrumented_files,
providers = [p.compile.merged_provider, p.collect_jars.jars2labels] + p.compile.coverage.providers,
runfiles = ctx.runfiles(coverage_runfiles, transitive_files = p.runfiles.runfiles.files),
)
return [defaultInfo, p.compile.merged_provider, p.collect_jars.jars2labels] + p.compile.coverage.providers
16 changes: 8 additions & 8 deletions scala/private/rule_impls.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ _scala_extension = ".scala"
_srcjar_extension = ".srcjar"

_empty_coverage_struct = struct(
instrumented_files = struct(),
instrumented_files = None,
providers = [],
replacements = {},
)
Expand Down Expand Up @@ -871,14 +871,14 @@ def _jacoco_offline_instrument(ctx, input_jar):
provider = _coverage_replacements_provider.create(
replacements = replacements,
)

instrumented_files_provider = coverage_common.instrumented_files_info(
ctx,
source_attributes = ["srcs"],
dependency_attributes = _coverage_replacements_provider.dependency_attributes,
extensions = ["scala", "java"],
)
return struct(
instrumented_files = struct(
dependency_attributes = _coverage_replacements_provider.dependency_attributes,
extensions = ["scala", "java"],
source_attributes = ["srcs"],
),
providers = [provider],
providers = [provider, instrumented_files_provider],
replacements = replacements,
)

Expand Down
17 changes: 6 additions & 11 deletions scala/scala_import.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,13 @@ def _scala_import_impl(ctx):
# TODO(#8867): Migrate away from the placeholder jar hack when #8867 is fixed.
current_target_providers = [_new_java_info(ctx, ctx.file._placeholder_jar)]

return struct(
scala = struct(
outputs = struct(jars = intellij_metadata),
return [
java_common.merge(current_target_providers),
DefaultInfo(
files = current_jars,
),
providers = [
java_common.merge(current_target_providers),
DefaultInfo(
files = current_jars,
),
JarsToLabelsInfo(jars_to_labels = jars2labels),
],
)
JarsToLabelsInfo(jars_to_labels = jars2labels),
]

def _new_java_info(ctx, jar):
return JavaInfo(
Expand Down