Skip to content

Commit

Permalink
This is specifically for android_binary rule. (prev change was for an…
Browse files Browse the repository at this point in the history
…droid_library rule bazelbuild@98bd4ae)

Native changes required to support linking against resource apks.

Note that this only wires up for validation in the native pipeline. The main implementation here is in the Starlark pipeline, but there is still one existing validation step in native (which we will need to clean up separately).

PiperOrigin-RevId: 520801511
Change-Id: I8e7f9376e41c5645aeba66e713567d1831983fa0
  • Loading branch information
Googler authored and fweikert committed May 25, 2023
1 parent c53fc7c commit ddb536a
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.
package com.google.devtools.build.android;

import static com.google.common.collect.ImmutableList.toImmutableList;
import static com.google.common.collect.Streams.concat;
import static java.util.stream.Collectors.toList;

Expand Down Expand Up @@ -344,6 +345,16 @@ public static final class Options extends OptionsBase {
effectTags = {OptionEffectTag.AFFECTS_OUTPUTS},
help = "When generating proguard configurations, include location references.")
public boolean includeProguardLocationReferences;

@Option(
name = "resourceApks",
defaultValue = "null",
category = "input",
converter = PathListConverter.class,
documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
effectTags = {OptionEffectTag.UNKNOWN},
help = "List of reource only APK files to link against.")
public List<Path> resourceApks;
}

public static void main(String[] args) throws Exception {
Expand Down Expand Up @@ -474,6 +485,12 @@ public static void main(String[] args) throws Exception {
.collect(toList()));
}

ImmutableList<StaticLibrary> resourceApks = ImmutableList.of();
if (options.resourceApks != null) {
resourceApks =
options.resourceApks.stream().map(StaticLibrary::from).collect(toImmutableList());
}

final PackagedResources packagedResources =
ResourceLinker.create(aaptConfigOptions.aapt2, executorService, linkedOut)
.profileUsing(profiler)
Expand All @@ -482,6 +499,7 @@ public static void main(String[] args) throws Exception {
options.packageId != -1 ? Optional.of(options.packageId) : Optional.empty())
.outputAsProto(aaptConfigOptions.resourceTableAsProto)
.dependencies(ImmutableList.copyOf(dependencies))
.resourceApks(resourceApks)
.include(compiledResourceDeps)
.withAssets(assetDirs)
.buildVersion(aaptConfigOptions.buildToolsVersion)
Expand Down

0 comments on commit ddb536a

Please sign in to comment.