Skip to content

Commit

Permalink
Make gcno-files available in CcCompilationOutputs
Browse files Browse the repository at this point in the history
This is needed to do custom code coverage rules.
  • Loading branch information
torgil authored and Torgil Svensson committed Sep 18, 2020
1 parent 49c9475 commit 78f4211
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1857,6 +1857,9 @@ private Collection<Artifact> createSourceAction(
// Host targets don't produce .dwo files.
result.addPicDwoFile(dwoFile);
}
if (gcnoFile != null) {
result.addPicGcnoFile(gcnoFile);
}
}

if (generateNoPicAction) {
Expand Down Expand Up @@ -1931,6 +1934,9 @@ private Collection<Artifact> createSourceAction(
// Host targets don't produce .dwo files.
result.addDwoFile(noPicDwoFile);
}
if (gcnoFile != null) {
result.addGcnoFile(gcnoFile);
}
}
return directOutputs.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ public class CcCompilationOutputs implements CcCompilationOutputsApi<Artifact> {
*/
private final ImmutableList<Artifact> picDwoFiles;

/**
* All .gcno files built by the target, corresponding to .o outputs.
*/
private final ImmutableList<Artifact> gcnoFiles;

/**
* All .pic.gcno files built by the target, corresponding to .pic.o outputs.
*/
private final ImmutableList<Artifact> picGcnoFiles;

/**
* All artifacts that are created if "--save_temps" is true.
*/
Expand All @@ -73,13 +83,17 @@ private CcCompilationOutputs(
LtoCompilationContext ltoCompilationContext,
ImmutableList<Artifact> dwoFiles,
ImmutableList<Artifact> picDwoFiles,
ImmutableList<Artifact> gcnoFiles,
ImmutableList<Artifact> picGcnoFiles,
NestedSet<Artifact> temps,
ImmutableList<Artifact> headerTokenFiles) {
this.objectFiles = objectFiles;
this.picObjectFiles = picObjectFiles;
this.ltoCompilationContext = ltoCompilationContext;
this.dwoFiles = dwoFiles;
this.picDwoFiles = picDwoFiles;
this.gcnoFiles = gcnoFiles;
this.picGcnoFiles = picGcnoFiles;
this.temps = temps;
this.headerTokenFiles = headerTokenFiles;
}
Expand Down Expand Up @@ -129,6 +143,30 @@ public ImmutableList<Artifact> getPicDwoFiles() {
return picDwoFiles;
}

/**
* Returns an unmodifiable view of the .dwo files set.
*/
public ImmutableList<Artifact> getGcnoFiles() {
return gcnoFiles;
}

/**
* Returns an unmodifiable view of the .pic.dwo files set.
*/
public ImmutableList<Artifact> getPicGcnoFiles() {
return picGcnoFiles;
}

@Override
public Sequence<Artifact> getStarlarkGcnoFiles() throws EvalException {
return StarlarkList.immutableCopyOf(getGcnoFiles());
}

@Override
public Sequence<Artifact> getStarlarkPicGcnoFiles() throws EvalException {
return StarlarkList.immutableCopyOf(getPicGcnoFiles());
}

/**
* Returns an unmodifiable view of the temp files set.
*/
Expand Down Expand Up @@ -166,6 +204,8 @@ public static final class Builder {
new LtoCompilationContext.Builder();
private final Set<Artifact> dwoFiles = new LinkedHashSet<>();
private final Set<Artifact> picDwoFiles = new LinkedHashSet<>();
private final Set<Artifact> gcnoFiles = new LinkedHashSet<>();
private final Set<Artifact> picGcnoFiles = new LinkedHashSet<>();
private final NestedSetBuilder<Artifact> temps = NestedSetBuilder.stableOrder();
private final Set<Artifact> headerTokenFiles = new LinkedHashSet<>();

Expand All @@ -180,6 +220,8 @@ public CcCompilationOutputs build() {
ltoCompilationContext.build(),
ImmutableList.copyOf(dwoFiles),
ImmutableList.copyOf(picDwoFiles),
ImmutableList.copyOf(gcnoFiles),
ImmutableList.copyOf(picGcnoFiles),
temps.build(),
ImmutableList.copyOf(headerTokenFiles));
}
Expand All @@ -189,6 +231,8 @@ public Builder merge(CcCompilationOutputs outputs) {
this.picObjectFiles.addAll(outputs.picObjectFiles);
this.dwoFiles.addAll(outputs.dwoFiles);
this.picDwoFiles.addAll(outputs.picDwoFiles);
this.gcnoFiles.addAll(outputs.gcnoFiles);
this.picGcnoFiles.addAll(outputs.picGcnoFiles);
this.temps.addTransitive(outputs.temps);
this.headerTokenFiles.addAll(outputs.headerTokenFiles);
this.ltoCompilationContext.addAll(outputs.ltoCompilationContext);
Expand Down Expand Up @@ -251,6 +295,16 @@ public Builder addPicDwoFile(Artifact artifact) {
return this;
}

public Builder addGcnoFile(Artifact artifact) {
gcnoFiles.add(artifact);
return this;
}

public Builder addPicGcnoFile(Artifact artifact) {
picGcnoFiles.add(artifact);
return this;
}

/**
* Adds temp files.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,18 @@ public interface CcCompilationOutputsApi<FileT extends FileApi> extends Starlark
documented = true,
structField = true)
Sequence<FileT> getStarlarkPicObjects() throws EvalException;

@StarlarkMethod(
name = "gcno_files",
doc = "Non-PIC gcno files.",
documented = true,
structField = true)
Sequence<FileT> getStarlarkGcnoFiles() throws EvalException;

@StarlarkMethod(
name = "pic_gcno_files",
doc = "PIC gcno files.",
documented = true,
structField = true)
Sequence<FileT> getStarlarkPicGcnoFiles() throws EvalException;
}

0 comments on commit 78f4211

Please sign in to comment.