Skip to content

Commit

Permalink
Add InstrumentedFilesInfo created from Java
Browse files Browse the repository at this point in the history
The Starlark API is not powerful enough yet to do the same thing.

RELNOTES:none
PiperOrigin-RevId: 384237566
  • Loading branch information
oquenchil authored and copybara-github committed Jul 12, 2021
1 parent 6501f30 commit c5c15f9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,13 @@ public InstrumentedFilesInfo getInstrumentedFilesProviderForStarlark() {
* @param objectFiles the object files generated by this target
* @return an instrumented files provider
*/
public InstrumentedFilesInfo getInstrumentedFilesProvider(ImmutableList<Artifact> objectFiles) {
protected InstrumentedFilesInfo getInstrumentedFilesProvider(
ImmutableList<Artifact> objectFiles) {
return getInstrumentedFilesProvider(ruleContext, objectFiles);
}

protected static InstrumentedFilesInfo getInstrumentedFilesProvider(
RuleContext ruleContext, ImmutableList<Artifact> objectFiles) {
return InstrumentedFilesCollector.collect(
ruleContext,
INSTRUMENTATION_SPEC,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.google.devtools.build.lib.analysis.TemplateVariableInfo;
import com.google.devtools.build.lib.analysis.TransitiveInfoCollection;
import com.google.devtools.build.lib.analysis.starlark.StarlarkRuleContext;
import com.google.devtools.build.lib.analysis.test.InstrumentedFilesInfo;
import com.google.devtools.build.lib.packages.NativeInfo;
import com.google.devtools.build.lib.packages.RuleClass.ConfiguredTargetFactory.RuleErrorException;
import com.google.devtools.build.lib.packages.Type;
Expand Down Expand Up @@ -252,4 +253,18 @@ public CompilationSupport createCompilationSupport(
throw new EvalException(e);
}
}

@StarlarkMethod(
name = "instrumented_files_info",
documented = false,
parameters = {
@Param(name = "ctx", positional = false, named = true),
@Param(name = "object_files", positional = false, defaultValue = "[]", named = true),
})
public InstrumentedFilesInfo createInstrumentedFilesInfo(
StarlarkRuleContext starlarkRuleContext, Sequence<?> objectFiles) throws EvalException {
return CompilationSupport.getInstrumentedFilesProvider(
starlarkRuleContext.getRuleContext(),
Sequence.cast(objectFiles, Artifact.class, "object_files").getImmutableList());
}
}
8 changes: 1 addition & 7 deletions src/main/starlark/builtins_bzl/common/objc/objc_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -166,19 +166,13 @@ def _objc_library_impl(ctx):
linking_context = linking_context,
)

instrumented_files_info = coverage_common.instrumented_files_info(
ctx = ctx,
source_attributes = ["srcs", "non_arc_srcs", "hdrs"],
dependency_attributes = ["deps", "data", "binary", "xctest_app"],
)

return [
DefaultInfo(files = depset(files), data_runfiles = ctx.runfiles(files = files)),
cc_info,
objc_provider,
j2objc_providers[0],
j2objc_providers[1],
instrumented_files_info,
objc_internal.instrumented_files_info(ctx = ctx, object_files = compilation_outputs.objects),
output_group_info,
]

Expand Down

0 comments on commit c5c15f9

Please sign in to comment.