media: Refactor SkCanvasVideoRenderer to use SkImages and not SkBitmaps.
[chromium-blink-merge.git] / mojo / public / mojo_application.gni
blob0dfcefaf71abaf9ab9f65bf7ec5f1535adc0c401
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/toolchain/toolchain.gni")
6 import("mojo.gni")
8 # Generate a binary Mojo application in a self-named directory.
9 # Application resources are copied to a "resources" directory alongside the app.
10 # The parameters of this template are those of a shared library.
11 template("mojo_native_application") {
12   base_target_name = target_name
13   if (defined(invoker.output_name)) {
14     base_target_name = invoker.output_name
15   }
17   final_target_name = target_name
19   mojo_deps = []
20   if (defined(invoker.deps)) {
21     mojo_deps += invoker.deps
22   }
24   if (defined(invoker.resources)) {
25     copy_step_name = "${base_target_name}__copy_resources"
26     copy(copy_step_name) {
27       sources = invoker.resources
28       outputs = [
29         "${root_out_dir}/${base_target_name}/resources/{{source_file_part}}",
30       ]
31       if (defined(invoker.testonly)) {
32         testonly = invoker.testonly
33       }
34       deps = mojo_deps
35     }
36     mojo_deps += [ ":$copy_step_name" ]
37   }
39   if (!is_nacl) {
40     output = base_target_name + ".mojo"
41     library_target_name = base_target_name + "_library"
42     library_name = "${shlib_prefix}${library_target_name}${shlib_extension}"
44     shared_library(library_target_name) {
45       if (defined(invoker.cflags)) {
46         cflags = invoker.cflags
47       }
48       if (defined(invoker.cflags_c)) {
49         cflags_c = invoker.cflags_c
50       }
51       if (defined(invoker.cflags_cc)) {
52         cflags_cc = invoker.cflags_cc
53       }
54       if (defined(invoker.cflags_objc)) {
55         cflags_objc = invoker.cflags_objc
56       }
57       if (defined(invoker.cflags_objcc)) {
58         cflags_objcc = invoker.cflags_objcc
59       }
60       if (defined(invoker.defines)) {
61         defines = invoker.defines
62       }
63       if (defined(invoker.include_dirs)) {
64         include_dirs = invoker.include_dirs
65       }
66       if (defined(invoker.ldflags)) {
67         ldflags = invoker.ldflags
68       }
69       if (defined(invoker.lib_dirs)) {
70         lib_dirs = invoker.lib_dirs
71       }
72       if (defined(invoker.libs)) {
73         libs = invoker.libs
74       }
76       data_deps = []
77       if (defined(invoker.data_deps)) {
78         data_deps = invoker.data_deps
79       }
81       # Copy any necessary prebuilt artifacts.
82       if (mojo_use_prebuilt_mojo_shell) {
83         data_deps +=
84             [ rebase_path("mojo/public/tools:copy_mojo_shell", ".", mojo_root) ]
85       }
86       if (mojo_use_prebuilt_network_service) {
87         data_deps += [ rebase_path("mojo/public/tools:copy_network_service",
88                                    ".",
89                                    mojo_root) ]
90       }
92       deps = rebase_path([
93                            "mojo/public/c/system",
94                            "mojo/public/platform/native:system",
95                          ],
96                          ".",
97                          mojo_root)
98       deps += mojo_deps
99       if (defined(invoker.forward_dependent_configs_from)) {
100         forward_dependent_configs_from = invoker.forward_dependent_configs_from
101       }
102       if (defined(invoker.public_deps)) {
103         public_deps = invoker.public_deps
104       }
105       if (defined(invoker.all_dependent_configs)) {
106         all_dependent_configs = invoker.all_dependent_configs
107       }
108       if (defined(invoker.public_configs)) {
109         public_configs = invoker.public_configs
110       }
111       if (defined(invoker.check_includes)) {
112         check_includes = invoker.check_includes
113       }
114       if (defined(invoker.configs)) {
115         configs += invoker.configs
116       }
117       if (defined(invoker.data)) {
118         data = invoker.data
119       }
120       if (defined(invoker.inputs)) {
121         inputs = invoker.inputs
122       }
123       if (defined(invoker.public)) {
124         public = invoker.public
125       }
126       if (defined(invoker.sources)) {
127         sources = invoker.sources
128       }
129       if (defined(invoker.testonly)) {
130         testonly = invoker.testonly
131       }
133       visibility = [ ":${final_target_name}" ]
134     }
136     copy(final_target_name) {
137       if (defined(invoker.testonly)) {
138         testonly = invoker.testonly
139       }
140       if (defined(invoker.visibility)) {
141         visibility = invoker.visibility
142       }
143       deps = [
144         ":${library_target_name}",
145       ]
147       sources = [
148         "${root_shlib_dir}/${library_name}",
149       ]
150       outputs = [
151         "${root_out_dir}/${base_target_name}/${output}",
152       ]
153     }
154   } else {
155     nexe_target_name = base_target_name + "_nexe"
156     nexe_name = base_target_name + ".nexe"
158     output = "${base_target_name}_${target_cpu}.nexe.mojo"
160     executable(nexe_target_name) {
161       output_name = base_target_name
163       if (defined(invoker.cflags)) {
164         cflags = invoker.cflags
165       }
166       if (defined(invoker.cflags_c)) {
167         cflags_c = invoker.cflags_c
168       }
169       if (defined(invoker.cflags_cc)) {
170         cflags_cc = invoker.cflags_cc
171       }
172       if (defined(invoker.cflags_objc)) {
173         cflags_objc = invoker.cflags_objc
174       }
175       if (defined(invoker.cflags_objcc)) {
176         cflags_objcc = invoker.cflags_objcc
177       }
178       if (defined(invoker.defines)) {
179         defines = invoker.defines
180       }
181       if (defined(invoker.include_dirs)) {
182         include_dirs = invoker.include_dirs
183       }
184       if (defined(invoker.ldflags)) {
185         ldflags = invoker.ldflags
186       }
187       if (defined(invoker.lib_dirs)) {
188         lib_dirs = invoker.lib_dirs
189       }
190       if (defined(invoker.libs)) {
191         libs = invoker.libs
192       }
194       data_deps = []
195       if (defined(invoker.data_deps)) {
196         data_deps = invoker.data_deps
197       }
199       # Copy any necessary prebuilt artifacts.
200       if (mojo_use_prebuilt_mojo_shell) {
201         data_deps +=
202             [ rebase_path("mojo/public/tools:copy_mojo_shell", ".", mojo_root) ]
203       }
204       if (mojo_use_prebuilt_network_service) {
205         data_deps += [ rebase_path("mojo/public/tools:copy_network_service",
206                                    ".",
207                                    mojo_root) ]
208       }
210       deps = rebase_path([
211                            "mojo/public/c/system",
212                            "mojo/public/platform/nacl:system",
213                          ],
214                          ".",
215                          mojo_root)
216       deps += mojo_deps
217       if (defined(invoker.forward_dependent_configs_from)) {
218         forward_dependent_configs_from = invoker.forward_dependent_configs_from
219       }
220       if (defined(invoker.public_deps)) {
221         public_deps = invoker.public_deps
222       }
223       if (defined(invoker.all_dependent_configs)) {
224         all_dependent_configs = invoker.all_dependent_configs
225       }
226       if (defined(invoker.public_configs)) {
227         public_configs = invoker.public_configs
228       }
229       if (defined(invoker.check_includes)) {
230         check_includes = invoker.check_includes
231       }
232       if (defined(invoker.configs)) {
233         configs += invoker.configs
234       }
235       if (defined(invoker.data)) {
236         data = invoker.data
237       }
238       if (defined(invoker.inputs)) {
239         inputs = invoker.inputs
240       }
241       if (defined(invoker.public)) {
242         public = invoker.public
243       }
244       if (defined(invoker.sources)) {
245         sources = invoker.sources
246       }
247       if (defined(invoker.testonly)) {
248         testonly = invoker.testonly
249       }
251       visibility = [ ":${final_target_name}" ]
252     }
254     action(target_name) {
255       if (defined(invoker.testonly)) {
256         testonly = invoker.testonly
257       }
258       if (defined(invoker.visibility)) {
259         visibility = invoker.visibility
260       }
262       script = rebase_path("mojo/public/tools/prepend.py", ".", mojo_root)
264       input_path = "${root_out_dir}/${nexe_name}"
265       inputs = [
266         input_path,
267       ]
269       output_path = "${root_build_dir}/${base_target_name}/${output}"
270       outputs = [
271         output_path,
272       ]
274       deps = [
275         ":${nexe_target_name}",
276       ]
278       rebase_input = rebase_path(input_path, root_build_dir)
279       rebase_output = rebase_path(output_path, root_build_dir)
280       args = [
281         "--input=$rebase_input",
282         "--output=$rebase_output",
283         "--line=#!mojo mojo:nacl_content_handler",
284       ]
285     }
286   }
289 if (is_android) {
290   # Declares an Android Mojo application consisting of an .so file and a
291   # corresponding .dex.jar file.
292   #
293   # Variables:
294   #   input_so: the .so file to bundle
295   #   input_dex_jar: the .dex.jar file to bundle
296   #   deps / public_deps / data_deps (optional):
297   #       Dependencies. The targets that generate the .so/jar inputs should be
298   #       listed in either deps or public_deps.
299   #   output_name (optional): override for the output file name
300   template("mojo_android_application") {
301     assert(defined(invoker.input_so))
302     assert(defined(invoker.input_dex_jar))
304     mojo_deps = []
305     if (defined(invoker.resources)) {
306       base_target_name = target_name
307       if (defined(invoker.output_name)) {
308         base_target_name = invoker.output_name
309       }
311       copy_step_name = "${base_target_name}__copy_resources"
312       copy(copy_step_name) {
313         sources = invoker.resources
314         outputs = [
315           "${root_out_dir}/${base_target_name}/resources/{{source_file_part}}",
316         ]
317         if (defined(invoker.testonly)) {
318           testonly = invoker.testonly
319         }
320         if (defined(invoker.deps)) {
321           deps = invoker.deps
322         }
323       }
324       mojo_deps += [ ":$copy_step_name" ]
325     }
327     zip_action_name = "${target_name}_zip"
328     zip_action_output = "$target_gen_dir/${target_name}.zip"
329     prepend_action_name = target_name
330     action(zip_action_name) {
331       visibility = [ ":$prepend_action_name" ]
332       script = "//build/android/gn/zip.py"
334       inputs = [
335         invoker.input_so,
336         invoker.input_dex_jar,
337       ]
339       output = zip_action_output
340       outputs = [
341         output,
342       ]
344       rebase_inputs = rebase_path(inputs, root_build_dir)
345       rebase_output = rebase_path(output, root_build_dir)
346       args = [
347         "--inputs=$rebase_inputs",
348         "--output=$rebase_output",
349       ]
351       if (defined(invoker.deps)) {
352         deps = invoker.deps
353       }
354       if (defined(invoker.public_deps)) {
355         public_deps = invoker.public_deps
356       }
357       if (defined(invoker.data_deps)) {
358         data_deps = invoker.data_deps
359       }
360     }
362     action(target_name) {
363       script = rebase_path("mojo/public/tools/prepend.py", ".", mojo_root)
365       base_target_name = target_name
366       if (defined(invoker.output_name)) {
367         base_target_name = invoker.output_name
368       }
370       input = zip_action_output
371       inputs = [
372         input,
373       ]
375       output = "${root_out_dir}/${base_target_name}/${base_target_name}.mojo"
376       outputs = [
377         output,
378       ]
380       rebase_input = rebase_path(input, root_build_dir)
381       rebase_output = rebase_path(output, root_build_dir)
382       args = [
383         "--input=$rebase_input",
384         "--output=$rebase_output",
385         "--line=#!mojo mojo:android_handler",
386       ]
388       deps = mojo_deps
390       public_deps = [
391         ":$zip_action_name",
392       ]
393     }
394   }