Enable new bookmark apps everywhere but Mac.
[chromium-blink-merge.git] / chrome / BUILD.gn
blob0ab9496a535a5e658eda5f4827c6304b3852a986
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:widevinecdmadapter",
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       "$root_gen_dir/base/trace_event/etw_manifest/chrome_events_win.rc",
169       "//base/win/dllmain.cc",
170       "app/chrome_command_ids.h",
171       "app/chrome_dll.rc",
172       "app/chrome_dll_resource.h",
173       "app/chrome_main.cc",
174       "app/chrome_main_delegate.cc",
175       "app/chrome_main_delegate.h",
176       "app/close_handle_hook_win.cc",
177       "app/close_handle_hook_win.h",
178       "app/delay_load_hook_win.cc",
179       "app/delay_load_hook_win.h",
180     ]
182     deps += [
183       # On Windows, link the dependencies (libraries) that make up actual
184       # Chromium functionality into this .dll.
185       ":chrome_version_resources",
186       "//base/trace_event/etw_manifest:chrome_events_win",
187       "//chrome/app/theme:chrome_unscaled_resources",
188       "//chrome_elf",
189       "//content/app/resources",
190       "//crypto",
191       "//net:net_resources",
192       "//third_party/wtl",
193       "//ui/views",
194     ]
195     if (enable_configuration_policy) {
196       deps += [ "//components/policy" ]
197     }
198     if (current_cpu == "x86") {
199       # Add a dependency to custom import library for user32 delay imports only
200       # in x86 builds.
201       #deps += [ 'chrome_user32_delay_imports' ]  TODO(GYP)
202     }
204     # This is a large module that can't do incremental linking in some cases.
205     configs -= [ "//build/config/win:default_incremental_linking" ]
206     configs += [ "//build/config/win:default_large_module_incremental_linking" ]
208     # TODO(GYP) Lots of VCLinkerTool stuff on Windows.
210     # TODO(GYP) chrome_pgo_phase on Windows.
211   }
213   if (use_aura) {
214     deps += [ "//ui/compositor" ]
215   }
217   #TODO(GYP) add chrome_multiple_dll support
218   if (false) {  #chrome_multiple_dll) {
219     defines += [ "CHROME_MULTIPLE_DLL_BROWSER" ]
220     deps += [ "//content/public/app:browser" ]
221   } else {
222     deps += [
223       ":child_dependencies",
224       "//content/public/app:both",
225     ]
226   }
228   if (cld_version == 0 || cld_version == 2) {
229     deps += [ "//third_party/cld_2" ]
230   }
232   if (is_mac) {
233     #['OS=="mac" and component!="shared_library"', {  TODO(GYP)
234     #  'includes': [ 'chrome_dll_bundle.gypi' ],
235     #}],
236     # TODO(GYP) Lots of other stuff in the OS=="mac" block.
237   }
239   if (enable_plugins) {
240     deps += [ "//pdf" ]
241   }
244 # GYP version: chromium_browser_dependencies variable in chrome.gyp
245 group("browser_dependencies") {
246   deps = [
247     "//chrome/browser",
248     "//chrome/common",
249     "//sync",
250   ]
251   if (!is_ios) {
252     deps += [ "//ppapi/host" ]
253   }
255   if (enable_basic_printing || enable_print_preview) {
256     deps += [ "//printing" ]
257     if (enable_print_preview) {
258       deps += [ "//chrome/service" ]
259     }
260   }
263 # GYP version: chromium_child_dependencies variable in chrome.gyp
264 group("child_dependencies") {
265   deps = [
266     "//chrome/common",
267     "//sync",
268   ]
269   if (!is_ios) {
270     deps += [
271       "//chrome/browser/devtools",
272       "//chrome/child",
273       "//chrome/plugin",
274       "//chrome/renderer",
275       "//chrome/utility",
276       "//content/public/child",
277       "//third_party/WebKit/public:blink_devtools_frontend_resources",
278     ]
279   }
280   if (cld_version == 0 || cld_version == 2) {
281     deps += [ "//third_party/cld_2:cld2_platform_impl" ]
282   }
284   if (enable_nacl) {
285     deps += [ "//components/nacl/renderer/plugin:nacl_trusted_plugin" ]
286   }
287   if (enable_remoting) {
288     deps += [ "//remoting/client/plugin" ]
289   }
292 if (is_win) {
293   # TODO(brettw) this duplicates "//chrome/common:version" which applies to
294   # Linux.
295   process_version("version_header") {
296     # TODO(brettW) this should have more reduced visibility, but chrome/browser
297     # currently depends on this.
298     #visibility = [ ":*" ]
300     # This one just uses the custom template and no separate sources.
301     sources = []
302     template_file = "version.h.in"
304     # TODO(brettw) this should move to $target_gen_dir/version.h and
305     # source files including it should reference it via "chrome/version.h"
306     output = "$root_gen_dir/version.h"
307   }
309   process_version("chrome_exe_version") {
310     sources = [
311       "app/chrome_exe.ver",
312     ]
313     output = "$target_gen_dir/chrome_exe_version.rc"
314   }
316   process_version("chrome_dll_version") {
317     sources = [
318       "app/chrome_dll.ver",
319     ]
320     output = "$target_gen_dir/chrome_dll_version.rc"
321   }
323   process_version("nacl64_exe_version") {
324     sources = [
325       "app/nacl64_exe.ver",
326     ]
327     output = "$target_gen_dir/nacl64_exe_version.rc"
328   }
330   process_version("other_version") {
331     sources = [
332       "app/other.ver",
333     ]
334     output = "$target_gen_dir/other_version.rc"
335   }
337   group("chrome_version_resources") {
338     deps = [
339       ":chrome_exe_version",
340       ":chrome_dll_version",
341       ":nacl64_exe_version",
342       ":other_version",
343     ]
344   }
346   source_set("image_pre_reader") {
347     sources = [
348       "app/image_pre_reader_win.cc",
349       "app/image_pre_reader_win.h",
350     ]
351     deps = [
352       "//base",
353     ]
354   }
357 # GYP version: chrome/chrome_resources.gyp:chrome_resources
358 group("resources") {
359   deps = [
360     # Note: GYP lists some dependencies in addition to these actions. However,
361     # these are just dependencies for the actions themselves, which our actions
362     # list individually when needed.
363     "//chrome/browser:resources",
364     "//chrome/common:resources",
365     "//chrome/renderer:resources",
366   ]
368   if (enable_extensions) {
369     deps += [ "//chrome/common:extensions_api_resources" ]
370   }
373 # GYP version: chrome/chrome_resources.gyp:chrome_extra_resources
374 group("extra_resources") {
375   deps = [
376     "//chrome/browser/resources:invalidations_resources",
377     "//chrome/browser/resources:memory_internals_resources",
378     "//chrome/browser/resources:net_internals_resources",
379     "//chrome/browser/resources:password_manager_internals_resources",
380     "//chrome/browser/resources:signin_internals_resources",
381     "//chrome/browser/resources:sync_internals_resources",
382     "//chrome/browser/resources:translate_internals_resources",
383   ]
384   if (!is_ios) {
385     deps += [
386       "//chrome/browser/resources:component_extension_resources",
387       "//chrome/browser/resources:options_resources",
388       "//chrome/browser/resources:settings_resources",
389     ]
390   }
392   if (enable_chromevox_next) {
393     deps += [
394       #'browser/resources/chromeos/chromevox2/chromevox.gyp:chromevox2',  TODO(GYP)
395     ]
396   } else {
397     deps += [
398       #'browser/resources/chromeos/chromevox/chromevox.gyp:chromevox',  TODO(GYP)
399     ]
400   }
402   if (enable_extensions) {
403     deps += [
404       "//chrome/browser/resources:quota_internals_resources",
405       "//chrome/browser/resources:sync_file_system_internals_resources",
406     ]
407   }
410 if (is_chrome_branded) {
411   copy("default_apps") {
412     visibility = [ ":packed_resources" ]
413     sources = [
414       "browser/resources/default_apps/docs.crx",
415       "browser/resources/default_apps/drive.crx",
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     ]
421     outputs = [
422       "$root_out_dir/default_apps/{{source_file_part}}",
423     ]
424   }
427 group("packed_resources") {
428   deps = [
429     ":repack_locales_pack",
430     ":repack_pseudo_locales_pack",
431     ":repack_chrome_100_percent",
432   ]
434   if (is_chrome_branded) {
435     deps += [ ":default_apps" ]
436   }
438   if (enable_hidpi) {
439     deps += [ ":repack_chrome_200_percent" ]
440   }
443 repack("packed_extra_resources") {
444   visibility = [ "./*" ]
445   sources = [
446     "$root_gen_dir/chrome/browser_resources.pak",
447     "$root_gen_dir/chrome/chrome_unscaled_resources.pak",
448     "$root_gen_dir/chrome/common_resources.pak",
449     "$root_gen_dir/chrome/invalidations_resources.pak",
450     "$root_gen_dir/chrome/memory_internals_resources.pak",
451     "$root_gen_dir/chrome/net_internals_resources.pak",
452     "$root_gen_dir/chrome/password_manager_internals_resources.pak",
453     "$root_gen_dir/chrome/signin_internals_resources.pak",
454     "$root_gen_dir/chrome/sync_internals_resources.pak",
455     "$root_gen_dir/chrome/translate_internals_resources.pak",
456     "$root_gen_dir/components/components_resources.pak",
457     "$root_gen_dir/net/net_resources.pak",
458     "$root_gen_dir/ui/resources/webui_resources.pak",
459   ]
460   deps = [
461     "//chrome/browser:resources",
462     "//chrome/app/theme:chrome_unscaled_resources",
463     "//chrome/common:resources",
464     "//chrome/browser/resources:invalidations_resources",
465     "//chrome/browser/resources:memory_internals_resources",
466     "//chrome/browser/resources:net_internals_resources",
467     "//chrome/browser/resources:password_manager_internals_resources",
468     "//chrome/browser/resources:signin_internals_resources",
469     "//chrome/browser/resources:sync_internals_resources",
470     "//chrome/browser/resources:translate_internals_resources",
471     "//components/resources",
472     "//net:net_resources",
473     "//ui/resources",
474   ]
476   if (!is_ios && !is_android) {
477     # New paks should be added here by default.
478     sources += [
479       "$root_gen_dir/blink/devtools_resources.pak",
480       "$root_gen_dir/chrome/component_extension_resources.pak",
481       "$root_gen_dir/chrome/options_resources.pak",
482       "$root_gen_dir/chrome/quota_internals_resources.pak",
483       "$root_gen_dir/chrome/settings_resources.pak",
484       "$root_gen_dir/chrome/sync_file_system_internals_resources.pak",
485       "$root_gen_dir/chrome/webrtc_device_provider_resources.pak",
486     ]
487     deps += [
488       "//chrome/browser/devtools:webrtc_device_provider_resources",
489       "//chrome/browser/resources:component_extension_resources",
490       "//chrome/browser/resources:options_resources",
491       "//chrome/browser/resources:settings_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     sources += [ "$root_gen_dir/ui/oobe/oobe_resources.pak" ]
507     deps += [ "//ui/file_manager:resources" ]
508     deps += [ "//ui/oobe:resources" ]
509   }
510   if (enable_extensions) {
511     sources += [
512       "$root_gen_dir/chrome/extensions_api_resources.pak",
513       "$root_gen_dir/extensions/extensions_renderer_resources.pak",
514       "$root_gen_dir/extensions/extensions_resources.pak",
515     ]
516     deps += [ "//chrome/common:extensions_api_resources" ]
517   }
519   # GYP outputs the file in the gen/repack directory. On non-Mac/iOS platforms
520   # it them copies it. This skipes the copy step and writes it to the final
521   # location.
522   if (is_mac || is_ios) {
523     output = "$root_gen_dir/repack/resources.pak"
524   } else {
525     output = "$root_out_dir/resources.pak"
526   }
529 # GYP version: chrome/chrome_resources.gyp:browser_tests_pak
530 repack("browser_tests_pak") {
531   sources = [
532     "$root_gen_dir/chrome/options_test_resources.pak",
533   ]
534   output = "$root_out_dir/browser_tests.pak"
537 # Collects per-locale grit files from many sources into global per-locale files.
538 chrome_repack_locales("repack_locales_pack") {
539   visibility = [ ":*" ]
541   input_locales = locales
543   if (is_mac) {
544     output_locales = locales_as_mac_outputs
545   } else {
546     output_locales = locales
547   }
550 chrome_repack_locales("repack_pseudo_locales_pack") {
551   visibility = [ ":*" ]
553   input_locales = [ "fake-bidi" ]
555   if (is_mac) {
556     output_locales = [ "fake_bidi" ]  # Mac uses underscores.
557   } else {
558     output_locales = [ "fake-bidi" ]
559   }
562 # Generates a rule to repack a set of resources, substituting a given string
563 # in for the percentage (e.g. "100", "200"). It generates the repacked files in
564 # the "gen" directory, and then introduces a copy rule to copy it to the root
565 # build directory.
567 # It's not clear why this two-step dance is necessary as opposed to just
568 # generating the file in the destination. However, this is what the GYP build
569 # does, and for maintenance purposes, this keeps the same files in the same
570 # place between the two builds when possible.
572 # Argument:
573 #   percent [required]
574 #      String to substitute for the percentage.
575 template("chrome_repack_percent") {
576   percent = invoker.percent
578   repack_name = "${target_name}_repack"
579   repack_output_file = "$root_gen_dir/repack/chrome_${percent}_percent.pak"
581   copy_name = target_name
583   repack(repack_name) {
584     visibility = [ ":$copy_name" ]
586     # All sources should also have deps for completeness.
587     sources = [
588       "$root_gen_dir/chrome/renderer_resources_${percent}_percent.pak",
589       "$root_gen_dir/chrome/theme_resources_${percent}_percent.pak",
590       "$root_gen_dir/components/components_resources_${percent}_percent.pak",
591       "$root_gen_dir/ui/resources/ui_resources_${percent}_percent.pak",
592     ]
594     deps = [
595       "//chrome/app/theme:theme_resources",
596       "//chrome/renderer:resources",
597       "//components/strings",
598       "//net:net_resources",
599     ]
601     if (!is_ios) {
602       sources += [
603         "$root_gen_dir/blink/public/resources/blink_image_resources_${percent}_percent.pak",
604         "$root_gen_dir/content/app/resources/content_resources_${percent}_percent.pak",
605       ]
606       deps += [ "//content:resources" ]
607     }
608     if (use_ash) {
609       sources +=
610           [ "$root_gen_dir/ash/resources/ash_resources_${percent}_percent.pak" ]
611       deps += [ "//ash/resources" ]
612     }
613     if (is_chromeos) {
614       sources += [ "$root_gen_dir/ui/chromeos/resources/ui_chromeos_resources_${percent}_percent.pak" ]
615       deps += [ "//ui/chromeos/resources" ]
616     }
617     if (enable_extensions) {
618       sources += [ "$root_gen_dir/extensions/extensions_browser_resources_${percent}_percent.pak" ]
619     }
621     output = repack_output_file
622   }
624   copy(copy_name) {
625     visibility = [ ":*" ]
626     deps = [
627       ":$repack_name",
628     ]
629     sources = [
630       repack_output_file,
631     ]
632     outputs = [
633       "$root_build_dir/chrome_${percent}_percent.pak",
634     ]
635   }
638 chrome_repack_percent("repack_chrome_100_percent") {
639   percent = "100"
642 if (enable_hidpi) {
643   chrome_repack_percent("repack_chrome_200_percent") {
644     percent = "200"
645   }
648 # GYP version: chrome/chrome_resources.gyp:chrome_strings
649 group("strings") {
650   deps = [
651     "//chrome/app:chromium_strings",
652     "//chrome/app:generated_resources",
653     "//chrome/app:google_chrome_strings",
654     "//chrome/app/resources:locale_settings",
655   ]
658 if (is_android) {
659   # GYP: //chrome/chrome.gyp:content_setting_java
660   java_cpp_enum("content_setting_javagen") {
661     sources = [
662       "../components/content_settings/core/common/content_settings.h",
663     ]
664     outputs = [
665       "org/chromium/chrome/browser/ContentSetting.java",
666     ]
667   }
669   # GYP: //chrome/chrome.gyp:content_settings_type_java
670   java_cpp_enum("content_settings_type_javagen") {
671     sources = [
672       "../components/content_settings/core/common/content_settings_types.h",
673     ]
674     outputs = [
675       "org/chromium/chrome/browser/ContentSettingsType.java",
676     ]
677   }
679   # GYP: //chrome/chrome.gyp:page_info_connection_type_java
680   java_cpp_enum("page_info_connection_type_javagen") {
681     sources = [
682       "browser/ui/android/website_settings_popup_android.h",
683     ]
684     outputs = [
685       "org/chromium/chrome/browser/PageInfoConnectionType.java",
686     ]
687   }
689   # GYP: //chrome/chrome_android.gypi:chrome_android_core
690   static_library("chrome_android_core") {
691     sources = [
692       "app/android/chrome_android_initializer.cc",
693       "app/android/chrome_android_initializer.h",
694       "app/android/chrome_jni_onload.cc",
695       "app/android/chrome_jni_onload.h",
696       "app/android/chrome_main_delegate_android.cc",
697       "app/android/chrome_main_delegate_android.h",
698       "app/chrome_main_delegate.cc",
699       "app/chrome_main_delegate.h",
700     ]
702     include_dirs = [ android_ndk_include_dir ]
704     libs = [
705       "android",
706       "jnigraphics",
707     ]
709     deps = [
710       "//chrome/browser",
711       "//chrome/browser/ui",
712       "//chrome/child",
713       "//chrome/plugin",
714       "//chrome/renderer",
715       "//chrome/utility",
716       "//components/enhanced_bookmarks",
717       "//content/public/app:both",
718     ]
719   }
722 if (is_linux) {
723   action("manpage") {
724     if (is_chrome_branded) {
725       name = "Google Chrome"
726       filename = "google-chrome"
727       confdir = "google-chrome"
728     } else {
729       name = "Chromium"
730       filename = "chromium-browser"
731       confdir = "chromium"
732     }
734     script = "//chrome/tools/build/linux/sed.py"
735     infile = "app/resources/manpage.1.in"
736     inputs = [
737       infile,
738     ]
740     outfile = "$root_out_dir/chrome.1"
741     outputs = [
742       outfile,
743     ]
745     args = [
746       rebase_path(infile, root_build_dir),
747       rebase_path(outfile, root_build_dir),
748       "-e s/@@NAME@@/$name/",
749       "-e s/@@FILENAME@@/$filename/",
750       "-e s/@@CONFDIR@@/$confdir/",
751     ]
752   }