Skip to content

Commit

Permalink
Support the ability to link against additional apks.
Browse files Browse the repository at this point in the history
RELNOTES: None.
PiperOrigin-RevId: 298726063
  • Loading branch information
Googler authored and copybara-github committed Mar 4, 2020
1 parent 1048cd8 commit 3c7cc74
Showing 1 changed file with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
import com.android.builder.core.VariantType;
import com.android.utils.StdLogger;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.devtools.build.android.Converters.DependencyAndroidDataListConverter;
import com.google.devtools.build.android.Converters.PathConverter;
import com.google.devtools.build.android.Converters.PathListConverter;
import com.google.devtools.build.android.Converters.SerializedAndroidDataListConverter;
import com.google.devtools.build.android.Converters.UnvalidatedAndroidDataConverter;
import com.google.devtools.build.android.Converters.VariantTypeConverter;
Expand Down Expand Up @@ -143,6 +145,16 @@ public static final class Options extends OptionsBase {
+ "[,...]")
public List<SerializedAndroidData> directAssets;

@Option(
name = "additionalApksToLinkAgainst",
defaultValue = "null",
category = "input",
converter = PathListConverter.class,
documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
effectTags = {OptionEffectTag.UNKNOWN},
help = "List of APKs used during linking.")
public List<Path> additionalApksToLinkAgainst;

@Option(
name = "rOutput",
defaultValue = "null",
Expand Down Expand Up @@ -430,12 +442,21 @@ public static void main(String[] args) throws Exception {
.flatMap(dep -> dep.assetDirs.stream()))
.collect(toList());

List<StaticLibrary> dependencies =
Lists.newArrayList(StaticLibrary.from(aaptConfigOptions.androidJar));
if (options.additionalApksToLinkAgainst != null) {
dependencies.addAll(
options.additionalApksToLinkAgainst.stream()
.map(StaticLibrary::from)
.collect(toList()));
}

final PackagedResources packagedResources =
ResourceLinker.create(aaptConfigOptions.aapt2, executorService, linkedOut)
.profileUsing(profiler)
.customPackage(options.packageForR)
.outputAsProto(aaptConfigOptions.resourceTableAsProto)
.dependencies(ImmutableList.of(StaticLibrary.from(aaptConfigOptions.androidJar)))
.dependencies(ImmutableList.copyOf(dependencies))
.include(compiledResourceDeps)
.withAssets(assetDirs)
.buildVersion(aaptConfigOptions.buildToolsVersion)
Expand Down

0 comments on commit 3c7cc74

Please sign in to comment.