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