aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/android/AssetDependencies.java
diff options
context:
space:
mode:
authorGravatar asteinb <asteinb@google.com>2018-05-29 10:29:44 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-05-29 10:31:19 -0700
commit6d33f2874eb1647526557d291496e78163d94095 (patch)
treeeca449eee4152117e1edd0fa99055a60b5387600 /src/main/java/com/google/devtools/build/lib/rules/android/AssetDependencies.java
parent4b9b530d7e99582e350fa1dfc9c67114134fa1a2 (diff)
Use independently passed assets in aapt2 packaging as well
Much earlier, I made a change that allowed passing assets without resources to aapt packaging. Do the same for aapt2 packaging too. The busybox seems to be expecting compiled symbols, so compile assets and pass the compiled version in. (Compiling assets doesn't save any time, but doesn't cost much either, and means that we'll eventually be able to phase out the parsed form entirely. Adapting the Busybox to take parsed assets would probably work too, but getting the code to handle it would be really messy.) RELNOTES: none PiperOrigin-RevId: 198417111
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/android/AssetDependencies.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/AssetDependencies.java43
1 files changed, 37 insertions, 6 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AssetDependencies.java b/src/main/java/com/google/devtools/build/lib/rules/android/AssetDependencies.java
index 1cfe929fc6..531d2501cf 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/AssetDependencies.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/AssetDependencies.java
@@ -37,6 +37,7 @@ public class AssetDependencies {
private final NestedSet<ParsedAndroidAssets> transitiveParsedAssets;
private final NestedSet<Artifact> transitiveAssets;
private final NestedSet<Artifact> transitiveSymbols;
+ private final NestedSet<Artifact> transitiveCompiledSymbols;
public static AssetDependencies fromRuleDeps(RuleContext ruleContext, boolean neverlink) {
return fromProviders(
@@ -51,15 +52,23 @@ public class AssetDependencies {
NestedSetBuilder<ParsedAndroidAssets> transitive = NestedSetBuilder.naiveLinkOrder();
NestedSetBuilder<Artifact> assets = NestedSetBuilder.naiveLinkOrder();
NestedSetBuilder<Artifact> symbols = NestedSetBuilder.naiveLinkOrder();
+ NestedSetBuilder<Artifact> compiledSymbols = NestedSetBuilder.naiveLinkOrder();
for (AndroidAssetsInfo info : providers) {
direct.addTransitive(info.getDirectParsedAssets());
transitive.addTransitive(info.getTransitiveParsedAssets());
assets.addTransitive(info.getAssets());
symbols.addTransitive(info.getSymbols());
+ compiledSymbols.addTransitive(info.getCompiledSymbols());
}
- return of(neverlink, direct.build(), transitive.build(), assets.build(), symbols.build());
+ return of(
+ neverlink,
+ direct.build(),
+ transitive.build(),
+ assets.build(),
+ symbols.build(),
+ compiledSymbols.build());
}
public static AssetDependencies empty() {
@@ -68,6 +77,7 @@ public class AssetDependencies {
NestedSetBuilder.emptySet(Order.NAIVE_LINK_ORDER),
NestedSetBuilder.emptySet(Order.NAIVE_LINK_ORDER),
NestedSetBuilder.emptySet(Order.NAIVE_LINK_ORDER),
+ NestedSetBuilder.emptySet(Order.NAIVE_LINK_ORDER),
NestedSetBuilder.emptySet(Order.NAIVE_LINK_ORDER));
}
@@ -77,9 +87,15 @@ public class AssetDependencies {
NestedSet<ParsedAndroidAssets> directParsedAssets,
NestedSet<ParsedAndroidAssets> transitiveParsedAssets,
NestedSet<Artifact> transitiveAssets,
- NestedSet<Artifact> transitiveSymbols) {
+ NestedSet<Artifact> transitiveSymbols,
+ NestedSet<Artifact> transitiveCompiledSymbols) {
return new AssetDependencies(
- neverlink, directParsedAssets, transitiveParsedAssets, transitiveAssets, transitiveSymbols);
+ neverlink,
+ directParsedAssets,
+ transitiveParsedAssets,
+ transitiveAssets,
+ transitiveSymbols,
+ transitiveCompiledSymbols);
}
private AssetDependencies(
@@ -87,12 +103,14 @@ public class AssetDependencies {
NestedSet<ParsedAndroidAssets> directParsedAssets,
NestedSet<ParsedAndroidAssets> transitiveParsedAssets,
NestedSet<Artifact> transitiveAssets,
- NestedSet<Artifact> transitiveSymbols) {
+ NestedSet<Artifact> transitiveSymbols,
+ NestedSet<Artifact> transitiveCompiledSymbols) {
this.neverlink = neverlink;
this.directParsedAssets = directParsedAssets;
this.transitiveParsedAssets = transitiveParsedAssets;
this.transitiveAssets = transitiveAssets;
this.transitiveSymbols = transitiveSymbols;
+ this.transitiveCompiledSymbols = transitiveCompiledSymbols;
}
/** Creates a new AndroidAssetInfo using the passed assets as the direct dependency. */
@@ -104,6 +122,13 @@ public class AssetDependencies {
// Create a new object to avoid passing around unwanted merge information to the provider
ParsedAndroidAssets parsedAssets = new ParsedAndroidAssets(assets);
+ NestedSetBuilder<Artifact> transitiveCompiledSymbolsBuilder =
+ NestedSetBuilder.<Artifact>naiveLinkOrder().addTransitive(transitiveCompiledSymbols);
+
+ if (assets.getCompiledSymbols() != null) {
+ transitiveCompiledSymbolsBuilder.add(assets.getCompiledSymbols());
+ }
+
return AndroidAssetsInfo.of(
assets.getLabel(),
assets.getMergedAssets(),
@@ -119,7 +144,8 @@ public class AssetDependencies {
NestedSetBuilder.<Artifact>naiveLinkOrder()
.addTransitive(transitiveSymbols)
.add(assets.getSymbols())
- .build());
+ .build(),
+ transitiveCompiledSymbolsBuilder.build());
}
/** Creates a new AndroidAssetsInfo from this target's dependencies, without any local assets. */
@@ -134,7 +160,8 @@ public class AssetDependencies {
directParsedAssets,
transitiveParsedAssets,
transitiveAssets,
- transitiveSymbols);
+ transitiveSymbols,
+ transitiveCompiledSymbols);
}
public NestedSet<ParsedAndroidAssets> getDirectParsedAssets() {
@@ -152,4 +179,8 @@ public class AssetDependencies {
public NestedSet<Artifact> getTransitiveSymbols() {
return transitiveSymbols;
}
+
+ public NestedSet<Artifact> getTransitiveCompiledSymbols() {
+ return transitiveCompiledSymbols;
+ }
}