Roll src/third_party/WebKit 129741d:3ffd812 (svn 192915:192926)
[chromium-blink-merge.git] / chrome / BUILD.gn
blob4806a3d12c8ff9b1b31e9025b8b8f57290761a6f
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/content/browser/tracing/tracing_resources.pak",
490       "$root_gen_dir/content/content_resources.pak",
491     ]
492   }
493   if (is_chromeos) {
494     sources += [ "$root_gen_dir/ui/file_manager/file_manager_resources.pak" ]
495     sources += [ "$root_gen_dir/ui/oobe/oobe_resources.pak" ]
496     deps += [ "//ui/file_manager:resources" ]
497     deps += [ "//ui/oobe:resources" ]
498   }
499   if (enable_extensions) {
500     sources += [
501       "$root_gen_dir/chrome/extensions_api_resources.pak",
502       "$root_gen_dir/extensions/extensions_renderer_resources.pak",
503       "$root_gen_dir/extensions/extensions_resources.pak",
504     ]
505     deps += [ "//chrome/common:extensions_api_resources" ]
506   }
508   # GYP outputs the file in the gen/repack directory. On non-Mac/iOS platforms
509   # it them copies it. This skipes the copy step and writes it to the final
510   # location.
511   if (is_mac || is_ios) {
512     output = "$root_gen_dir/repack/resources.pak"
513   } else {
514     output = "$root_out_dir/resources.pak"
515   }
518 # GYP version: chrome/chrome_resources.gyp:browser_tests_pak
519 repack("browser_tests_pak") {
520   sources = [
521     "$root_gen_dir/chrome/options_test_resources.pak",
522   ]
523   output = "$root_out_dir/browser_tests.pak"
526 # Collects per-locale grit files from many sources into global per-locale files.
527 chrome_repack_locales("repack_locales_pack") {
528   visibility = [ ":*" ]
530   input_locales = locales
532   if (is_mac) {
533     output_locales = locales_as_mac_outputs
534   } else {
535     output_locales = locales
536   }
539 chrome_repack_locales("repack_pseudo_locales_pack") {
540   visibility = [ ":*" ]
542   input_locales = [ "fake-bidi" ]
544   if (is_mac) {
545     output_locales = [ "fake_bidi" ]  # Mac uses underscores.
546   } else {
547     output_locales = [ "fake-bidi" ]
548   }
551 # Generates a rule to repack a set of resources, substituting a given string
552 # in for the percentage (e.g. "100", "200"). It generates the repacked files in
553 # the "gen" directory, and then introduces a copy rule to copy it to the root
554 # build directory.
556 # It's not clear why this two-step dance is necessary as opposed to just
557 # generating the file in the destination. However, this is what the GYP build
558 # does, and for maintenance purposes, this keeps the same files in the same
559 # place between the two builds when possible.
561 # Argument:
562 #   percent [required]
563 #      String to substitute for the percentage.
564 template("chrome_repack_percent") {
565   percent = invoker.percent
567   repack_name = "${target_name}_repack"
568   repack_output_file = "$root_gen_dir/repack/chrome_${percent}_percent.pak"
570   copy_name = target_name
572   repack(repack_name) {
573     visibility = [ ":$copy_name" ]
575     # All sources should also have deps for completeness.
576     sources = [
577       "$root_gen_dir/chrome/renderer_resources_${percent}_percent.pak",
578       "$root_gen_dir/chrome/theme_resources_${percent}_percent.pak",
579       "$root_gen_dir/components/components_resources_${percent}_percent.pak",
580       "$root_gen_dir/ui/resources/ui_resources_${percent}_percent.pak",
581     ]
583     deps = [
584       "//chrome/app/theme:theme_resources",
585       "//chrome/renderer:resources",
586       "//components/strings",
587       "//net:net_resources",
588     ]
590     if (!is_ios) {
591       sources += [
592         "$root_gen_dir/blink/public/resources/blink_resources_${percent}_percent.pak",
593         "$root_gen_dir/content/app/resources/content_resources_${percent}_percent.pak",
594       ]
595       deps += [ "//content:resources" ]
596     }
597     if (use_ash) {
598       sources +=
599           [ "$root_gen_dir/ash/resources/ash_resources_${percent}_percent.pak" ]
600       deps += [ "//ash/resources" ]
601     }
602     if (is_chromeos) {
603       sources += [ "$root_gen_dir/ui/chromeos/resources/ui_chromeos_resources_${percent}_percent.pak" ]
604       deps += [ "//ui/chromeos/resources" ]
605     }
606     if (enable_extensions) {
607       sources += [ "$root_gen_dir/extensions/extensions_browser_resources_${percent}_percent.pak" ]
608     }
610     output = repack_output_file
611   }
613   copy(copy_name) {
614     visibility = [ ":*" ]
615     deps = [
616       ":$repack_name",
617     ]
618     sources = [
619       repack_output_file,
620     ]
621     outputs = [
622       "$root_build_dir/chrome_${percent}_percent.pak",
623     ]
624   }
627 chrome_repack_percent("repack_chrome_100_percent") {
628   percent = "100"
631 if (enable_hidpi) {
632   chrome_repack_percent("repack_chrome_200_percent") {
633     percent = "200"
634   }
637 # GYP version: chrome/chrome_resources.gyp:chrome_strings
638 group("strings") {
639   deps = [
640     "//chrome/app:chromium_strings",
641     "//chrome/app:generated_resources",
642     "//chrome/app:google_chrome_strings",
643     "//chrome/app/resources:locale_settings",
644   ]
647 if (is_android) {
648   # GYP: //chrome/chrome.gyp:content_setting_java
649   java_cpp_enum("content_setting_javagen") {
650     sources = [
651       "../components/content_settings/core/common/content_settings.h",
652     ]
653     outputs = [
654       "org/chromium/chrome/browser/ContentSetting.java",
655     ]
656   }
658   # GYP: //chrome/chrome.gyp:content_settings_type_java
659   java_cpp_enum("content_settings_type_javagen") {
660     sources = [
661       "../components/content_settings/core/common/content_settings_types.h",
662     ]
663     outputs = [
664       "org/chromium/chrome/browser/ContentSettingsType.java",
665     ]
666   }
668   # GYP: //chrome/chrome.gyp:page_info_connection_type_java
669   java_cpp_enum("page_info_connection_type_javagen") {
670     sources = [
671       "browser/ui/android/website_settings_popup_android.h",
672     ]
673     outputs = [
674       "org/chromium/chrome/browser/PageInfoConnectionType.java",
675     ]
676   }
678   # GYP: //chrome/chrome_android.gypi:chrome_android_core
679   static_library("chrome_android_core") {
680     sources = [
681       "app/android/chrome_android_initializer.cc",
682       "app/android/chrome_android_initializer.h",
683       "app/android/chrome_jni_onload.cc",
684       "app/android/chrome_jni_onload.h",
685       "app/android/chrome_main_delegate_android.cc",
686       "app/android/chrome_main_delegate_android.h",
687       "app/chrome_main_delegate.cc",
688       "app/chrome_main_delegate.h",
689     ]
691     include_dirs = [ android_ndk_include_dir ]
693     libs = [
694       "android",
695       "jnigraphics",
696     ]
698     deps = [
699       "//chrome/browser",
700       "//chrome/browser/ui",
701       "//chrome/child",
702       "//chrome/plugin",
703       "//chrome/renderer",
704       "//chrome/utility",
705       "//components/enhanced_bookmarks",
706       "//content/public/app:both",
707     ]
708   }
711 if (is_linux) {
712   action("manpage") {
713     if (is_chrome_branded) {
714       name = "Google Chrome"
715       filename = "google-chrome"
716       confdir = "google-chrome"
717     } else {
718       name = "Chromium"
719       filename = "chromium-browser"
720       confdir = "chromium"
721     }
723     script = "//chrome/tools/build/linux/sed.py"
724     infile = "app/resources/manpage.1.in"
725     inputs = [
726       infile,
727     ]
729     outfile = "$root_out_dir/chrome.1"
730     outputs = [
731       outfile,
732     ]
734     args = [
735       rebase_path(infile, root_build_dir),
736       rebase_path(outfile, root_build_dir),
737       "-e s/@@NAME@@/$name/",
738       "-e s/@@FILENAME@@/$filename/",
739       "-e s/@@CONFDIR@@/$confdir/",
740     ]
741   }