Mohamed Heikal | 3e5a2ae | 2023-07-26 19:10:31 | [diff] [blame] | 1 | # Copyright 2023 The Chromium Authors |
| 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
| 5 | import("//build/config/android/rules.gni") |
| 6 | |
| 7 | template("_androidx_prebuilt") { |
| 8 | target(invoker.target_type, target_name) { |
| 9 | forward_variables_from(invoker, "*", [ "target_type" ]) |
| 10 | |
Andrew Grieve | a283deb | 2024-02-14 15:14:39 | [diff] [blame] | 11 | if (target_name == "androidx_annotation_annotation_java") { |
| 12 | # Ensure this dep is the suggested one when targets are missing it. |
| 13 | preferred_dep = true |
| 14 | } else if (target_name == "androidx_annotation_annotation_jvm_java") { |
Mohamed Heikal | 3e5a2ae | 2023-07-26 19:10:31 | [diff] [blame] | 15 | # https://crbug.com/989505 |
| 16 | jar_excluded_patterns = [ "META-INF/proguard/*" ] |
| 17 | proguard_configs = [ "androidx_annotations.flags" ] |
| 18 | } else if (target_name == "androidx_benchmark_benchmark_common_java") { |
| 19 | ignore_native_libraries = true |
| 20 | } else if (target_name == "androidx_benchmark_benchmark_macro_java") { |
| 21 | # Manually add dep onto DISALLOWED_DEP androidx.profileinstaller. |
| 22 | deps += [ ":androidx_profileinstaller_profileinstaller_java" ] |
Mohamed Heikal | 3e5a2ae | 2023-07-26 19:10:31 | [diff] [blame] | 23 | } else if (target_name == |
| 24 | "androidx_coordinatorlayout_coordinatorlayout_java") { |
| 25 | # Reduce binary size. https:crbug.com/954584 |
| 26 | ignore_proguard_configs = true |
Andrew Grieve | 724c3165 | 2025-02-05 17:15:36 | [diff] [blame] | 27 | } else if (target_name == "androidx_appcompat_appcompat_java") { |
| 28 | deps += [ ":core_overrides_java" ] |
Mohamed Heikal | 3e5a2ae | 2023-07-26 19:10:31 | [diff] [blame] | 29 | } else if (target_name == "androidx_core_core_java") { |
| 30 | # Target has AIDL, but we do not support it yet: http://crbug.com/644439 |
| 31 | ignore_aidl = true |
| 32 | |
| 33 | # Manifest and proguard config have just one entry: Adding (and -keep'ing |
| 34 | # android:appComponentFactory="androidx.core.app.CoreComponentFactory" |
| 35 | # Chrome does not use this feature and it causes a scary stack trace to be |
| 36 | # shown when incremental_install=true. |
| 37 | ignore_manifest = true |
| 38 | ignore_proguard_configs = true |
| 39 | |
| 40 | # https://crbug.com/1414452 |
Andrew Grieve | 724c3165 | 2025-02-05 17:15:36 | [diff] [blame] | 41 | jar_excluded_patterns = [ |
| 42 | "androidx/core/os/BuildCompat*", |
| 43 | "androidx/core/content/res/TypedArrayUtils*", |
| 44 | ] |
Mohamed Heikal | 3e5a2ae | 2023-07-26 19:10:31 | [diff] [blame] | 45 | public_deps = [ "//third_party/androidx/local_modifications/buildcompat:buildcompat_java" ] |
| 46 | |
| 47 | if (!enable_java_asserts) { |
| 48 | # Omit the file since we use our own copy. |
| 49 | jar_excluded_patterns += [ "androidx/core/util/Preconditions.class" ] |
| 50 | deps += [ "//third_party/android_deps/local_modifications/preconditions:androidx_stub_preconditions_java" ] |
| 51 | } |
| 52 | } else if (target_name == "androidx_fragment_fragment_java") { |
| 53 | deps += [ "//third_party/android_deps/utils:java" ] |
| 54 | |
| 55 | proguard_configs = [ "androidx_fragment.flags" ] |
Mohamed Heikal | 3e5a2ae | 2023-07-26 19:10:31 | [diff] [blame] | 56 | } else if (target_name == "androidx_lifecycle_lifecycle_process_java") { |
| 57 | # Only useful for very old SDKs. |
| 58 | ignore_proguard_configs = true |
Andrew Grieve | f3e9c70 | 2024-06-21 21:10:26 | [diff] [blame] | 59 | } else if (target_name == "androidx_graphics_graphics_path_java") { |
| 60 | ignore_native_libraries = true |
Mohamed Heikal | 3e5a2ae | 2023-07-26 19:10:31 | [diff] [blame] | 61 | } else if (target_name == "androidx_media_media_java") { |
| 62 | # Target has AIDL, but we do not support it yet: http://crbug.com/644439 |
| 63 | ignore_aidl = true |
| 64 | } else if (target_name == "androidx_mediarouter_mediarouter_java") { |
| 65 | # https://crbug.com/1000382 |
| 66 | proguard_configs = [ "androidx_mediarouter.flags" ] |
| 67 | } else if (target_name == "androidx_preference_preference_java") { |
Mohamed Heikal | 3e5a2ae | 2023-07-26 19:10:31 | [diff] [blame] | 68 | proguard_configs = [ "androidx_preferences.flags" ] |
| 69 | |
| 70 | # Replace broad library -keep rules with a more limited set in |
| 71 | # chrome/android/java/proguard.flags instead. |
| 72 | ignore_proguard_configs = true |
Mohamed Heikal | 3e5a2ae | 2023-07-26 19:10:31 | [diff] [blame] | 73 | } else if (target_name == "androidx_startup_startup_runtime_java") { |
| 74 | # Keeps emoji2 code. See http://crbug.com/1205141 |
| 75 | ignore_proguard_configs = true |
Mohamed Heikal | 3e5a2ae | 2023-07-26 19:10:31 | [diff] [blame] | 76 | } else if (target_name == "androidx_test_uiautomator_uiautomator_java") { |
| 77 | deps += [ ":androidx_test_runner_java" ] |
Andrew Grieve | acffb5d5 | 2023-10-17 20:07:17 | [diff] [blame] | 78 | } else if (target_name == "androidx_tracing_tracing_perfetto_java") { |
| 79 | # b/280878596 |
| 80 | jar_excluded_patterns = [ "dalvik/*" ] |
Mohamed Heikal | 3e5a2ae | 2023-07-26 19:10:31 | [diff] [blame] | 81 | } else if (target_name == "androidx_transition_transition_java") { |
| 82 | # Not specified in the POM, compileOnly dependency not supposed to be used unless |
| 83 | # the library is present: b/70887421 |
| 84 | deps += [ ":androidx_fragment_fragment_java" ] |
| 85 | } else if (target_name == "androidx_tracing_tracing_perfetto_binary_java") { |
| 86 | ignore_native_libraries = true |
| 87 | } else if (target_name == |
| 88 | "androidx_versionedparcelable_versionedparcelable_java") { |
| 89 | # Target has AIDL, but we do not support it yet: http://crbug.com/644439 |
| 90 | ignore_aidl = true |
Sam Maier | 35686f0 | 2024-09-17 20:09:09 | [diff] [blame] | 91 | } else if (target_name == "androidx_window_window_java") { |
| 92 | deps += [ |
| 93 | # This library has a <uses-library> to enable some extra OS APIs, so ensure the |
| 94 | # .jar file is made available to R8 via this dep. |
| 95 | "//third_party/android_sdk:android_window_extensions_java", |
| 96 | |
| 97 | # Sidecar as a library seems to be gone in Maven, so deps don't exist |
| 98 | # onto sidecar. |
| 99 | "//third_party/androidx:androidx_window_sidecar_sidecar_java", |
| 100 | ] |
Mohamed Heikal | 3e5a2ae | 2023-07-26 19:10:31 | [diff] [blame] | 101 | } else if (target_name == "androidx_webkit_webkit_java") { |
| 102 | visibility = [ |
| 103 | "//android_webview/tools/system_webview_shell:*", |
| 104 | "//third_party/android_deps:*", |
| 105 | ] |
Mohamed Heikal | 569f311 | 2025-01-09 18:06:39 | [diff] [blame] | 106 | } else if (target_name == "androidx_datastore_datastore_core_android_java") { |
| 107 | ignore_native_libraries = true |
Andrew Grieve | 724c3165 | 2025-02-05 17:15:36 | [diff] [blame] | 108 | } else if (target_name == "androidx_compose_ui_ui_android_java") { |
| 109 | jar_excluded_patterns = [ |
| 110 | "androidx/compose/ui/graphics/vector/compat/AndroidVectorParser*", |
| 111 | "androidx/compose/ui/graphics/vector/compat/XmlVectorParser*", |
| 112 | ] |
| 113 | } else if (target_name == "androidx_compose_ui_ui_java") { |
| 114 | public_deps = [ ":compose_ui_overrides_java" ] |
Andrew Grieve | a54cd8e | 2025-02-21 20:30:21 | [diff] [blame] | 115 | } else if (filter_include([ target_name ], [ "androidx_xr_*" ]) != []) { |
| 116 | # Configs are overly broad. |
| 117 | ignore_proguard_configs = true |
Gurmeet Kalra | 8812f33 | 2025-02-25 23:39:16 | [diff] [blame] | 118 | proguard_configs = [ "androidx_xr.flags" ] |
Andrew Grieve | a54cd8e | 2025-02-21 20:30:21 | [diff] [blame] | 119 | |
| 120 | # We do not use the APIs that require the native code. |
| 121 | ignore_native_libraries = true |
| 122 | |
| 123 | # It adds: |
| 124 | # <uses-native-library android:name="libopenxr.google.so" android:required="false"/> |
| 125 | # <uses-library android:name="com.android.extensions.xr" android:required="false"/> |
| 126 | # We do not need the uses-native-library, but do need the uses-library. |
| 127 | # However, we add it via the dep onto android_xr_extensions_java. |
| 128 | ignore_manifest = true |
| 129 | deps += [ "//third_party/android_sdk:android_xr_extensions_java" ] |
Mohamed Heikal | 3e5a2ae | 2023-07-26 19:10:31 | [diff] [blame] | 130 | } |
| 131 | } |
Andrew Grieve | c0809760b | 2023-09-25 19:44:15 | [diff] [blame] | 132 | |
| 133 | # Arbitrarily use this target to add new top-level GN targets. |
| 134 | if (target_name == "androidx_annotation_annotation_jvm_java") { |
| 135 | java_group("androidx_window_stubs_java") { |
| 136 | deps = [ "//third_party/androidx/local_modifications/window:androidx_window_shims_java" ] |
| 137 | } |
| 138 | } |
Mohamed Heikal | 3e5a2ae | 2023-07-26 19:10:31 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | template("androidx_java_prebuilt") { |
| 142 | _androidx_prebuilt(target_name) { |
| 143 | forward_variables_from(invoker, "*") |
| 144 | target_type = "java_prebuilt" |
| 145 | |
Andrew Grieve | 5b2bd85 | 2024-12-02 16:04:51 | [diff] [blame] | 146 | # If this target only "supports_android", then it will not be allowed to |
| 147 | # depend on a target that "requires_android". https://crbug.com/1412551 |
| 148 | if (target_name != "androidx_annotation_annotation_jvm_java") { |
| 149 | requires_android = true |
| 150 | } |
Mohamed Heikal | 3e5a2ae | 2023-07-26 19:10:31 | [diff] [blame] | 151 | } |
| 152 | } |
| 153 | |
| 154 | template("androidx_android_aar_prebuilt") { |
| 155 | _androidx_prebuilt(target_name) { |
| 156 | forward_variables_from(invoker, "*") |
| 157 | target_type = "android_aar_prebuilt" |
| 158 | |
| 159 | # The libraries have duplicate resources such as |
| 160 | # "primary_text_default_material_dark". |
| 161 | resource_overlay = true |
Shu Yang | 1a4e626 | 2024-08-12 17:53:22 | [diff] [blame] | 162 | |
Andrew Grieve | f392d62 | 2025-06-25 14:41:58 | [diff] [blame] | 163 | if (target_name == "androidx_pdf_pdf_viewer_java" || |
| 164 | target_name == "androidx_pdf_pdf_document_service_java") { |
| 165 | # Target has AIDL, which we do not need (and don't support). |
Shu Yang | 1a4e626 | 2024-08-12 17:53:22 | [diff] [blame] | 166 | ignore_aidl = true |
| 167 | } |
Mohamed Heikal | 3e5a2ae | 2023-07-26 19:10:31 | [diff] [blame] | 168 | } |
| 169 | } |
Andrew Grieve | a283deb | 2024-02-14 15:14:39 | [diff] [blame] | 170 | |
| 171 | template("androidx_java_group") { |
| 172 | _androidx_prebuilt(target_name) { |
| 173 | forward_variables_from(invoker, "*") |
| 174 | target_type = "java_group" |
| 175 | } |
| 176 | } |