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/config.gni") | |
6 import("//build/config/android/rules.gni") | |
7 | |
8 declare_args() { | 5 declare_args() { |
9 # Controls whether we build app.skyx bundles in the sky_app template below. | 6 # Controls whether we build app.skyx bundles in the sky_app template below. |
10 # An app.skyx bundle contains all the code an resources needed to run a Sky | 7 # An app.skyx bundle contains all the code an resources needed to run a Sky |
11 # app offline. Unfortunately, we don't yet have all the Dart packages we need | 8 # app offline. Unfortunately, we don't yet have all the Dart packages we need |
12 # to create skyx packages installed on the build bots, so this functionality | 9 # to create skyx packages installed on the build bots, so this functionality |
13 # is currently disabled. This flag allows for local testing of this feature. | 10 # is currently disabled. This flag allows for local testing of this feature. |
14 enable_skyx = false | 11 enable_skyx = false |
15 } | 12 } |
16 | 13 |
17 package_root = "$root_gen_dir/dart-pkg/packages" | 14 package_root = "$root_gen_dir/dart-pkg/packages" |
18 | 15 |
19 template("sky_apk") { | 16 template("skyx") { |
20 android_apk(target_name) { | 17 bundle_prefix = target_name |
21 apk_name = invoker.apk_name | 18 bundle = "$target_gen_dir/${bundle_prefix}.skyx" |
22 android_manifest = invoker.android_manifest | 19 snapshot = "$target_gen_dir/${bundle_prefix}_snapshot.bin" |
23 | 20 |
24 native_libs = [ "libsky_shell.so" ] | 21 action("gen_${bundle_prefix}_snapshot") { |
25 asset_location = "$root_build_dir/sky_shell/assets" | |
26 | |
27 deps = [ | |
28 "//base:base_java", | |
29 "//sky/shell:assets", | |
30 "//sky/shell:java", | |
31 "//sky/shell:sky_shell", | |
32 ] + invoker.deps | |
33 } | |
34 } | |
35 | |
36 template("sky_app") { | |
37 # Note: org.domokit.sky.shell.SkyApplication knows about 'snapshot_blob.bin'. | |
38 snapshot = "$target_gen_dir/snapshot_blob.bin" | |
39 | |
40 action("gen_snapshot") { | |
41 main_dart = invoker.main_dart | 22 main_dart = invoker.main_dart |
42 | 23 |
43 inputs = [ | 24 inputs = [ |
44 main_dart, | 25 main_dart, |
45 ] | 26 ] |
46 outputs = [ | 27 outputs = [ |
47 snapshot, | 28 snapshot, |
48 ] | 29 ] |
49 | 30 |
| 31 if (defined(invoker.sources)) { |
| 32 inputs += sources |
| 33 } |
| 34 |
50 sky_packager_dir = | 35 sky_packager_dir = |
51 get_label_info("//sky/tools/packager($host_toolchain)", "root_out_dir") | 36 get_label_info("//sky/tools/packager($host_toolchain)", "root_out_dir") |
52 | 37 |
53 script = "//sky/tools/sky_packager.py" | 38 script = "//sky/tools/sky_packager.py" |
54 | 39 |
55 src_dir = "//" | 40 src_dir = "//" |
56 cwd = rebase_path(src_dir, root_build_dir) | 41 cwd = rebase_path(src_dir, root_build_dir) |
57 | 42 |
58 args = [ | 43 args = [ |
59 rebase_path("$sky_packager_dir/sky_packager", src_dir), | 44 rebase_path("$sky_packager_dir/sky_packager", src_dir), |
60 rebase_path(main_dart, src_dir), | 45 rebase_path(main_dart, src_dir), |
61 "--package-root", | 46 "--package-root", |
62 rebase_path(package_root, src_dir), | 47 rebase_path(package_root, src_dir), |
63 "--snapshot", | 48 "--snapshot", |
64 rebase_path(snapshot, src_dir), | 49 rebase_path(snapshot, src_dir), |
65 "-C", | 50 "-C", |
66 cwd, | 51 cwd, |
67 ] | 52 ] |
68 | 53 |
69 deps = [ | 54 deps = [ |
70 "//sky/tools/packager($host_toolchain)", | 55 "//sky/tools/packager($host_toolchain)", |
71 "//sky/sdk", | 56 "//sky/sdk", |
72 ] | 57 ] |
| 58 |
| 59 if (defined(invoker.deps)) { |
| 60 deps += invoker.deps |
| 61 } |
73 } | 62 } |
74 | 63 |
75 app_bundle = "$target_gen_dir/app.skyx" | 64 action("gen_${bundle_prefix}_bundle") { |
76 | |
77 action("gen_bundle") { | |
78 asset_base = "$package_root/sky/assets/material-design-icons" | 65 asset_base = "$package_root/sky/assets/material-design-icons" |
79 sky_yaml = invoker.sky_yaml | |
80 | 66 |
81 sources = [ | 67 sources = [ |
82 "//sky/tools/skyx/bin/skyx.dart", | 68 "//sky/tools/skyx/bin/skyx.dart", |
83 sky_yaml, | |
84 snapshot, | 69 snapshot, |
85 ] | 70 ] |
86 | 71 |
87 outputs = [ | 72 outputs = [ |
88 app_bundle, | 73 bundle, |
89 ] | 74 ] |
90 | 75 |
91 script = "//sky/tools/skyx.py" | 76 script = "//sky/tools/skyx.py" |
92 args = [ | 77 args = [ |
93 "--asset-base", | 78 "--asset-base", |
94 rebase_path(asset_base, root_build_dir), | 79 rebase_path(asset_base, root_build_dir), |
95 "--snapshot", | 80 "--snapshot", |
96 rebase_path(snapshot, root_build_dir), | 81 rebase_path(snapshot, root_build_dir), |
97 "-o", | 82 "-o", |
98 rebase_path(app_bundle, root_build_dir), | 83 rebase_path(bundle, root_build_dir), |
99 rebase_path(sky_yaml, root_build_dir), | |
100 ] | 84 ] |
101 | 85 |
| 86 if (defined(invoker.manifest)) { |
| 87 sources += [ invoker.manifest ] |
| 88 args += [ |
| 89 "--manifest", |
| 90 rebase_path(invoker.manifest, root_build_dir), |
| 91 ] |
| 92 } |
| 93 |
102 deps = [ | 94 deps = [ |
103 ":gen_snapshot", | 95 ":gen_${bundle_prefix}_snapshot", |
104 ] | 96 ] |
105 } | 97 } |
106 | 98 |
107 copy_ex("assets") { | 99 group(target_name) { |
108 clear_dir = true | |
109 dest = "$target_gen_dir/assets" | |
110 | |
111 sources = [ | |
112 "$root_build_dir/icudtl.dat", | |
113 ] | |
114 | |
115 deps = [ | |
116 "//third_party/icu", | |
117 ] | |
118 | |
119 if (enable_skyx) { | 100 if (enable_skyx) { |
120 sources += [ app_bundle ] | 101 deps = [ |
121 deps += [ ":gen_bundle" ] | 102 ":gen_${bundle_prefix}_bundle", |
122 } | 103 ] |
123 } | |
124 | |
125 android_apk(target_name) { | |
126 apk_name = invoker.apk_name | |
127 android_manifest = "apk/AndroidManifest.xml" | |
128 | |
129 native_libs = [ "libsky_shell.so" ] | |
130 asset_location = "$target_gen_dir/assets" | |
131 | |
132 deps = [ | |
133 "//base:base_java", | |
134 "//sky/shell:assets", | |
135 "//sky/shell:java", | |
136 "//sky/shell:sky_shell", | |
137 ":assets", | |
138 ] | |
139 | |
140 if (defined(invoker.deps)) { | |
141 deps += invoker.deps | |
142 } | 104 } |
143 } | 105 } |
144 } | 106 } |
OLD | NEW |