Skip to content

Commit

Permalink
Fix multiplexed workers for Android busybox tools
Browse files Browse the repository at this point in the history
Unblocks merging for PR #15952.

RELNOTES:
PiperOrigin-RevId: 505149043
Change-Id: I1cb5ccb4c162f26fea51e0cdef8c8553f3a3d5df
  • Loading branch information
ted-xie committed Feb 7, 2023
1 parent c540ebf commit 1ef34cd
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,7 @@ public static class Options extends FragmentOptions {
"Enable persistent and multiplexed Android tools (dexing, desugaring, resource "
+ "processing).",
expansion = {
"--internal_persistent_multiplex_busybox_tools",
"--persistent_multiplex_android_resource_processor",
"--persistent_multiplex_android_dex_desugar",
})
Expand All @@ -962,6 +963,17 @@ public static class Options extends FragmentOptions {
help = "Tracking flag for when busybox workers are enabled.")
public boolean persistentBusyboxTools;

@Option(
name = "internal_persistent_multiplex_busybox_tools",
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
effectTags = {
OptionEffectTag.HOST_MACHINE_RESOURCE_OPTIMIZATIONS,
OptionEffectTag.EXECUTION,
},
defaultValue = "false",
help = "Tracking flag for when multiplexed busybox workers are enabled.")
public boolean persistentMultiplexBusyboxTools;

@Option(
name = "experimental_remove_r_classes_from_instrumentation_test_jar",
defaultValue = "true",
Expand Down Expand Up @@ -1096,6 +1108,7 @@ public FragmentOptions getHost() {
oneVersionEnforcementUseTransitiveJarsForBinaryUnderTest;
host.persistentBusyboxTools = persistentBusyboxTools;
host.disableNativeAndroidRules = disableNativeAndroidRules;
host.persistentMultiplexBusyboxTools = persistentMultiplexBusyboxTools;

// Unless the build was started from an Android device, host means MAIN.
host.configurationDistinguisher = ConfigurationDistinguisher.MAIN;
Expand Down Expand Up @@ -1141,6 +1154,7 @@ public FragmentOptions getHost() {
private final boolean dataBindingUpdatedArgs;
private final boolean dataBindingAndroidX;
private final boolean persistentBusyboxTools;
private final boolean persistentMultiplexBusyboxTools;
private final boolean filterRJarsFromAndroidTest;
private final boolean removeRClassesFromInstrumentationTestJar;
private final boolean alwaysFilterDuplicateClassesFromAndroidTest;
Expand Down Expand Up @@ -1201,6 +1215,7 @@ public AndroidConfiguration(BuildOptions buildOptions) throws InvalidConfigurati
this.dataBindingUpdatedArgs = options.dataBindingUpdatedArgs;
this.dataBindingAndroidX = options.dataBindingAndroidX;
this.persistentBusyboxTools = options.persistentBusyboxTools;
this.persistentMultiplexBusyboxTools = options.persistentMultiplexBusyboxTools;
this.filterRJarsFromAndroidTest = options.filterRJarsFromAndroidTest;
this.removeRClassesFromInstrumentationTestJar =
options.removeRClassesFromInstrumentationTestJar;
Expand Down Expand Up @@ -1453,6 +1468,11 @@ public boolean persistentBusyboxTools() {
return persistentBusyboxTools;
}

@Override
public boolean persistentMultiplexBusyboxTools() {
return persistentMultiplexBusyboxTools;
}

@Override
public boolean incompatibleUseToolchainResolution() {
return incompatibleUseToolchainResolution;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public class AndroidDataContext implements AndroidDataContextApi {
private final FilesToRunProvider busybox;
private final AndroidSdkProvider sdk;
private final boolean persistentBusyboxToolsEnabled;
private final boolean persistentMultiplexBusyboxToolsEnabled;
private final boolean optOutOfResourcePathShortening;
private final boolean optOutOfResourceNameObfuscation;
private final boolean throwOnShrinkResources;
Expand All @@ -90,6 +91,7 @@ public static AndroidDataContext makeContext(RuleContext ruleContext) {
ruleContext,
ruleContext.getExecutablePrerequisite("$android_resources_busybox"),
androidConfig.persistentBusyboxTools(),
androidConfig.persistentMultiplexBusyboxTools(),
AndroidSdkProvider.fromRuleContext(ruleContext),
hasExemption(ruleContext, "allow_raw_access_to_resource_paths", false),
hasExemption(ruleContext, "allow_resource_name_obfuscation_opt_out", false),
Expand All @@ -114,6 +116,7 @@ protected AndroidDataContext(
RuleContext ruleContext,
FilesToRunProvider busybox,
boolean persistentBusyboxToolsEnabled,
boolean persistentMultiplexBusyboxToolsEnabled,
AndroidSdkProvider sdk,
boolean optOutOfResourcePathShortening,
boolean optOutOfResourceNameObfuscation,
Expand All @@ -126,6 +129,7 @@ protected AndroidDataContext(
boolean includeProguardLocationReferences,
ImmutableMap<String, String> executionInfo) {
this.persistentBusyboxToolsEnabled = persistentBusyboxToolsEnabled;
this.persistentMultiplexBusyboxToolsEnabled = persistentMultiplexBusyboxToolsEnabled;
this.ruleContext = ruleContext;
this.busybox = busybox;
this.sdk = sdk;
Expand Down Expand Up @@ -222,6 +226,10 @@ public boolean isPersistentBusyboxToolsEnabled() {
return persistentBusyboxToolsEnabled;
}

public boolean isPersistentMultiplexBusyboxToolsEnabled() {
return persistentMultiplexBusyboxToolsEnabled;
}

public boolean optOutOfResourcePathShortening() {
return optOutOfResourcePathShortening;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,10 @@ public void buildAndRegister(String message, String mnemonic) {
commandLine.add("--logWarnings=false");
spawnActionBuilder.addCommandLine(commandLine.build(), WORKERS_FORCED_PARAM_FILE_INFO);
executionInfo.putAll(ExecutionRequirements.WORKER_MODE_ENABLED);

if (dataContext.isPersistentMultiplexBusyboxToolsEnabled()) {
executionInfo.putAll(ExecutionRequirements.WORKER_MULTIPLEX_MODE_ENABLED);
}
} else {
spawnActionBuilder.addCommandLine(commandLine.build(), FORCED_PARAM_FILE_INFO);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,13 @@ public interface AndroidConfigurationApi extends StarlarkValue {
documented = false)
boolean persistentBusyboxTools();

@StarlarkMethod(
name = "persistent_multiplex_busybox_tools",
structField = true,
doc = "",
documented = false)
boolean persistentMultiplexBusyboxTools();

@StarlarkMethod(
name = "get_output_directory_name",
structField = true,
Expand Down

0 comments on commit 1ef34cd

Please sign in to comment.