Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: build/config/android/internal_rules.gni

Issue 361633002: [Android][gn] Add android resources templates (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gn-java
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 import("config.gni") 1 import("config.gni")
2 2
3 assert(is_android)
4
5
6 rebased_android_sdk = rebase_path(android_sdk, root_build_dir)
7 rebased_android_sdk_root = rebase_path(android_sdk_root, root_build_dir)
8 rebased_android_sdk_build_tools = rebase_path(android_sdk_build_tools, root_buil d_dir)
9
10
3 template("write_build_config") { 11 template("write_build_config") {
4 assert(defined(invoker.type)) 12 assert(defined(invoker.type))
5 assert(defined(invoker.base_path)) 13 assert(defined(invoker.base_path))
6 14
7 base_path = invoker.base_path 15 base_path = invoker.base_path
8 type = invoker.type 16 type = invoker.type
9 build_config = base_path + ".build_config" 17 build_config = base_path + ".build_config"
10 18
11 assert(type == "android_library" || type == "android_binary") 19 assert(type == "android_binary" || type == "android_library" || type == "andro id_resources")
12 20
13 action(target_name) { 21 action(target_name) {
14 script = "//build/android/gyp/write_build_config.py" 22 script = "//build/android/gyp/write_build_config.py"
15 depfile = "$target_gen_dir/$target_name.d" 23 depfile = "$target_gen_dir/$target_name.d"
16 24
17 deps = [] 25 deps = []
18 if (defined(invoker.deps)) { 26 if (defined(invoker.deps)) {
19 deps += invoker.deps 27 deps += invoker.deps
20 } 28 }
21 29
(...skipping 10 matching lines...) Expand all
32 "--possible-deps-configs=$rebase_possible_deps_configs", 40 "--possible-deps-configs=$rebase_possible_deps_configs",
33 "--build-config", rebase_path(build_config, root_build_dir), 41 "--build-config", rebase_path(build_config, root_build_dir),
34 ] 42 ]
35 43
36 if (type == "android_library") { 44 if (type == "android_library") {
37 jar_path = base_path + ".jar" 45 jar_path = base_path + ".jar"
38 args += [ 46 args += [
39 "--jar-path", rebase_path(jar_path, root_build_dir), 47 "--jar-path", rebase_path(jar_path, root_build_dir),
40 ] 48 ]
41 } 49 }
50
51 if (type == "android_resources") {
52 assert(defined(invoker.resources_zip))
53 args += [
54 "--resources-zip", rebase_path(invoker.resources_zip, root_build_dir),
55 ]
56 if (defined(invoker.srcjar)) {
57 args += [
58 "--srcjar", rebase_path(invoker.srcjar, root_build_dir)
59 ]
60 }
61 }
42 } 62 }
43 } 63 }
44 64
65
45 # Creates a zip archive of the inputs. 66 # Creates a zip archive of the inputs.
46 # If base_dir is provided, the archive paths will be relative to it. 67 # If base_dir is provided, the archive paths will be relative to it.
47 template("zip") { 68 template("zip") {
48 assert(defined(invoker.inputs)) 69 assert(defined(invoker.inputs))
49 assert(defined(invoker.output)) 70 assert(defined(invoker.output))
50 71
51 rebase_inputs = rebase_path(invoker.inputs, root_build_dir) 72 rebase_inputs = rebase_path(invoker.inputs, root_build_dir)
52 rebase_output = rebase_path(invoker.output, root_build_dir) 73 rebase_output = rebase_path(invoker.output, root_build_dir)
53 action(target_name) { 74 action(target_name) {
54 script = "//build/android/gn/zip.py" 75 script = "//build/android/gn/zip.py"
55 depfile = "$target_gen_dir/$target_name.d" 76 depfile = "$target_gen_dir/$target_name.d"
56 source_prereqs = invoker.inputs 77 source_prereqs = invoker.inputs
57 outputs = [depfile, invoker.output] 78 outputs = [depfile, invoker.output]
58 args = [ 79 args = [
59 "--depfile", rebase_path(depfile, root_build_dir), 80 "--depfile", rebase_path(depfile, root_build_dir),
60 "--inputs=$rebase_inputs", 81 "--inputs=$rebase_inputs",
61 "--output=$rebase_output", 82 "--output=$rebase_output",
62 ] 83 ]
63 if (defined(invoker.base_dir)) { 84 if (defined(invoker.base_dir)) {
64 args += [ 85 args += [
65 "--base-dir", rebase_path(invoker.base_dir, root_build_dir) 86 "--base-dir", rebase_path(invoker.base_dir, root_build_dir)
66 ] 87 ]
67 } 88 }
68 } 89 }
69 } 90 }
70 91
71 # Compiles and jars a set of java_files. 92
93 # Compiles and jars a set of java files.
72 # 94 #
73 # Outputs: 95 # Outputs:
74 # $jar_path.jar 96 # $jar_path.jar
75 # $jar_path.jar.TOC 97 # $jar_path.jar.TOC
76 # 98 #
77 # Variables 99 # Variables
78 # java_files: List of .java files to compile. 100 # java_files: List of .java files to compile.
79 # java_deps: List of java dependencies. These should all have a .jar output 101 # java_deps: List of java dependencies. These should all have a .jar output
80 # at "${target_gen_dir}/${target_name}.jar. 102 # at "${target_gen_dir}/${target_name}.jar.
81 # chromium_code: If 1, enable extra warnings. 103 # chromium_code: If 1, enable extra warnings.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 rebase_system_jars = rebase_path(system_jars, root_build_dir) 157 rebase_system_jars = rebase_path(system_jars, root_build_dir)
136 rebase_java_srcjars = rebase_path(java_srcjars, root_build_dir) 158 rebase_java_srcjars = rebase_path(java_srcjars, root_build_dir)
137 rebase_build_config = rebase_path(build_config, root_build_dir) 159 rebase_build_config = rebase_path(build_config, root_build_dir)
138 rebase_depfile = rebase_path(depfile, root_build_dir) 160 rebase_depfile = rebase_path(depfile, root_build_dir)
139 args = [ 161 args = [
140 "--depfile=$rebase_depfile", 162 "--depfile=$rebase_depfile",
141 "--classpath=$rebase_system_jars", 163 "--classpath=$rebase_system_jars",
142 "--classpath=@($rebase_build_config:javac:classpath)", 164 "--classpath=@($rebase_build_config:javac:classpath)",
143 "--jar-path=$rebase_jar_path", 165 "--jar-path=$rebase_jar_path",
144 "--java-srcjars=$rebase_java_srcjars", 166 "--java-srcjars=$rebase_java_srcjars",
167 "--java-srcjars=@($rebase_build_config:javac:srcjars)",
145 "--jar-excluded-classes=$jar_excluded_patterns", 168 "--jar-excluded-classes=$jar_excluded_patterns",
146 ] 169 ]
147 if (chromium_code) { 170 if (chromium_code) {
148 args += ["--chromium-code"] 171 args += ["--chromium-code"]
149 } 172 }
150 173
151 args += rebase_path(java_files, root_build_dir) 174 args += rebase_path(java_files, root_build_dir)
152 } 175 }
153 176
154 # TODO(cjhopman): proguard 177 # TODO(cjhopman): proguard
(...skipping 12 matching lines...) Expand all
167 } 190 }
168 191
169 group(target_name) { 192 group(target_name) {
170 deps = [ 193 deps = [
171 ":${target_name}__javac", 194 ":${target_name}__javac",
172 ":${target_name}__jar_toc", 195 ":${target_name}__jar_toc",
173 ] 196 ]
174 } 197 }
175 } 198 }
176 199
200
177 # This adds Android-specific parts to the java_library template. 201 # This adds Android-specific parts to the java_library template.
178 # 202 #
179 # Runs Android lint against the compiled java files. 203 # Runs Android lint against the compiled java files.
180 # Dexes the output jar for inclusion in an APK. 204 # Dexes the output jar for inclusion in an APK.
181 template("android_java_library") { 205 template("android_java_library") {
182 assert(defined(invoker.java_files)) 206 assert(defined(invoker.java_files))
183 207
184 assert(defined(invoker.build_config)) 208 assert(defined(invoker.build_config))
185 assert(defined(invoker.jar_path)) 209 assert(defined(invoker.jar_path))
186 210
(...skipping 12 matching lines...) Expand all
199 223
200 # TODO(cjhopman): lint 224 # TODO(cjhopman): lint
201 # TODO(cjhopman): dex 225 # TODO(cjhopman): dex
202 226
203 group(target_name) { 227 group(target_name) {
204 deps = [ 228 deps = [
205 ":${target_name}__java_library" 229 ":${target_name}__java_library"
206 ] 230 ]
207 } 231 }
208 } 232 }
233
234
235 # Runs process_resources.py
236 template("process_resources") {
237 zip_path = invoker.zip_path
238 srcjar_path = invoker.srcjar_path
239 build_config = invoker.build_config
240 resource_dirs = invoker.resource_dirs
241 android_manifest = invoker.android_manifest
242
243 action(target_name) {
244 script = "//build/android/gyp/process_resources.py"
245
246 depfile = "$target_gen_dir/$target_name.d"
247 outputs = [
248 depfile,
249 zip_path,
250 srcjar_path,
251 ]
252
253 sources_build_rel = exec_script(
254 "//build/android/gyp/find.py",
255 rebase_path(resource_dirs, root_build_dir),
256 "list lines"
257 )
258 sources = rebase_path(sources_build_rel, ".", root_build_dir)
259
260 source_prereqs = [
261 build_config,
262 android_manifest,
263 ]
264
265 rebase_resource_dirs = rebase_path(resource_dirs, root_build_dir)
266 rebase_build_config = rebase_path(build_config, root_build_dir)
267 args = [
268 "--depfile", rebase_path(depfile, root_build_dir),
269 "--android-sdk", rebase_path(android_sdk, root_build_dir),
270 "--android-sdk-tools", rebase_path(android_sdk_build_tools, root_build_dir ),
271 "--non-constant-id",
272 "--android-manifest", rebase_path(android_manifest, root_build_dir),
273
274 "--resource-dirs=$rebase_resource_dirs",
275 "--srcjar-out", rebase_path(srcjar_path, root_build_dir),
276 "--resource-zip-out", rebase_path(zip_path, root_build_dir),
277
278 "--dependencies-res-zips=@($rebase_build_config:resources:dependency_zips) ",
279 ]
280
281 if (defined(invoker.custom_package)) {
282 args += [
283 "--custom-package", invoker.custom_package,
284 ]
285 }
286
287 if (defined(invoker.v14_verify_only) && invoker.v14_verify_only) {
288 args += ["--v14-verify-only"]
289 }
290 }
291 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698