Fix AndroidDevice to never put the unified launcher's runfiles middleman in the runfiles tree.
As I understand it, this is only a theoretical issue today because
$unified_launcher is generally a flat file. (Flat files never have
runfiles middlemen.) However, it's good to be future proof.
@@ -110,16 +110,20 @@ public class AndroidDevice implements RuleConfiguredTargetFactory {
deviceAttributes.createStubScriptAction(metadata, images, executable, ruleContext);
deviceAttributes.createBootAction(metadata, images);
- Runfiles runfiles =
+ FilesToRunProvider unifiedLauncher = deviceAttributes.getUnifiedLauncher();
+ Runfiles.Builder runfilesBuilder =
new Runfiles.Builder(ruleContext.getWorkspaceName())
.addTransitiveArtifacts(filesToBuild)
.addArtifacts(commonDependencyArtifacts)
- .addRunfiles(ruleContext, RunfilesProvider.DEFAULT_RUNFILES)
- .merge(
- ruleContext
- .getExecutablePrerequisite("$unified_launcher", Mode.HOST)
- .getRunfilesSupport())
- .build();
+ .addRunfiles(ruleContext, RunfilesProvider.DEFAULT_RUNFILES);
+ if (unifiedLauncher.getRunfilesSupport() != null) {
+ runfilesBuilder
+ .merge(unifiedLauncher.getRunfilesSupport().getRunfiles())
+ .addLegacyExtraMiddleman(unifiedLauncher.getRunfilesSupport().getRunfilesMiddleman());
+ } else {
+ runfilesBuilder.addTransitiveArtifacts(unifiedLauncher.getFilesToRun());
+ }
+ Runfiles runfiles = runfilesBuilder.build();
RunfilesSupport runfilesSupport =
RunfilesSupport.withExecutable(ruleContext, runfiles, executable);
NestedSet<Artifact> extraFilesToRun =
@@ -265,7 +269,6 @@ public class AndroidDevice implements RuleConfiguredTargetFactory {
.addAll(xvfbSupportFiles)
.add(mksdcard)
.add(snapshotFs)
- .addAll(unifiedLauncher.getFilesToRun())
.addAll(androidRuntestDeps)
.addAll(testingShbaseDeps)
.addAll(platformApks)
@@ -314,6 +317,10 @@ public class AndroidDevice implements RuleConfiguredTargetFactory {
ruleContext.getActionOwner(), executable, STUB_SCRIPT, arguments, true));
}
+ public FilesToRunProvider getUnifiedLauncher() {
+ return unifiedLauncher;
+ }
+
public void createBootAction(Artifact metadata, Artifact images) {
// the boot action will run during the build so use execpath
// strings to find all dependent artifacts (there is no nicely created runfiles
