OLD | NEW |
1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import("//build/config/android/rules.gni") | 5 import("//build/config/android/rules.gni") |
6 | 6 |
7 declare_args() { | 7 declare_args() { |
8 # The origin URL of the WebAPK. Used to generate a unique package name for | 8 # The origin URL of the WebAPK. Used to generate a unique package name for |
9 # WebAPK. Example: "foo.com" | 9 # WebAPK. Example: "foo.com" |
10 webapk_manifest_package_origin = "template" | 10 webapk_manifest_package_origin = "template" |
11 | 11 |
12 # The URL that the WebAPK should navigate to when it is launched. | 12 # The URL that the WebAPK should navigate to when it is launched. |
13 webapk_start_url = "https://www.template.com/home_page" | 13 webapk_start_url = "https://www.template.com/home_page" |
14 | 14 |
15 # The browser that the WebAPK will be bound to. | 15 # The browser that the WebAPK will be bound to. |
16 webapk_runtime_host = "com.google.android.apps.chrome" | 16 webapk_runtime_host = "com.google.android.apps.chrome" |
17 | 17 |
18 # The scope of the urls that the WebAPK can navigate to. | 18 # The scope of the urls that the WebAPK can navigate to. |
19 webapk_scope_url = "https://www.template.com" | 19 webapk_scope_url = "https://www.template.com" |
20 | 20 |
21 # Host part of |webapk_scope|. | 21 # Host part of |webapk_scope|. |
22 webapk_scope_url_host = "www.template.com" | 22 webapk_scope_url_host = "www.template.com" |
23 } | 23 } |
24 | 24 |
25 shell_apk_manifest_package = | 25 shell_apk_manifest_package = |
26 "org.chromium.webapk.$webapk_manifest_package_origin" | 26 "org.chromium.webapk.$webapk_manifest_package_origin" |
| 27 test_shell_apk_manifest_package = "org.chromium.webapk.template.test" |
27 | 28 |
28 shell_apk_manifest = "$target_gen_dir/shell_apk_manifest/AndroidManifest.xml" | 29 webapk_common_jinja_variables = [ |
| 30 "host_url=$webapk_start_url", |
| 31 "scope_url=$webapk_scope_url", |
| 32 "scope_url_host=$webapk_scope_url_host", |
| 33 ] |
| 34 |
| 35 webapk_jinja_variables = [ |
| 36 "manifest_package=$shell_apk_manifest_package", |
| 37 "runtime_host=$webapk_runtime_host", |
| 38 ] |
| 39 |
| 40 test_webapk_jinja_variables = [ |
| 41 "manifest_package=$test_shell_apk_manifest_package", |
| 42 "runtime_host=org.chromium.chrome", |
| 43 ] |
29 | 44 |
30 jinja_template("shell_apk_manifest") { | 45 jinja_template("shell_apk_manifest") { |
31 input = "AndroidManifest.xml" | 46 input = "AndroidManifest.xml" |
32 output = shell_apk_manifest | 47 output = "$target_gen_dir/shell_apk_manifest/AndroidManifest.xml" |
| 48 variables = webapk_common_jinja_variables + webapk_jinja_variables |
| 49 } |
33 | 50 |
34 variables = [ | 51 jinja_template("test_shell_apk_manifest") { |
35 "manifest_package=$shell_apk_manifest_package", | 52 input = "AndroidManifest.xml" |
36 "host_url=$webapk_start_url", | 53 output = "$target_gen_dir/test_shell_apk_manifest/AndroidManifest.xml" |
37 "runtime_host=$webapk_runtime_host", | 54 variables = webapk_common_jinja_variables + test_webapk_jinja_variables |
38 "scope_url=$webapk_scope_url", | |
39 "scope_url_host=$webapk_scope_url_host", | |
40 ] | |
41 } | 55 } |
42 | 56 |
43 android_resources("shell_apk_resources") { | 57 android_resources("shell_apk_resources") { |
44 resource_dirs = [ "res" ] | 58 resource_dirs = [ "res" ] |
45 custom_package = "org.chromium.webapk.shell_apk" | 59 custom_package = "org.chromium.webapk.shell_apk" |
46 } | 60 } |
47 | 61 |
48 android_library("dex_loader_lib") { | 62 android_library("dex_loader_lib") { |
49 java_files = [ "src/org/chromium/webapk/shell_apk/DexLoader.java" ] | 63 java_files = [ "src/org/chromium/webapk/shell_apk/DexLoader.java" ] |
50 } | 64 } |
51 | 65 |
52 # Template for WebAPK. When a WebAPK is generated: | 66 # Template for WebAPK. When a WebAPK is generated: |
53 # - Android manifest is customized to the website. | 67 # - Android manifest is customized to the website. |
54 # - App icon is extracted from the website and added to the APK's resources. | 68 # - App icon is extracted from the website and added to the APK's resources. |
55 android_apk("webapk") { | 69 template("webapk_template") { |
56 android_manifest = shell_apk_manifest | 70 android_apk(target_name) { |
57 apk_name = "WebApk.$webapk_manifest_package_origin" | 71 forward_variables_from(invoker, "*") |
58 java_files = [ | 72 java_files = [ |
59 "src/org/chromium/webapk/shell_apk/MainActivity.java", | 73 "src/org/chromium/webapk/shell_apk/MainActivity.java", |
60 "src/org/chromium/webapk/shell_apk/WebApkServiceFactory.java", | 74 "src/org/chromium/webapk/shell_apk/WebApkServiceFactory.java", |
61 ] | 75 ] |
62 deps = [ | 76 deps += [ |
63 ":dex_loader_lib", | 77 ":dex_loader_lib", |
64 ":shell_apk_manifest", | 78 ":shell_apk_manifest", |
65 ":shell_apk_resources", | 79 ":shell_apk_resources", |
66 "//chrome/android/webapk/libs/common", | 80 "//chrome/android/webapk/libs/common", |
67 "//chrome/android/webapk/libs/runtime_library", | 81 "//chrome/android/webapk/libs/runtime_library", |
68 ] | 82 ] |
69 if (!is_debug) { | 83 if (!is_debug) { |
70 proguard_enabled = true | 84 proguard_enabled = true |
71 proguard_configs = [ "//chrome/android/java/proguard.flags" ] | 85 proguard_configs = [ "//chrome/android/java/proguard.flags" ] |
| 86 } |
72 } | 87 } |
73 } | 88 } |
74 | 89 |
| 90 webapk_template("webapk") { |
| 91 android_manifest = get_target_outputs(":shell_apk_manifest") |
| 92 android_manifest = android_manifest[1] |
| 93 apk_name = "WebApk.$webapk_manifest_package_origin" |
| 94 |
| 95 deps = [ |
| 96 ":shell_apk_manifest", |
| 97 ] |
| 98 } |
| 99 |
| 100 # The |test_webapk| target is used for WebAPK's instrumentation tests in the |
| 101 # target chrome_public_test_apk. |test_webapk|'s package name and runtime |
| 102 # host are set to be compatible with the instrumentation tests and are not |
| 103 # customizable. |
| 104 webapk_template("test_webapk") { |
| 105 android_manifest = get_target_outputs(":test_shell_apk_manifest") |
| 106 android_manifest = android_manifest[1] |
| 107 apk_name = "TestWebApk" |
| 108 |
| 109 deps = [ |
| 110 ":test_shell_apk_manifest", |
| 111 ] |
| 112 } |
| 113 |
75 android_library("shell_apk_javatests") { | 114 android_library("shell_apk_javatests") { |
76 testonly = true | 115 testonly = true |
77 java_files = | 116 java_files = |
78 [ "javatests/src/org/chromium/webapk/shell_apk/DexLoaderTest.java" ] | 117 [ "javatests/src/org/chromium/webapk/shell_apk/DexLoaderTest.java" ] |
79 deps = [ | 118 deps = [ |
80 ":dex_loader_lib", | 119 ":dex_loader_lib", |
81 "//base:base_java", | 120 "//base:base_java", |
82 "//base:base_java_test_support", | 121 "//base:base_java_test_support", |
83 "//chrome/android/webapk/libs/common", | 122 "//chrome/android/webapk/libs/common", |
84 "//content/public/test/android:content_java_test_support", | 123 "//content/public/test/android:content_java_test_support", |
85 ] | 124 ] |
86 srcjar_deps = [ "javatests/dex_optimizer:dex_optimizer_service_aidl" ] | 125 srcjar_deps = [ "javatests/dex_optimizer:dex_optimizer_service_aidl" ] |
87 } | 126 } |
OLD | NEW |