Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / ui / base / BUILD.gn
blob253ccea86e0d3b936faf36edff57a68e14accbaf
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/ui.gni")
7 if (is_android) {
8   import("//build/config/android/config.gni")
9   import("//build/config/android/rules.gni")
12 component("base") {
13   output_name = "ui_base"
14   sources = [
15     "accelerators/accelerator.cc",
16     "accelerators/accelerator.h",
17     "accelerators/accelerator_manager.cc",
18     "accelerators/accelerator_manager.h",
19     "accelerators/menu_label_accelerator_util_linux.cc",
20     "accelerators/menu_label_accelerator_util_linux.h",
21     "accelerators/platform_accelerator.h",
22     "accelerators/platform_accelerator_cocoa.h",
23     "accelerators/platform_accelerator_cocoa.mm",
24     "android/system_ui_resource_manager.h",
25     "android/ui_base_jni_registrar.cc",
26     "android/ui_base_jni_registrar.h",
27     "android/view_android.cc",
28     "android/view_android.h",
29     "android/window_android.cc",
30     "android/window_android.h",
31     "android/window_android_compositor.h",
32     "android/window_android_observer.h",
33     "base_window.cc",
34     "base_window.h",
35     "clipboard/clipboard.cc",
36     "clipboard/clipboard.h",
37     "clipboard/clipboard_android.cc",
38     "clipboard/clipboard_android_initialization.h",
39     "clipboard/clipboard_constants.cc",
40     "clipboard/clipboard_mac.mm",
41     "clipboard/clipboard_types.h",
42     "clipboard/clipboard_util_win.cc",
43     "clipboard/clipboard_util_win.h",
44     "clipboard/clipboard_win.cc",
45     "clipboard/custom_data_helper.cc",
46     "clipboard/custom_data_helper.h",
47     "clipboard/custom_data_helper_linux.cc",
48     "clipboard/custom_data_helper_mac.mm",
49     "clipboard/scoped_clipboard_writer.cc",
50     "clipboard/scoped_clipboard_writer.h",
51     "cocoa/animation_utils.h",
52     "cocoa/appkit_utils.h",
53     "cocoa/appkit_utils.mm",
54     "cocoa/base_view.h",
55     "cocoa/base_view.mm",
56     "cocoa/cocoa_base_utils.h",
57     "cocoa/cocoa_base_utils.mm",
58     "cocoa/controls/blue_label_button.h",
59     "cocoa/controls/blue_label_button.mm",
60     "cocoa/controls/hover_image_menu_button.h",
61     "cocoa/controls/hover_image_menu_button.mm",
62     "cocoa/controls/hover_image_menu_button_cell.h",
63     "cocoa/controls/hover_image_menu_button_cell.mm",
64     "cocoa/controls/hyperlink_button_cell.h",
65     "cocoa/controls/hyperlink_button_cell.mm",
66     "cocoa/find_pasteboard.h",
67     "cocoa/find_pasteboard.mm",
68     "cocoa/flipped_view.h",
69     "cocoa/flipped_view.mm",
70     "cocoa/focus_tracker.h",
71     "cocoa/focus_tracker.mm",
72     "cocoa/focus_window_set.h",
73     "cocoa/focus_window_set.mm",
74     "cocoa/fullscreen_window_manager.h",
75     "cocoa/fullscreen_window_manager.mm",
76     "cocoa/hover_button.h",
77     "cocoa/hover_button.mm",
78     "cocoa/hover_image_button.h",
79     "cocoa/hover_image_button.mm",
80     "cocoa/menu_controller.h",
81     "cocoa/menu_controller.mm",
82     "cocoa/nib_loading.h",
83     "cocoa/nib_loading.mm",
84     "cocoa/nsgraphics_context_additions.h",
85     "cocoa/nsgraphics_context_additions.mm",
86     "cocoa/remote_layer_api.h",
87     "cocoa/remote_layer_api.mm",
88     "cocoa/tracking_area.h",
89     "cocoa/tracking_area.mm",
90     "cocoa/underlay_opengl_hosting_window.h",
91     "cocoa/underlay_opengl_hosting_window.mm",
92     "cocoa/view_description.h",
93     "cocoa/view_description.mm",
94     "cocoa/window_size_constants.h",
95     "cocoa/window_size_constants.mm",
96     "cursor/cursor.cc",
97     "cursor/cursor.h",
98     "cursor/cursor_android.cc",
99     "cursor/cursor_loader.h",
100     "cursor/cursor_util.cc",
101     "cursor/cursor_util.h",
102     "cursor/cursor_win.cc",
103     "cursor/cursors_aura.cc",
104     "cursor/cursors_aura.h",
105     "cursor/image_cursors.cc",
106     "cursor/image_cursors.h",
107     "default_theme_provider.cc",
108     "default_theme_provider.h",
109     "default_theme_provider_mac.mm",
110     "device_form_factor_android.cc",
111     "device_form_factor_android.h",
112     "device_form_factor_desktop.cc",
113     "device_form_factor_ios.mm",
114     "device_form_factor.h",
115     "dragdrop/cocoa_dnd_util.h",
116     "dragdrop/cocoa_dnd_util.mm",
117     "dragdrop/drag_drop_types.h",
118     "dragdrop/drag_drop_types_win.cc",
119     "dragdrop/drag_source_win.cc",
120     "dragdrop/drag_source_win.h",
121     "dragdrop/drag_utils.cc",
122     "dragdrop/drag_utils.h",
123     "dragdrop/drag_utils_aura.cc",
124     "dragdrop/drag_utils_mac.mm",
125     "dragdrop/drag_utils_win.cc",
126     "dragdrop/drop_target_event.cc",
127     "dragdrop/drop_target_event.h",
128     "dragdrop/drop_target_win.cc",
129     "dragdrop/drop_target_win.h",
130     "dragdrop/file_info.cc",
131     "dragdrop/file_info.h",
132     "dragdrop/os_exchange_data.cc",
133     "dragdrop/os_exchange_data.h",
134     "dragdrop/os_exchange_data_provider_mac.h",
135     "dragdrop/os_exchange_data_provider_mac.mm",
136     "dragdrop/os_exchange_data_provider_win.cc",
137     "dragdrop/os_exchange_data_provider_win.h",
138     "hit_test.h",
139     "l10n/formatter.cc",
140     "l10n/formatter.h",
141     "l10n/l10n_font_util.cc",
142     "l10n/l10n_font_util.h",
143     "l10n/l10n_util.cc",
144     "l10n/l10n_util.h",
145     "l10n/l10n_util_android.cc",
146     "l10n/l10n_util_android.h",
147     "l10n/l10n_util_collator.h",
148     "l10n/l10n_util_mac.h",
149     "l10n/l10n_util_mac.mm",
150     "l10n/l10n_util_plurals.cc",
151     "l10n/l10n_util_plurals.h",
152     "l10n/l10n_util_posix.cc",
153     "l10n/l10n_util_win.cc",
154     "l10n/l10n_util_win.h",
155     "l10n/time_format.cc",
156     "l10n/time_format.h",
157     "layout.cc",
158     "layout.h",
159     "layout_mac.mm",
160     "models/button_menu_item_model.cc",
161     "models/button_menu_item_model.h",
162     "models/combobox_model.cc",
163     "models/combobox_model.h",
164     "models/combobox_model_observer.h",
165     "models/dialog_model.cc",
166     "models/dialog_model.h",
167     "models/list_model.h",
168     "models/list_model_observer.h",
169     "models/list_selection_model.cc",
170     "models/list_selection_model.h",
171     "models/menu_model.cc",
172     "models/menu_model.h",
173     "models/menu_model_delegate.h",
174     "models/menu_separator_types.h",
175     "models/simple_combobox_model.cc",
176     "models/simple_combobox_model.h",
177     "models/simple_menu_model.cc",
178     "models/simple_menu_model.h",
179     "models/table_model.cc",
180     "models/table_model.h",
181     "models/table_model_observer.h",
182     "models/tree_model.cc",
183     "models/tree_model.h",
184     "models/tree_node_iterator.h",
185     "models/tree_node_model.h",
186     "nine_image_painter_factory.cc",
187     "nine_image_painter_factory.h",
188     "resource/data_pack.cc",
189     "resource/data_pack.h",
190     "resource/resource_bundle.cc",
191     "resource/resource_bundle.h",
192     "resource/resource_bundle_android.cc",
193     "resource/resource_bundle_auralinux.cc",
194     "resource/resource_bundle_ios.mm",
195     "resource/resource_bundle_mac.mm",
196     "resource/resource_bundle_win.cc",
197     "resource/resource_bundle_win.h",
198     "resource/resource_data_dll_win.cc",
199     "resource/resource_data_dll_win.h",
200     "resource/resource_handle.h",
201     "text/bytes_formatting.cc",
202     "text/bytes_formatting.h",
203     "theme_provider.cc",
204     "theme_provider.h",
205     "touch/touch_device.h",
206     "touch/touch_editing_controller.cc",
207     "touch/touch_editing_controller.h",
208     "touch/touch_enabled.cc",
209     "touch/touch_enabled.h",
210     "ui_base_export.h",
211     "ui_base_exports.cc",
212     "ui_base_paths.cc",
213     "ui_base_paths.h",
214     "ui_base_switches.cc",
215     "ui_base_switches.h",
216     "ui_base_switches_util.cc",
217     "ui_base_switches_util.h",
218     "ui_base_types.cc",
219     "ui_base_types.h",
220     "view_prop.cc",
221     "view_prop.h",
222     "webui/jstemplate_builder.cc",
223     "webui/jstemplate_builder.h",
224     "webui/web_ui_util.cc",
225     "webui/web_ui_util.h",
226     "win/accessibility_ids_win.h",
227     "win/accessibility_misc_utils.cc",
228     "win/accessibility_misc_utils.h",
229     "win/atl_module.h",
230     "win/dpi_setup.cc",
231     "win/dpi_setup.h",
232     "win/foreground_helper.cc",
233     "win/foreground_helper.h",
234     "win/hidden_window.cc",
235     "win/hidden_window.h",
236     "win/hwnd_subclass.cc",
237     "win/hwnd_subclass.h",
238     "win/internal_constants.cc",
239     "win/internal_constants.h",
240     "win/lock_state.cc",
241     "win/lock_state.h",
242     "win/open_file_name_win.cc",
243     "win/open_file_name_win.h",
244     "win/message_box_win.cc",
245     "win/message_box_win.h",
246     "win/mouse_wheel_util.cc",
247     "win/mouse_wheel_util.h",
248     "win/scoped_ole_initializer.cc",
249     "win/scoped_ole_initializer.h",
250     "win/shell.cc",
251     "win/shell.h",
252     "win/touch_input.cc",
253     "win/touch_input.h",
254     "win/window_event_target.cc",
255     "win/window_event_target.h",
256     "window_open_disposition.cc",
257     "window_open_disposition.h",
258     "work_area_watcher_observer.h",
259     "x/x11_foreign_window_manager.cc",
260     "x/x11_foreign_window_manager.h",
261     "x/x11_menu_list.cc",
262     "x/x11_menu_list.h",
263     "x/x11_util.cc",
264     "x/x11_util.h",
265     "x/x11_util_internal.h",
266   ]
268   if (is_win) {
269     sources += [ "touch/touch_device_win.cc" ]
270   } else if (is_android) {
271     sources += [ "touch/touch_device_android.cc" ]
272   } else if (use_ozone) {
273     sources += [ "touch/touch_device_ozone.cc" ]
274   } else if (use_aura && use_x11) { 
275     sources += [ "touch/touch_device_aurax11.cc" ]
276   } else {
277     # Empty implementation for all other cases.
278     sources += [ "touch/touch_device.cc" ]
279   }
281   defines = [ "UI_BASE_IMPLEMENTATION" ]
283   deps = [
284     "//base",
285     "//base/third_party/dynamic_annotations",
286     "//base:base_static",
287     "//base:i18n",
288     "//net",
289     "//skia",
290     "//third_party/icu",
291     "//ui/events/platform",
292     "//ui/events:events_base",
293     "//ui/gfx",
294     "//ui/gfx/geometry",
295     "//ui/resources",
296     "//ui/strings",
297     "//url",
298   ]
299   # We expose these things in our headers:
300   forward_dependent_configs_from = [
301     "//ui/gfx",
302   ]
304   if (is_ios) {
305     sources += [
306       "l10n/l10n_util_mac.h",
307       "l10n/l10n_util_mac.mm",
308     ]
309   } else {
310     deps += [ "//ui/base/ime" ]
311   }
313   if (toolkit_views) {
314     deps += [
315       "//ui/events",
316     ]
317   }
319   if (use_x11 && use_aura) {
320     sources += [
321       "x/selection_owner.cc",
322       "x/selection_owner.h",
323       "x/selection_requestor.cc",
324       "x/selection_requestor.h",
325       "x/selection_utils.cc",
326       "x/selection_utils.h",
327     ]
328   }
330   if (use_aura) {
331     deps += [
332       "//ui/events",
333     ]
334   } else {
335     sources -= [
336       "cursor/cursor.cc",
337       "cursor/cursor.h",
338       "dragdrop/drag_utils_aura.cc",
339     ]
340   }
341   if (!use_x11) {
342     sources -= [
343       "x/x11_foreign_window_manager.cc",
344       "x/x11_foreign_window_manager.h",
345       "x/x11_menu_list.cc",
346       "x/x11_menu_list.h",
347       "x/x11_util.cc",
348       "x/x11_util.h",
349       "x/x11_util_internal.h",
350     ]
351   }
353   if (!use_aura || !is_linux) {
354     sources -= [
355       "resource/resource_bundle_auralinux.cc",
356     ]
357   }
359   if (use_aura && is_win) {
360     sources -= [
361       "dragdrop/drag_utils_aura.cc",
362     ]
363   }
365   if (is_linux) {
366     configs += [
367       "//build/config/linux:fontconfig",
368       "//build/config/linux:glib",
369     ]
370   }
372   if ((is_linux && !is_chromeos) || is_chromeos) {
373     if (!toolkit_views && !use_aura) {
374       sources -= [
375         "dragdrop/drag_utils.cc",
376         "dragdrop/drag_utils.h",
377       ]
378     }
379   }
381   if (is_chromeos || (use_aura && is_linux && !use_x11)) {
382     sources += [
383       "dragdrop/os_exchange_data_provider_aura.cc",
384       "dragdrop/os_exchange_data_provider_aura.h",
385     ]
386   }
388   libs = []
389   if (is_win) {
390     sources += [
391       "cursor/cursor_loader_win.cc",
392       "cursor/cursor_loader_win.h",
393     ]
394     deps += [
395       "//third_party/wtl",
396     ]
397     cflags = [
398       "/wd4267",  # TODO(jschuh): C4267: http://crbug.com/167187 size_t -> int.
399       "/wd4324",  # Structure was padded due to __declspec(align()), which is
400                   # uninteresting.
401     ]
402     ldflags = [
403       "/DELAYLOAD:d2d1.dll",
404       "/DELAYLOAD:d3d10_1.dll",
405       "/DELAYLOAD:dwmapi.dll",
406     ]
407     libs += [
408       "d2d1.lib",
409       "d3d10_1.lib",
410       "dwmapi.lib",
411       "imm32.lib",
412       "d2d1.lib",
413       "dwmapi.lib",
414       "oleacc.lib",
415     ]
416   } else {
417     if (!use_aura) {
418       sources -= [
419         "view_prop.cc",
420         "view_prop.h",
421       ]
422     }
423   }
425   if (is_mac) {
426     deps += [
427       #TODO(tfarina): port this third_party component to GN.
428       #"//third_party/mozilla",
429     ]
431     sources -= [
432       "cursor/image_cursors.cc",
433       "cursor/image_cursors.h",
434       "dragdrop/drag_utils.cc",
435       "dragdrop/drag_utils.h",
436     ]
438     libs += [
439       "Accelerate.framework",
440       "AudioUnit.framework",
441       "CoreVideo.framework",
442     ]
443   }
445   if (use_x11) {
446     #'all_dependent_settings': {
447       #'ldflags': [
448         #'-L<(PRODUCT_DIR)',
449       #],
450     #},
451     configs += [
452       "//build/config/linux:x11"
453     ]
454   }
456   if (use_aura) {
457     if (use_x11) {
458       sources += [
459         "cursor/cursor_loader_x11.cc",
460         "cursor/cursor_loader_x11.h",
461         "cursor/cursor_x11.cc",
462       ]
463       if (!is_chromeos) {
464         # These Aura X11 files aren't used on ChromeOS.
465         sources += [
466           "dragdrop/os_exchange_data_provider_aurax11.cc",
467           "dragdrop/os_exchange_data_provider_aurax11.h",
468         ]
469       }
470     }
471   }
472   if (use_ozone) {
473     sources += [
474       "cursor/cursor_loader_ozone.cc",
475       "cursor/cursor_loader_ozone.h",
476       "cursor/cursor_ozone.cc",
477       "cursor/ozone/bitmap_cursor_factory_ozone.cc",
478       "cursor/ozone/bitmap_cursor_factory_ozone.h",
479     ]
481     deps += [
482       "//ui/ozone:ozone_base",
483     ]
484   }
486   if (!toolkit_views) {
487     sources -= [
488       "dragdrop/drag_drop_types.h",
489       "dragdrop/drop_target_event.cc",
490       "dragdrop/drop_target_event.h",
491       "dragdrop/os_exchange_data.cc",
492       "dragdrop/os_exchange_data.h",
493       "nine_image_painter_factory.cc",
494       "nine_image_painter_factory.h",
495     ]
496   }
498   if (is_android) {
499     sources -= [
500       "default_theme_provider.cc",
501       "dragdrop/drag_utils.cc",
502       "dragdrop/drag_utils.h",
503       "l10n/l10n_font_util.cc",
504       "models/button_menu_item_model.cc",
505       "models/dialog_model.cc",
506       "theme_provider.cc",
507       "touch/touch_editing_controller.cc",
508       "ui_base_types.cc",
509     ]
511     deps += [
512       ":ui_base_jni_headers",
513     ]
515     libs += [
516       "jnigraphics",
517     ]
518   }
520   if (is_android && is_android_webview_build) {
521     deps += [
522       #TODO(GYP): port this component to GN.
523       #"//ui/android:ui_java",
524     ]
525   }
527   if (is_android && !use_aura) {
528     sources -= [
529       "cursor/cursor_android.cc",
530     ]
531   }
533   # Aura clipboard.
534   if (use_aura) {
535     if (use_x11) {
536       sources += [ "clipboard/clipboard_aurax11.cc" ]
537     } else if (!is_win) {
538       # This file is used for all non-X11, non-Windows aura Builds.
539       sources += [ "clipboard/clipboard_aura.cc" ]
540     }
541   }
543   if (is_android || is_ios) {
544     sources -= [
545       "device_form_factor_desktop.cc",
546     ]
547   }
550 source_set("test_support") {
551   sources = [
552     "test/ui_controls.h",
553     "test/ui_controls_aura.cc",
554     "test/ui_controls_internal_win.cc",
555     "test/ui_controls_internal_win.h",
556     "test/ui_controls_mac.mm",
557     "test/ui_controls_win.cc",
558   ]
560   deps = [
561     "//base",
562     "//skia",
563     "//testing/gtest",
564     "//ui/events:events_base",
565     "//ui/gfx",
566     "//ui/gfx/geometry",
567   ]
569   if (!is_ios) {
570     sources += [
571       "ime/dummy_input_method.cc",
572       "ime/dummy_input_method.h",
573       "ime/dummy_text_input_client.cc",
574       "ime/dummy_text_input_client.h",
575     ]
576   }
579 if (is_android) {
580   generate_jni("ui_base_jni_headers") {
581     sources = [
582       "../android/java/src/org/chromium/ui/base/Clipboard.java",
583       "../android/java/src/org/chromium/ui/base/DeviceFormFactor.java",
584       "../android/java/src/org/chromium/ui/base/LocalizationUtils.java",
585       "../android/java/src/org/chromium/ui/base/ResourceBundle.java",
586       "../android/java/src/org/chromium/ui/base/SelectFileDialog.java",
587       "../android/java/src/org/chromium/ui/base/TouchDevice.java",
588       "../android/java/src/org/chromium/ui/base/ViewAndroid.java",
589       "../android/java/src/org/chromium/ui/base/WindowAndroid.java",
590     ]
591     jni_package = "base"
592   }