Add an UMA stat to be able to see if the User pods are show on start screen,
[chromium-blink-merge.git] / chrome / BUILD.gn
blob229863c119c064ca6d72e5370924794ba64580f4
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         "$target_gen_dir/chrome_exe_version.rc",
35         "//content/app/startup_helper_win.cc",
36         "//content/public/common/content_switches.cc",
37         "app/chrome_crash_reporter_client.cc",
38         "app/chrome_crash_reporter_client.h",
39         "app/chrome_exe.rc",
40         "app/chrome_exe_main_win.cc",
41         "app/chrome_watcher_client_win.cc",
42         "app/chrome_watcher_client_win.h",
43         "app/chrome_watcher_command_line_win.cc",
44         "app/chrome_watcher_command_line_win.h",
45         "app/client_util.cc",
46         "app/client_util.h",
47         "app/kasko_client.cc",
48         "app/kasko_client.h",
49         "app/signature_validator_win.cc",
50         "app/signature_validator_win.h",
51         "common/crash_keys.cc",
52         "common/crash_keys.h'",
53       ]
54       deps += [
55         ":chrome_version_resources",
56         ":image_pre_reader",
57         ":main_dll",
59         # 'chrome_nacl_win64" TODO(GYP)
60         # '../win8/delegate_execute/delegate_execute.gyp:*', TODO(GYP)
61         # '../win8/metro_driver/metro_driver.gyp:metro_driver', TODO(GYP)
62         "//base",
63         "//breakpad:breakpad_handler",
64         "//breakpad:breakpad_sender",
65         "//chrome/browser:chrome_process_finder",
66         "//chrome/chrome_watcher",
67         "//chrome/chrome_watcher:client",
68         "//chrome/installer/util",
69         "//chrome_elf",
70         "//components/browser_watcher:browser_watcher_client",
71         "//components/crash/app",
72         "//crypto",
73         "//sandbox",
74         "//ui/gfx",
75       ]
76       libs = [
77         "wintrust.lib",
78         "crypt32.lib",
79       ]
80       configs -= [ "//build/config/win:console" ]
81       configs += [ "//build/config/win:windowed" ]
82     } else if (use_aura) {
83       # Non-Windows aura entrypoint.
84       sources += [ "app/chrome_exe_main_aura.cc" ]
85     }
87     if (is_linux) {
88       sources += [
89         "app/chrome_dll_resource.h",
90         "app/chrome_main.cc",
91         "app/chrome_main_delegate.cc",
92         "app/chrome_main_delegate.h",
93       ]
95       deps += [
96         # On Linux, link the dependencies (libraries) that make up actual
97         # Chromium functionality directly into the executable.
98         ":browser_dependencies",
99         ":child_dependencies",
100         ":manpage",
101         "//base/allocator",
103         # Needed to use the master_preferences functions
104         "//chrome/installer/util",
105         "//content/public/app:both",
106       ]
108       # Needed for chrome_main.cc initialization of libraries.
109       configs += [ "//build/config/linux:pangocairo" ]
111       # TODO(GYP) ['profiling==0 and linux_disable_pie==0', {
112       #   'ldflags': [
113       #      '-pie',
114       #   ],
115       #}],
117       if (use_x11) {
118         configs += [
119           "//build/config/linux:x11",
120           "//build/config/linux:xext",
121         ]
122       }
123     }
125     if (is_mac) {
126       sources += [ "app/chrome_exe_main_mac.cc" ]
127       # TODO(GYP) lots more stuff in the is_mac block.
128     } else {  # Non-Mac.
129       deps += [
130         ":packed_extra_resources",
131         ":packed_resources",
132         "//components/startup_metric_utils",
134         # Precompiled plugins that need to get copied to the output directory.
135         # On Mac, internal plugins go inside the framework, so these
136         # dependencies are on chrome.dll.
137         "//third_party/adobe/flash:flapper_binaries",
138         "//third_party/widevine/cdm:adapter",
139       ]
140       # TODO(GYP) some stuff from GYP including chrome_multiple_dll.
141     }
143     if (is_linux && enable_plugins) {
144       deps += [ "//pdf" ]
145     }
146   }
147 }  # !is_android
149 shared_library("main_dll") {
150   configs += [ "//build/config/compiler:wexit_time_destructors" ]
152   deps = [
153     ":browser_dependencies",
154     "//base/allocator",
155   ]
156   if (is_win) {
157     output_name = "chrome"
159     sources = [
160       "//base/win/dllmain.cc",
161       "app/chrome_command_ids.h",
162       "app/chrome_dll.rc",
163       "app/chrome_dll_resource.h",
164       "app/chrome_main.cc",
165       "app/chrome_main_delegate.cc",
166       "app/chrome_main_delegate.h",
167       "app/close_handle_hook_win.cc",
168       "app/close_handle_hook_win.h",
169       "app/delay_load_hook_win.cc",
170       "app/delay_load_hook_win.h",
171     ]
173     deps += [
174       # On Windows, link the dependencies (libraries) that make up actual
175       # Chromium functionality into this .dll.
176       ":chrome_version_resources",
177       "//chrome/app/theme:chrome_unscaled_resources",
178       "//chrome_elf",
179       "//content/app/resources",
180       "//crypto",
181       "//net:net_resources",
182       "//third_party/wtl",
183       "//ui/views",
184     ]
185     if (enable_configuration_policy) {
186       deps += [ "//components/policy" ]
187     }
188     if (current_cpu == "x86") {
189       # Add a dependency to custom import library for user32 delay imports only
190       # in x86 builds.
191       #deps += [ 'chrome_user32_delay_imports' ]  TODO(GYP)
192     }
194     # This is a large module that can't do incremental linking in some cases.
195     configs -= [ "//build/config/win:default_incremental_linking" ]
196     configs += [ "//build/config/win:default_large_module_incremental_linking" ]
198     # TODO(GYP) Lots of VCLinkerTool stuff on Windows.
200     # TODO(GYP) chrome_pgo_phase on Windows.
201   }
203   if (use_aura) {
204     deps += [ "//ui/compositor" ]
205   }
207   #TODO(GYP) add chrome_multiple_dll support
208   if (false) {  #chrome_multiple_dll) {
209     defines = [ "CHROME_MULTIPLE_DLL_BROWSER" ]
210     deps += [ "//content/public/app:browser" ]
211   } else {
212     deps += [
213       ":child_dependencies",
214       "//content/public/app:both",
215     ]
216   }
218   if (cld_version == 0 || cld_version == 2) {
219     deps += [ "//third_party/cld_2" ]
220   }
222   if (is_mac) {
223     #['OS=="mac" and component!="shared_library"', {  TODO(GYP)
224     #  'includes': [ 'chrome_dll_bundle.gypi' ],
225     #}],
226     # TODO(GYP) Lots of other stuff in the OS=="mac" block.
227   }
229   if (enable_plugins) {
230     deps += [ "//pdf" ]
231   }
234 # GYP version: chromium_browser_dependencies variable in chrome.gyp
235 group("browser_dependencies") {
236   deps = [
237     "//chrome/browser",
238     "//chrome/common",
239     "//sync",
240   ]
241   if (!is_ios) {
242     deps += [ "//ppapi/host" ]
243   }
245   if (enable_basic_printing || enable_print_preview) {
246     deps += [ "//printing" ]
247     if (enable_print_preview) {
248       deps += [ "//chrome/service" ]
249     }
250   }
253 # GYP version: chromium_child_dependencies variable in chrome.gyp
254 group("child_dependencies") {
255   deps = [
256     "//chrome/common",
257     "//sync",
258   ]
259   if (!is_ios) {
260     deps += [
261       "//chrome/browser/devtools",
262       "//chrome/child",
263       "//chrome/plugin",
264       "//chrome/renderer",
265       "//chrome/utility",
266       "//content/public/child",
267       "//third_party/WebKit/public:blink_devtools_frontend_resources",
268     ]
269   }
270   if (cld_version == 0 || cld_version == 2) {
271     deps += [ "//third_party/cld_2:cld2_platform_impl" ]
272   }
274   if (enable_nacl) {
275     deps += [ "//components/nacl/renderer/plugin:nacl_trusted_plugin" ]
276   }
277   if (enable_remoting) {
278     deps += [ "//remoting/client/plugin" ]
279   }
282 if (is_win) {
283   # TODO(brettw) this duplicates "//chrome/common:version" which applies to
284   # Linux.
285   process_version("version_header") {
286     # TODO(brettW) this should have more reduced visibility, but chrome/browser
287     # currently depends on this.
288     #visibility = [ ":*" ]
290     # This one just uses the custom template and no separate sources.
291     sources = []
292     template_file = "version.h.in"
294     # TODO(brettw) this should move to $target_gen_dir/version.h and
295     # source files including it should reference it via "chrome/version.h"
296     output = "$root_gen_dir/version.h"
297   }
299   process_version("chrome_exe_version") {
300     sources = [
301       "app/chrome_exe.ver",
302     ]
303     output = "$target_gen_dir/chrome_exe_version.rc"
304   }
306   process_version("chrome_dll_version") {
307     sources = [
308       "app/chrome_dll.ver",
309     ]
310     output = "$target_gen_dir/chrome_dll_version.rc"
311   }
313   process_version("nacl64_exe_version") {
314     sources = [
315       "app/nacl64_exe.ver",
316     ]
317     output = "$target_gen_dir/nacl64_exe_version.rc"
318   }
320   process_version("other_version") {
321     sources = [
322       "app/other.ver",
323     ]
324     output = "$target_gen_dir/other_version.rc"
325   }
327   group("chrome_version_resources") {
328     deps = [
329       ":chrome_exe_version",
330       ":chrome_dll_version",
331       ":nacl64_exe_version",
332       ":other_version",
333     ]
334   }
336   source_set("image_pre_reader") {
337     sources = [
338       "app/image_pre_reader_win.cc",
339       "app/image_pre_reader_win.h",
340     ]
341     deps = [
342       "//base",
343     ]
344   }
347 # GYP version: chrome/chrome_resources.gyp:chrome_resources
348 group("resources") {
349   deps = [
350     # Note: GYP lists some dependencies in addition to these actions. However,
351     # these are just dependencies for the actions themselves, which our actions
352     # list individually when needed.
353     "//chrome/browser:resources",
354     "//chrome/common:resources",
355     "//chrome/renderer:resources",
356   ]
358   if (enable_extensions) {
359     deps += [ "//chrome/common:extensions_api_resources" ]
360   }
363 # GYP version: chrome/chrome_resources.gyp:chrome_extra_resources
364 group("extra_resources") {
365   deps = [
366     "//chrome/browser/resources:invalidations_resources",
367     "//chrome/browser/resources:memory_internals_resources",
368     "//chrome/browser/resources:net_internals_resources",
369     "//chrome/browser/resources:password_manager_internals_resources",
370     "//chrome/browser/resources:signin_internals_resources",
371     "//chrome/browser/resources:sync_internals_resources",
372     "//chrome/browser/resources:translate_internals_resources",
373   ]
374   if (!is_ios) {
375     deps += [
376       "//chrome/browser/resources:component_extension_resources",
377       "//chrome/browser/resources:options_resources",
378       "//chrome/browser/resources:settings_resources",
379     ]
380   }
382   if (enable_chromevox_next) {
383     deps += [
384       #'browser/resources/chromeos/chromevox2/chromevox.gyp:chromevox2',  TODO(GYP)
385     ]
386   } else {
387     deps += [
388       #'browser/resources/chromeos/chromevox/chromevox.gyp:chromevox',  TODO(GYP)
389     ]
390   }
392   if (enable_extensions) {
393     deps += [
394       "//chrome/browser/resources:quota_internals_resources",
395       "//chrome/browser/resources:sync_file_system_internals_resources",
396     ]
397   }
400 if (is_chrome_branded) {
401   copy("default_apps") {
402     visibility = [ ":packed_resources" ]
403     sources = [
404       "browser/resources/default_apps/docs.crx",
405       "browser/resources/default_apps/drive.crx",
406       "browser/resources/default_apps/external_extensions.json",
407       "browser/resources/default_apps/gmail.crx",
408       "browser/resources/default_apps/search.crx",
409       "browser/resources/default_apps/youtube.crx",
410     ]
411     outputs = [
412       "$root_out_dir/default_apps/{{source_file_part}}",
413     ]
414   }
417 group("packed_resources") {
418   deps = [
419     ":repack_locales_pack",
420     ":repack_pseudo_locales_pack",
421     ":repack_chrome_100_percent",
422   ]
424   if (is_chrome_branded) {
425     deps += [ ":default_apps" ]
426   }
428   if (enable_hidpi) {
429     deps += [ ":repack_chrome_200_percent" ]
430   }
433 repack("packed_extra_resources") {
434   visibility = [ "./*" ]
435   sources = [
436     "$root_gen_dir/chrome/browser_resources.pak",
437     "$root_gen_dir/chrome/chrome_unscaled_resources.pak",
438     "$root_gen_dir/chrome/common_resources.pak",
439     "$root_gen_dir/chrome/invalidations_resources.pak",
440     "$root_gen_dir/chrome/memory_internals_resources.pak",
441     "$root_gen_dir/chrome/net_internals_resources.pak",
442     "$root_gen_dir/chrome/password_manager_internals_resources.pak",
443     "$root_gen_dir/chrome/signin_internals_resources.pak",
444     "$root_gen_dir/chrome/sync_internals_resources.pak",
445     "$root_gen_dir/chrome/translate_internals_resources.pak",
446     "$root_gen_dir/components/components_resources.pak",
447     "$root_gen_dir/net/net_resources.pak",
448     "$root_gen_dir/ui/resources/webui_resources.pak",
449   ]
450   deps = [
451     "//chrome/browser:resources",
452     "//chrome/app/theme:chrome_unscaled_resources",
453     "//chrome/common:resources",
454     "//chrome/browser/resources:invalidations_resources",
455     "//chrome/browser/resources:memory_internals_resources",
456     "//chrome/browser/resources:net_internals_resources",
457     "//chrome/browser/resources:password_manager_internals_resources",
458     "//chrome/browser/resources:signin_internals_resources",
459     "//chrome/browser/resources:sync_internals_resources",
460     "//chrome/browser/resources:translate_internals_resources",
461     "//components/resources",
462     "//net:net_resources",
463     "//ui/resources",
464   ]
466   if (!is_ios && !is_android) {
467     # New paks should be added here by default.
468     sources += [
469       "$root_gen_dir/blink/devtools_resources.pak",
470       "$root_gen_dir/chrome/component_extension_resources.pak",
471       "$root_gen_dir/chrome/options_resources.pak",
472       "$root_gen_dir/chrome/quota_internals_resources.pak",
473       "$root_gen_dir/chrome/settings_resources.pak",
474       "$root_gen_dir/chrome/sync_file_system_internals_resources.pak",
475       "$root_gen_dir/chrome/webrtc_device_provider_resources.pak",
476     ]
477     deps += [
478       "//chrome/browser/devtools:webrtc_device_provider_resources",
479       "//chrome/browser/resources:component_extension_resources",
480       "//chrome/browser/resources:options_resources",
481       "//chrome/browser/resources:settings_resources",
482       "//chrome/browser/resources:quota_internals_resources",
483       "//chrome/browser/resources:sync_file_system_internals_resources",
484       "//content/browser/devtools:devtools_resources",
485     ]
486   }
487   if (!is_ios) {
488     sources += [
489       "$root_gen_dir/blink/public/resources/blink_resources.pak",
490       "$root_gen_dir/content/browser/tracing/tracing_resources.pak",
491       "$root_gen_dir/content/content_resources.pak",
492     ]
493   }
494   if (is_chromeos) {
495     sources += [ "$root_gen_dir/ui/file_manager/file_manager_resources.pak" ]
496     sources += [ "$root_gen_dir/ui/oobe/oobe_resources.pak" ]
497     deps += [ "//ui/file_manager:resources" ]
498     deps += [ "//ui/oobe:resources" ]
499   }
500   if (enable_extensions) {
501     sources += [
502       "$root_gen_dir/chrome/extensions_api_resources.pak",
503       "$root_gen_dir/extensions/extensions_renderer_resources.pak",
504       "$root_gen_dir/extensions/extensions_resources.pak",
505     ]
506     deps += [ "//chrome/common:extensions_api_resources" ]
507   }
509   # GYP outputs the file in the gen/repack directory. On non-Mac/iOS platforms
510   # it them copies it. This skipes the copy step and writes it to the final
511   # location.
512   if (is_mac || is_ios) {
513     output = "$root_gen_dir/repack/resources.pak"
514   } else {
515     output = "$root_out_dir/resources.pak"
516   }
519 # GYP version: chrome/chrome_resources.gyp:browser_tests_pak
520 repack("browser_tests_pak") {
521   sources = [
522     "$root_gen_dir/chrome/options_test_resources.pak",
523   ]
524   output = "$root_out_dir/browser_tests.pak"
527 # Collects per-locale grit files from many sources into global per-locale files.
528 chrome_repack_locales("repack_locales_pack") {
529   visibility = [ ":*" ]
531   input_locales = locales
533   if (is_mac) {
534     output_locales = locales_as_mac_outputs
535   } else {
536     output_locales = locales
537   }
540 chrome_repack_locales("repack_pseudo_locales_pack") {
541   visibility = [ ":*" ]
543   input_locales = [ "fake-bidi" ]
545   if (is_mac) {
546     output_locales = [ "fake_bidi" ]  # Mac uses underscores.
547   } else {
548     output_locales = [ "fake-bidi" ]
549   }
552 # Generates a rule to repack a set of resources, substituting a given string
553 # in for the percentage (e.g. "100", "200"). It generates the repacked files in
554 # the "gen" directory, and then introduces a copy rule to copy it to the root
555 # build directory.
557 # It's not clear why this two-step dance is necessary as opposed to just
558 # generating the file in the destination. However, this is what the GYP build
559 # does, and for maintenance purposes, this keeps the same files in the same
560 # place between the two builds when possible.
562 # Argument:
563 #   percent [required]
564 #      String to substitute for the percentage.
565 template("chrome_repack_percent") {
566   percent = invoker.percent
568   repack_name = "${target_name}_repack"
569   repack_output_file = "$root_gen_dir/repack/chrome_${percent}_percent.pak"
571   copy_name = target_name
573   repack(repack_name) {
574     visibility = [ ":$copy_name" ]
576     # All sources should also have deps for completeness.
577     sources = [
578       "$root_gen_dir/chrome/renderer_resources_${percent}_percent.pak",
579       "$root_gen_dir/chrome/theme_resources_${percent}_percent.pak",
580       "$root_gen_dir/components/components_resources_${percent}_percent.pak",
581       "$root_gen_dir/ui/resources/ui_resources_${percent}_percent.pak",
582     ]
584     deps = [
585       "//chrome/app/theme:theme_resources",
586       "//chrome/renderer:resources",
587       "//components/strings",
588       "//net:net_resources",
589     ]
591     if (!is_ios) {
592       sources += [
593         "$root_gen_dir/blink/public/resources/blink_image_resources_${percent}_percent.pak",
594         "$root_gen_dir/content/app/resources/content_resources_${percent}_percent.pak",
595       ]
596       deps += [ "//content:resources" ]
597     }
598     if (use_ash) {
599       sources +=
600           [ "$root_gen_dir/ash/resources/ash_resources_${percent}_percent.pak" ]
601       deps += [ "//ash/resources" ]
602     }
603     if (is_chromeos) {
604       sources += [ "$root_gen_dir/ui/chromeos/resources/ui_chromeos_resources_${percent}_percent.pak" ]
605       deps += [ "//ui/chromeos/resources" ]
606     }
607     if (enable_extensions) {
608       sources += [ "$root_gen_dir/extensions/extensions_browser_resources_${percent}_percent.pak" ]
609     }
611     output = repack_output_file
612   }
614   copy(copy_name) {
615     visibility = [ ":*" ]
616     deps = [
617       ":$repack_name",
618     ]
619     sources = [
620       repack_output_file,
621     ]
622     outputs = [
623       "$root_build_dir/chrome_${percent}_percent.pak",
624     ]
625   }
628 chrome_repack_percent("repack_chrome_100_percent") {
629   percent = "100"
632 if (enable_hidpi) {
633   chrome_repack_percent("repack_chrome_200_percent") {
634     percent = "200"
635   }
638 # GYP version: chrome/chrome_resources.gyp:chrome_strings
639 group("strings") {
640   deps = [
641     "//chrome/app:chromium_strings",
642     "//chrome/app:generated_resources",
643     "//chrome/app:google_chrome_strings",
644     "//chrome/app/resources:locale_settings",
645   ]
648 if (is_android) {
649   # GYP: //chrome/chrome.gyp:content_setting_java
650   java_cpp_enum("content_setting_javagen") {
651     sources = [
652       "../components/content_settings/core/common/content_settings.h",
653     ]
654     outputs = [
655       "org/chromium/chrome/browser/ContentSetting.java",
656     ]
657   }
659   # GYP: //chrome/chrome.gyp:content_settings_type_java
660   java_cpp_enum("content_settings_type_javagen") {
661     sources = [
662       "../components/content_settings/core/common/content_settings_types.h",
663     ]
664     outputs = [
665       "org/chromium/chrome/browser/ContentSettingsType.java",
666     ]
667   }
669   # GYP: //chrome/chrome.gyp:page_info_connection_type_java
670   java_cpp_enum("page_info_connection_type_javagen") {
671     sources = [
672       "browser/ui/android/website_settings_popup_android.h",
673     ]
674     outputs = [
675       "org/chromium/chrome/browser/PageInfoConnectionType.java",
676     ]
677   }
679   # GYP: //chrome/chrome_android.gypi:chrome_android_core
680   static_library("chrome_android_core") {
681     sources = [
682       "app/android/chrome_android_initializer.cc",
683       "app/android/chrome_android_initializer.h",
684       "app/android/chrome_jni_onload.cc",
685       "app/android/chrome_jni_onload.h",
686       "app/android/chrome_main_delegate_android.cc",
687       "app/android/chrome_main_delegate_android.h",
688       "app/chrome_main_delegate.cc",
689       "app/chrome_main_delegate.h",
690     ]
692     include_dirs = [ android_ndk_include_dir ]
694     libs = [
695       "android",
696       "jnigraphics",
697     ]
699     deps = [
700       "//chrome/browser",
701       "//chrome/browser/ui",
702       "//chrome/child",
703       "//chrome/plugin",
704       "//chrome/renderer",
705       "//chrome/utility",
706       "//components/enhanced_bookmarks",
707       "//content/public/app:both",
708     ]
709   }
712 if (is_linux) {
713   action("manpage") {
714     if (is_chrome_branded) {
715       name = "Google Chrome"
716       filename = "google-chrome"
717       confdir = "google-chrome"
718     } else {
719       name = "Chromium"
720       filename = "chromium-browser"
721       confdir = "chromium"
722     }
724     script = "//chrome/tools/build/linux/sed.py"
725     infile = "app/resources/manpage.1.in"
726     inputs = [
727       infile,
728     ]
730     outfile = "$root_out_dir/chrome.1"
731     outputs = [
732       outfile,
733     ]
735     args = [
736       rebase_path(infile, root_build_dir),
737       rebase_path(outfile, root_build_dir),
738       "-e s/@@NAME@@/$name/",
739       "-e s/@@FILENAME@@/$filename/",
740       "-e s/@@CONFDIR@@/$confdir/",
741     ]
742   }