Unregister from GCM when the only GCM app is removed
[chromium-blink-merge.git] / chrome / BUILD.gn
blob903ff5045fcc094784e2bdd88aa777b6327ffc79
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       # TODO(GYP) manpage action
97       sources += [
98         "app/chrome_dll_resource.h",
99         "app/chrome_main.cc",
100         "app/chrome_main_delegate.cc",
101         "app/chrome_main_delegate.h",
102       ]
104       deps += [
105         # On Linux, link the dependencies (libraries) that make up actual
106         # Chromium functionality directly into the executable.
107         ":browser_dependencies",
108         ":child_dependencies",
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         # Copy Flash Player files to PRODUCT_DIR if applicable. Let the .gyp
143         # file decide what to do on a per-OS basis; on Mac, internal plugins
144         # go inside the framework, so this dependency is in chrome_dll.gypi.
145         #'../third_party/adobe/flash/flash_player.gyp:flapper_binaries',  TODO(GYP)
147         # Copy CDM files to PRODUCT_DIR if applicable. Let the .gyp
148         # file decide what to do on a per-OS basis; on Mac, internal plugins
149         # go inside the framework, so this dependency is in chrome_dll.gypi.
150         #'../third_party/widevine/cdm/widevine_cdm.gyp:widevinecdmadapter',  TODO(GYP)
151       ]
152       # TODO(GYP) some stuff from GYP including chrome_multiple_dll.
153     }
155     if (is_linux && enable_plugins) {
156       deps += [ "//pdf" ]
157     }
158   }
159 }  # !is_android
161 if (!is_win || link_chrome_on_windows) {
162   shared_library("main_dll") {
163     configs += [ "//build/config/compiler:wexit_time_destructors" ]
165     deps = [
166       ":browser_dependencies",
167       "//base/allocator",
168     ]
169     if (is_win) {
170       output_name = "chrome"
172       sources = [
173         "app/chrome_command_ids.h",
174         "app/chrome_dll.rc",
175         "app/chrome_dll_resource.h",
176         "app/chrome_main.cc",
177         "app/chrome_main_delegate.cc",
178         "app/chrome_main_delegate.h",
179         "app/close_handle_hook_win.cc",
180         "app/close_handle_hook_win.h",
181         "app/delay_load_hook_win.cc",
182         "app/delay_load_hook_win.h",
183         "//base/win/dllmain.cc",
184       ]
186       deps += [
187         # On Windows, link the dependencies (libraries) that make up actual
188         # Chromium functionality into this .dll.
189         ":chrome_version_resources",
190         "//chrome/app/theme:chrome_unscaled_resources",
191         "//chrome_elf",
192         "//content/app/resources",
193         "//crypto",
194         "//net:net_resources",
195         "//third_party/wtl",
196         "//ui/views",
197       ]
198       if (enable_configuration_policy) {
199         deps += [ "//components/policy" ]
200       }
201       if (cpu_arch == "x86") {
202         # Add a dependency to custom import library for user32 delay imports only
203         # in x86 builds.
204         #deps += [ 'chrome_user32_delay_imports' ]  TODO(GYP)
205       }
207       # TODO(GYP) incremental linking flags in debug builds
208       #'LinkIncremental': '<(msvs_large_module_debug_link_mode)',
210       # TODO(GYP) Lots of VCLinkerTool stuff on Windows.
212       # TODO(GYP) chrome_pgo_phase on Windows.
213     }
215     if (use_aura) {
216       deps += [ "//ui/compositor" ]
217     }
219     #TODO(GYP) add chrome_multiple_dll support
220     if (false) {  #chrome_multiple_dll) {
221       defines = [ "CHROME_MULTIPLE_DLL_BROWSER" ]
222       deps += [ "//content/public/app:browser" ]
223     } else {
224       deps += [
225         ":child_dependencies",
226         "//content/public/app:both",
227       ]
228     }
230     if (cld_version == 0 || cld_version == 2) {
231       deps += [ "//third_party/cld_2" ]
232     }
234     if (is_mac) {
235       #['OS=="mac" and component!="shared_library"', {  TODO(GYP)
236       #  'includes': [ 'chrome_dll_bundle.gypi' ],
237       #}],
238       # TODO(GYP) Lots of other stuff in the OS=="mac" block.
239     }
241     if (enable_plugins) {
242       deps += [ "//pdf" ]
243     }
244   }
247 # GYP version: chromium_browser_dependencies variable in chrome.gyp
248 group("browser_dependencies") {
249   deps = [
250     "//chrome/browser",
251     "//chrome/common",
252     "//sync",
253   ]
254   if (!is_ios) {
255     deps += [ "//ppapi:ppapi_host" ]
256   }
258   if (enable_basic_printing || enable_print_preview) {
259     deps += [ "//printing" ]
260     if (enable_print_preview) {
261       deps += [ "//chrome/service" ]
262     }
263   }
266 # GYP version: chromium_child_dependencies variable in chrome.gyp
267 group("child_dependencies") {
268   deps = [
269     "//chrome/common",
270     "//sync",
271   ]
272   if (!is_ios) {
273     deps += [
274       "//chrome/browser/devtools",
275       "//chrome/child",
276       "//chrome/plugin",
277       "//chrome/renderer",
278       "//chrome/utility",
279       "//content/public/child",
280       "//third_party/WebKit/public:blink_devtools_frontend_resources",
281     ]
282   }
283   if (cld_version == 0 || cld_version == 2) {
284     deps += [ "//third_party/cld_2:cld2_platform_impl" ]
285   }
287   # TODO(gyp) if (enable_nacl) {
288   #  deps += [ "<(DEPTH)/components/nacl/renderer/plugin/plugin.gyp:nacl_trusted_plugin" ]
289   #}
290   if (enable_remoting) {
291     deps += [ "//remoting/client/plugin" ]
292   }
295 if (is_win) {
296   # TODO(brettw) this duplicates "//chrome/common:version" which applies to
297   # Linux.
298   process_version("version_header") {
299     # TODO(brettW) this should have more reduced visibility, but chrome/browser
300     # currently depends on this.
301     #visibility = [ ":*" ]
302     source = "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     source = "//chrome/app/chrome_version.rc.version"
311     output = "$target_gen_dir/chrome_exe_version.rc"
312     extra_args = [
313       "-f",
314       rebase_path("app/chrome_exe.ver", root_build_dir),
315     ]
316   }
318   process_version("chrome_dll_version") {
319     source = "//chrome/app/chrome_version.rc.version"
320     output = "$target_gen_dir/chrome_dll_version.rc"
321     extra_args = [
322       "-f",
323       rebase_path("app/chrome_dll.ver", root_build_dir),
324     ]
325   }
327   process_version("nacl64_exe_version") {
328     source = "//chrome/app/chrome_version.rc.version"
329     output = "$target_gen_dir/nacl64_exe_version.rc"
330     extra_args = [
331       "-f",
332       rebase_path("app/nacl64_exe.ver", root_build_dir),
333     ]
334   }
336   process_version("other_version") {
337     source = "//chrome/app/chrome_version.rc.version"
338     output = "$target_gen_dir/other_version.rc"
339     extra_args = [
340       "-f",
341       rebase_path("app/other.ver", root_build_dir),
342     ]
343   }
345   group("chrome_version_resources") {
346     deps = [
347       ":chrome_exe_version",
348       ":chrome_dll_version",
349       ":nacl64_exe_version",
350       ":other_version",
351     ]
352   }
354   source_set("image_pre_reader") {
355     sources = [
356       "app/image_pre_reader_win.cc",
357       "app/image_pre_reader_win.h",
358     ]
359     deps = [
360       "//base",
361     ]
362   }
365 # GYP version: chrome/chrome_resources.gyp:chrome_resources
366 group("resources") {
367   deps = [
368     # Note: GYP lists some dependencies in addition to these actions. However,
369     # these are just dependencies for the actions themselves, which our actions
370     # list individually when needed.
371     "//chrome/browser:resources",
372     "//chrome/common:resources",
373     "//chrome/renderer:resources",
374   ]
376   if (enable_extensions) {
377     deps += [ "//chrome/common:extensions_api_resources" ]
378   }
381 # GYP version: chrome/chrome_resources.gyp:chrome_extra_resources
382 group("extra_resources") {
383   deps = [
384     "//chrome/browser/resources:invalidations_resources",
385     "//chrome/browser/resources:memory_internals_resources",
386     "//chrome/browser/resources:net_internals_resources",
387     "//chrome/browser/resources:password_manager_internals_resources",
388     "//chrome/browser/resources:signin_internals_resources",
389     "//chrome/browser/resources:sync_internals_resources",
390     "//chrome/browser/resources:translate_internals_resources",
391   ]
392   if (!is_ios) {
393     deps += [
394       "//chrome/browser/resources:component_extension_resources",
395       "//chrome/browser/resources:options_resources",
396     ]
397   }
399   if (enable_chromevox_next) {
400     deps += [
401       #'browser/resources/chromeos/chromevox2/chromevox.gyp:chromevox2',  TODO(GYP)
402     ]
403   } else {
404     deps += [
405       #'browser/resources/chromeos/chromevox/chromevox.gyp:chromevox',  TODO(GYP)
406     ]
407   }
409   if (enable_extensions) {
410     deps += [
411       "//chrome/browser/resources:quota_internals_resources",
412       "//chrome/browser/resources:sync_file_system_internals_resources",
413     ]
414   }
417 group("packed_resources") {
418   deps = [
419     ":repack_locales_pack",
420     ":repack_pseudo_locales_pack",
421     ":repack_chrome_100_percent",
422   ]
424   # TODO(GYP) if (is_chrome_branded) {
425   # ... copy default_apps from default_apps_list
427   if (enable_hidpi) {
428     deps += [ ":repack_chrome_200_percent" ]
429   }
432 repack("packed_extra_resources") {
433   visibility = [ "./*" ]
434   sources = [
435     "$root_gen_dir/chrome/browser_resources.pak",
436     "$root_gen_dir/chrome/chrome_unscaled_resources.pak",
437     "$root_gen_dir/chrome/common_resources.pak",
438     "$root_gen_dir/chrome/invalidations_resources.pak",
439     "$root_gen_dir/chrome/memory_internals_resources.pak",
440     "$root_gen_dir/chrome/net_internals_resources.pak",
441     "$root_gen_dir/chrome/password_manager_internals_resources.pak",
442     "$root_gen_dir/chrome/signin_internals_resources.pak",
443     "$root_gen_dir/chrome/sync_internals_resources.pak",
444     "$root_gen_dir/chrome/translate_internals_resources.pak",
445     "$root_gen_dir/components/components_resources.pak",
446     "$root_gen_dir/net/net_resources.pak",
447     "$root_gen_dir/ui/resources/webui_resources.pak",
448   ]
449   deps = [
450     "//chrome/browser:resources",
451     "//chrome/app/theme:chrome_unscaled_resources",
452     "//chrome/common:resources",
453     "//chrome/browser/resources:invalidations_resources",
454     "//chrome/browser/resources:memory_internals_resources",
455     "//chrome/browser/resources:net_internals_resources",
456     "//chrome/browser/resources:password_manager_internals_resources",
457     "//chrome/browser/resources:signin_internals_resources",
458     "//chrome/browser/resources:sync_internals_resources",
459     "//chrome/browser/resources:translate_internals_resources",
460     "//components/resources",
461     "//net:net_resources",
462     "//ui/resources",
463   ]
465   if (!is_ios && !is_android) {
466     # New paks should be added here by default.
467     sources += [
468       "$root_gen_dir/chrome/component_extension_resources.pak",
469       "$root_gen_dir/chrome/options_resources.pak",
470       "$root_gen_dir/chrome/quota_internals_resources.pak",
471       "$root_gen_dir/chrome/sync_file_system_internals_resources.pak",
472       "$root_gen_dir/chrome/webrtc_device_provider_resources.pak",
473       "$root_gen_dir/blink/devtools_resources.pak",
474     ]
475     deps += [
476       "//chrome/browser/devtools:webrtc_device_provider_resources",
477       "//chrome/browser/resources:component_extension_resources",
478       "//chrome/browser/resources:options_resources",
479       "//chrome/browser/resources:quota_internals_resources",
480       "//chrome/browser/resources:sync_file_system_internals_resources",
481       "//content/browser/devtools:devtools_resources",
482     ]
483   }
484   if (!is_ios) {
485     sources += [
486       "$root_gen_dir/blink/public/resources/blink_resources.pak",
487       "$root_gen_dir/content/browser/tracing/tracing_resources.pak",
488       "$root_gen_dir/content/content_resources.pak",
489     ]
490   }
491   if (is_chromeos) {
492     sources += [ "$root_gen_dir/ui/file_manager/file_manager_resources.pak" ]
493     deps += [ "//ui/file_manager:resources" ]
494   }
495   if (enable_extensions) {
496     sources += [
497       "$root_gen_dir/chrome/extensions_api_resources.pak",
498       "$root_gen_dir/extensions/extensions_renderer_resources.pak",
499       "$root_gen_dir/extensions/extensions_resources.pak",
500     ]
501     deps += [ "//chrome/common:extensions_api_resources" ]
502   }
504   # GYP outputs the file in the gen/repack directory. On non-Mac/iOS platforms
505   # it them copies it. This skipes the copy step and writes it to the final
506   # location.
507   if (is_mac || is_ios) {
508     output = "$root_gen_dir/repack/resources.pak"
509   } else {
510     output = "$root_out_dir/resources.pak"
511   }
514 # GYP version: chrome/chrome_resources.gyp:browser_tests_pak
515 repack("browser_tests_pak") {
516   sources = [
517     "$root_gen_dir/chrome/options_test_resources.pak",
518   ]
519   output = "$root_out_dir/browser_tests.pak"
522 # Collects per-locale grit files from many sources into global per-locale files.
523 chrome_repack_locales("repack_locales_pack") {
524   visibility = [ ":*" ]
526   input_locales = locales
528   if (is_mac) {
529     output_locales = locales_as_mac_outputs
530   } else {
531     output_locales = locales
532   }
535 chrome_repack_locales("repack_pseudo_locales_pack") {
536   visibility = [ ":*" ]
538   input_locales = [ "fake-bidi" ]
540   if (is_mac) {
541     output_locales = [ "fake_bidi" ]  # Mac uses underscores.
542   } else {
543     output_locales = [ "fake-bidi" ]
544   }
547 # Generates a rule to repack a set of resources, substituting a given string
548 # in for the percentage (e.g. "100", "200"). It generates the repacked files in
549 # the "gen" directory, and then introduces a copy rule to copy it to the root
550 # build directory.
552 # It's not clear why this two-step dance is necessary as opposed to just
553 # generating the file in the destination. However, this is what the GYP build
554 # does, and for maintenance purposes, this keeps the same files in the same
555 # place between the two builds when possible.
557 # Argument:
558 #   percent [required]
559 #      String to substitute for the percentage.
560 template("chrome_repack_percent") {
561   percent = invoker.percent
563   repack_name = "${target_name}_repack"
564   repack_output_file = "$root_gen_dir/repack/chrome_${percent}_percent.pak"
566   copy_name = target_name
568   repack(repack_name) {
569     visibility = [ ":$copy_name" ]
571     # All sources should also have deps for completeness.
572     sources = [
573       "$root_gen_dir/components/components_resources_${percent}_percent.pak",
574       "$root_gen_dir/ui/resources/ui_resources_${percent}_percent.pak",
575       "$root_gen_dir/chrome/renderer_resources_${percent}_percent.pak",
576       "$root_gen_dir/chrome/theme_resources_${percent}_percent.pak",
577     ]
579     deps = [
580       "//chrome/app/theme:theme_resources",
581       "//chrome/renderer:resources",
582       "//components/strings",
583       "//net:net_resources",
584     ]
586     if (!is_ios) {
587       sources += [ "$root_gen_dir/content/app/resources/content_resources_${percent}_percent.pak" ]
588       deps += [ "//content:resources" ]
589     }
590     if (use_ash) {
591       sources +=
592           [ "$root_gen_dir/ash/resources/ash_resources_${percent}_percent.pak" ]
593       deps += [ "//ash/resources" ]
594     }
595     if (is_chromeos) {
596       sources += [ "$root_gen_dir/ui/chromeos/resources/ui_chromeos_resources_${percent}_percent.pak" ]
597       deps += [ "//ui/chromeos/resources" ]
598     }
599     if (enable_extensions) {
600       sources += [ "$root_gen_dir/extensions/extensions_browser_resources_${percent}_percent.pak" ]
601     }
603     output = repack_output_file
604   }
606   copy(copy_name) {
607     visibility = [ ":*" ]
608     deps = [
609       ":$repack_name",
610     ]
611     sources = [
612       repack_output_file,
613     ]
614     outputs = [
615       "$root_build_dir/chrome_${percent}_percent.pak",
616     ]
617   }
620 chrome_repack_percent("repack_chrome_100_percent") {
621   percent = "100"
624 if (enable_hidpi) {
625   chrome_repack_percent("repack_chrome_200_percent") {
626     percent = "200"
627   }
630 # GYP version: chrome/chrome_resources.gyp:chrome_strings
631 group("strings") {
632   deps = [
633     "//chrome/app:chromium_strings",
634     "//chrome/app:generated_resources",
635     "//chrome/app:google_chrome_strings",
636     "//chrome/app/resources:locale_settings",
637   ]
640 if (is_android) {
641   # GYP: //chrome/chrome.gyp:content_setting_java
642   java_cpp_enum("content_setting_javagen") {
643     sources = [
644       "../components/content_settings/core/common/content_settings.h",
645     ]
646     outputs = [
647       "org/chromium/chrome/browser/ContentSetting.java",
648     ]
649   }
651   # GYP: //chrome/chrome.gyp:content_settings_type_java
652   java_cpp_enum("content_settings_type_javagen") {
653     sources = [
654       "../components/content_settings/core/common/content_settings_types.h",
655     ]
656     outputs = [
657       "org/chromium/chrome/browser/ContentSettingsType.java",
658     ]
659   }
661   # GYP: //chrome/chrome.gyp:page_info_connection_type_java
662   java_cpp_enum("page_info_connection_type_javagen") {
663     sources = [
664       "browser/ui/android/website_settings_popup_android.h",
665     ]
666     outputs = [
667       "org/chromium/chrome/browser/PageInfoConnectionType.java",
668     ]
669   }
671   # GYP: //chrome/chrome_android.gypi:chrome_android_core
672   static_library("chrome_android_core") {
673     sources = [
674       "app/android/chrome_android_initializer.cc",
675       "app/android/chrome_android_initializer.h",
676       "app/android/chrome_jni_onload.cc",
677       "app/android/chrome_main_delegate_android.cc",
678       "app/android/chrome_main_delegate_android.h",
679       "app/chrome_main_delegate.cc",
680       "app/chrome_main_delegate.h",
681     ]
683     include_dirs = [ android_ndk_include_dir ]
685     libs = [
686       "android",
687       "jnigraphics",
688     ]
690     deps = [
691       "//chrome/browser",
692       "//chrome/browser/ui",
693       "//chrome/child",
694       "//chrome/plugin",
695       "//chrome/renderer",
696       "//chrome/utility",
697       "//components/enhanced_bookmarks",
698       "//content/public/app:browser",
699     ]
700   }