Allowing size increase of nacl_helper.
[chromium-blink-merge.git] / chrome / BUILD.gn
blobab95acd332d77b7c978bb308a9f7e4d8fade02a3
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_win && !link_chrome_on_windows) {
16   # When linking is disabled on Windows, create a dummy Chrome target to
17   # make targets work that depend on Chrome.
18   group("chrome") {
19   }
20   group("main_dll") {
21   }
24 if (!is_android && (!is_win || link_chrome_on_windows)) {
25   # TODO(GYP) for Windows need to the the reorder-imports step which probably
26   # means adding another target and renaming this to chrome_initial like in GYP.
27   executable("chrome") {
28     # Because the sources list varies so significantly per-platform, generally
29     # each platform lists its own files rather than relying on filtering or
30     # removing unused files.
31     sources = [
32       "app/chrome_exe_resource.h",
33     ]
34     deps = []
35     datadeps = []
37     # TODO(GYP) mac_bundle_resources, xcode_settings
39     # TODO(GYP) order_profiling, order_text_section
41     if (is_win) {
42       sources += [
43         "$target_gen_dir/chrome_exe_version.rc",
44         "app/chrome_crash_reporter_client.cc",
45         "app/chrome_crash_reporter_client.h",
46         "app/chrome_exe.rc",
47         "app/chrome_exe_main_win.cc",
48         "app/chrome_watcher_client_win.cc",
49         "app/chrome_watcher_client_win.h",
50         "app/chrome_watcher_command_line_win.cc",
51         "app/chrome_watcher_command_line_win.h",
52         "app/client_util.cc",
53         "app/client_util.h",
54         "app/signature_validator_win.cc",
55         "app/signature_validator_win.h",
56         "common/crash_keys.cc",
57         "common/crash_keys.h'",
58         "//content/app/startup_helper_win.cc",
59         "//content/public/common/content_switches.cc",
60       ]
61       deps += [
62         ":chrome_version_resources",
63         ":image_pre_reader",
64         ":main_dll",
66         # 'chrome_nacl_win64" TODO(GYP)
67         # '../win8/delegate_execute/delegate_execute.gyp:*', TODO(GYP)
68         # '../win8/metro_driver/metro_driver.gyp:metro_driver', TODO(GYP)
69         "//base",
70         "//breakpad:breakpad_handler",
71         "//breakpad:breakpad_sender",
72         "//chrome/browser:chrome_process_finder",
73         "//chrome/chrome_watcher",
74         "//chrome/chrome_watcher:client",
75         "//chrome/installer/util",
76         "//chrome_elf",
77         "//components/browser_watcher:browser_watcher_client",
78         "//components/crash/app",
79         "//crypto",
80         "//sandbox",
81         "//ui/gfx",
82       ]
83       libs = [
84         "wintrust.lib",
85         "crypt32.lib",
86       ]
87       configs -= [ "//build/config/win:console" ]
88       configs += [ "//build/config/win:windowed" ]
89     } else if (use_aura) {
90       # Non-Windows aura entrypoint.
91       sources += [ "app/chrome_exe_main_aura.cc" ]
92     }
94     if (is_linux) {
95       sources += [
96         "app/chrome_dll_resource.h",
97         "app/chrome_main.cc",
98         "app/chrome_main_delegate.cc",
99         "app/chrome_main_delegate.h",
100       ]
102       deps += [
103         # On Linux, link the dependencies (libraries) that make up actual
104         # Chromium functionality directly into the executable.
105         ":browser_dependencies",
106         ":child_dependencies",
107         ":manpage",
108         "//base/allocator",
110         # Needed to use the master_preferences functions
111         "//chrome/installer/util",
112         "//content/public/app:both",
113       ]
115       # Needed for chrome_main.cc initialization of libraries.
116       configs += [ "//build/config/linux:pangocairo" ]
118       # TODO(GYP) ['profiling==0 and linux_disable_pie==0', {
119       #   'ldflags': [
120       #      '-pie',
121       #   ],
122       #}],
124       if (use_x11) {
125         configs += [
126           "//build/config/linux:x11",
127           "//build/config/linux:xext",
128         ]
129       }
130     }
132     if (is_mac) {
133       sources += [ "app/chrome_exe_main_mac.cc" ]
134       # TODO(GYP) lots more stuff in the is_mac block.
135     } else {  # Non-Mac.
136       deps += [
137         ":packed_extra_resources",
138         ":packed_resources",
139         "//components/startup_metric_utils",
141         # Precompiled plugins that need to get copied to the output directory.
142         # On Mac, internal plugins go inside the framework, so these
143         # dependencies are on chrome.dll.
144         "//third_party/adobe/flash:flapper_binaries",
145         "//third_party/widevine/cdm:adapter",
146       ]
147       # TODO(GYP) some stuff from GYP including chrome_multiple_dll.
148     }
150     if (is_linux && enable_plugins) {
151       deps += [ "//pdf" ]
152     }
153   }
154 }  # !is_android
156 if (!is_win || link_chrome_on_windows) {
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       # TODO(GYP) incremental linking flags in debug builds
203       #'LinkIncremental': '<(msvs_large_module_debug_link_mode)',
205       # TODO(GYP) Lots of VCLinkerTool stuff on Windows.
207       # TODO(GYP) chrome_pgo_phase on Windows.
208     }
210     if (use_aura) {
211       deps += [ "//ui/compositor" ]
212     }
214     #TODO(GYP) add chrome_multiple_dll support
215     if (false) {  #chrome_multiple_dll) {
216       defines = [ "CHROME_MULTIPLE_DLL_BROWSER" ]
217       deps += [ "//content/public/app:browser" ]
218     } else {
219       deps += [
220         ":child_dependencies",
221         "//content/public/app:both",
222       ]
223     }
225     if (cld_version == 0 || cld_version == 2) {
226       deps += [ "//third_party/cld_2" ]
227     }
229     if (is_mac) {
230       #['OS=="mac" and component!="shared_library"', {  TODO(GYP)
231       #  'includes': [ 'chrome_dll_bundle.gypi' ],
232       #}],
233       # TODO(GYP) Lots of other stuff in the OS=="mac" block.
234     }
236     if (enable_plugins) {
237       deps += [ "//pdf" ]
238     }
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   # TODO(gyp) if (enable_nacl) {
283   #  deps += [ "<(DEPTH)/components/nacl/renderer/plugin/plugin.gyp: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 = [ ":*" ]
297     source = "version.h.in"
299     # TODO(brettw) this should move to $target_gen_dir/version.h and
300     # source files including it should reference it via "chrome/version.h"
301     output = "$root_gen_dir/version.h"
302   }
304   process_version("chrome_exe_version") {
305     source = "//chrome/app/chrome_version.rc.version"
306     output = "$target_gen_dir/chrome_exe_version.rc"
307     extra_args = [
308       "-f",
309       rebase_path("app/chrome_exe.ver", root_build_dir),
310     ]
311   }
313   process_version("chrome_dll_version") {
314     source = "//chrome/app/chrome_version.rc.version"
315     output = "$target_gen_dir/chrome_dll_version.rc"
316     extra_args = [
317       "-f",
318       rebase_path("app/chrome_dll.ver", root_build_dir),
319     ]
320   }
322   process_version("nacl64_exe_version") {
323     source = "//chrome/app/chrome_version.rc.version"
324     output = "$target_gen_dir/nacl64_exe_version.rc"
325     extra_args = [
326       "-f",
327       rebase_path("app/nacl64_exe.ver", root_build_dir),
328     ]
329   }
331   process_version("other_version") {
332     source = "//chrome/app/chrome_version.rc.version"
333     output = "$target_gen_dir/other_version.rc"
334     extra_args = [
335       "-f",
336       rebase_path("app/other.ver", root_build_dir),
337     ]
338   }
340   group("chrome_version_resources") {
341     deps = [
342       ":chrome_exe_version",
343       ":chrome_dll_version",
344       ":nacl64_exe_version",
345       ":other_version",
346     ]
347   }
349   source_set("image_pre_reader") {
350     sources = [
351       "app/image_pre_reader_win.cc",
352       "app/image_pre_reader_win.h",
353     ]
354     deps = [
355       "//base",
356     ]
357   }
360 # GYP version: chrome/chrome_resources.gyp:chrome_resources
361 group("resources") {
362   deps = [
363     # Note: GYP lists some dependencies in addition to these actions. However,
364     # these are just dependencies for the actions themselves, which our actions
365     # list individually when needed.
366     "//chrome/browser:resources",
367     "//chrome/common:resources",
368     "//chrome/renderer:resources",
369   ]
371   if (enable_extensions) {
372     deps += [ "//chrome/common:extensions_api_resources" ]
373   }
376 # GYP version: chrome/chrome_resources.gyp:chrome_extra_resources
377 group("extra_resources") {
378   deps = [
379     "//chrome/browser/resources:invalidations_resources",
380     "//chrome/browser/resources:memory_internals_resources",
381     "//chrome/browser/resources:net_internals_resources",
382     "//chrome/browser/resources:password_manager_internals_resources",
383     "//chrome/browser/resources:signin_internals_resources",
384     "//chrome/browser/resources:sync_internals_resources",
385     "//chrome/browser/resources:translate_internals_resources",
386   ]
387   if (!is_ios) {
388     deps += [
389       "//chrome/browser/resources:component_extension_resources",
390       "//chrome/browser/resources:options_resources",
391     ]
392   }
394   if (enable_chromevox_next) {
395     deps += [
396       #'browser/resources/chromeos/chromevox2/chromevox.gyp:chromevox2',  TODO(GYP)
397     ]
398   } else {
399     deps += [
400       #'browser/resources/chromeos/chromevox/chromevox.gyp:chromevox',  TODO(GYP)
401     ]
402   }
404   if (enable_extensions) {
405     deps += [
406       "//chrome/browser/resources:quota_internals_resources",
407       "//chrome/browser/resources:sync_file_system_internals_resources",
408     ]
409   }
412 if (is_chrome_branded) {
413   copy("default_apps") {
414     visibility = [ ":packed_resources" ]
415     sources = [
416       "browser/resources/default_apps/external_extensions.json",
417       "browser/resources/default_apps/gmail.crx",
418       "browser/resources/default_apps/search.crx",
419       "browser/resources/default_apps/youtube.crx",
420       "browser/resources/default_apps/drive.crx",
421       "browser/resources/default_apps/docs.crx",
422     ]
423     outputs = [
424       "$root_out_dir/default_apps/{{source_file_part}}",
425     ]
426   }
429 group("packed_resources") {
430   deps = [
431     ":repack_locales_pack",
432     ":repack_pseudo_locales_pack",
433     ":repack_chrome_100_percent",
434   ]
436   if (is_chrome_branded) {
437     deps += [ ":default_apps" ]
438   }
440   if (enable_hidpi) {
441     deps += [ ":repack_chrome_200_percent" ]
442   }
445 repack("packed_extra_resources") {
446   visibility = [ "./*" ]
447   sources = [
448     "$root_gen_dir/chrome/browser_resources.pak",
449     "$root_gen_dir/chrome/chrome_unscaled_resources.pak",
450     "$root_gen_dir/chrome/common_resources.pak",
451     "$root_gen_dir/chrome/invalidations_resources.pak",
452     "$root_gen_dir/chrome/memory_internals_resources.pak",
453     "$root_gen_dir/chrome/net_internals_resources.pak",
454     "$root_gen_dir/chrome/password_manager_internals_resources.pak",
455     "$root_gen_dir/chrome/signin_internals_resources.pak",
456     "$root_gen_dir/chrome/sync_internals_resources.pak",
457     "$root_gen_dir/chrome/translate_internals_resources.pak",
458     "$root_gen_dir/components/components_resources.pak",
459     "$root_gen_dir/net/net_resources.pak",
460     "$root_gen_dir/ui/resources/webui_resources.pak",
461   ]
462   deps = [
463     "//chrome/browser:resources",
464     "//chrome/app/theme:chrome_unscaled_resources",
465     "//chrome/common:resources",
466     "//chrome/browser/resources:invalidations_resources",
467     "//chrome/browser/resources:memory_internals_resources",
468     "//chrome/browser/resources:net_internals_resources",
469     "//chrome/browser/resources:password_manager_internals_resources",
470     "//chrome/browser/resources:signin_internals_resources",
471     "//chrome/browser/resources:sync_internals_resources",
472     "//chrome/browser/resources:translate_internals_resources",
473     "//components/resources",
474     "//net:net_resources",
475     "//ui/resources",
476   ]
478   if (!is_ios && !is_android) {
479     # New paks should be added here by default.
480     sources += [
481       "$root_gen_dir/chrome/component_extension_resources.pak",
482       "$root_gen_dir/chrome/options_resources.pak",
483       "$root_gen_dir/chrome/quota_internals_resources.pak",
484       "$root_gen_dir/chrome/sync_file_system_internals_resources.pak",
485       "$root_gen_dir/chrome/webrtc_device_provider_resources.pak",
486       "$root_gen_dir/blink/devtools_resources.pak",
487     ]
488     deps += [
489       "//chrome/browser/devtools:webrtc_device_provider_resources",
490       "//chrome/browser/resources:component_extension_resources",
491       "//chrome/browser/resources:options_resources",
492       "//chrome/browser/resources:quota_internals_resources",
493       "//chrome/browser/resources:sync_file_system_internals_resources",
494       "//content/browser/devtools:devtools_resources",
495     ]
496   }
497   if (!is_ios) {
498     sources += [
499       "$root_gen_dir/blink/public/resources/blink_resources.pak",
500       "$root_gen_dir/content/browser/tracing/tracing_resources.pak",
501       "$root_gen_dir/content/content_resources.pak",
502     ]
503   }
504   if (is_chromeos) {
505     sources += [ "$root_gen_dir/ui/file_manager/file_manager_resources.pak" ]
506     deps += [ "//ui/file_manager: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/components/components_resources_${percent}_percent.pak",
587       "$root_gen_dir/ui/resources/ui_resources_${percent}_percent.pak",
588       "$root_gen_dir/chrome/renderer_resources_${percent}_percent.pak",
589       "$root_gen_dir/chrome/theme_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 += [ "$root_gen_dir/content/app/resources/content_resources_${percent}_percent.pak" ]
601       deps += [ "//content:resources" ]
602     }
603     if (use_ash) {
604       sources +=
605           [ "$root_gen_dir/ash/resources/ash_resources_${percent}_percent.pak" ]
606       deps += [ "//ash/resources" ]
607     }
608     if (is_chromeos) {
609       sources += [ "$root_gen_dir/ui/chromeos/resources/ui_chromeos_resources_${percent}_percent.pak" ]
610       deps += [ "//ui/chromeos/resources" ]
611     }
612     if (enable_extensions) {
613       sources += [ "$root_gen_dir/extensions/extensions_browser_resources_${percent}_percent.pak" ]
614     }
616     output = repack_output_file
617   }
619   copy(copy_name) {
620     visibility = [ ":*" ]
621     deps = [
622       ":$repack_name",
623     ]
624     sources = [
625       repack_output_file,
626     ]
627     outputs = [
628       "$root_build_dir/chrome_${percent}_percent.pak",
629     ]
630   }
633 chrome_repack_percent("repack_chrome_100_percent") {
634   percent = "100"
637 if (enable_hidpi) {
638   chrome_repack_percent("repack_chrome_200_percent") {
639     percent = "200"
640   }
643 # GYP version: chrome/chrome_resources.gyp:chrome_strings
644 group("strings") {
645   deps = [
646     "//chrome/app:chromium_strings",
647     "//chrome/app:generated_resources",
648     "//chrome/app:google_chrome_strings",
649     "//chrome/app/resources:locale_settings",
650   ]
653 if (is_android) {
654   # GYP: //chrome/chrome.gyp:content_setting_java
655   java_cpp_enum("content_setting_javagen") {
656     sources = [
657       "../components/content_settings/core/common/content_settings.h",
658     ]
659     outputs = [
660       "org/chromium/chrome/browser/ContentSetting.java",
661     ]
662   }
664   # GYP: //chrome/chrome.gyp:content_settings_type_java
665   java_cpp_enum("content_settings_type_javagen") {
666     sources = [
667       "../components/content_settings/core/common/content_settings_types.h",
668     ]
669     outputs = [
670       "org/chromium/chrome/browser/ContentSettingsType.java",
671     ]
672   }
674   # GYP: //chrome/chrome.gyp:page_info_connection_type_java
675   java_cpp_enum("page_info_connection_type_javagen") {
676     sources = [
677       "browser/ui/android/website_settings_popup_android.h",
678     ]
679     outputs = [
680       "org/chromium/chrome/browser/PageInfoConnectionType.java",
681     ]
682   }
684   # GYP: //chrome/chrome_android.gypi:chrome_android_core
685   static_library("chrome_android_core") {
686     sources = [
687       "app/android/chrome_android_initializer.cc",
688       "app/android/chrome_android_initializer.h",
689       "app/android/chrome_jni_onload.cc",
690       "app/android/chrome_main_delegate_android.cc",
691       "app/android/chrome_main_delegate_android.h",
692       "app/chrome_main_delegate.cc",
693       "app/chrome_main_delegate.h",
694     ]
696     include_dirs = [ android_ndk_include_dir ]
698     libs = [
699       "android",
700       "jnigraphics",
701     ]
703     deps = [
704       "//chrome/browser",
705       "//chrome/browser/ui",
706       "//chrome/child",
707       "//chrome/plugin",
708       "//chrome/renderer",
709       "//chrome/utility",
710       "//components/enhanced_bookmarks",
711       "//content/public/app:browser",
712     ]
713   }
716 if (is_linux) {
717   action("manpage") {
718     if (is_chrome_branded) {
719       name = "Google Chrome"
720       filename = "google-chrome"
721       confdir = "google-chrome"
722     } else {
723       name = "Chromium"
724       filename = "chromium-browser"
725       confdir = "chromium"
726     }
728     script = "//chrome/tools/build/linux/sed.py"
729     infile = "app/resources/manpage.1.in"
730     inputs = [
731       infile,
732     ]
734     outfile = "$root_out_dir/chrome.1"
735     outputs = [
736       outfile,
737     ]
739     args = [
740       rebase_path(infile, root_build_dir),
741       rebase_path(outfile, root_build_dir),
742       "-e s/@@NAME@@/$name/",
743       "-e s/@@FILENAME@@/$filename/",
744       "-e s/@@CONFDIR@@/$confdir/",
745     ]
746   }