BUILD.gn 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. # Copyright 2014 The Chromium Authors. All rights reserved.
  2. # Use of this source code is governed by a BSD-style license that can be
  3. # found in the LICENSE file.
  4. import("//build/config/android/build_vars.gni")
  5. import("//build/config/android/config.gni")
  6. import("//build/config/android/rules.gni")
  7. import("//build/config/python.gni")
  8. import("//build_overrides/build.gni")
  9. if (enable_java_templates) {
  10. # Create or update the API versions cache if necessary by running a
  11. # functionally empty lint task. This prevents racy creation of the
  12. # cache while linting java targets in android_lint.
  13. android_lint("prepare_android_lint_cache") {
  14. create_cache = true
  15. }
  16. if (enable_jdk_library_desugaring) {
  17. dex_jdk_libs("all_jdk_libs") {
  18. output = "$target_out_dir/$target_name.l8.dex"
  19. min_sdk_version = default_min_sdk_version
  20. }
  21. }
  22. generate_build_config_srcjar("build_config_gen") {
  23. use_final_fields = false
  24. }
  25. generate_build_config_srcjar("build_config_for_testing_gen") {
  26. use_final_fields = false
  27. testonly = true
  28. }
  29. write_native_libraries_java("native_libraries_gen") {
  30. use_final_fields = false
  31. }
  32. java_library("build_java") {
  33. supports_android = true
  34. srcjar_deps = [
  35. ":build_config_gen",
  36. ":native_libraries_gen",
  37. ]
  38. sources = [
  39. "java/src/org/chromium/base/annotations/CheckDiscard.java",
  40. "java/src/org/chromium/base/annotations/DoNotClassMerge.java",
  41. "java/src/org/chromium/base/annotations/DoNotInline.java",
  42. "java/src/org/chromium/base/annotations/IdentifierNameString.java",
  43. "java/src/org/chromium/base/annotations/MainDex.java",
  44. "java/src/org/chromium/base/annotations/MockedInTests.java",
  45. "java/src/org/chromium/base/annotations/UsedByReflection.java",
  46. ]
  47. jar_excluded_patterns = [ "*/build/BuildConfig.class" ]
  48. # New version of NativeLibraries.java (with the actual correct values) will
  49. # be created when creating an apk.
  50. jar_excluded_patterns += [ "*/NativeLibraries.class" ]
  51. }
  52. # Not all //build embedders pull in junit_binary deps that live in //third_party.
  53. if (build_with_chromium) {
  54. android_assets("junit_test_assets") {
  55. testonly = true
  56. # We just need any file here, so use the test itself.
  57. sources = [ "junit/src/org/chromium/build/AndroidAssetsTest.java" ]
  58. }
  59. android_resources("junit_test_resources") {
  60. testonly = true
  61. sources = [ "junit/res/values/strings.xml" ]
  62. mergeable_android_manifests = [ "junit/AndroidManifest_mergetest.xml" ]
  63. }
  64. robolectric_binary("build_junit_tests") {
  65. # Test has no JNI, so skip JNI Generator step.
  66. generate_final_jni = false
  67. resources_package = "org.chromium.build"
  68. sources = [
  69. "junit/src/org/chromium/build/AndroidAssetsTest.java",
  70. "junit/src/org/chromium/build/IncrementalJavacTest.java",
  71. ]
  72. deps = [
  73. ":junit_test_assets",
  74. ":junit_test_resources",
  75. "//build/android/test/incremental_javac_gn:no_signature_change_prebuilt_java",
  76. "//third_party/junit",
  77. ]
  78. }
  79. }
  80. }
  81. # TODO(go/turn-down-test-results): Remove once we turn down
  82. # test-results.appspot.com
  83. python_library("test_result_presentations_py") {
  84. pydeps_file = "pylib/results/presentation/test_results_presentation.pydeps"
  85. data = [
  86. "//build/android/pylib/results/presentation/template",
  87. "//build/android/pylib/results/presentation/javascript/main_html.js",
  88. "//third_party/catapult/third_party/gsutil/",
  89. "//third_party/jinja2/debug.py",
  90. "//third_party/six",
  91. ]
  92. }
  93. python_library("devil_chromium_py") {
  94. pydeps_file = "devil_chromium.pydeps"
  95. data = [
  96. "devil_chromium.py",
  97. "devil_chromium.json",
  98. "//third_party/catapult/third_party/gsutil/",
  99. "//third_party/catapult/devil/devil/devil_dependencies.json",
  100. # Read by gn_helpers.BuildWithChromium()
  101. "//build/config/gclient_args.gni",
  102. ]
  103. }
  104. # Contains runtime deps for installing apks.
  105. # E.g. from test_runner.py or from apk_operations.py.
  106. group("apk_installer_data") {
  107. # Other //build users let devil library fetch these from Google Storage.
  108. if (build_with_chromium) {
  109. data_deps = [
  110. "//build/android/pylib/device/commands",
  111. "//tools/android/md5sum",
  112. ]
  113. data = [ "//third_party/android_build_tools/bundletool/bundletool.jar" ]
  114. }
  115. }
  116. python_library("apk_operations_py") {
  117. pydeps_file = "apk_operations.pydeps"
  118. deps = [ ":apk_installer_data" ]
  119. }
  120. group("test_runner_py") {
  121. testonly = true
  122. deps = [
  123. ":test_runner_core_py",
  124. ":test_runner_device_support",
  125. ]
  126. }
  127. python_library("test_runner_core_py") {
  128. testonly = true
  129. pydeps_file = "test_runner.pydeps"
  130. data = [
  131. "pylib/gtest/filter/",
  132. "pylib/instrumentation/render_test.html.jinja",
  133. "test_wrapper/logdog_wrapper.py",
  134. "//third_party/requests/",
  135. ]
  136. data_deps = [ ":logdog_wrapper_py" ]
  137. }
  138. group("test_runner_device_support") {
  139. testonly = true
  140. data = [
  141. "${android_sdk_build_tools}/aapt",
  142. "${android_sdk_build_tools}/dexdump",
  143. "${android_sdk_build_tools}/lib64/libc++.so",
  144. "${android_sdk_build_tools}/split-select",
  145. "${android_sdk_root}/platform-tools/adb",
  146. ]
  147. data_deps = [
  148. ":apk_installer_data",
  149. ":devil_chromium_py",
  150. ":stack_tools",
  151. ]
  152. # Other //build users let devil library fetch these from Google Storage.
  153. if (build_with_chromium) {
  154. data_deps += [ "//tools/android/forwarder2" ]
  155. data += [ "//tools/android/avd/proto/" ]
  156. if (is_asan) {
  157. data_deps += [ "//tools/android/asan/third_party:asan_device_setup" ]
  158. }
  159. }
  160. # Proguard is needed only when using apks (rather than native executables).
  161. if (enable_java_templates) {
  162. data_deps += [ "//build/android/stacktrace:java_deobfuscate" ]
  163. }
  164. }
  165. python_library("logdog_wrapper_py") {
  166. pydeps_file = "test_wrapper/logdog_wrapper.pydeps"
  167. }
  168. python_library("resource_sizes_py") {
  169. pydeps_file = "resource_sizes.pydeps"
  170. data_deps = [
  171. ":devil_chromium_py",
  172. "//third_party/catapult/tracing:convert_chart_json",
  173. ]
  174. data = [
  175. build_vars_file,
  176. android_readelf,
  177. rebase_path("$android_ndk_library_path/libc++.so.1", root_build_dir),
  178. ]
  179. }
  180. # Tools necessary for symbolizing tombstones or stack traces that are output to
  181. # logcat.
  182. # Hidden behind build_with_chromium because some third party repos that use
  183. # //build don't pull in //third_party/android_platform.
  184. # TODO(crbug.com/1120190): Move stack script into //build/third_party
  185. # and enable unconditionally.
  186. group("stack_tools") {
  187. if (build_with_chromium) {
  188. data = [
  189. "tombstones.py",
  190. "pylib/symbols/",
  191. "stacktrace/",
  192. ]
  193. data_deps =
  194. [ "//third_party/android_platform/development/scripts:stack_py" ]
  195. }
  196. }
  197. # GN evaluates each .gn file once per toolchain, so restricting to default
  198. # toolchain will ensure write_file() is called only once.
  199. assert(current_toolchain == default_toolchain)
  200. # NOTE: If other platforms would benefit from exporting variables, we should
  201. # move this to a more top-level place.
  202. # It is currently here (instead of //BUILD.gn) to ensure that the file is
  203. # written even for non-chromium embedders of //build.
  204. _build_vars_json = {
  205. # Underscore prefix so that it appears at the top.
  206. _HEADER = "Generated during 'gn gen' by //build/android/BUILD.gn."
  207. forward_variables_from(android_build_vars_json, "*")
  208. }
  209. write_file(build_vars_file, _build_vars_json, "json")