Add video metrics from webrtc to histograms.xml.
[chromium-blink-merge.git] / chrome / BUILD.gn
blobf4414af23fb420bfe2c67a66a2bdd0384348175c
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/locales.gni")
7 import("//build/config/ui.gni")
8 import("//chrome/chrome_repack_locales.gni")
9 import("//chrome/version.gni")
11 if (is_android) {
12   import("//build/config/android/rules.gni")
15 if (!is_android) {
16   # TODO(GYP) for Windows need to the the reorder-imports step which probably
17   # means adding another target and renaming this to chrome_initial like in GYP.
18   executable("chrome") {
19     # Because the sources list varies so significantly per-platform, generally
20     # each platform lists its own files rather than relying on filtering or
21     # removing unused files.
22     sources = [
23       "app/chrome_exe_resource.h",
24     ]
25     deps = []
26     datadeps = []
28     # TODO(GYP) mac_bundle_resources, xcode_settings
30     # TODO(GYP) order_profiling, order_text_section
32     if (is_win) {
33       sources += [
34         "app/chrome_exe_main_win.cc",
35         "app/client_util.cc",
36         "app/client_util.h",
37         "app/signature_validator_win.cc",
38         "app/signature_validator_win.h",
39         "//content/app/startup_helper_win.cc",
40       ]
41       deps += [
42         ":image_pre_reader",
43         "//chrome/browser:chrome_process_finder",
44         "//chrome/chrome_watcher",
45         "//chrome/chrome_watcher:client",
46         "//components/browser_watcher:browser_watcher_client",
47         "//ui/gfx",
48       ]
49     } else if (use_aura) {
50       # Non-Windows aura entrypoint.
51       sources += [ "app/chrome_exe_main_aura.cc" ]
52     }
54     if (is_linux) {
55       # TODO(GYP) manpage action
57       sources += [
58         "app/chrome_dll_resource.h",
59         "app/chrome_main.cc",
60         "app/chrome_main_delegate.cc",
61         "app/chrome_main_delegate.h",
62       ]
64       deps += [
65         # On Linux, link the dependencies (libraries) that make up actual
66         # Chromium functionality directly into the executable.
67         ":browser_dependencies",
68         ":child_dependencies",
69         "//base/allocator",
71         # Needed to use the master_preferences functions
72         "//chrome/installer/util",
73         "//content/public/app:both",
74       ]
76       # Needed for chrome_main.cc initialization of libraries.
77       configs += [ "//build/config/linux:pangocairo" ]
79       # TODO(GYP) ['profiling==0 and linux_disable_pie==0', {
80       #   'ldflags': [
81       #      '-pie',
82       #   ],
83       #}],
85       if (use_x11) {
86         configs += [
87           "//build/config/linux:x11",
88           "//build/config/linux:xext",
89         ]
90       }
91     }
93     if (is_mac) {
94       sources += [ "app/chrome_exe_main_mac.cc" ]
95       # TODO(GYP) lots more stuff in the is_mac block.
96     } else {  # Non-Mac.
97       deps += [
98         ":packed_extra_resources",
99         ":packed_resources",
101         # Copy Flash Player files to PRODUCT_DIR if applicable. Let the .gyp
102         # file decide what to do on a per-OS basis; on Mac, internal plugins
103         # go inside the framework, so this dependency is in chrome_dll.gypi.
104         #'../third_party/adobe/flash/flash_player.gyp:flapper_binaries',  TODO(GYP)
106         # Copy CDM files to PRODUCT_DIR if applicable. Let the .gyp
107         # file decide what to do on a per-OS basis; on Mac, internal plugins
108         # go inside the framework, so this dependency is in chrome_dll.gypi.
109         #'../third_party/widevine/cdm/widevine_cdm.gyp:widevinecdmadapter',  TODO(GYP)
110       ]
111       # TODO(GYP) some stuff from GYP including chrome_multiple_dll.
112     }
114     if (!is_mac) {
115       # On Mac this is done in chrome_dll.gypi.
116       datadeps += [ "//pdf" ]
117       # TODO(GYP) pdf linux symbols
118     }
119   }
120 }  # !is_android
122 shared_library("main_dll") {
123   configs += [ "//build/config/compiler:wexit_time_destructors" ]
125   deps = [
126     ":browser_dependencies",
127     "//base/allocator",
128   ]
129   if (is_win) {
130     output_name = "chrome"
132     sources = [
133       "app/chrome_command_ids.h",
134       "app/chrome_dll.rc",
135       "app/chrome_dll_resource.h",
136       "app/chrome_main.cc",
137       "app/chrome_main_delegate.cc",
138       "app/chrome_main_delegate.h",
139       "app/close_handle_hook_win.cc",
140       "app/close_handle_hook_win.h",
141       "app/delay_load_hook_win.cc",
142       "app/delay_load_hook_win.h",
143       "//base/win/dllmain.cc",
144     ]
146     deps += [
147       # On Windows, link the dependencies (libraries) that make up actual
148       # Chromium functionality into this .dll.
149       #'chrome_version_resources',  TODO(GYP)
150       "//chrome/app/theme:chrome_unscaled_resources",
151       "//chrome_elf",
152       "//content/app/resources",
153       "//crypto",
154       "//net:net_resources",
155       "//third_party/wtl",
156       "//ui/views",
157     ]
158     if (enable_configuration_policy) {
159       deps += [ "//components/policy" ]
160     }
161     if (cpu_arch == "x86") {
162       # Add a dependency to custom import library for user32 delay imports only
163       # in x86 builds.
164       #deps += [ 'chrome_user32_delay_imports' ]  TODO(GYP)
165     }
167     # TODO(GYP) incremental linking flags in debug builds
168     #'LinkIncremental': '<(msvs_large_module_debug_link_mode)',
170     # TODO(GYP) Lots of VCLinkerTool stuff on Windows.
172     # TODO(GYP) chrome_pgo_phase on Windows.
173   }
175   if (use_aura) {
176     deps += [ "//ui/compositor" ]
177   }
179   #TODO(GYP) add chrome_multiple_dll support
180   if (false) {  #chrome_multiple_dll) {
181     defines = [ "CHROME_MULTIPLE_DLL_BROWSER" ]
182     deps += [ "//content/public/app:browser" ]
183   } else {
184     deps += [
185       ":child_dependencies",
186       "//content/public/app:both",
187     ]
188   }
190   if (cld_version == 0 || cld_version == 2) {
191     deps += [ "//third_party/cld_2" ]
192   }
194   if (is_mac) {
195     #['OS=="mac" and component!="shared_library"', {  TODO(GYP)
196     #  'includes': [ 'chrome_dll_bundle.gypi' ],
197     #}],
198     # TODO(GYP) Lots of other stuff in the OS=="mac" block.
199   }
202 # GYP version: chromium_browser_dependencies variable in chrome.gyp
203 group("browser_dependencies") {
204   deps = [
205     "//chrome/browser",
206     "//chrome/common",
207     "//sync",
208   ]
209   if (!is_ios) {
210     deps += [ "//ppapi:ppapi_host" ]
211   }
213   if (enable_basic_printing || enable_print_preview) {
214     deps += [ "//printing" ]
215     if (enable_print_preview) {
216       deps += [ "//chrome/service" ]
217     }
218   }
221 # GYP version: chromium_child_dependencies variable in chrome.gyp
222 group("child_dependencies") {
223   deps = [
224     "//chrome/common",
225     "//sync",
226   ]
227   if (!is_ios) {
228     deps += [
229       "//chrome/browser/devtools",
230       "//chrome/plugin",
231       "//chrome/renderer",
232       "//chrome/utility",
233       "//content/public/child",
234       "//third_party/WebKit/public:blink_devtools_frontend_resources",
235     ]
236   }
237   if (cld_version == 0 || cld_version == 2) {
238     deps += [ "//third_party/cld_2:cld2_platform_impl" ]
239   }
241   # TODO(gyp) if (enable_nacl) {
242   #  deps += [ "<(DEPTH)/ppapi/native_client/src/trusted/plugin/plugin.gyp:nacl_trusted_plugin" ]
243   #}
244   if (enable_remoting) {
245     deps += [ "//remoting/client/plugin" ]
246   }
249 if (is_win) {
250   # TODO(brettw) this duplicates "//chrome/common:version" which applies to
251   # Linux.
252   process_version("version_header") {
253     # TODO(brettW) this should have more reduced visibility, but chrome/browser
254     # currently depends on this.
255     #visibility = [ ":*" ]
256     source = "version.h.in"
258     # TODO(brettw) this should move to $target_gen_dir/version.h and
259     # source files including it should reference it via "chrome/version.h"
260     output = "$root_gen_dir/version.h"
261   }
263   source_set("image_pre_reader") {
264     sources = [
265       "app/image_pre_reader_win.cc",
266       "app/image_pre_reader_win.h",
267     ]
268     deps = [
269       "//base",
270     ]
271   }
274 # GYP version: chrome/chrome_resources.gyp:chrome_resources
275 group("resources") {
276   deps = [
277     # Note: GYP lists some dependencies in addition to these actions. However,
278     # these are just dependencies for the actions themselves, which our actions
279     # list individually when needed.
280     "//chrome/browser:resources",
281     "//chrome/common:resources",
282     "//chrome/renderer:resources",
283   ]
285   if (enable_extensions) {
286     deps += [ "//chrome/common:extensions_api_resources" ]
287   }
290 # GYP version: chrome/chrome_resources.gyp:chrome_extra_resources
291 group("extra_resources") {
292   deps = [
293     "//chrome/browser/resources:invalidations_resources",
294     "//chrome/browser/resources:memory_internals_resources",
295     "//chrome/browser/resources:net_internals_resources",
296     "//chrome/browser/resources:password_manager_internals_resources",
297     "//chrome/browser/resources:signin_internals_resources",
298     "//chrome/browser/resources:sync_internals_resources",
299     "//chrome/browser/resources:translate_internals_resources",
300   ]
301   if (!is_ios) {
302     deps += [
303       "//chrome/browser/resources:component_extension_resources",
304       "//chrome/browser/resources:options_resources",
305     ]
306   }
308   if (enable_chromevox_next) {
309     deps += [
310       #'browser/resources/chromeos/chromevox2/chromevox.gyp:chromevox2',  TODO(GYP)
311     ]
312   } else {
313     deps += [
314       #'browser/resources/chromeos/chromevox/chromevox.gyp:chromevox',  TODO(GYP)
315     ]
316   }
318   if (enable_extensions) {
319     deps += [
320       "//chrome/browser/resources:quota_internals_resources",
321       "//chrome/browser/resources:sync_file_system_internals_resources",
322     ]
323   }
326 group("packed_resources") {
327   deps = [
328     ":repack_locales_pack",
329     ":repack_pseudo_locales_pack",
330     ":repack_chrome_100_percent",
331   ]
333   # TODO(GYP) if (is_chrome_branded) {
334   # ... copy default_apps from default_apps_list
336   if (enable_hidpi) {
337     deps += [ ":repack_chrome_200_percent" ]
338   }
341 repack("packed_extra_resources") {
342   visibility = [ "./*" ]
343   sources = [
344     "$root_gen_dir/chrome/browser_resources.pak",
345     "$root_gen_dir/chrome/chrome_unscaled_resources.pak",
346     "$root_gen_dir/chrome/common_resources.pak",
347     "$root_gen_dir/chrome/invalidations_resources.pak",
348     "$root_gen_dir/chrome/memory_internals_resources.pak",
349     "$root_gen_dir/chrome/net_internals_resources.pak",
350     "$root_gen_dir/chrome/password_manager_internals_resources.pak",
351     "$root_gen_dir/chrome/signin_internals_resources.pak",
352     "$root_gen_dir/chrome/sync_internals_resources.pak",
353     "$root_gen_dir/chrome/translate_internals_resources.pak",
354     "$root_gen_dir/components/components_resources.pak",
355     "$root_gen_dir/net/net_resources.pak",
356     "$root_gen_dir/ui/resources/webui_resources.pak",
357   ]
358   deps = [
359     "//chrome/browser:resources",
360     "//chrome/app/theme:chrome_unscaled_resources",
361     "//chrome/common:resources",
362     "//chrome/browser/resources:invalidations_resources",
363     "//chrome/browser/resources:memory_internals_resources",
364     "//chrome/browser/resources:net_internals_resources",
365     "//chrome/browser/resources:password_manager_internals_resources",
366     "//chrome/browser/resources:signin_internals_resources",
367     "//chrome/browser/resources:sync_internals_resources",
368     "//chrome/browser/resources:translate_internals_resources",
369     "//components/resources",
370     "//net:net_resources",
371     "//ui/resources",
372   ]
374   if (!is_ios && !is_android) {
375     # New paks should be added here by default.
376     sources += [
377       "$root_gen_dir/chrome/component_extension_resources.pak",
378       "$root_gen_dir/chrome/options_resources.pak",
379       "$root_gen_dir/chrome/quota_internals_resources.pak",
380       "$root_gen_dir/chrome/sync_file_system_internals_resources.pak",
381       "$root_gen_dir/chrome/webrtc_device_provider_resources.pak",
382       "$root_gen_dir/blink/devtools_resources.pak",
383     ]
384     deps += [
385       "//chrome/browser/devtools:webrtc_device_provider_resources",
386       "//chrome/browser/resources:component_extension_resources",
387       "//chrome/browser/resources:options_resources",
388       "//chrome/browser/resources:quota_internals_resources",
389       "//chrome/browser/resources:sync_file_system_internals_resources",
390       "//content/browser/devtools:devtools_resources",
391     ]
392   }
393   if (!is_ios) {
394     sources += [
395       "$root_gen_dir/blink/public/resources/blink_resources.pak",
396       "$root_gen_dir/content/browser/tracing/tracing_resources.pak",
397       "$root_gen_dir/content/content_resources.pak",
398     ]
399   }
400   if (is_chromeos) {
401     sources += [ "$root_gen_dir/ui/file_manager/file_manager_resources.pak" ]
402     deps += [ "//ui/file_manager:resources" ]
403   }
404   if (enable_extensions) {
405     sources += [
406       "$root_gen_dir/chrome/extensions_api_resources.pak",
407       "$root_gen_dir/extensions/extensions_renderer_resources.pak",
408       "$root_gen_dir/extensions/extensions_resources.pak",
409     ]
410     deps += [ "//chrome/common:extensions_api_resources" ]
411   }
413   # GYP outputs the file in the gen/repack directory. On non-Mac/iOS platforms
414   # it them copies it. This skipes the copy step and writes it to the final
415   # location.
416   if (is_mac || is_ios) {
417     output = "$root_gen_dir/repack/resources.pak"
418   } else {
419     output = "$root_out_dir/resources.pak"
420   }
423 # GYP version: chrome/chrome_resources.gyp:browser_tests_pak
424 repack("browser_tests_pak") {
425   sources = [
426     "$root_gen_dir/chrome/options_test_resources.pak",
427   ]
428   output = "$root_out_dir/browser_tests.pak"
431 # Collects per-locale grit files from many sources into global per-locale files.
432 chrome_repack_locales("repack_locales_pack") {
433   visibility = [ ":*" ]
435   input_locales = locales
437   if (is_mac) {
438     output_locales = locales_as_mac_outputs
439   } else {
440     output_locales = locales
441   }
444 chrome_repack_locales("repack_pseudo_locales_pack") {
445   visibility = [ ":*" ]
447   input_locales = [ "fake-bidi" ]
449   if (is_mac) {
450     output_locales = [ "fake_bidi" ]  # Mac uses underscores.
451   } else {
452     output_locales = [ "fake-bidi" ]
453   }
456 # Generates a rule to repack a set of resources, substituting a given string
457 # in for the percentage (e.g. "100", "200"). It generates the repacked files in
458 # the "gen" directory, and then introduces a copy rule to copy it to the root
459 # build directory.
461 # It's not clear why this two-step dance is necessary as opposed to just
462 # generating the file in the destination. However, this is what the GYP build
463 # does, and for maintenance purposes, this keeps the same files in the same
464 # place between the two builds when possible.
466 # Argument:
467 #   percent [required]
468 #      String to substitute for the percentage.
469 template("chrome_repack_percent") {
470   percent = invoker.percent
472   repack_name = "${target_name}_repack"
473   repack_output_file = "$root_gen_dir/repack/chrome_${percent}_percent.pak"
475   copy_name = target_name
477   repack(repack_name) {
478     visibility = [ ":$copy_name" ]
480     # All sources should also have deps for completeness.
481     sources = [
482       "$root_gen_dir/components/components_resources_${percent}_percent.pak",
483       "$root_gen_dir/ui/resources/ui_resources_${percent}_percent.pak",
484       "$root_gen_dir/chrome/renderer_resources_${percent}_percent.pak",
485       "$root_gen_dir/chrome/theme_resources_${percent}_percent.pak",
486     ]
488     deps = [
489       "//chrome/app/theme:theme_resources",
490       "//chrome/renderer:resources",
491       "//components/strings",
492       "//net:net_resources",
493     ]
495     if (!is_ios) {
496       sources += [ "$root_gen_dir/content/app/resources/content_resources_${percent}_percent.pak" ]
497       deps += [ "//content:resources" ]
498     }
499     if (use_ash) {
500       sources +=
501           [ "$root_gen_dir/ash/resources/ash_resources_${percent}_percent.pak" ]
502       deps += [ "//ash/resources" ]
503     }
504     if (is_chromeos) {
505       sources += [ "$root_gen_dir/ui/chromeos/resources/ui_chromeos_resources_${percent}_percent.pak" ]
506       deps += [ "//ui/chromeos/resources" ]
507     }
508     if (enable_extensions) {
509       sources += [ "$root_gen_dir/extensions/extensions_browser_resources_${percent}_percent.pak" ]
510     }
512     output = repack_output_file
513   }
515   copy(copy_name) {
516     visibility = [ ":*" ]
517     deps = [
518       ":$repack_name",
519     ]
520     sources = [
521       repack_output_file,
522     ]
523     outputs = [
524       "$root_build_dir/chrome_${percent}_percent.pak",
525     ]
526   }
529 chrome_repack_percent("repack_chrome_100_percent") {
530   percent = "100"
533 if (enable_hidpi) {
534   chrome_repack_percent("repack_chrome_200_percent") {
535     percent = "200"
536   }
539 # GYP version: chrome/chrome_resources.gyp:chrome_strings
540 group("strings") {
541   deps = [
542     "//chrome/app:chromium_strings",
543     "//chrome/app:generated_resources",
544     "//chrome/app:google_chrome_strings",
545     "//chrome/app/resources:locale_settings",
546   ]
549 if (is_android) {
550   # GYP: //chrome/chrome.gyp:content_setting_java
551   java_cpp_enum("content_setting_javagen") {
552     sources = [
553       "../components/content_settings/core/common/content_settings.h",
554     ]
555     outputs = [
556       "org/chromium/chrome/browser/ContentSetting.java",
557     ]
558   }
560   # GYP: //chrome/chrome.gyp:content_settings_type_java
561   java_cpp_enum("content_settings_type_javagen") {
562     sources = [
563       "../components/content_settings/core/common/content_settings_types.h",
564     ]
565     outputs = [
566       "org/chromium/chrome/browser/ContentSettingsType.java",
567     ]
568   }
570   # GYP: //chrome/chrome.gyp:page_info_connection_type_java
571   java_cpp_enum("page_info_connection_type_javagen") {
572     sources = [
573       "browser/ui/android/website_settings_popup_android.h",
574     ]
575     outputs = [
576       "org/chromium/chrome/browser/PageInfoConnectionType.java",
577     ]
578   }
580   # GYP: //chrome/chrome_android.gypi:chrome_android_core
581   static_library("chrome_android_core") {
582     sources = [
583       "app/android/chrome_android_initializer.cc",
584       "app/android/chrome_android_initializer.h",
585       "app/android/chrome_main_delegate_android.cc",
586       "app/android/chrome_main_delegate_android.h",
587       "app/chrome_main_delegate.cc",
588       "app/chrome_main_delegate.h",
589     ]
591     include_dirs = [ android_ndk_include_dir ]
593     libs = [
594       "android",
595       "jnigraphics",
596     ]
598     deps = [
599       "//chrome/browser",
600       "//chrome/browser/ui",
601       "//chrome/plugin",
602       "//chrome/renderer",
603       "//chrome/utility",
604       "//components/enhanced_bookmarks",
605       "//content/public/app:browser",
606     ]
607   }