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