Roll src/third_party/WebKit 4e80045:b43d4aa (svn 187778:187783)
[chromium-blink-merge.git] / chrome / BUILD.gn
blobc6255f343bd0c746fe2eae5fe8449a76f107fab5
1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 import("//build/config/features.gni")
6 import("//build/config/locales.gni")
7 import("//build/config/ui.gni")
8 import("//chrome/chrome_repack_locales.gni")
9 import("//chrome/version.gni")
11 if (is_android) {
12   import("//build/config/android/rules.gni")
15 if (!is_android) {
16   # TODO(GYP) for Windows need to the the reorder-imports step which probably
17   # means adding another target and renaming this to chrome_initial like in GYP.
18   executable("chrome") {
19     # Because the sources list varies so significantly per-platform, generally
20     # each platform lists its own files rather than relying on filtering or
21     # removing unused files.
22     sources = [
23       "app/chrome_exe_resource.h",
24     ]
25     deps = []
26     datadeps = []
28     # TODO(GYP) mac_bundle_resources, xcode_settings
30     # TODO(GYP) order_profiling, order_text_section
32     if (is_win) {
33       sources += [
34         "app/chrome_exe_main_win.cc",
35         "app/client_util.cc",
36         "app/client_util.h",
37         "app/signature_validator_win.cc",
38         "app/signature_validator_win.h",
39         "//content/app/startup_helper_win.cc",
40       ]
41       deps += [ "//ui/gfx" ]
42     } else if (use_aura) {
43       # Non-Windows aura entrypoint.
44       sources += [ "app/chrome_exe_main_aura.cc" ]
45     }
47     if (is_linux) {
48       # TODO(GYP) manpage action
50       sources += [
51         "app/chrome_dll_resource.h",
52         "app/chrome_main.cc",
53         "app/chrome_main_delegate.cc",
54         "app/chrome_main_delegate.h",
55       ]
57       deps += [
58         # On Linux, link the dependencies (libraries) that make up actual
59         # Chromium functionality directly into the executable.
60         ":browser_dependencies",
61         ":child_dependencies",
62         "//base/allocator",
64         # Needed to use the master_preferences functions
65         "//chrome/installer/util",
66         "//content/public/app:both",
67       ]
69       # Needed for chrome_main.cc initialization of libraries.
70       configs += [ "//build/config/linux:pangocairo" ]
72       # TODO(GYP) ['profiling==0 and linux_disable_pie==0', {
73       #   'ldflags': [
74       #      '-pie',
75       #   ],
76       #}],
78       if (use_x11) {
79         configs += [
80           "//build/config/linux:x11",
81           "//build/config/linux:xext",
82         ]
83       }
84     }
86     if (is_mac) {
87       sources += [ "app/chrome_exe_main_mac.cc" ]
88       # TODO(GYP) lots more stuff in the is_mac block.
89     } else {  # Non-Mac.
90       deps += [
91         ":packed_extra_resources",
92         ":packed_resources",
94         # Copy Flash Player files to PRODUCT_DIR if applicable. Let the .gyp
95         # file decide what to do on a per-OS basis; on Mac, internal plugins
96         # go inside the framework, so this dependency is in chrome_dll.gypi.
97         #'../third_party/adobe/flash/flash_player.gyp:flapper_binaries',  TODO(GYP)
99         # Copy CDM files to PRODUCT_DIR if applicable. Let the .gyp
100         # file decide what to do on a per-OS basis; on Mac, internal plugins
101         # go inside the framework, so this dependency is in chrome_dll.gypi.
102         #'../third_party/widevine/cdm/widevine_cdm.gyp:widevinecdmadapter',  TODO(GYP)
103       ]
104       # TODO(GYP) some stuff from GYP including chrome_multiple_dll.
105     }
107     if (!is_mac) {
108       # On Mac this is done in chrome_dll.gypi.
109       datadeps += [ "//pdf" ]
110       # TODO(GYP) pdf linux symbols
111     }
112   }
113 }  # !is_android
115 shared_library("main_dll") {
116   configs += [ "//build/config/compiler:wexit_time_destructors" ]
118   deps = [
119     ":browser_dependencies",
120     "//base/allocator",
121   ]
122   if (is_win) {
123     output_name = "chrome"
125     sources = [
126       "app/chrome_command_ids.h",
127       "app/chrome_dll.rc",
128       "app/chrome_dll_resource.h",
129       "app/chrome_main.cc",
130       "app/chrome_main_delegate.cc",
131       "app/chrome_main_delegate.h",
132       "app/close_handle_hook_win.cc",
133       "app/close_handle_hook_win.h",
134       "app/delay_load_hook_win.cc",
135       "app/delay_load_hook_win.h",
136       "//base/win/dllmain.cc",
137     ]
139     deps += [
140       # On Windows, link the dependencies (libraries) that make up actual
141       # Chromium functionality into this .dll.
142       #'chrome_version_resources',  TODO(GYP)
143       "//chrome/app/theme:chrome_unscaled_resources",
144       "//content/app/resources",
145       "//crypto",
146       "//net:net_resources",
147       "//third_party/wtl",
148       "//ui/views",
150       #'<(DEPTH)/chrome_elf/chrome_elf.gyp:chrome_elf' ]  TODO(GYP)
151     ]
152     if (enable_configuration_policy) {
153       deps += [ "//components/policy" ]
154     }
155     if (cpu_arch == "x86") {
156       # Add a dependency to custom import library for user32 delay imports only
157       # in x86 builds.
158       #deps += [ 'chrome_user32_delay_imports' ]  TODO(GYP)
159     }
161     # TODO(GYP) incremental linking flags in debug builds
162     #'LinkIncremental': '<(msvs_large_module_debug_link_mode)',
164     # TODO(GYP) Lots of VCLinkerTool stuff on Windows.
166     # TODO(GYP) chrome_pgo_phase on Windows.
167   }
169   if (use_aura) {
170     deps += [ "//ui/compositor" ]
171   }
173   #TODO(GYP) add chrome_multiple_dll support
174   if (false) {  #chrome_multiple_dll) {
175     defines = [ "CHROME_MULTIPLE_DLL_BROWSER" ]
176     deps += [ "//content/public/app:browser" ]
177   } else {
178     deps += [
179       ":child_dependencies",
180       "//content/public/app:both",
181     ]
182   }
184   if (cld_version == 0 || cld_version == 2) {
185     deps += [ "//third_party/cld_2" ]
186   }
188   if (is_mac) {
189     #['OS=="mac" and component!="shared_library"', {  TODO(GYP)
190     #  'includes': [ 'chrome_dll_bundle.gypi' ],
191     #}],
192     # TODO(GYP) Lots of other stuff in the OS=="mac" block.
193   }
196 # GYP version: chromium_browser_dependencies variable in chrome.gyp
197 group("browser_dependencies") {
198   deps = [
199     "//chrome/browser",
200     "//chrome/common",
201     "//sync",
202   ]
203   if (!is_ios) {
204     deps += [ "//ppapi:ppapi_host" ]
205   }
207   if (enable_basic_printing || enable_print_preview) {
208     deps += [ "//printing" ]
209     if (enable_print_preview) {
210       deps += [ "//chrome/service" ]
211     }
212   }
215 # GYP version: chromium_child_dependencies variable in chrome.gyp
216 group("child_dependencies") {
217   deps = [
218     "//chrome/common",
219     "//sync",
220   ]
221   if (!is_ios) {
222     deps += [
223       "//chrome/browser/devtools",
224       "//chrome/plugin",
225       "//chrome/renderer",
226       "//chrome/utility",
227       "//content/public/child",
228       "//third_party/WebKit/public:blink_devtools_frontend_resources",
229     ]
230   }
231   if (cld_version == 0 || cld_version == 2) {
232     deps += [ "//third_party/cld_2:cld2_platform_impl" ]
233   }
235   # TODO(gyp) if (enable_nacl) {
236   #  deps += [ "<(DEPTH)/ppapi/native_client/src/trusted/plugin/plugin.gyp:nacl_trusted_plugin" ]
237   #}
238   if (enable_remoting) {
239     deps += [ "//remoting/client/plugin" ]
240   }
243 if (is_win) {
244   # TODO(brettw) this duplicates "//chrome/common:version" which applies to
245   # Linux.
246   process_version("version_header") {
247     # TODO(brettW) this should have more reduced visibility, but chrome/browser
248     # currently depends on this.
249     #visibility = [ ":*" ]
250     source = "version.h.in"
252     # TODO(brettw) this should move to $target_gen_dir/version.h and
253     # source files including it should reference it via "chrome/version.h"
254     output = "$root_gen_dir/version.h"
255   }
258 # GYP version: chrome/chrome_resources.gyp:chrome_resources
259 group("resources") {
260   deps = [
261     # Note: GYP lists some dependencies in addition to these actions. However,
262     # these are just dependencies for the actions themselves, which our actions
263     # list individually when needed.
264     "//chrome/browser:resources",
265     "//chrome/common:resources",
266     "//chrome/renderer:resources",
267   ]
269   if (enable_extensions) {
270     deps += [ "//chrome/common:extensions_api_resources" ]
271   }
274 # GYP version: chrome/chrome_resources.gyp:chrome_extra_resources
275 group("extra_resources") {
276   deps = [
277     "//chrome/browser/resources:invalidations_resources",
278     "//chrome/browser/resources:memory_internals_resources",
279     "//chrome/browser/resources:net_internals_resources",
280     "//chrome/browser/resources:password_manager_internals_resources",
281     "//chrome/browser/resources:signin_internals_resources",
282     "//chrome/browser/resources:sync_internals_resources",
283     "//chrome/browser/resources:translate_internals_resources",
284   ]
285   if (!is_ios) {
286     deps += [
287       "//chrome/browser/resources:component_extension_resources",
288       "//chrome/browser/resources:options_resources",
289     ]
290   }
292   if (enable_chromevox_next) {
293     deps += [
294       #'browser/resources/chromeos/chromevox2/chromevox.gyp:chromevox2',  TODO(GYP)
295     ]
296   } else {
297     deps += [
298       #'browser/resources/chromeos/chromevox/chromevox.gyp:chromevox',  TODO(GYP)
299     ]
300   }
302   if (enable_extensions) {
303     deps += [
304       "//chrome/browser/resources:quota_internals_resources",
305       "//chrome/browser/resources:sync_file_system_internals_resources",
306     ]
307   }
310 group("packed_resources") {
311   deps = [
312     ":repack_locales_pack",
313     ":repack_pseudo_locales_pack",
314     ":repack_chrome_100_percent",
315   ]
317   # TODO(GYP) if (is_chrome_branded) {
318   # ... copy default_apps from default_apps_list
320   if (enable_hidpi) {
321     deps += [ ":repack_chrome_200_percent" ]
322   }
325 repack("packed_extra_resources") {
326   visibility = [ "./*" ]
327   sources = [
328     "$root_gen_dir/chrome/browser_resources.pak",
329     "$root_gen_dir/chrome/chrome_unscaled_resources.pak",
330     "$root_gen_dir/chrome/common_resources.pak",
331     "$root_gen_dir/chrome/invalidations_resources.pak",
332     "$root_gen_dir/chrome/memory_internals_resources.pak",
333     "$root_gen_dir/chrome/net_internals_resources.pak",
334     "$root_gen_dir/chrome/password_manager_internals_resources.pak",
335     "$root_gen_dir/chrome/signin_internals_resources.pak",
336     "$root_gen_dir/chrome/sync_internals_resources.pak",
337     "$root_gen_dir/chrome/translate_internals_resources.pak",
338     "$root_gen_dir/components/components_resources.pak",
339     "$root_gen_dir/net/net_resources.pak",
340     "$root_gen_dir/ui/resources/webui_resources.pak",
341   ]
342   deps = [
343     "//chrome/browser:resources",
344     "//chrome/app/theme:chrome_unscaled_resources",
345     "//chrome/common:resources",
346     "//chrome/browser/resources:invalidations_resources",
347     "//chrome/browser/resources:memory_internals_resources",
348     "//chrome/browser/resources:net_internals_resources",
349     "//chrome/browser/resources:password_manager_internals_resources",
350     "//chrome/browser/resources:signin_internals_resources",
351     "//chrome/browser/resources:sync_internals_resources",
352     "//chrome/browser/resources:translate_internals_resources",
353     "//components/resources",
354     "//net:net_resources",
355     "//ui/resources",
356   ]
358   if (!is_ios && !is_android) {
359     # New paks should be added here by default.
360     sources += [
361       "$root_gen_dir/chrome/component_extension_resources.pak",
362       "$root_gen_dir/chrome/options_resources.pak",
363       "$root_gen_dir/chrome/quota_internals_resources.pak",
364       "$root_gen_dir/chrome/sync_file_system_internals_resources.pak",
365       "$root_gen_dir/chrome/webrtc_device_provider_resources.pak",
366       "$root_gen_dir/blink/devtools_resources.pak",
367     ]
368     deps += [
369       "//chrome/browser/devtools:webrtc_device_provider_resources",
370       "//chrome/browser/resources:component_extension_resources",
371       "//chrome/browser/resources:options_resources",
372       "//chrome/browser/resources:quota_internals_resources",
373       "//chrome/browser/resources:sync_file_system_internals_resources",
374       "//content/browser/devtools:devtools_resources",
375     ]
376   }
377   if (!is_ios) {
378     sources += [
379       "$root_gen_dir/blink/public/resources/blink_resources.pak",
380       "$root_gen_dir/content/browser/tracing/tracing_resources.pak",
381       "$root_gen_dir/content/content_resources.pak",
382     ]
383   }
384   if (is_chromeos) {
385     sources += [ "$root_gen_dir/ui/file_manager/file_manager_resources.pak" ]
386     deps += [ "//ui/file_manager:resources" ]
387   }
388   if (enable_extensions) {
389     sources += [
390       "$root_gen_dir/chrome/extensions_api_resources.pak",
391       "$root_gen_dir/extensions/extensions_renderer_resources.pak",
392       "$root_gen_dir/extensions/extensions_resources.pak",
393     ]
394     deps += [ "//chrome/common:extensions_api_resources" ]
395   }
397   # GYP outputs the file in the gen/repack directory. On non-Mac/iOS platforms
398   # it them copies it. This skipes the copy step and writes it to the final
399   # location.
400   if (is_mac || is_ios) {
401     output = "$root_gen_dir/repack/resources.pak"
402   } else {
403     output = "$root_out_dir/resources.pak"
404   }
407 # GYP version: chrome/chrome_resources.gyp:browser_tests_pak
408 repack("browser_tests_pak") {
409   sources = [
410     "$root_gen_dir/chrome/options_test_resources.pak",
411   ]
412   output = "$root_out_dir/browser_tests.pak"
415 # Collects per-locale grit files from many sources into global per-locale files.
416 chrome_repack_locales("repack_locales_pack") {
417   visibility = [ ":*" ]
419   input_locales = locales
421   if (is_mac) {
422     output_locales = locales_as_mac_outputs
423   } else {
424     output_locales = locales
425   }
428 chrome_repack_locales("repack_pseudo_locales_pack") {
429   visibility = [ ":*" ]
431   input_locales = [ "fake-bidi" ]
433   if (is_mac) {
434     output_locales = [ "fake_bidi" ]  # Mac uses underscores.
435   } else {
436     output_locales = [ "fake-bidi" ]
437   }
440 # Generates a rule to repack a set of resources, substituting a given string
441 # in for the percentage (e.g. "100", "200"). It generates the repacked files in
442 # the "gen" directory, and then introduces a copy rule to copy it to the root
443 # build directory.
445 # It's not clear why this two-step dance is necessary as opposed to just
446 # generating the file in the destination. However, this is what the GYP build
447 # does, and for maintenance purposes, this keeps the same files in the same
448 # place between the two builds when possible.
450 # Argument:
451 #   percent [required]
452 #      String to substitute for the percentage.
453 template("chrome_repack_percent") {
454   percent = invoker.percent
456   repack_name = "${target_name}_repack"
457   repack_output_file = "$root_gen_dir/repack/chrome_${percent}_percent.pak"
459   copy_name = target_name
461   repack(repack_name) {
462     visibility = [ ":$copy_name" ]
464     # All sources should also have deps for completeness.
465     sources = [
466       "$root_gen_dir/components/components_resources_${percent}_percent.pak",
467       "$root_gen_dir/ui/resources/ui_resources_${percent}_percent.pak",
468       "$root_gen_dir/chrome/renderer_resources_${percent}_percent.pak",
469       "$root_gen_dir/chrome/theme_resources_${percent}_percent.pak",
470     ]
472     deps = [
473       "//chrome/app/theme:theme_resources",
474       "//chrome/renderer:resources",
475       "//components/strings",
476       "//net:net_resources",
477     ]
479     if (!is_ios) {
480       sources += [ "$root_gen_dir/content/app/resources/content_resources_${percent}_percent.pak" ]
481       deps += [ "//content:resources" ]
482     }
483     if (use_ash) {
484       sources +=
485           [ "$root_gen_dir/ash/resources/ash_resources_${percent}_percent.pak" ]
486       deps += [ "//ash/resources" ]
487     }
488     if (use_athena) {
489       sources += [ "$root_gen_dir/athena/resources/athena_resources_${percent}_percent.pak" ]
490       deps += [ "//athena/resources" ]
491     }
492     if (is_chromeos) {
493       sources += [ "$root_gen_dir/ui/chromeos/resources/ui_chromeos_resources_${percent}_percent.pak" ]
494       deps += [ "//ui/chromeos/resources" ]
495     }
496     if (enable_extensions) {
497       sources += [ "$root_gen_dir/extensions/extensions_browser_resources_${percent}_percent.pak" ]
498     }
500     output = repack_output_file
501   }
503   copy(copy_name) {
504     visibility = [ ":*" ]
505     deps = [
506       ":$repack_name",
507     ]
508     sources = [
509       repack_output_file,
510     ]
511     outputs = [
512       "$root_build_dir/chrome_${percent}_percent.pak",
513     ]
514   }
517 chrome_repack_percent("repack_chrome_100_percent") {
518   percent = "100"
521 if (enable_hidpi) {
522   chrome_repack_percent("repack_chrome_200_percent") {
523     percent = "200"
524   }
527 # GYP version: chrome/chrome_resources.gyp:chrome_strings
528 group("strings") {
529   deps = [
530     "//chrome/app:chromium_strings",
531     "//chrome/app:generated_resources",
532     "//chrome/app:google_chrome_strings",
533     "//chrome/app/resources:locale_settings",
534   ]
537 if (is_android) {
538   # GYP: //chrome/chrome.gyp:content_setting_java
539   java_cpp_enum("content_setting_javagen") {
540     sources = [
541       "../components/content_settings/core/common/content_settings.h",
542     ]
543     outputs = [
544       "org/chromium/chrome/browser/ContentSetting.java",
545     ]
546   }
548   # GYP: //chrome/chrome.gyp:content_settings_type_java
549   java_cpp_enum("content_settings_type_javagen") {
550     sources = [
551       "../components/content_settings/core/common/content_settings_types.h",
552     ]
553     outputs = [
554       "org/chromium/chrome/browser/ContentSettingsType.java",
555     ]
556   }
558   # GYP: //chrome/chrome.gyp:page_info_connection_type_java
559   java_cpp_enum("page_info_connection_type_javagen") {
560     sources = [
561       "browser/ui/android/website_settings_popup_android.h",
562     ]
563     outputs = [
564       "org/chromium/chrome/browser/PageInfoConnectionType.java",
565     ]
566   }
568   # GYP: //chrome/chrome_android.gypi:chrome_android_core
569   static_library("chrome_android_core") {
570     sources = [
571       "app/android/chrome_android_initializer.cc",
572       "app/android/chrome_android_initializer.h",
573       "app/android/chrome_main_delegate_android.cc",
574       "app/android/chrome_main_delegate_android.h",
575       "app/chrome_main_delegate.cc",
576       "app/chrome_main_delegate.h",
577     ]
579     include_dirs = [ android_ndk_include_dir ]
581     libs = [
582       "android",
583       "jnigraphics",
584     ]
586     deps = [
587       "//chrome/browser",
588       "//chrome/browser/ui",
589       "//chrome/plugin",
590       "//chrome/renderer",
591       "//chrome/utility",
592       "//components/enhanced_bookmarks",
593       "//content/public/app:browser",
594     ]
595   }