@Override
public ArtifactSet link(TreeLogger logger, LinkerContext context,
ArtifactSet artifacts, boolean onePermutation)
throws UnableToCompleteException {
if (onePermutation) {
ArtifactSet toReturn = new ArtifactSet(artifacts);
ArtifactSet writableArtifacts = new ArtifactSet(artifacts);
/*
* Support having multiple compilation results because this method is also
* called from the legacy link method.
*/
for (CompilationResult compilation : toReturn.find(CompilationResult.class)) {
// pass a writable set so that other stages can use this set for temporary storage
toReturn.addAll(doEmitCompilation(logger, context, compilation, writableArtifacts));
maybeAddHostedModeFile(logger, context, toReturn, compilation);
}
/*
* Find edit artifacts added during linking and add them. This is done as a way of returning
* arbitrary extra outputs from within the linker methods without having to modify
* their return signatures to pass extra return data around.
*/
for (SymbolMapsLinker.ScriptFragmentEditsArtifact ea : writableArtifacts.find(
SymbolMapsLinker.ScriptFragmentEditsArtifact.class)) {
toReturn.add(ea);
}
return toReturn;
} else {
permutationsUtil.setupPermutationsMap(artifacts);
ArtifactSet toReturn = new ArtifactSet(artifacts);
EmittedArtifact art = emitSelectionScript(logger, context, artifacts);
if (art != null) {
toReturn.add(art);
}
maybeOutputPropertyMap(logger, context, toReturn);
maybeAddHostedModeFile(logger, context, toReturn, null);
return toReturn;
}