Roll src/third_party/WebKit 3529d49:06e8485 (svn 202554:202555)
[chromium-blink-merge.git] / chrome / android / BUILD.gn
blob15d7b992da1d86348451815a336b4c526b76f1a1
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.
5 import("//build/config/android/config.gni")
6 import("//build/config/android/rules.gni")
7 import("//build/module_args/v8.gni")
8 import("//chrome/version.gni")
9 import("//testing/test.gni")
10 import("//third_party/icu/config.gni")
11 import("//third_party/protobuf/proto_library.gni")
12 import("channel.gni")
14 manifest_package = "org.chromium.chrome"
15 if (enable_configuration_policy) {
16   configuration_policy = 1
17 } else {
18   configuration_policy = 0
21 jinja_variables = [
22   "channel=$android_channel",
23   "manifest_package=$manifest_package",
24   "configuration_policy=$configuration_policy",
27 chrome_android_paks_gypi =
28     exec_script("//build/gypi_to_gn.py",
29                 [
30                   rebase_path("//chrome/chrome_android_paks.gypi"),
31                   "--replace=<(PRODUCT_DIR)=$root_out_dir",
32                 ],
33                 "scope",
34                 [ "//chrome/chrome_android_paks.gypi" ])
36 locale_pak_resources("chrome_locale_paks") {
37   sources = chrome_android_paks_gypi.chrome_android_pak_locale_resources
39   deps = [
40     "//chrome:packed_resources",
41   ]
44 # GYP: //chrome/chrome.gyp:chrome_java (resources part)
45 android_resources("chrome_java_resources") {
46   resource_dirs = [
47     "java/res",
48     "//chrome/android/java/res_chromium",
49   ]
50   deps = [
51     ":chrome_locale_paks",
52     ":chrome_strings_grd",
53     "//components/policy:app_restrictions_resources",
54     "//content/public/android:content_java_resources",
55     "//chrome/app:java_strings_grd",
56     "//third_party/android_data_chart:android_data_chart_java_resources",
57     "//third_party/android_media:android_media_resources",
58   ]
59   if (!enable_configuration_policy) {
60     deps -= [ "//components/policy:app_restrictions_resources" ]
61   }
62   custom_package = "org.chromium.chrome"
65 # GYP: //chrome/chrome.gyp:chrome_strings_grd
66 java_strings_grd("chrome_strings_grd") {
67   grd_file = "java/strings/android_chrome_strings.grd"
68   outputs = [
69     "values-am/android_chrome_strings.xml",
70     "values-ar/android_chrome_strings.xml",
71     "values-bg/android_chrome_strings.xml",
72     "values-ca/android_chrome_strings.xml",
73     "values-cs/android_chrome_strings.xml",
74     "values-da/android_chrome_strings.xml",
75     "values-de/android_chrome_strings.xml",
76     "values-el/android_chrome_strings.xml",
77     "values/android_chrome_strings.xml",
78     "values-en-rGB/android_chrome_strings.xml",
79     "values-es/android_chrome_strings.xml",
80     "values-es-rUS/android_chrome_strings.xml",
81     "values-fa/android_chrome_strings.xml",
82     "values-fi/android_chrome_strings.xml",
83     "values-tl/android_chrome_strings.xml",
84     "values-fr/android_chrome_strings.xml",
85     "values-hi/android_chrome_strings.xml",
86     "values-hr/android_chrome_strings.xml",
87     "values-hu/android_chrome_strings.xml",
88     "values-in/android_chrome_strings.xml",
89     "values-it/android_chrome_strings.xml",
90     "values-iw/android_chrome_strings.xml",
91     "values-ja/android_chrome_strings.xml",
92     "values-ko/android_chrome_strings.xml",
93     "values-lt/android_chrome_strings.xml",
94     "values-lv/android_chrome_strings.xml",
95     "values-nl/android_chrome_strings.xml",
96     "values-nb/android_chrome_strings.xml",
97     "values-pl/android_chrome_strings.xml",
98     "values-pt-rBR/android_chrome_strings.xml",
99     "values-pt-rPT/android_chrome_strings.xml",
100     "values-ro/android_chrome_strings.xml",
101     "values-ru/android_chrome_strings.xml",
102     "values-sk/android_chrome_strings.xml",
103     "values-sl/android_chrome_strings.xml",
104     "values-sr/android_chrome_strings.xml",
105     "values-sv/android_chrome_strings.xml",
106     "values-sw/android_chrome_strings.xml",
107     "values-th/android_chrome_strings.xml",
108     "values-tr/android_chrome_strings.xml",
109     "values-uk/android_chrome_strings.xml",
110     "values-vi/android_chrome_strings.xml",
111     "values-zh-rCN/android_chrome_strings.xml",
112     "values-zh-rTW/android_chrome_strings.xml",
113   ]
116 # GYP: //chrome/chrome.gyp:chrome_java
117 android_library("chrome_java") {
118   deps = [
119     ":chrome_java_resources",
120     ":document_tab_model_info_proto_java",
121     "//base:base_java",
122     "//net/android:net_java",
123     "//components/bookmarks/common/android:bookmarks_java",
124     "//components/dom_distiller/android:dom_distiller_content_java",
125     "//components/dom_distiller/android:dom_distiller_core_java",
126     "//components/gcm_driver/android:gcm_driver_java",
127     "//components/invalidation/impl:java",
128     "//components/navigation_interception/android:navigation_interception_java",
129     "//components/policy/android:policy_java",
130     "//components/precache/android:precache_java",
131     "//components/safe_json/android:safe_json_java",
132     "//components/service_tab_launcher:service_tab_launcher_java",
133     "//components/signin/core/browser/android:java",
134     "//components/variations/android:variations_java",
135     "//components/web_contents_delegate_android:web_contents_delegate_android_java",
136     "//content/public/android:content_java",
137     "//media/base/android:media_java",
138     "//printing:printing_java",
139     "//sync/android:sync_java",
140     "//third_party/android_data_chart:android_data_chart_java",
141     "//third_party/android_media:android_media_java",
142     "//third_party/android_protobuf:protobuf_nano_javalib",
143     "//third_party/android_swipe_refresh:android_swipe_refresh_java",
144     "//third_party/android_tools:android_gcm_java",
145     "//third_party/android_tools:android_support_design_java",
146     "//third_party/android_tools:android_support_v13_java",
147     "//third_party/android_tools:android_support_v7_appcompat_java",
148     "//third_party/android_tools:android_support_v7_mediarouter_java",
149     "//third_party/android_tools:android_support_v7_mediarouter_resources",
150     "//third_party/android_tools:android_support_v7_recyclerview_java",
151     "//third_party/cacheinvalidation:cacheinvalidation_javalib",
152     "//third_party/cacheinvalidation:cacheinvalidation_proto_java",
153     "//third_party/jsr-305:jsr_305_javalib",
154     "//third_party/WebKit/public:blink_headers_java",
155     "//media/base/android:media_java",
156     "//media/midi:midi_java",
157     "//ui/android:ui_java",
158     "//ui/android:ui_java_resources",
159     google_play_services_library,
160   ]
162   srcjar_deps = [
163     ":chrome_android_java_enums_srcjar",
164     ":chrome_version_srcjar",
165     ":custom_tabs_service_aidl",
166     ":resource_id_javagen",
167     "//chrome:page_info_connection_type_javagen",
168     "//chrome:content_setting_javagen",
169     "//chrome:content_settings_type_javagen",
170     "//components/enhanced_bookmarks:enhanced_bookmarks_java_enums_srcjar",
171     "//components/offline_pages:offline_pages_enums_java",
172   ]
174   DEPRECATED_java_in_dir = "java/src"
177 # GYP: //chrome/chrome_browser.gypi:activity_type_ids_java
178 # GYP: //chrome/chrome_browser.gypi:connectivity_check_result_java
179 # GYP: //chrome/chrome_browser.gypi:shortcut_source_java
180 # GYP: //chrome/chrome_browser.gypi:profile_account_management_metrics_java
181 # GYP: //chrome/chrome_browser.gypi:connection_security_levels_java
182 # GYP: //chrome/chrome_browser.gypi:tab_load_status_java
183 # GYP: //chrome/chrome_browser.gypi:infobar_action_type_java
184 java_cpp_enum("chrome_android_java_enums_srcjar") {
185   sources = [
186     "//chrome/browser/android/activity_type_ids.h",
187     "//chrome/browser/android/feedback/connectivity_checker.cc",
188     "//chrome/browser/android/shortcut_info.h",
189     "//chrome/browser/android/tab_android.h",
190     "//chrome/browser/profiles/profile_metrics.h",
191     "//chrome/browser/ssl/security_state_model.h",
192     "//chrome/browser/ui/android/infobars/infobar_android.h",
193   ]
194   outputs = [
195     "org/chromium/chrome/browser/ActivityTypeIds.java",
196     "org/chromium/chrome/browser/feedback/ConnectivityCheckResult.java",
197     "org/chromium/chrome/browser/ShortcutSource.java",
198     "org/chromium/chrome/browser/TabLoadStatus.java",
199     "org/chromium/chrome/browser/profiles/ProfileAccountManagementMetrics.java",
200     "org/chromium/chrome/browser/ssl/ConnectionSecurityLevel.java",
201     "org/chromium/chrome/browser/infobar/ActionType.java",
202   ]
205 # GYP: //chrome/chrome_browser.gypi:document_tab_model_info_proto_java
206 proto_java_library("document_tab_model_info_proto_java") {
207   proto_path = "java/src/org/chromium/chrome/browser/tabmodel/document"
208   sources = [
209     "$proto_path/document_tab_model_info.proto",
210   ]
213 # GYP: //chrome/chrome_browser.gypi:resource_id_java
214 java_cpp_template("resource_id_javagen") {
215   sources = [
216     "java/ResourceId.template",
217   ]
218   package_name = "org/chromium/chrome/browser"
219   inputs = [
220     "../browser/android/resource_id.h",
221   ]
224 # GYP: //chrome/chrome_tests.gypi:chrome_junit_tests
225 junit_binary("chrome_junit_tests") {
226   java_files = [
227     "junit/src/org/chromium/chrome/browser/childaccounts/ChildAccountServiceTest.java",
228     "junit/src/org/chromium/chrome/browser/externalauth/ExternalAuthUtilsTest.java",
229     "junit/src/org/chromium/chrome/browser/omaha/ResponseParserTest.java",
230     "junit/src/org/chromium/chrome/browser/media/remote/AbstractMediaRouteControllerTest.java",
231     "junit/src/org/chromium/chrome/browser/media/remote/MediaUrlResolverTest.java",
232     "junit/src/org/chromium/chrome/browser/media/remote/RemoteVideoInfoTest.java",
233     "junit/src/org/chromium/chrome/browser/media/remote/TransportControlTest.java",
234   ]
235   deps = [
236     ":chrome_java",
237     "//base:base_java",
238     "//base:base_java_test_support",
239     "//base:base_junit_test_support",
240     "//sync:sync_java_test_support",
241     "//sync/android:sync_java",
242     "//third_party/junit:hamcrest",
243     "//third_party/android_tools:android_support_v7_mediarouter_java",
244   ]
247 # GYP: //chrome/chrome_tests.gypi:chrome_uiautomator_tests_java
248 android_library("chrome_uiautomator_tests_java") {
249   testonly = true
250   DEPRECATED_java_in_dir = "uiautomator_tests/src"
251   deps = [
252     "//base:base_java_test_support",
253     "//third_party/android_tools:uiautomator_java",
254   ]
257 # GYP: //chrome/chrome_tests.gypi:chrome_uiautomator_tests
258 uiautomator_test("chrome_uiautomator_tests") {
259   testonly = true
260   deps = [
261     ":chrome_uiautomator_tests_java",
262   ]
265 # GYP: //chrome/chrome_android.gypi:chrome_version_java
266 chrome_version_java_dir = "$root_gen_dir/templates/chrome_version_java"
267 chrome_version_java_file = "$chrome_version_java_dir/org/chromium/chrome/browser/ChromeVersionConstants.java"
268 process_version("chrome_version_java") {
269   template_file = "java/ChromeVersionConstants.java.version"
270   output = chrome_version_java_file
271   extra_args = [
272     "-e",
273     "CHANNEL=str.upper('$android_channel')",
274   ]
277 zip("chrome_version_srcjar") {
278   inputs = [
279     chrome_version_java_file,
280   ]
281   output = "$target_gen_dir/$target_name.srcjar"
282   base_dir = chrome_version_java_dir
283   deps = [
284     ":chrome_version_java",
285   ]
288 #GYP: //chrome/android/chrome_apk.gyp:custom_tabs_service_aidl
289 android_aidl("custom_tabs_service_aidl") {
290   import_include = "java/src/android/support/customtabs"
291   interface_file = "java/src/android/support/customtabs/common.aidl"
292   sources = [
293     "java/src/android/support/customtabs/ICustomTabsCallback.aidl",
294     "java/src/android/support/customtabs/ICustomTabsService.aidl",
295   ]
298 # GYP: //chrome/android/chrome_apk.gyp:chrome_shared_test_java
299 android_library("chrome_shared_test_java") {
300   testonly = true
301   DEPRECATED_java_in_dir = "javatests/src"
303   deps = [
304     "//base:base_java",
305     "//base:base_java_test_support",
306     "//chrome/android:chrome_java",
307     "//chrome/android:chrome_java_resources",
308     "//chrome/test/android:chrome_java_test_support",
309     "//components/bookmarks/common/android:bookmarks_java",
310     "//components/dom_distiller/android:dom_distiller_core_java",
311     "//components/invalidation/impl:java",
312     "//components/invalidation/impl:javatests",
313     "//components/navigation_interception/android:navigation_interception_java",
314     "//components/policy/android:policy_java",
315     "//components/precache/android:precache_java",
316     "//components/precache/android:precache_javatests",
317     "//components/web_contents_delegate_android:web_contents_delegate_android_java",
318     "//content/public/android:content_java",
319     "//content/public/test/android:content_java_test_support",
320     "//net/android:net_java",
321     "//net/android:net_java_test_support",
322     "//printing:printing_java",
323     "//sync/android:sync_java",
324     "//sync/android:sync_javatests",
325     "//sync:sync_java_test_support",
326     "//third_party/android_tools:android_support_v7_appcompat_java",
327     "//third_party/android_tools:android_support_v7_recyclerview_java",
328     "//third_party/android_tools:android_support_v13_java",
329     "//third_party/android_tools:legacy_http_javalib",
330     "//third_party/cacheinvalidation:cacheinvalidation_javalib",
331     "//third_party/jsr-305:jsr_305_javalib",
332     "//ui/android:ui_java",
333     "//ui/android:ui_javatests",
334   ]
337 # Overrides icon / name defined in chrome_java_resources.
338 android_resources("chrome_public_apk_resources") {
339   resource_dirs = [ "java/res_chromium" ]
341   # Dep needed to ensure override works properly.
342   deps = [
343     ":chrome_java_resources",
344   ]
347 chrome_public_apk_assets_dir = "$root_build_dir/chrome_public_apk_assets"
349 copy_ex("chrome_public_apk_assets") {
350   clear_dir = true
351   dest = chrome_public_apk_assets_dir
352   sources = chrome_android_paks_gypi.chrome_android_pak_input_resources
353   if (icu_use_data_file) {
354     sources += [ "$root_build_dir/icudtl.dat" ]
355   }
356   deps = [
357     "//chrome:packed_extra_resources",
358     "//chrome:packed_resources",
359     "//third_party/icu:icudata",
360   ]
362   if (v8_use_external_startup_data) {
363     sources += [
364       "$root_build_dir/natives_blob.bin",
365       "$root_build_dir/snapshot_blob.bin",
366     ]
367     deps += [ "//v8" ]
368   }
370   sources += [ "$root_build_dir/resources.pak" ]
373 # GYP: //chrome/android/chrome_apk.gyp:chrome_apk_manifest
374 jinja_template("chrome_public_apk_manifest") {
375   input = "java/AndroidManifest.xml"
376   output = "$root_gen_dir/chrome_public_apk_manifest/AndroidManifest.xml"
377   variables = jinja_variables
378   variables += [
379     "min_sdk_version=16",
380     "target_sdk_version=23",
381   ]
384 # GYP: //chrome/android/chrome_apk.gyp:chrome_public_template_resources
385 jinja_template_resources("chrome_public_template_resources") {
386   resources = [
387     "java/res_template/xml/searchable.xml",
388     "java/res_template/xml/syncadapter.xml",
389   ]
390   res_dir = "java/res_template"
391   variables = jinja_variables
394 # GYP: //chrome/android/chrome_apk.gyp:libchrome_public
395 shared_library("chrome_public") {
396   deps = [
397     "//build/config/sanitizers:deps",
398     "//chrome:chrome_android_core",
399   ]
400   gypi_values = exec_script(
401           "//build/gypi_to_gn.py",
402           [
403             rebase_path("chrome_apk.gyp"),
404             "--replace=<(chrome_native_sources_dir)=../browser/android/",
405           ],
406           "scope",
407           [ "chrome_apk.gyp" ])
408   sources = gypi_values.chrome_public_app_native_sources
410   # TODO(GYP):
411   #'target_conditions': [
412   #['component != "shared_library"', {
413   #'product_extension': '<(version_libchrome_short).so',
414   #}],
415   #],
418 android_apk("chrome_public_apk") {
419   version_name = "Developer Build"
420   version_code = "1"
421   android_manifest = get_target_outputs(":chrome_public_apk_manifest")
422   android_manifest = android_manifest[1]
423   apk_name = "ChromePublic"
424   native_libs = [ "$root_build_dir/lib.stripped/libchrome_public.so" ]
425   native_lib_version_rule = "//build/util:chrome_version_json"
426   _native_lib_file =
427       rebase_path("$root_gen_dir/CHROME_VERSION.json", root_out_dir)
428   native_lib_version_arg = "@FileArg($_native_lib_file:full-quoted)"
429   asset_location = chrome_public_apk_assets_dir
431   deps = [
432     ":chrome_java",
433     ":chrome_public",
434     ":chrome_public_apk_assets",
435     ":chrome_public_apk_manifest",
436     ":chrome_public_apk_resources",
437     ":chrome_public_template_resources",
438     "//base:base_java",
439     google_play_services_resources,
440   ]
443 chrome_public_test_apk_manifest =
444     "$root_gen_dir/chrome_public_test_apk_manifest/AndroidManifest.xml"
446 # GYP: //chrome/android/chrome_apk.gyp:chrome_public_test_apk_manifest
447 jinja_template("chrome_public_test_apk_manifest") {
448   input = "javatests/AndroidManifest.xml"
449   output = chrome_public_test_apk_manifest
450   variables = jinja_variables
453 # GYP: //chrome/android/chrome_apk.gyp:chrome_public_test_apk
454 instrumentation_test_apk("chrome_public_test_apk") {
455   # TODO(GYP,cjhopman): Does this need version code/name?
456   apk_name = "ChromePublicTest"
457   apk_under_test = ":chrome_public_apk"
458   android_manifest = chrome_public_test_apk_manifest
459   deps = [
460     ":chrome_public_test_apk_manifest",
461     "//chrome/android:chrome_shared_test_java",
462   ]
463   isolate_file = "../chrome_public_test_apk.isolate"