Skip to content

Commit

Permalink
Add multiplex worker support to dexbuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
Bencodes committed Apr 22, 2022
1 parent bc0eb51 commit ac96cd3
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ public enum WorkerProtocolFormat {
public static final ImmutableMap<String, String> WORKER_MODE_ENABLED =
ImmutableMap.of(SUPPORTS_WORKERS, "1");

public static final ImmutableMap<String, String> WORKER_MULTIPLEX_MODE_ENABLED =
ImmutableMap.of(SUPPORTS_MULTIPLEX_WORKERS, "1");

/**
* Requires local execution without sandboxing for a spawn.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,14 @@ public static class Options extends FragmentOptions {
help = "Whether dexbuilder supports being run in local worker mode.")
public boolean useWorkersWithDexbuilder;

@Option(
name = "use_multiplex_workers_with_dexbuilder",
defaultValue = "false",
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
effectTags = {OptionEffectTag.EXECUTION},
help = "Whether dexbuilder supports being run in local multiplex worker mode.")
public boolean useMultiplexWorkersWithDexbuilder;

@Option(
name = "experimental_android_rewrite_dexes_with_rex",
defaultValue = "false",
Expand Down Expand Up @@ -1016,6 +1024,7 @@ public FragmentOptions getHost() {
host.dexoptsSupportedInDexMerger = dexoptsSupportedInDexMerger;
host.dexoptsSupportedInDexSharder = dexoptsSupportedInDexSharder;
host.useWorkersWithDexbuilder = useWorkersWithDexbuilder;
host.useMultiplexWorkersWithDexbuilder = useMultiplexWorkersWithDexbuilder;
host.manifestMerger = manifestMerger;
host.manifestMergerOrder = manifestMergerOrder;
host.allowAndroidLibraryDepsWithoutSrcs = allowAndroidLibraryDepsWithoutSrcs;
Expand All @@ -1042,6 +1051,7 @@ public FragmentOptions getHost() {
private final ImmutableList<String> dexoptsSupportedInDexMerger;
private final ImmutableList<String> dexoptsSupportedInDexSharder;
private final boolean useWorkersWithDexbuilder;
private final boolean useMultiplexWorkersWithDexbuilder;
private final boolean desugarJava8;
private final boolean desugarJava8Libs;
private final boolean checkDesugarDeps;
Expand Down Expand Up @@ -1096,6 +1106,7 @@ public AndroidConfiguration(BuildOptions buildOptions) throws InvalidConfigurati
this.dexoptsSupportedInDexMerger = ImmutableList.copyOf(options.dexoptsSupportedInDexMerger);
this.dexoptsSupportedInDexSharder = ImmutableList.copyOf(options.dexoptsSupportedInDexSharder);
this.useWorkersWithDexbuilder = options.useWorkersWithDexbuilder;
this.useMultiplexWorkersWithDexbuilder = options.useMultiplexWorkersWithDexbuilder;
this.desugarJava8 = options.desugarJava8;
this.desugarJava8Libs = options.desugarJava8Libs;
this.checkDesugarDeps = options.checkDesugarDeps;
Expand Down Expand Up @@ -1234,6 +1245,12 @@ public boolean useWorkersWithDexbuilder() {
return useWorkersWithDexbuilder;
}

/** Whether to assume the dexbuilder tool supports local worker mode. */
@Override
public boolean useMultiplexWorkersWithDexbuilder() {
return useMultiplexWorkersWithDexbuilder;
}

@Override
public boolean desugarJava8() {
return desugarJava8;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,9 @@ static Artifact createDexArchiveAction(
if (getAndroidConfig(ruleContext).useWorkersWithDexbuilder()) {
dexbuilder.setExecutionInfo(ExecutionRequirements.WORKER_MODE_ENABLED);
}
if (getAndroidConfig(ruleContext).useMultiplexWorkersWithDexbuilder()) {
dexbuilder.setExecutionInfo(ExecutionRequirements.WORKER_MULTIPLEX_MODE_ENABLED);
}
ruleContext.registerAction(dexbuilder.build(ruleContext));
return dexArchive;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ public interface AndroidConfigurationApi extends StarlarkValue {
documented = false)
boolean useWorkersWithDexbuilder();

@StarlarkMethod(
name = "use_multiplex_workers_with_dexbuilder",
structField = true,
doc = "",
documented = false)
boolean useMultiplexWorkersWithDexbuilder();

@StarlarkMethod(name = "desugar_java8", structField = true, doc = "", documented = false)
boolean desugarJava8();

Expand Down

0 comments on commit ac96cd3

Please sign in to comment.