Revert of Linux MSan: enable swarming/sharding for browser_tests. (patchset #1 id...
[chromium-blink-merge.git] / chrome / BUILD.gn
blob6deb300898f0bbc30659dcd49b5c62c66bf71996
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/chrome_watcher_command_line_win.cc",
55         "app/chrome_watcher_command_line_win.h",
56         "app/signature_validator_win.cc",
57         "app/signature_validator_win.h",
58         "common/crash_keys.cc",
59         "common/crash_keys.h'",
60         "//content/app/startup_helper_win.cc",
61         "//content/public/common/content_switches.cc",
62       ]
63       deps += [
64         ":chrome_version_resources",
65         ":image_pre_reader",
66         ":main_dll",
68         # 'chrome_nacl_win64" TODO(GYP)
69         # '../win8/delegate_execute/delegate_execute.gyp:*', TODO(GYP)
70         # '../win8/metro_driver/metro_driver.gyp:metro_driver', TODO(GYP)
71         "//base",
72         "//breakpad:breakpad_handler",
73         "//breakpad:breakpad_sender",
74         "//chrome/browser:chrome_process_finder",
75         "//chrome/chrome_watcher",
76         "//chrome/chrome_watcher:client",
77         "//chrome/installer/util",
78         "//chrome_elf",
79         "//components/browser_watcher:browser_watcher_client",
80         "//components/crash/app",
81         "//crypto",
82         "//sandbox",
83         "//ui/gfx",
84       ]
85       libs = [
86         "wintrust.lib",
87         "crypt32.lib",
88       ]
89       configs -= [ "//build/config/win:console" ]
90       configs += [ "//build/config/win:windowed" ]
91     } else if (use_aura) {
92       # Non-Windows aura entrypoint.
93       sources += [ "app/chrome_exe_main_aura.cc" ]
94     }
96     if (is_linux) {
97       # TODO(GYP) manpage action
99       sources += [
100         "app/chrome_dll_resource.h",
101         "app/chrome_main.cc",
102         "app/chrome_main_delegate.cc",
103         "app/chrome_main_delegate.h",
104       ]
106       deps += [
107         # On Linux, link the dependencies (libraries) that make up actual
108         # Chromium functionality directly into the executable.
109         ":browser_dependencies",
110         ":child_dependencies",
111         "//base/allocator",
113         # Needed to use the master_preferences functions
114         "//chrome/installer/util",
115         "//content/public/app:both",
116       ]
118       # Needed for chrome_main.cc initialization of libraries.
119       configs += [ "//build/config/linux:pangocairo" ]
121       # TODO(GYP) ['profiling==0 and linux_disable_pie==0', {
122       #   'ldflags': [
123       #      '-pie',
124       #   ],
125       #}],
127       if (use_x11) {
128         configs += [
129           "//build/config/linux:x11",
130           "//build/config/linux:xext",
131         ]
132       }
133     }
135     if (is_mac) {
136       sources += [ "app/chrome_exe_main_mac.cc" ]
137       # TODO(GYP) lots more stuff in the is_mac block.
138     } else {  # Non-Mac.
139       deps += [
140         ":packed_extra_resources",
141         ":packed_resources",
142         "//components/startup_metric_utils",
144         # Copy Flash Player files to PRODUCT_DIR if applicable. Let the .gyp
145         # file decide what to do on a per-OS basis; on Mac, internal plugins
146         # go inside the framework, so this dependency is in chrome_dll.gypi.
147         #'../third_party/adobe/flash/flash_player.gyp:flapper_binaries',  TODO(GYP)
149         # Copy CDM files to PRODUCT_DIR if applicable. Let the .gyp
150         # file decide what to do on a per-OS basis; on Mac, internal plugins
151         # go inside the framework, so this dependency is in chrome_dll.gypi.
152         #'../third_party/widevine/cdm/widevine_cdm.gyp:widevinecdmadapter',  TODO(GYP)
153       ]
154       # TODO(GYP) some stuff from GYP including chrome_multiple_dll.
155     }
157     if (enable_plugins) {
158       deps += [ "//pdf" ]
159     }
160   }
161 }  # !is_android
163 if (!is_win || link_chrome_on_windows) {
164   shared_library("main_dll") {
165     configs += [ "//build/config/compiler:wexit_time_destructors" ]
167     deps = [
168       ":browser_dependencies",
169       "//base/allocator",
170     ]
171     if (is_win) {
172       output_name = "chrome"
174       sources = [
175         "app/chrome_command_ids.h",
176         "app/chrome_dll.rc",
177         "app/chrome_dll_resource.h",
178         "app/chrome_main.cc",
179         "app/chrome_main_delegate.cc",
180         "app/chrome_main_delegate.h",
181         "app/close_handle_hook_win.cc",
182         "app/close_handle_hook_win.h",
183         "app/delay_load_hook_win.cc",
184         "app/delay_load_hook_win.h",
185         "//base/win/dllmain.cc",
186       ]
188       deps += [
189         # On Windows, link the dependencies (libraries) that make up actual
190         # Chromium functionality into this .dll.
191         ":chrome_version_resources",
192         "//chrome/app/theme:chrome_unscaled_resources",
193         "//chrome_elf",
194         "//content/app/resources",
195         "//crypto",
196         "//net:net_resources",
197         "//third_party/wtl",
198         "//ui/views",
199       ]
200       if (enable_configuration_policy) {
201         deps += [ "//components/policy" ]
202       }
203       if (cpu_arch == "x86") {
204         # Add a dependency to custom import library for user32 delay imports only
205         # in x86 builds.
206         #deps += [ 'chrome_user32_delay_imports' ]  TODO(GYP)
207       }
209       # TODO(GYP) incremental linking flags in debug builds
210       #'LinkIncremental': '<(msvs_large_module_debug_link_mode)',
212       # TODO(GYP) Lots of VCLinkerTool stuff on Windows.
214       # TODO(GYP) chrome_pgo_phase on Windows.
215     }
217     if (use_aura) {
218       deps += [ "//ui/compositor" ]
219     }
221     #TODO(GYP) add chrome_multiple_dll support
222     if (false) {  #chrome_multiple_dll) {
223       defines = [ "CHROME_MULTIPLE_DLL_BROWSER" ]
224       deps += [ "//content/public/app:browser" ]
225     } else {
226       deps += [
227         ":child_dependencies",
228         "//content/public/app:both",
229       ]
230     }
232     if (cld_version == 0 || cld_version == 2) {
233       deps += [ "//third_party/cld_2" ]
234     }
236     if (is_mac) {
237       #['OS=="mac" and component!="shared_library"', {  TODO(GYP)
238       #  'includes': [ 'chrome_dll_bundle.gypi' ],
239       #}],
240       # TODO(GYP) Lots of other stuff in the OS=="mac" block.
241     }
243     if (enable_plugins) {
244       deps += [ "//pdf" ]
245     }
246   }
249 # GYP version: chromium_browser_dependencies variable in chrome.gyp
250 group("browser_dependencies") {
251   deps = [
252     "//chrome/browser",
253     "//chrome/common",
254     "//sync",
255   ]
256   if (!is_ios) {
257     deps += [ "//ppapi:ppapi_host" ]
258   }
260   if (enable_basic_printing || enable_print_preview) {
261     deps += [ "//printing" ]
262     if (enable_print_preview) {
263       deps += [ "//chrome/service" ]
264     }
265   }
268 # GYP version: chromium_child_dependencies variable in chrome.gyp
269 group("child_dependencies") {
270   deps = [
271     "//chrome/common",
272     "//sync",
273   ]
274   if (!is_ios) {
275     deps += [
276       "//chrome/browser/devtools",
277       "//chrome/child",
278       "//chrome/plugin",
279       "//chrome/renderer",
280       "//chrome/utility",
281       "//content/public/child",
282       "//third_party/WebKit/public:blink_devtools_frontend_resources",
283     ]
284   }
285   if (cld_version == 0 || cld_version == 2) {
286     deps += [ "//third_party/cld_2:cld2_platform_impl" ]
287   }
289   # TODO(gyp) if (enable_nacl) {
290   #  deps += [ "<(DEPTH)/components/nacl/renderer/plugin/plugin.gyp:nacl_trusted_plugin" ]
291   #}
292   if (enable_remoting) {
293     deps += [ "//remoting/client/plugin" ]
294   }
297 if (is_win) {
298   # TODO(brettw) this duplicates "//chrome/common:version" which applies to
299   # Linux.
300   process_version("version_header") {
301     # TODO(brettW) this should have more reduced visibility, but chrome/browser
302     # currently depends on this.
303     #visibility = [ ":*" ]
304     source = "version.h.in"
306     # TODO(brettw) this should move to $target_gen_dir/version.h and
307     # source files including it should reference it via "chrome/version.h"
308     output = "$root_gen_dir/version.h"
309   }
311   process_version("chrome_exe_version") {
312     source = "//chrome/app/chrome_version.rc.version"
313     output = "$target_gen_dir/chrome_exe_version.rc"
314     extra_args = [
315       "-f",
316       rebase_path("app/chrome_exe.ver", root_build_dir),
317     ]
318   }
320   process_version("chrome_dll_version") {
321     source = "//chrome/app/chrome_version.rc.version"
322     output = "$target_gen_dir/chrome_dll_version.rc"
323     extra_args = [
324       "-f",
325       rebase_path("app/chrome_dll.ver", root_build_dir),
326     ]
327   }
329   process_version("nacl64_exe_version") {
330     source = "//chrome/app/chrome_version.rc.version"
331     output = "$target_gen_dir/nacl64_exe_version.rc"
332     extra_args = [
333       "-f",
334       rebase_path("app/nacl64_exe.ver", root_build_dir),
335     ]
336   }
338   process_version("other_version") {
339     source = "//chrome/app/chrome_version.rc.version"
340     output = "$target_gen_dir/other_version.rc"
341     extra_args = [
342       "-f",
343       rebase_path("app/other.ver", root_build_dir),
344     ]
345   }
347   group("chrome_version_resources") {
348     deps = [
349       ":chrome_exe_version",
350       ":chrome_dll_version",
351       ":nacl64_exe_version",
352       ":other_version",
353     ]
354   }
356   source_set("image_pre_reader") {
357     sources = [
358       "app/image_pre_reader_win.cc",
359       "app/image_pre_reader_win.h",
360     ]
361     deps = [
362       "//base",
363     ]
364   }
367 # GYP version: chrome/chrome_resources.gyp:chrome_resources
368 group("resources") {
369   deps = [
370     # Note: GYP lists some dependencies in addition to these actions. However,
371     # these are just dependencies for the actions themselves, which our actions
372     # list individually when needed.
373     "//chrome/browser:resources",
374     "//chrome/common:resources",
375     "//chrome/renderer:resources",
376   ]
378   if (enable_extensions) {
379     deps += [ "//chrome/common:extensions_api_resources" ]
380   }
383 # GYP version: chrome/chrome_resources.gyp:chrome_extra_resources
384 group("extra_resources") {
385   deps = [
386     "//chrome/browser/resources:invalidations_resources",
387     "//chrome/browser/resources:memory_internals_resources",
388     "//chrome/browser/resources:net_internals_resources",
389     "//chrome/browser/resources:password_manager_internals_resources",
390     "//chrome/browser/resources:signin_internals_resources",
391     "//chrome/browser/resources:sync_internals_resources",
392     "//chrome/browser/resources:translate_internals_resources",
393   ]
394   if (!is_ios) {
395     deps += [
396       "//chrome/browser/resources:component_extension_resources",
397       "//chrome/browser/resources:options_resources",
398     ]
399   }
401   if (enable_chromevox_next) {
402     deps += [
403       #'browser/resources/chromeos/chromevox2/chromevox.gyp:chromevox2',  TODO(GYP)
404     ]
405   } else {
406     deps += [
407       #'browser/resources/chromeos/chromevox/chromevox.gyp:chromevox',  TODO(GYP)
408     ]
409   }
411   if (enable_extensions) {
412     deps += [
413       "//chrome/browser/resources:quota_internals_resources",
414       "//chrome/browser/resources:sync_file_system_internals_resources",
415     ]
416   }
419 group("packed_resources") {
420   deps = [
421     ":repack_locales_pack",
422     ":repack_pseudo_locales_pack",
423     ":repack_chrome_100_percent",
424   ]
426   # TODO(GYP) if (is_chrome_branded) {
427   # ... copy default_apps from default_apps_list
429   if (enable_hidpi) {
430     deps += [ ":repack_chrome_200_percent" ]
431   }
434 repack("packed_extra_resources") {
435   visibility = [ "./*" ]
436   sources = [
437     "$root_gen_dir/chrome/browser_resources.pak",
438     "$root_gen_dir/chrome/chrome_unscaled_resources.pak",
439     "$root_gen_dir/chrome/common_resources.pak",
440     "$root_gen_dir/chrome/invalidations_resources.pak",
441     "$root_gen_dir/chrome/memory_internals_resources.pak",
442     "$root_gen_dir/chrome/net_internals_resources.pak",
443     "$root_gen_dir/chrome/password_manager_internals_resources.pak",
444     "$root_gen_dir/chrome/signin_internals_resources.pak",
445     "$root_gen_dir/chrome/sync_internals_resources.pak",
446     "$root_gen_dir/chrome/translate_internals_resources.pak",
447     "$root_gen_dir/components/components_resources.pak",
448     "$root_gen_dir/net/net_resources.pak",
449     "$root_gen_dir/ui/resources/webui_resources.pak",
450   ]
451   deps = [
452     "//chrome/browser:resources",
453     "//chrome/app/theme:chrome_unscaled_resources",
454     "//chrome/common:resources",
455     "//chrome/browser/resources:invalidations_resources",
456     "//chrome/browser/resources:memory_internals_resources",
457     "//chrome/browser/resources:net_internals_resources",
458     "//chrome/browser/resources:password_manager_internals_resources",
459     "//chrome/browser/resources:signin_internals_resources",
460     "//chrome/browser/resources:sync_internals_resources",
461     "//chrome/browser/resources:translate_internals_resources",
462     "//components/resources",
463     "//net:net_resources",
464     "//ui/resources",
465   ]
467   if (!is_ios && !is_android) {
468     # New paks should be added here by default.
469     sources += [
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/sync_file_system_internals_resources.pak",
474       "$root_gen_dir/chrome/webrtc_device_provider_resources.pak",
475       "$root_gen_dir/blink/devtools_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:quota_internals_resources",
482       "//chrome/browser/resources:sync_file_system_internals_resources",
483       "//content/browser/devtools:devtools_resources",
484     ]
485   }
486   if (!is_ios) {
487     sources += [
488       "$root_gen_dir/blink/public/resources/blink_resources.pak",
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     deps += [ "//ui/file_manager:resources" ]
496   }
497   if (enable_extensions) {
498     sources += [
499       "$root_gen_dir/chrome/extensions_api_resources.pak",
500       "$root_gen_dir/extensions/extensions_renderer_resources.pak",
501       "$root_gen_dir/extensions/extensions_resources.pak",
502     ]
503     deps += [ "//chrome/common:extensions_api_resources" ]
504   }
506   # GYP outputs the file in the gen/repack directory. On non-Mac/iOS platforms
507   # it them copies it. This skipes the copy step and writes it to the final
508   # location.
509   if (is_mac || is_ios) {
510     output = "$root_gen_dir/repack/resources.pak"
511   } else {
512     output = "$root_out_dir/resources.pak"
513   }
516 # GYP version: chrome/chrome_resources.gyp:browser_tests_pak
517 repack("browser_tests_pak") {
518   sources = [
519     "$root_gen_dir/chrome/options_test_resources.pak",
520   ]
521   output = "$root_out_dir/browser_tests.pak"
524 # Collects per-locale grit files from many sources into global per-locale files.
525 chrome_repack_locales("repack_locales_pack") {
526   visibility = [ ":*" ]
528   input_locales = locales
530   if (is_mac) {
531     output_locales = locales_as_mac_outputs
532   } else {
533     output_locales = locales
534   }
537 chrome_repack_locales("repack_pseudo_locales_pack") {
538   visibility = [ ":*" ]
540   input_locales = [ "fake-bidi" ]
542   if (is_mac) {
543     output_locales = [ "fake_bidi" ]  # Mac uses underscores.
544   } else {
545     output_locales = [ "fake-bidi" ]
546   }
549 # Generates a rule to repack a set of resources, substituting a given string
550 # in for the percentage (e.g. "100", "200"). It generates the repacked files in
551 # the "gen" directory, and then introduces a copy rule to copy it to the root
552 # build directory.
554 # It's not clear why this two-step dance is necessary as opposed to just
555 # generating the file in the destination. However, this is what the GYP build
556 # does, and for maintenance purposes, this keeps the same files in the same
557 # place between the two builds when possible.
559 # Argument:
560 #   percent [required]
561 #      String to substitute for the percentage.
562 template("chrome_repack_percent") {
563   percent = invoker.percent
565   repack_name = "${target_name}_repack"
566   repack_output_file = "$root_gen_dir/repack/chrome_${percent}_percent.pak"
568   copy_name = target_name
570   repack(repack_name) {
571     visibility = [ ":$copy_name" ]
573     # All sources should also have deps for completeness.
574     sources = [
575       "$root_gen_dir/components/components_resources_${percent}_percent.pak",
576       "$root_gen_dir/ui/resources/ui_resources_${percent}_percent.pak",
577       "$root_gen_dir/chrome/renderer_resources_${percent}_percent.pak",
578       "$root_gen_dir/chrome/theme_resources_${percent}_percent.pak",
579     ]
581     deps = [
582       "//chrome/app/theme:theme_resources",
583       "//chrome/renderer:resources",
584       "//components/strings",
585       "//net:net_resources",
586     ]
588     if (!is_ios) {
589       sources += [ "$root_gen_dir/content/app/resources/content_resources_${percent}_percent.pak" ]
590       deps += [ "//content:resources" ]
591     }
592     if (use_ash) {
593       sources +=
594           [ "$root_gen_dir/ash/resources/ash_resources_${percent}_percent.pak" ]
595       deps += [ "//ash/resources" ]
596     }
597     if (is_chromeos) {
598       sources += [ "$root_gen_dir/ui/chromeos/resources/ui_chromeos_resources_${percent}_percent.pak" ]
599       deps += [ "//ui/chromeos/resources" ]
600     }
601     if (enable_extensions) {
602       sources += [ "$root_gen_dir/extensions/extensions_browser_resources_${percent}_percent.pak" ]
603     }
605     output = repack_output_file
606   }
608   copy(copy_name) {
609     visibility = [ ":*" ]
610     deps = [
611       ":$repack_name",
612     ]
613     sources = [
614       repack_output_file,
615     ]
616     outputs = [
617       "$root_build_dir/chrome_${percent}_percent.pak",
618     ]
619   }
622 chrome_repack_percent("repack_chrome_100_percent") {
623   percent = "100"
626 if (enable_hidpi) {
627   chrome_repack_percent("repack_chrome_200_percent") {
628     percent = "200"
629   }
632 # GYP version: chrome/chrome_resources.gyp:chrome_strings
633 group("strings") {
634   deps = [
635     "//chrome/app:chromium_strings",
636     "//chrome/app:generated_resources",
637     "//chrome/app:google_chrome_strings",
638     "//chrome/app/resources:locale_settings",
639   ]
642 if (is_android) {
643   # GYP: //chrome/chrome.gyp:content_setting_java
644   java_cpp_enum("content_setting_javagen") {
645     sources = [
646       "../components/content_settings/core/common/content_settings.h",
647     ]
648     outputs = [
649       "org/chromium/chrome/browser/ContentSetting.java",
650     ]
651   }
653   # GYP: //chrome/chrome.gyp:content_settings_type_java
654   java_cpp_enum("content_settings_type_javagen") {
655     sources = [
656       "../components/content_settings/core/common/content_settings_types.h",
657     ]
658     outputs = [
659       "org/chromium/chrome/browser/ContentSettingsType.java",
660     ]
661   }
663   # GYP: //chrome/chrome.gyp:page_info_connection_type_java
664   java_cpp_enum("page_info_connection_type_javagen") {
665     sources = [
666       "browser/ui/android/website_settings_popup_android.h",
667     ]
668     outputs = [
669       "org/chromium/chrome/browser/PageInfoConnectionType.java",
670     ]
671   }
673   # GYP: //chrome/chrome_android.gypi:chrome_android_core
674   static_library("chrome_android_core") {
675     sources = [
676       "app/android/chrome_android_initializer.cc",
677       "app/android/chrome_android_initializer.h",
678       "app/android/chrome_jni_onload.cc",
679       "app/android/chrome_main_delegate_android.cc",
680       "app/android/chrome_main_delegate_android.h",
681       "app/chrome_main_delegate.cc",
682       "app/chrome_main_delegate.h",
683     ]
685     include_dirs = [ android_ndk_include_dir ]
687     libs = [
688       "android",
689       "jnigraphics",
690     ]
692     deps = [
693       "//chrome/browser",
694       "//chrome/browser/ui",
695       "//chrome/child",
696       "//chrome/plugin",
697       "//chrome/renderer",
698       "//chrome/utility",
699       "//components/enhanced_bookmarks",
700       "//content/public/app:browser",
701     ]
702   }