From 85b3c2a956d2cef02f16cb45e6b8a470fa2efe26 Mon Sep 17 00:00:00 2001 From: Stefano Duo Date: Wed, 11 Jan 2023 13:46:47 +0000 Subject: [PATCH] Introduce is_cronet_build and move process_launcher into its own target Cronet doesn't require the setup and handling of multiple processes (it simply spawns threads within the application process that uses it). This wouldn't be that big of a problem, but many of the multiprocess tooling makes use of AndroidX, which Cronet is trying not to depend on. To achieve that, move process_launcher files into its own target not included in base_java (which Cronet depends on). Also, drop IntentUtils for Cronet's builds (through the use of the new GN arg is_cronet_built). Test: m Change-Id: I84f0d81f4feddce8094b6f400f6291a78c953dff --- base/BUILD.gn | 53 ++++++++++++++++++++++++---------- base/test/BUILD.gn | 1 + build/config/cronet/config.gni | 10 +++++++ build/config/ios/config.gni | 5 ---- net/BUILD.gn | 2 +- 5 files changed, 49 insertions(+), 22 deletions(-) create mode 100644 build/config/cronet/config.gni diff --git a/base/BUILD.gn b/base/BUILD.gn index 255ed8a9806bd..b737dad33c4a7 100644 --- a/base/BUILD.gn +++ b/base/BUILD.gn @@ -26,6 +26,7 @@ import("//build/config/c++/c++.gni") import("//build/config/chromecast_build.gni") import("//build/config/chromeos/ui_mode.gni") import("//build/config/compiler/compiler.gni") +import("//build/config/cronet/config.gni") import("//build/config/dcheck_always_on.gni") import("//build/config/ios/config.gni") import("//build/config/logging.gni") @@ -4146,10 +4147,39 @@ if (is_android) { template = "android/java/src/org/chromium/base/BaseSwitches.java.tmpl" } + android_library("process_launcher_java") { + srcjar_deps = [ ":process_launcher_aidl" ] + deps = [ + ":base_java", + ":jni_java", + "//build/android:build_java", + "//third_party/android_deps:com_google_code_findbugs_jsr305_java", + "//third_party/androidx:androidx_annotation_annotation_experimental_java", + "//third_party/androidx:androidx_annotation_annotation_java", + "//third_party/androidx:androidx_collection_collection_java", + "//third_party/androidx:androidx_core_core_java", + ] + sources = [ + "android/java/src/org/chromium/base/process_launcher/BindService.java", + "android/java/src/org/chromium/base/process_launcher/ChildConnectionAllocator.java", + "android/java/src/org/chromium/base/process_launcher/ChildProcessConnection.java", + "android/java/src/org/chromium/base/process_launcher/ChildProcessConstants.java", + "android/java/src/org/chromium/base/process_launcher/ChildProcessLauncher.java", + "android/java/src/org/chromium/base/process_launcher/ChildProcessService.java", + "android/java/src/org/chromium/base/process_launcher/ChildProcessServiceDelegate.java", + "android/java/src/org/chromium/base/process_launcher/ChildServiceConnection.java", + "android/java/src/org/chromium/base/process_launcher/ChildServiceConnectionDelegate.java", + "android/java/src/org/chromium/base/process_launcher/ChildServiceConnectionFactory.java", + "android/java/src/org/chromium/base/process_launcher/ChildServiceConnectionImpl.java", + "android/java/src/org/chromium/base/process_launcher/FileDescriptorInfo.java", + ] + + annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ] + } + android_library("base_java") { srcjar_deps = [ ":base_android_java_enums_srcjar", - ":base_java_aidl", ":java_features_srcjar", ":java_switches_srcjar", ] @@ -4191,7 +4221,6 @@ if (is_android) { "android/java/src/org/chromium/base/Flag.java", "android/java/src/org/chromium/base/ImportantFileWriterAndroid.java", "android/java/src/org/chromium/base/IntStringCallback.java", - "android/java/src/org/chromium/base/IntentUtils.java", "android/java/src/org/chromium/base/JNIUtils.java", "android/java/src/org/chromium/base/JavaExceptionReporter.java", "android/java/src/org/chromium/base/JavaHandlerThread.java", @@ -4269,18 +4298,6 @@ if (is_android) { "android/java/src/org/chromium/base/metrics/TimingMetric.java", "android/java/src/org/chromium/base/metrics/UmaRecorder.java", "android/java/src/org/chromium/base/metrics/UmaRecorderHolder.java", - "android/java/src/org/chromium/base/process_launcher/BindService.java", - "android/java/src/org/chromium/base/process_launcher/ChildConnectionAllocator.java", - "android/java/src/org/chromium/base/process_launcher/ChildProcessConnection.java", - "android/java/src/org/chromium/base/process_launcher/ChildProcessConstants.java", - "android/java/src/org/chromium/base/process_launcher/ChildProcessLauncher.java", - "android/java/src/org/chromium/base/process_launcher/ChildProcessService.java", - "android/java/src/org/chromium/base/process_launcher/ChildProcessServiceDelegate.java", - "android/java/src/org/chromium/base/process_launcher/ChildServiceConnection.java", - "android/java/src/org/chromium/base/process_launcher/ChildServiceConnectionDelegate.java", - "android/java/src/org/chromium/base/process_launcher/ChildServiceConnectionFactory.java", - "android/java/src/org/chromium/base/process_launcher/ChildServiceConnectionImpl.java", - "android/java/src/org/chromium/base/process_launcher/FileDescriptorInfo.java", "android/java/src/org/chromium/base/supplier/DestroyableObservableSupplier.java", "android/java/src/org/chromium/base/supplier/ObservableSupplier.java", "android/java/src/org/chromium/base/supplier/ObservableSupplierImpl.java", @@ -4308,6 +4325,10 @@ if (is_android) { "android/java/src/org/chromium/base/task/TaskTraitsExtensionDescriptor.java", ] + if (!is_cronet_build) { + sources += [ "android/java/src/org/chromium/base/IntentUtils.java" ] + } + annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ] resources_package = "org.chromium.base" @@ -4319,7 +4340,7 @@ if (is_android) { ] } - android_aidl("base_java_aidl") { + android_aidl("process_launcher_aidl") { import_include = [ "android/java/src" ] sources = [ "android/java/src/org/chromium/base/process_launcher/IChildProcessService.aidl", @@ -4513,7 +4534,7 @@ if (is_android) { android_library("base_java_process_launcher_test_support") { testonly = true - deps = [ ":base_java" ] + public_deps = [ ":process_launcher_java" ] sources = [ "test/android/javatests/src/org/chromium/base/process_launcher/TestChildProcessConnection.java" ] } diff --git a/base/test/BUILD.gn b/base/test/BUILD.gn index ca4a051cce41c..061c169690918 100644 --- a/base/test/BUILD.gn +++ b/base/test/BUILD.gn @@ -397,6 +397,7 @@ if (is_android) { deps = [ "//base:base_java", "//base:jni_java", + "//base:process_launcher_java", "//testing/android/native_test:native_main_runner_java", "//third_party/android_deps:com_google_code_findbugs_jsr305_java", ] diff --git a/build/config/cronet/config.gni b/build/config/cronet/config.gni new file mode 100644 index 0000000000000..1468ec17a05ee --- /dev/null +++ b/build/config/cronet/config.gni @@ -0,0 +1,10 @@ +# Copyright 2022 The Chromium Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +declare_args() { + # Control whether cronet is built (this is usually set by the script + # components/cronet/tools/cr_cronet.py as cronet requires specific + # gn args to build correctly). + is_cronet_build = false +} diff --git a/build/config/ios/config.gni b/build/config/ios/config.gni index 74d064532d5f8..c5c10c3f7e5c3 100644 --- a/build/config/ios/config.gni +++ b/build/config/ios/config.gni @@ -9,11 +9,6 @@ declare_args() { # default is only there for compatibility reasons and will be removed (see # crbug.com/1138425 for more details). target_environment = "" - - # Control whether cronet is built (this is usually set by the script - # components/cronet/tools/cr_cronet.py as cronet requires specific - # gn args to build correctly). - is_cronet_build = false } if (target_environment == "") { diff --git a/net/BUILD.gn b/net/BUILD.gn index c633dcd9554d0..2fc1a575d0387 100644 --- a/net/BUILD.gn +++ b/net/BUILD.gn @@ -6,8 +6,8 @@ import("//build/buildflag_header.gni") import("//build/config/chromecast_build.gni") import("//build/config/chromeos/ui_mode.gni") import("//build/config/compiler/compiler.gni") +import("//build/config/cronet/config.gni") import("//build/config/features.gni") -import("//build/config/ios/config.gni") import("//crypto/features.gni") import("//net/features.gni") import("//testing/libfuzzer/fuzzer_test.gni") -- 2.40.0.348.gf938b09366-goog