From 2a503b4626e7a46c782c2769b5887e373fcf831e Mon Sep 17 00:00:00 2001 From: Alexander Frick Date: Tue, 7 Mar 2023 08:04:01 -0600 Subject: [PATCH] android fixes --- arm/android_ARM32_args.gn | 2 +- arm/android_ARM64_args.gn | 2 +- setup.sh | 21 ++- src/BUILD.gn | 4 +- src/content/shell/android/BUILD.gn | 284 +++++++++++++++++++++++++++++ trunk.sh | 8 + 6 files changed, 310 insertions(+), 11 deletions(-) create mode 100644 src/content/shell/android/BUILD.gn diff --git a/arm/android_ARM32_args.gn b/arm/android_ARM32_args.gn index e7e01491..d986f73d 100644 --- a/arm/android_ARM32_args.gn +++ b/arm/android_ARM32_args.gn @@ -61,7 +61,6 @@ use_webaudio_ffmpeg = false use_webaudio_pffft = true # enable_av1_decoder = true # enable_dav1d_decoder = true -enable_library_cdms = true enable_widevine = true bundle_widevine_cdm = false enable_widevine_cdm_component = true @@ -87,3 +86,4 @@ enable_platform_dts_audio = true enable_mse_mpeg2ts_stream_parser = true use_thin_lto = true thin_lto_enable_optimizations = true +chrome_pgo_phase = 0 diff --git a/arm/android_ARM64_args.gn b/arm/android_ARM64_args.gn index 7ea61bcb..beb06e5d 100644 --- a/arm/android_ARM64_args.gn +++ b/arm/android_ARM64_args.gn @@ -61,7 +61,6 @@ use_webaudio_ffmpeg = false use_webaudio_pffft = true # enable_av1_decoder = true # enable_dav1d_decoder = true -enable_library_cdms = true enable_widevine = true bundle_widevine_cdm = false enable_widevine_cdm_component = true @@ -87,3 +86,4 @@ enable_platform_dts_audio = true enable_mse_mpeg2ts_stream_parser = true use_thin_lto = true thin_lto_enable_optimizations = true +chrome_pgo_phase = 0 diff --git a/setup.sh b/setup.sh index 8b787688..b61b55f9 100755 --- a/setup.sh +++ b/setup.sh @@ -24,11 +24,11 @@ displayHelp () { printf "${bold}${YEL}Use the --woa flag for Windows on ARM builds.${c0}\n" && printf "${bold}${YEL}Use the --avx2 flag for AVX2 Builds.${c0}\n" && printf "${bold}${YEL}Use the --sse3 flag for SSE3 Builds.${c0}\n" && + printf "${bold}${YEL}Use the --android flag for Android Builds.${c0}\n" && printf "${bold}${YEL}IMPORTANT: For Polly builds, first run build_polly.sh in Thorium/infra, then use the setup_polly.sh${c0}\n" && printf "${bold}${YEL}script in Thorium/other/Polly. Both of these actions should be taken AFTER running this script!${c0}\n" && printf "\n" } - case $1 in --help) displayHelp; exit 0;; esac @@ -85,7 +85,6 @@ copyMacOS () { cp -r -v arm/mac_arm.gni $HOME/chromium/src/build/config/arm.gni && printf "\n" } - case $1 in --mac) copyMacOS; esac @@ -94,10 +93,9 @@ esac copyRaspi () { printf "\n" && printf "${YEL}Copying Raspberry Pi build files...${c0}\n" && - cp -r -v arm/raspi/* $HOME/chromium/src/&& + cp -r -v arm/raspi/* $HOME/chromium/src/ && printf "\n" } - case $1 in --raspi) copyRaspi; esac @@ -110,7 +108,6 @@ copyWOA () { cp -r -v arm/woa_arm.gni $HOME/chromium/src/build/config/arm.gni && printf "\n" } - case $1 in --woa) copyWOA; esac @@ -123,7 +120,6 @@ copyAVX2 () { cp -r -v other/AVX2/third_party/opus/src/* $HOME/chromium/src/third_party/opus/src/ && printf "\n" } - case $1 in --avx2) copyAVX2; esac @@ -135,11 +131,22 @@ copySSE3 () { cp -r -v other/SSE3/build/config/* $HOME/chromium/src/build/config/ && printf "\n" } - case $1 in --sse3) copySSE3; esac +# Copy Android files +copyAndroid () { + printf "\n" && + printf "${YEL}Copying Android (ARM64 and ARM32) build files...${c0}\n" && + cp -r -v arm/build/config/* $HOME/chromium/src/build/config/ && + cp -r -v arm/raspi/third_party/* $HOME/chromium/src/third_party/ && + printf "\n" +} +case $1 in + --android) copyAndroid; +esac + printf "${GRE}Done!\n" && printf "\n" && diff --git a/src/BUILD.gn b/src/BUILD.gn index 72622e7a..45f0f5e2 100644 --- a/src/BUILD.gn +++ b/src/BUILD.gn @@ -362,7 +362,7 @@ group("gn_all") { "//chrome/test:android_browsertests", "//components:components_junit_tests", "//content/public/android:content_junit_tests", - "//content/shell/android:content_shell_apk", + "//content/shell/android:thorium_shell_apk", "//device:device_junit_tests", "//media/gpu:video_decode_accelerator_unittest", "//net/android:net_junit_tests", @@ -407,7 +407,7 @@ group("gn_all") { "//chrome/android:chrome_public_unit_test_apk", "//chrome/browser/android/examples/custom_tabs_client:custom_tabs_client_example_apk", "//chrome/browser/android/examples/partner_browser_customizations_provider:partner_browser_customizations_example_apk", - "//content/shell/android:content_shell_test_apk", + "//content/shell/android:thorium_shell_test_apk", ] } diff --git a/src/content/shell/android/BUILD.gn b/src/content/shell/android/BUILD.gn new file mode 100644 index 00000000..d2ec9e63 --- /dev/null +++ b/src/content/shell/android/BUILD.gn @@ -0,0 +1,284 @@ +# Copyright 2014 The Chromium Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//build/config/android/config.gni") +import("//build/config/android/rules.gni") +import("//third_party/icu/config.gni") +import("//tools/v8_context_snapshot/v8_context_snapshot.gni") + +content_shell_manifest = + "$target_gen_dir/content_shell_manifest/AndroidManifest.xml" +content_shell_test_manifest = + "$target_gen_dir/content_shell_test_manifest/AndroidManifest.xml" + +generate_jni("content_shell_jni_headers") { + sources = [ + "java/src/org/chromium/content_shell/Shell.java", + "java/src/org/chromium/content_shell/ShellManager.java", + ] +} + +shared_library("libcontent_shell_content_view") { + testonly = true + deps = [ + ":content_shell_jni_headers", + "//components/crash/content/browser", + "//content/shell:content_shell_app", + "//content/shell:content_shell_lib", + "//content/shell:pak", + "//media", + "//skia", + ] + + # Explicit dependency required for JNI registration to be able to + # find the native side functions. + if (is_component_build) { + deps += [ + "//device/gamepad", + "//media/midi", + ] + } + sources = [ "shell_library_loader.cc" ] + configs -= [ "//build/config/android:hide_all_but_jni_onload" ] + configs += [ "//build/config/android:hide_all_but_jni" ] +} + +shared_library("libcontent_native_test") { + testonly = true + deps = [ + "//base", + "//base:base_javatests_lib", + "//content/public/test/android:content_native_test_support", + "//content/shell:content_shell_app", + "//content/shell:content_shell_lib", + ] + + sources = [ "shell_test_library_loader.cc" ] + configs -= [ "//build/config/android:hide_all_but_jni_onload" ] + configs += [ "//build/config/android:hide_all_but_jni" ] +} + +android_resources("content_shell_java_resources") { + testonly = true + sources = [ + "java/res/drawable/ic_refresh.png", + "java/res/drawable/progress.xml", + "java/res/layout/shell_view.xml", + "java/res/mipmap-hdpi/app_icon.png", + "java/res/mipmap-mdpi/app_icon.png", + "java/res/mipmap-xhdpi/app_icon.png", + "java/res/mipmap-xxhdpi/app_icon.png", + "java/res/mipmap-xxxhdpi/app_icon.png", + "java/res/values/strings.xml", + ] +} + +android_library("content_shell_java") { + testonly = true + resources_package = "org.chromium.thorium_shell" + deps = [ + ":content_shell_java_resources", + ":content_shell_manifest", + "//base:base_java", + "//base:jni_java", + "//build/android:build_java", + "//components/download/internal/common:internal_java", + "//components/embedder_support/android:content_view_java", + "//components/embedder_support/android:view_java", + "//components/viz/service:service_java", + "//content/public/android:content_java", + "//media/base/android:media_java", + "//media/capture/video/android:capture_java", + "//mojo/public/java:system_java", + "//net/android:net_java", + "//ui/android:ui_java", + "//ui/base/cursor/mojom:cursor_type_java", + "//url:gurl_java", + ] + sources = [ + "java/src/org/chromium/content_shell/Shell.java", + "java/src/org/chromium/content_shell/ShellManager.java", + "java/src/org/chromium/content_shell/ShellViewAndroidDelegate.java", + ] + + annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ] +} + +jinja_template("content_shell_manifest") { + testonly = true + input = "shell_apk/AndroidManifest.xml.jinja2" + output = content_shell_manifest + variables = [ "manifest_package=org.chromium.thorium_shell_apk" ] +} + +jinja_template("content_shell_test_manifest") { + testonly = true + input = "javatests/AndroidManifest.xml" + includes = [ "shell_apk/AndroidManifest.xml.jinja2" ] + output = content_shell_test_manifest + variables = [ "manifest_package=org.chromium.content_shell_apk.tests" ] +} + +android_resources("content_shell_apk_resources") { + testonly = true + sources = [ + "shell_apk/res/layout/content_shell_activity.xml", + "shell_apk/res/values/strings.xml", + ] + deps = [ ":content_shell_java_resources" ] +} + +android_library("content_shell_apk_java") { + testonly = true + + srcjar_deps = [ ":content_javatests_aidl" ] + + resources_package = "org.chromium.thorium_shell_apk" + deps = [ + ":content_shell_apk_resources", + ":content_shell_java", + ":content_shell_manifest", + "//base:base_java", + "//build/android:build_java", + "//components/embedder_support/android:view_java", + "//content/public/android:content_java", + "//media/capture/video/android:capture_java", + "//net/android:net_java", + "//third_party/android_deps:com_google_code_findbugs_jsr305_java", + "//ui/android:ui_java", + "//url:gurl_java", + ] + + sources = [ + "shell_apk/src/org/chromium/content_shell_apk/ChildProcessLauncherTestHelperService.java", + "shell_apk/src/org/chromium/content_shell_apk/ChildProcessLauncherTestUtils.java", + "shell_apk/src/org/chromium/content_shell_apk/ContentShellActivity.java", + "shell_apk/src/org/chromium/content_shell_apk/ContentShellApplication.java", + "shell_apk/src/org/chromium/content_shell_apk/TestChildProcessService.java", + "shell_apk/src/org/chromium/content_shell_apk/TestChildProcessService0.java", + "shell_apk/src/org/chromium/content_shell_apk/TestChildProcessService1.java", + ] +} + +android_aidl("content_javatests_aidl") { + import_include = [ "shell_apk/src" ] + sources = + [ "shell_apk/src/org/chromium/content_shell_apk/IChildProcessTest.aidl" ] +} + +android_assets("content_shell_assets") { + testonly = true + sources = [ "$root_out_dir/content_shell.pak" ] + disable_compression = true + deps = [ + "//content/shell:pak", + "//third_party/icu:icu_assets", + ] + if (use_v8_context_snapshot) { + deps += [ "//tools/v8_context_snapshot:v8_context_snapshot_assets" ] + } else { + deps += [ "//v8:v8_external_startup_data_assets" ] + } +} + +template("content_shell_apk_tmpl") { + _target_type = invoker.target_type + target(_target_type, target_name) { + forward_variables_from(invoker, "*") + testonly = true + if (!defined(deps)) { + deps = [] + } + deps += [ + ":content_shell_apk_java", + ":content_shell_assets", + ":content_shell_java", + "//base:base_java_test_support", + "//components/crash/android:java", + "//components/crash/core/app:chrome_crashpad_handler_named_as_so", + "//components/metrics:metrics_java", + "//content/public/android:content_java", + "//content/public/test/android:android_test_message_pump_support_java", + "//media/capture/video/android:capture_java", + "//net/android:net_java", + "//services/shape_detection:shape_detection_java", + "//third_party/mesa_headers", + "//ui/android:ui_java", + ] + loadable_modules = [ "$root_out_dir/libchrome_crashpad_handler.so" ] + } +} + +content_shell_apk_tmpl("thorium_shell_apk") { + target_type = "android_apk" + apk_name = "ThoriumShell" + android_manifest = content_shell_manifest + android_manifest_dep = ":content_shell_manifest" + shared_libraries = [ ":libcontent_shell_content_view" ] + command_line_flags_file = "content-shell-command-line" +} + +content_shell_apk_tmpl("thorium_shell_test_apk") { + target_type = "instrumentation_test_apk" + apk_name = "ThoriumShellTest" + android_manifest = content_shell_test_manifest + android_manifest_dep = ":content_shell_test_manifest" + shared_libraries = [ ":libcontent_native_test" ] + deps = [ + "//base:base_java_test_support", + "//base:base_javatests", + "//content/public/android:content_javatests", + "//net/android:net_javatests", + "//third_party/android_support_test_runner:runner_java", + ] + data_deps = [ "//testing/buildbot/filters:content_shell_test_apk_filters" ] + if (enable_chrome_android_internal) { + data_deps += [ "//clank/build/bot/filters:content_shell_test_apk_filters" ] + } + + additional_apks = [ "//net/android:net_test_support_apk" ] + + # TODO(crbug.com/1099536): Fix tests that break when this is increased. + target_sdk_version = 24 +} + +android_library("content_shell_test_java") { + testonly = true + deps = [ + ":content_shell_apk_java", + ":content_shell_java", + "//base:base_java", + "//base:base_java_test_support", + "//content/public/android:content_java", + "//content/public/test/android:content_java_test_support", + "//content/shell/android:content_shell_java", + "//mojo/public/java/system:test_support_java", + "//third_party/android_support_test_runner:rules_java", + "//third_party/android_support_test_runner:runner_java", + "//third_party/androidx:androidx_test_runner_java", + "//third_party/hamcrest:hamcrest_java", + "//third_party/junit:junit", + "//ui/android:ui_java", + "//url:gurl_java", + ] + sources = [ + "javatests/src/org/chromium/content_shell_apk/ContentShellActivityTestRule.java", + "javatests/src/org/chromium/content_shell_apk/ContentShellPreconditionsTest.java", + "javatests/src/org/chromium/content_shell_apk/ContentShellShellManagementTest.java", + "javatests/src/org/chromium/content_shell_apk/ContentShellUrlTest.java", + ] +} + +android_library("content_shell_browsertests_java") { + testonly = true + deps = [ + ":content_shell_java", + "//base:base_java", + "//content/public/android:content_java", + "//testing/android/native_test:native_test_java", + "//third_party/androidx:androidx_core_core_java", + "//ui/android:ui_java", + ] + sources = [ "browsertests/src/org/chromium/content_shell/browsertests/ContentShellBrowserTestActivity.java" ] +} diff --git a/trunk.sh b/trunk.sh index c12ea826..f3891a36 100755 --- a/trunk.sh +++ b/trunk.sh @@ -39,6 +39,10 @@ gsyncShallow () { cd $HOME/chromium/src/third_party/devtools-frontend/src && git checkout -f origin/main && + + cd $HOME/chromium/src/third_party/ffmpeg && + + git checkout -f origin/master && cd $HOME/chromium/src && @@ -164,6 +168,10 @@ cd $HOME/chromium/src/third_party/devtools-frontend/src && git checkout -f origin/main && +cd $HOME/chromium/src/third_party/ffmpeg && + +git checkout -f origin/master && + cd $HOME/chromium/src && rm -v -f $HOME/chromium/src/components/neterror/resources/images/default_100_percent/offline/favicon-16x16.png &&