Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiplex worker fixes and tests for Android busybox tools #17371

Merged
merged 3 commits into from
Feb 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,13 @@ function test_persistent_resource_processor() {
create_android_binary
setup_font_resources

assert_build //java/bazel:bin --persistent_android_resource_processor
assert_build //java/bazel:bin --persistent_android_resource_processor \
--worker_verbose &> $TEST_log
expect_log "Created new non-sandboxed AndroidResourceParser worker (id [0-9]\+)"
expect_log "Created new non-sandboxed AndroidResourceCompiler worker (id [0-9]\+)"
expect_log "Created new non-sandboxed AndroidCompiledResourceMerger worker (id [0-9]\+)"
expect_log "Created new non-sandboxed AndroidAapt2 worker (id [0-9]\+)"
expect_log "Created new non-sandboxed ManifestMerger worker (id [0-9]\+)"
}

function test_persistent_multiplex_resource_processor() {
Expand All @@ -121,7 +127,13 @@ function test_persistent_multiplex_resource_processor() {
setup_font_resources

assert_build //java/bazel:bin --experimental_worker_multiplex \
--persistent_multiplex_android_tools
--persistent_multiplex_android_tools \
--worker_verbose &> $TEST_log
expect_log "Created new non-sandboxed AndroidResourceParser multiplex-worker (id [0-9]\+)"
expect_log "Created new non-sandboxed AndroidResourceCompiler multiplex-worker (id [0-9]\+)"
expect_log "Created new non-sandboxed AndroidCompiledResourceMerger multiplex-worker (id [0-9]\+)"
expect_log "Created new non-sandboxed AndroidAapt2 multiplex-worker (id [0-9]\+)"
expect_log "Created new non-sandboxed ManifestMerger multiplex-worker (id [0-9]\+)"
}

run_suite "Resource processing integration tests"