Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / content / common / BUILD.gn
blob56e4598e4ba6730cc078309f0656386514515b42
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/features.gni")
6 import("//build/config/ui.gni")
7 import("//content/common/common.gni")
8 import("//third_party/mojo/src/mojo/public/tools/bindings/mojom.gni")
9 if (is_mac) {
10   import("//build/config/mac/mac_sdk.gni")
13 if (is_chromeos && current_cpu != "arm") {
14   action("libva_generate_stubs") {
15     extra_header = "gpu/media/va_stub_header.fragment"
17     script = "../../tools/generate_stubs/generate_stubs.py"
18     sources = [
19       "gpu/media/va.sigs",
20     ]
21     inputs = [
22       extra_header,
23     ]
24     if (use_x11) {
25       sources += [ "gpu/media/va_x11.sigs" ]
26     }
27     if (use_ozone) {
28       sources += [ "gpu/media/va_drm.sigs" ]
29     }
30     stubs_filename_root = "va_stubs"
32     outputs = [
33       "$target_gen_dir/gpu/media/$stubs_filename_root.cc",
34       "$target_gen_dir/gpu/media/$stubs_filename_root.h",
35     ]
36     args = [
37       "-i",
38       rebase_path("$target_gen_dir/gpu/media", root_build_dir),
39       "-o",
40       rebase_path("$target_gen_dir/gpu/media", root_build_dir),
41       "-t",
42       "posix_stubs",
43       "-e",
44       rebase_path(extra_header, root_build_dir),
45       "-s",
46       stubs_filename_root,
47       "-p",
48       "content/common/gpu/media",
49     ]
51     args += rebase_path(sources, root_build_dir)
52   }
55 if (is_chromeos && use_v4lplugin) {
56   action("libv4l2_generate_stubs") {
57     extra_header = "gpu/media/v4l2_stub_header.fragment"
59     script = "../../tools/generate_stubs/generate_stubs.py"
60     sources = [
61       "gpu/media/v4l2.sig",
62     ]
63     inputs = [
64       extra_header,
65     ]
66     stubs_filename_root = "v4l2_stubs"
68     outputs = [
69       "$target_gen_dir/gpu/media/$stubs_filename_root.cc",
70       "$target_gen_dir/gpu/media/$stubs_filename_root.h",
71     ]
72     args = [
73       "-i",
74       rebase_path("$target_gen_dir/gpu/media", root_build_dir),
75       "-o",
76       rebase_path("$target_gen_dir/gpu/media", root_build_dir),
77       "-t",
78       "posix_stubs",
79       "-e",
80       rebase_path(extra_header, root_build_dir),
81       "-s",
82       stubs_filename_root,
83       "-p",
84       "content/common/gpu/media",
85     ]
87     args += rebase_path(sources, root_build_dir)
88   }
91 if (is_mac) {
92   action("libvt_generate_stubs") {
93     extra_header = "gpu/media/vt_stubs_header.fragment"
95     script = "../../tools/generate_stubs/generate_stubs.py"
96     sources = [
97       "gpu/media/vt.sig",
98     ]
99     inputs = [
100       extra_header,
101     ]
102     stubs_filename_root = "vt_stubs"
104     outputs = [
105       "$target_gen_dir/gpu/media/$stubs_filename_root.cc",
106       "$target_gen_dir/gpu/media/$stubs_filename_root.h",
107     ]
108     args = [
109       "-i",
110       rebase_path("$target_gen_dir/gpu/media", root_build_dir),
111       "-o",
112       rebase_path("$target_gen_dir/gpu/media", root_build_dir),
113       "-t",
114       "posix_stubs",
115       "-e",
116       rebase_path(extra_header, root_build_dir),
117       "-s",
118       stubs_filename_root,
119       "-p",
120       "content/common/gpu/media",
121     ]
123     args += rebase_path(sources, root_build_dir)
124   }
127 source_set("common") {
128   # Only the public target should depend on this. All other targets (even
129   # internal content ones) should depend on the public one.
130   visibility = [ "//content/public/common:common_sources" ]
132   sources = rebase_path(content_common_gypi_values.private_common_sources,
133                         ".",
134                         "//content")
136   configs += [
137     "//content:content_implementation",
138     "//build/config:precompiled_headers",
139     "//build/config/compiler:no_size_t_to_int_warning",
140   ]
142   public_deps = [
143     "//gpu/command_buffer/common",
144     "//third_party/WebKit/public:blink_headers",
145   ]
146   deps = [
147     "//base",
148     "//build/util:webkit_version",
149     "//components/tracing",
150     "//components/tracing:startup_tracing",
151     "//gpu/command_buffer/client:gles2_interface",
152     "//gpu/command_buffer/common:gles2_utils",
153     "//net",
154     "//skia",
155     "//third_party/icu",
156     "//ui/accessibility",
157     "//ui/base",
158     "//ui/base/ime",
159     "//ui/events/ipc:events_ipc",
160     "//ui/gfx",
161     "//ui/gfx/geometry",
162     "//ui/gfx/ipc",
163     "//ui/shell_dialogs",
164     "//url",
165     "//third_party/libjingle",
166   ]
168   if (!is_ios) {
169     deps += [
170       "//cc",
171       "//device/bluetooth",
172       "//ipc",
173       "//ipc/mojo",
175       # TODO: the dependency on gl_in_process_context should be decoupled from
176       # content and moved to android_webview. See crbug.com/365797.
177       "//gpu/blink",
178       "//gpu/command_buffer/client:gl_in_process_context",
179       "//gpu/command_buffer/client:gles2_c_lib",
180       "//gpu/command_buffer/client:gles2_cmd_helper",
181       "//gpu/command_buffer/client:gles2_implementation",
182       "//gpu/command_buffer/service",
183       "//gpu/ipc",
184       "//gpu/skia_bindings",
185       "//media",
186       "//media/midi",
187       "//media:shared_memory_support",
188       "//mojo/application/public/interfaces",
189       "//mojo/common:common_base",
190       "//mojo/environment:chromium",
191       "//sandbox",
192       "//storage/common",
193       "//third_party/WebKit/public:blink",
194       "//third_party/mojo/src/mojo/edk/system",
195       "//ui/gl",
196       ":mojo_bindings",
197     ]
198   }
200   defines = []
201   include_dirs = []
202   libs = []
203   ldflags = []
205   if (is_android && use_seccomp_bpf) {
206     set_sources_assignment_filter([])
207     sources += [
208       "sandbox_linux/sandbox_bpf_base_policy_linux.cc",
209       "sandbox_linux/sandbox_bpf_base_policy_linux.h",
210     ]
211     set_sources_assignment_filter(sources_assignment_filter)
212   }
214   if (is_mac) {
215     sources += [
216                  "gpu/client/gpu_memory_buffer_impl_io_surface.cc",
217                  "gpu/client/gpu_memory_buffer_impl_io_surface.h",
218                  "gpu/gpu_memory_buffer_factory_io_surface.cc",
219                  "gpu/gpu_memory_buffer_factory_io_surface.h",
220                  "gpu/media/vt.h",
221                  "gpu/media/vt_video_decode_accelerator.cc",
222                  "gpu/media/vt_video_decode_accelerator.h",
223                ] + get_target_outputs(":libvt_generate_stubs")
225     sources -= [ "plugin_list_posix.cc" ]
227     deps += [
228       ":libvt_generate_stubs",
229       "//content/app/resources",
230       "//content:resources",
231       "//third_party/WebKit/public:image_resources",
232       "//third_party/WebKit/public:resources",
233       "//ui/accelerated_widget_mac",
234     ]
235     lib_dirs = [ "$mac_sdk_path/usr/lib" ]
236     libs += [
237       "IOSurface.framework",
238       "OpenGL.framework",
239       "QuartzCore.framework",
240       "sandbox",
241     ]
242   }
244   if (is_android) {
245     sources += [
246       "gpu/client/gpu_memory_buffer_impl_surface_texture.cc",
247       "gpu/client/gpu_memory_buffer_impl_surface_texture.h",
248       "gpu/gpu_memory_buffer_factory_surface_texture.cc",
249       "gpu/gpu_memory_buffer_factory_surface_texture.h",
250     ]
252     deps += [
253       "//content/public/android:jni",
254       "//content/public/android:common_aidl",
255     ]
257     libs += [ "android" ]
258   }
260   if (is_debug && !is_component_build) {
261     # Content depends on the PPAPI message logging stuff; if this isn't here,
262     # some unit test binaries won't compile. This only worked in release mode
263     # because logging is disabled there.
264     deps += [ "//ppapi/proxy:ipc_sources" ]
265   }
267   if (is_ios) {
268     sources -= [ "user_agent.cc" ]
269     assert(false, "Need to add lots of conditions here")
270   }
272   if (use_ozone) {
273     deps += [
274       "//ui/ozone:ozone",
275       "//ui/ozone:ozone_base",
276     ]
277   } else {
278     sources -= [
279       "cursors/webcursor_ozone.cc",
280       "font_list_ozone.cc",
281       "gpu/client/gpu_memory_buffer_impl_ozone_native_pixmap.cc",
282       "gpu/client/gpu_memory_buffer_impl_ozone_native_pixmap.h",
283       "gpu/gpu_memory_buffer_factory_ozone_native_pixmap.cc",
284       "gpu/gpu_memory_buffer_factory_ozone_native_pixmap.h",
285     ]
286   }
288   if (!use_aura || is_android) {
289     sources -= [ "cursors/webcursor_aura.cc" ]
290   }
292   if (!use_aura || !use_x11) {
293     sources -= [ "cursors/webcursor_aurax11.cc" ]
294   }
296   if (use_pango) {
297     configs += [ "//build/config/linux:pangocairo" ]
298     if (use_ozone) {
299       # If we're using pango, never use this ozone file (it was removed in all
300       # non-ozone cases above).
301       sources -= [ "font_list_ozone.cc" ]
302     }
303   } else {
304     sources -= [ "font_list_pango.cc" ]
305   }
307   if (use_x11) {
308     configs += [
309       "//build/config/linux:xcomposite",
310       "//third_party/khronos:khronos_headers",
311     ]
313     if (current_cpu != "arm" || !is_chromeos) {
314       sources += [ "gpu/x_util.h" ]
315     }
316   }
318   if (enable_plugins) {
319     deps += [ "//ppapi/shared_impl" ]
320   } else {
321     sources -= [
322       "pepper_file_util.cc",
323       "pepper_file_util.h",
324       "pepper_messages.h",
325       "pepper_plugin_list.cc",
326       "pepper_plugin_list.h",
327       "pepper_renderer_instance_data.cc",
328       "pepper_renderer_instance_data.h",
329       "plugin_list.cc",
330       "plugin_list.h",
331       "plugin_list_posix.cc",
332       "sandbox_util.cc",
333     ]
334   }
336   if (is_android) {
337     sources += [
338       "gpu/media/android_copying_backing_strategy.cc",
339       "gpu/media/android_copying_backing_strategy.h",
340       "gpu/media/android_video_decode_accelerator.cc",
341       "gpu/media/android_video_decode_accelerator.h",
342       "gpu/media/avda_return_on_failure.h",
343     ]
345     if (enable_webrtc) {
346       deps += [ "//third_party/libyuv" ]
347     }
348   }
350   if (is_chromeos) {
351     sources += [
352       "gpu/media/accelerated_video_decoder.h",
353       "gpu/media/h264_decoder.cc",
354       "gpu/media/h264_decoder.h",
355       "gpu/media/h264_dpb.cc",
356       "gpu/media/h264_dpb.h",
357       "gpu/media/vp8_decoder.cc",
358       "gpu/media/vp8_decoder.h",
359       "gpu/media/vp8_picture.cc",
360       "gpu/media/vp8_picture.h",
361       "gpu/media/vp9_decoder.cc",
362       "gpu/media/vp9_decoder.h",
363       "gpu/media/vp9_picture.cc",
364       "gpu/media/vp9_picture.h",
365     ]
366     if (use_v4lplugin) {
367       defines += [ "USE_LIBV4L2" ]
368       sources += get_target_outputs(":libv4l2_generate_stubs")
369       deps += [ ":libv4l2_generate_stubs" ]
370     }
371     if (use_v4l2_codec) {
372       defines += [ "USE_V4L2_CODEC" ]
373       sources += [
374         "gpu/media/generic_v4l2_device.cc",
375         "gpu/media/generic_v4l2_device.h",
376         "gpu/media/v4l2_device.cc",
377         "gpu/media/v4l2_device.h",
378         "gpu/media/v4l2_image_processor.cc",
379         "gpu/media/v4l2_image_processor.h",
380         "gpu/media/v4l2_jpeg_decode_accelerator.cc",
381         "gpu/media/v4l2_jpeg_decode_accelerator.h",
382         "gpu/media/v4l2_slice_video_decode_accelerator.cc",
383         "gpu/media/v4l2_slice_video_decode_accelerator.h",
384         "gpu/media/v4l2_video_decode_accelerator.cc",
385         "gpu/media/v4l2_video_decode_accelerator.h",
386         "gpu/media/v4l2_video_encode_accelerator.cc",
387         "gpu/media/v4l2_video_encode_accelerator.h",
388       ]
389       libs = [
390         "EGL",
391         "GLESv2",
392       ]
393     }
394     if (current_cpu == "arm") {
395       sources += [
396         "gpu/media/tegra_v4l2_device.cc",
397         "gpu/media/tegra_v4l2_device.h",
398       ]
399     }
400     if (current_cpu != "arm") {
401       sources += [
402                    "gpu/media/va_surface.h",
403                    "gpu/media/vaapi_jpeg_decode_accelerator.cc",
404                    "gpu/media/vaapi_jpeg_decode_accelerator.h",
405                    "gpu/media/vaapi_jpeg_decoder.cc",
406                    "gpu/media/vaapi_jpeg_decoder.h",
407                    "gpu/media/vaapi_picture.cc",
408                    "gpu/media/vaapi_picture.h",
409                    "gpu/media/vaapi_video_decode_accelerator.cc",
410                    "gpu/media/vaapi_video_decode_accelerator.h",
411                    "gpu/media/vaapi_video_encode_accelerator.cc",
412                    "gpu/media/vaapi_video_encode_accelerator.h",
413                    "gpu/media/vaapi_wrapper.cc",
414                    "gpu/media/vaapi_wrapper.h",
415                  ] + get_target_outputs(":libva_generate_stubs")
416       configs += [
417         "//third_party/libva:libva_config",
418         "//third_party/libyuv:libyuv_config",
419       ]
420       deps += [
421         ":libva_generate_stubs",
422         "//media",
423         "//third_party/libyuv",
424       ]
425       if (use_x11) {
426         sources += [
427           "gpu/media/vaapi_tfp_picture.cc",
428           "gpu/media/vaapi_tfp_picture.h",
429         ]
430       }
431       if (use_ozone) {
432         sources += [
433           "gpu/media/vaapi_drm_picture.cc",
434           "gpu/media/vaapi_drm_picture.h",
435         ]
436       }
437     }
438   }
440   if (is_win) {
441     sources += [
442       "gpu/media/dxva_video_decode_accelerator.cc",
443       "gpu/media/dxva_video_decode_accelerator.h",
444     ]
445     configs += [ "//third_party/khronos:khronos_headers" ]
446     deps += [ "//ui/gl" ]
447     libs += [
448       "d3d9.lib",
449       "d3d11.lib",
450       "dxva2.lib",
451       "strmiids.lib",
452       "mf.lib",
453       "mfplat.lib",
454       "mfuuid.lib",
455     ]
456     ldflags += [
457       "/DELAYLOAD:d3d9.dll",
458       "/DELAYLOAD:d3d11.dll",
459       "/DELAYLOAD:dxva2.dll",
460       "/DELAYLOAD:mf.dll",
461       "/DELAYLOAD:mfplat.dll",
462     ]
464     # TODO(GYP): extract_xinput action.
465   }
467   if (!is_win || !use_aura) {
468     sources -= [ "cursors/webcursor_aurawin.cc" ]
469   }
471   if (use_seccomp_bpf) {
472     defines += [ "USE_SECCOMP_BPF" ]
473   } else {
474     if (is_linux) {
475       sources -= [
476         "sandbox_linux/bpf_cros_arm_gpu_policy_linux.cc",
477         "sandbox_linux/bpf_cros_arm_gpu_policy_linux.h",
478         "sandbox_linux/bpf_gpu_policy_linux.cc",
479         "sandbox_linux/bpf_gpu_policy_linux.h",
480         "sandbox_linux/bpf_ppapi_policy_linux.cc",
481         "sandbox_linux/bpf_ppapi_policy_linux.h",
482         "sandbox_linux/bpf_renderer_policy_linux.cc",
483         "sandbox_linux/bpf_renderer_policy_linux.h",
484         "sandbox_linux/bpf_utility_policy_linux.cc",
485         "sandbox_linux/bpf_utility_policy_linux.h",
486         "sandbox_linux/sandbox_bpf_base_policy_linux.cc",
487         "sandbox_linux/sandbox_bpf_base_policy_linux.h",
488       ]
489     }
490     if (is_android) {
491       sources -= [
492         "sandbox_linux/android/sandbox_bpf_base_policy_android.cc",
493         "sandbox_linux/android/sandbox_bpf_base_policy_android.h",
494       ]
495     }
496   }
499 mojom("mojo_bindings") {
500   sources = [
501     "application_setup.mojom",
502     "background_sync_service.mojom",
503     "geolocation_service.mojom",
504     "image_downloader/image_downloader.mojom",
505     "permission_service.mojom",
506     "presentation/presentation_service.mojom",
507     "process_control.mojom",
508     "render_frame_setup.mojom",
509     "service_port_service.mojom",
510     "service_worker/embedded_worker_setup.mojom",
511     "vr_service.mojom",
512   ]
514   import_dirs = [ "//mojo/services" ]
516   deps = [
517     "//content/public/common:mojo_bindings",
518     "//mojo/application/public/interfaces",
519     "//skia/public/interfaces",
520     "//ui/mojo/geometry:interfaces",
521   ]