Cleanup: Only build extensions renderer code when extensions are enabled.
[chromium-blink-merge.git] / chrome / BUILD.gn
blobba69e8f6d6c90bb85baa9f89099224da8eecfa21
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 # TODO(GYP) for Windows need to the the reorder-imports step which probably
12 # means adding another target and renaming this to chrome_initial like in GYP.
13 executable("chrome") {
14   # Because the sources list varies so significantly per-platform, generally
15   # each platform lists its own files rather than relying on filtering or
16   # removing unused files.
17   sources = [
18     "app/chrome_exe_resource.h",
19   ]
20   deps = []
21   datadeps = []
23   # TODO(GYP) mac_bundle_resources, xcode_settings
25   # TODO(GYP) order_profiling, order_text_section
27   if (is_win) {
28     sources += [
29       "app/chrome_exe_main_win.cc",
30       "app/client_util.cc",
31       "app/client_util.h",
32       "app/signature_validator_win.cc",
33       "app/signature_validator_win.h",
34       "//content/app/startup_helper_win.cc",
35     ]
36     deps += [ "//ui/gfx" ]
37   } else if (use_aura) {
38     # Non-Windows aura entrypoint.
39     sources += [ "app/chrome_exe_main_aura.cc" ]
40   }
42   if (is_linux) {
43     # TODO(GYP) manpage action
45     sources += [
46       "app/chrome_dll_resource.h",
47       "app/chrome_main.cc",
48       "app/chrome_main_delegate.cc",
49       "app/chrome_main_delegate.h",
50     ]
52     deps += [
53       # On Linux, link the dependencies (libraries) that make up actual
54       # Chromium functionality directly into the executable.
55       ":browser_dependencies",
56       ":child_dependencies",
58       "//base/allocator",
59       # Needed to use the master_preferences functions
60       "//chrome/installer/util",
61       "//content/public/app:both",
62     ]
64     # Needed for chrome_main.cc initialization of libraries.
65     configs += [ "//build/config/linux:pangocairo" ]
67     # TODO(GYP) ['profiling==0 and linux_disable_pie==0', {
68     #   'ldflags': [
69     #      '-pie',
70     #   ],
71     #}],
73     if (use_x11) {
74       configs += [
75         "//build/config/linux:x11",
76         "//build/config/linux:xext",
77       ]
78     }
79   }
81   if (is_mac) {
82     sources += [
83       "app/chrome_exe_main_mac.cc",
84     ]
85     # TODO(GYP) lots more stuff in the is_mac block.
86   } else {  # Non-Mac.
87     deps += [
88       ":packed_extra_resources",
89       ":packed_resources",
91       # Copy Flash Player files to PRODUCT_DIR if applicable. Let the .gyp
92       # file decide what to do on a per-OS basis; on Mac, internal plugins
93       # go inside the framework, so this dependency is in chrome_dll.gypi.
94       #'../third_party/adobe/flash/flash_player.gyp:flapper_binaries',  TODO(GYP)
96       # Copy CDM files to PRODUCT_DIR if applicable. Let the .gyp
97       # file decide what to do on a per-OS basis; on Mac, internal plugins
98       # go inside the framework, so this dependency is in chrome_dll.gypi.
99       #'../third_party/widevine/cdm/widevine_cdm.gyp:widevinecdmadapter',  TODO(GYP)
100     ]
102     # TODO(GYP) some stuff from GYP including chrome_multiple_dll.
104   }
107   if (!is_mac && !is_android) {
108     # On Mac this is done in chrome_dll.gypi. Android doesn't use pdfium.
109     datadeps += [ "//pdf" ]
111     # TODO(GYP) pdf linux symbols
112   }
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",
149       #'<(DEPTH)/chrome_elf/chrome_elf.gyp:chrome_elf' ]  TODO(GYP)
150     ]
151     if (enable_configuration_policy) {
152       deps += [ "//components/policy" ]
153     }
154     if (cpu_arch == "x86") {
155       # Add a dependency to custom import library for user32 delay imports only
156       # in x86 builds.
157       #deps += [ 'chrome_user32_delay_imports' ]  TODO(GYP)
158     }
160     # TODO(GYP) incremental linking flags in debug builds
161     #'LinkIncremental': '<(msvs_large_module_debug_link_mode)',
163     # TODO(GYP) Lots of VCLinkerTool stuff on Windows.
165     # TODO(GYP) chrome_pgo_phase on Windows.
166   }
168   if (use_aura) {
169     deps += [ "//ui/compositor" ]
170   }
172   #TODO(GYP) add chrome_multiple_dll support
173   if (false) {  #chrome_multiple_dll) {
174     defines = [ "CHROME_MULTIPLE_DLL_BROWSER" ]
175     deps += [
176       "//content/public/app:browser",
177     ]
178   } else {
179     deps += [
180       ":child_dependencies",
181       "//content/public/app:both",
182     ]
183   }
185   if (cld_version == 0 || cld_version == 2) {
186     deps += [
187       "//third_party/cld_2",
188     ]
189   }
191   if (is_mac) {
192     #['OS=="mac" and component!="shared_library"', {  TODO(GYP)
193     #  'includes': [ 'chrome_dll_bundle.gypi' ],
194     #}],
196     # TODO(GYP) Lots of other stuff in the OS=="mac" block.
197   }
200 # GYP version: chromium_browser_dependencies variable in chrome.gyp
201 group("browser_dependencies") {
202   deps = [
203     "//chrome/browser",
204     "//chrome/common",
205     "//sync",
206   ]
207   if (!is_ios) {
208     deps += [
209       "//ppapi:ppapi_host",
210     ]
211   }
213   if (printing_mode != 0) {
214     deps += [ "//printing" ]
215     if (printing_mode == 1) {
216       deps += [ "//chrome/service" ]
217     }
218   }
221 # GYP version: chromium_child_dependencies variable in chrome.gyp
222 group("child_dependencies") {
223   deps = [
224     "//chrome/common",
225     "//sync",
226   ]
227   if (!is_ios) {
228     deps += [
229       "//chrome/browser/devtools",
230       "//chrome/plugin",
231       "//chrome/renderer",
232       "//chrome/utility",
233       "//content/public/child",
234       "//third_party/WebKit/public:blink_devtools_frontend_resources",
235     ]
236   }
239 if (is_win) {
240   # TODO(brettw) this duplicates "//chrome/common:version" which applies to
241   # Linux.
242   process_version("version_header") {
243     # TODO(brettW) this should have more reduced visibility, but chrome/browser
244     # currently depends on this.
245     #visibility = [ ":*" ]
246     source = "version.h.in"
247     # TODO(brettw) this should move to $target_gen_dir/version.h and
248     # source files including it should reference it via "chrome/version.h"
249     output = "$root_gen_dir/version.h"
250   }
253 # GYP version: chrome/chrome_resources.gyp:chrome_resources
254 group("resources") {
255   deps = [
256     # Note: GYP lists some dependencies in addition to these actions. However,
257     # these are just dependencies for the actions themselves, which our actions
258     # list individually when needed.
259     "//chrome/browser:resources",
260     "//chrome/common:resources",
261     "//chrome/renderer:resources",
262   ]
264   if (enable_extensions) {
265     deps += [ "//chrome/common:extensions_api_resources" ]
266   }
269 # GYP version: chrome/chrome_resources.gyp:chrome_extra_resources
270 group("extra_resources") {
271   deps = [
272     "//chrome/browser/resources:invalidations_resources",
273     "//chrome/browser/resources:memory_internals_resources",
274     "//chrome/browser/resources:net_internals_resources",
275     "//chrome/browser/resources:password_manager_internals_resources",
276     "//chrome/browser/resources:signin_internals_resources",
277     "//chrome/browser/resources:sync_internals_resources",
278     "//chrome/browser/resources:translate_internals_resources",
279   ]
280   if (!is_ios) {
281     deps += [
282       "//chrome/browser/resources:component_extension_resources",
283       "//chrome/browser/resources:options_resources",
284     ]
285   }
287   if (enable_chromevox_next) {
288     deps += [
289       #'browser/resources/chromeos/chromevox2/chromevox.gyp:chromevox2',  TODO(GYP)
290     ]
291   } else {
292     deps += [
293       #'browser/resources/chromeos/chromevox/chromevox.gyp:chromevox',  TODO(GYP)
294     ]
295   }
297   if (enable_extensions) {
298     deps += [
299       "//chrome/browser/resources:quota_internals_resources",
300       "//chrome/browser/resources:sync_file_system_internals_resources",
301     ]
302   }
305 group("packed_resources") {
306   deps = [
307     ":repack_locales_pack",
308     ":repack_pseudo_locales_pack",
309     ":repack_chrome_100_percent",
310   ]
312   # TODO(GYP) if (is_chrome_branded) {
313   # ... copy default_apps from default_apps_list
315   if (enable_hidpi) {
316     deps += [ ":repack_chrome_200_percent" ]
317   }
320 repack("packed_extra_resources") {
321   visibility = [ ":*" ]
322   sources = [
323     "$root_gen_dir/chrome/browser_resources.pak",
324     "$root_gen_dir/chrome/app/theme/chrome_unscaled_resources.pak",
325     "$root_gen_dir/chrome/common_resources.pak",
326     "$root_gen_dir/chrome/browser/resources/invalidations_resources.pak",
327     "$root_gen_dir/chrome/browser/resources/memory_internals_resources.pak",
328     "$root_gen_dir/chrome/browser/resources/net_internals_resources.pak",
329     "$root_gen_dir/chrome/browser/resources/password_manager_internals_resources.pak",
330     "$root_gen_dir/chrome/browser/resources/signin_internals_resources.pak",
331     "$root_gen_dir/chrome/browser/resources/sync_internals_resources.pak",
332     "$root_gen_dir/chrome/browser/resources/translate_internals_resources.pak",
333     "$root_gen_dir/components/resources/component_resources.pak",
334     "$root_gen_dir/net/net_resources.pak",
335     "$root_gen_dir/ui/resources/webui_resources.pak",
336   ]
337   deps = [
338     "//chrome/browser:resources",
339     "//chrome/app/theme:chrome_unscaled_resources",
340     "//chrome/common:resources",
341     "//chrome/browser/resources:invalidations_resources",
342     "//chrome/browser/resources:memory_internals_resources",
343     "//chrome/browser/resources:net_internals_resources",
344     "//chrome/browser/resources:password_manager_internals_resources",
345     "//chrome/browser/resources:signin_internals_resources",
346     "//chrome/browser/resources:sync_internals_resources",
347     "//chrome/browser/resources:translate_internals_resources",
348     "//components/resources",
349     "//net:net_resources",
350     "//ui/resources",
351   ]
353   if (!is_ios && !is_android) {
354     # New paks should be added here by default.
355     sources += [
356       "$root_gen_dir/webkit/devtools_resources.pak",
357       "$root_gen_dir/chrome/browser/resources/component_extension_resources.pak",
358       "$root_gen_dir/chrome/browser/resources/options_resources.pak",
359       "$root_gen_dir/chrome/browser/resources/quota_internals_resources.pak",
360       "$root_gen_dir/chrome/browser/resources/sync_file_system_internals_resources.pak",
361     ]
362     deps += [
363       "//content/browser/devtools:devtools_resources",
364       "//chrome/browser/resources:component_extension_resources",
365       "//chrome/browser/resources:options_resources",
366       "//chrome/browser/resources:quota_internals_resources",
367       "//chrome/browser/resources:sync_file_system_internals_resources",
368     ]
369   }
370   if (!is_ios) {
371     sources += [
372       "$root_gen_dir/blink/public/resources/blink_resources.pak",
373       "$root_gen_dir/content/browser/tracing/tracing_resources.pak",
374       "$root_gen_dir/content/content_resources.pak",
375       "$root_gen_dir/extensions/extensions_renderer_resources.pak", 
376       "$root_gen_dir/extensions/extensions_resources.pak",
377     ]
378   }
379   if (is_chromeos) {
380     sources += [ "$root_gen_dir/ui/file_manager/file_manager_resources.pak" ]
381     deps += [ "//ui/file_manager:resources" ]
382   }
383   if (enable_extensions) {
384     sources += [ "$root_gen_dir/chrome/extensions_api_resources.pak" ]
385     deps += [ "//chrome/common:extensions_api_resources" ]
386   }
388   # GYP outputs the file in the gen/repack directory. On non-Mac/iOS platforms
389   # it them copies it. This skipes the copy step and writes it to the final
390   # location.
391   if (is_mac || is_ios) {
392     output = "$root_gen_dir/repack/resources.pak"
393   } else {
394     output = "$root_out_dir/resources.pak"
395   }
398 # Collects per-locale grit files from many sources into global per-locale files.
399 chrome_repack_locales("repack_locales_pack") {
400   visibility = [ ":*" ]
402   input_locales = locales
404   if (is_mac) {
405     output_locales = locales_as_mac_outputs
406   } else {
407     output_locales = locales
408   }
411 chrome_repack_locales("repack_pseudo_locales_pack") {
412   visibility = [ ":*" ]
414   input_locales = [ "fake-bidi" ]
416   if (is_mac) {
417     output_locales = [ "fake_bidi" ]  # Mac uses underscores.
418   } else {
419     output_locales = [ "fake-bidi" ]
420   }
423 # Generates a rule to repack a set of resources, substituting a given string
424 # in for the percentage (e.g. "100", "200"). It generates the repacked files in
425 # the "gen" directory, and then introduces a copy rule to copy it to the root
426 # build directory.
428 # It's not clear why this two-step dance is necessary as opposed to just
429 # generating the file in the destination. However, this is what the GYP build
430 # does, and for maintenance purposes, this keeps the same files in the same
431 # place between the two builds when possible.
433 # Argument:
434 #   percent [required]
435 #      String to substitute for the percentage.
436 template("chrome_repack_percent") {
437   percent = invoker.percent
439   repack_name = "${target_name}_repack"
440   repack_output_file = "$root_gen_dir/repack/chrome_${percent}_percent.pak"
442   copy_name = target_name
444   repack(repack_name) {
445     visibility = [ ":$copy_name" ]
446     # All sources should also have deps for completeness.
447     sources = [
448       "$root_gen_dir/components/resources/component_resources_${percent}_percent.pak",
449       "$root_gen_dir/ui/resources/ui_resources_${percent}_percent.pak",
450       "$root_gen_dir/chrome/renderer_resources_${percent}_percent.pak",
451       "$root_gen_dir/chrome/app/theme/theme_resources_${percent}_percent.pak",
452     ]
454     deps = [
455       "//chrome/app/theme:theme_resources",
456       "//chrome/renderer:resources",
457       "//components/strings",
458       "//net:net_resources",
459     ]
461     if (!is_ios) {
462       sources += [
463         "$root_gen_dir/content/app/resources/content_resources_${percent}_percent.pak",
464       ]
465       deps += [ "//content:resources" ]
466     }
467     if (use_ash) {
468       sources += [ "$root_gen_dir/ash/resources/ash_resources_${percent}_percent.pak" ]
469       deps += [ "//ash/resources" ]
470     }
471     if (use_athena) {
472       sources += [
473         "$root_gen_dir/athena/resources/athena_resources_${percent}_percent.pak",
474       ]
475       deps += [ "//athena/resources" ]
476     }
477     if (is_chromeos) {
478       sources += [
479         "$root_gen_dir/ui/chromeos/resources/ui_chromeos_resources_${percent}_percent.pak",
480       ]
481       deps += [ "//ui/chromeos/resources" ]
482     }
483     if (enable_extensions) {
484       sources += [
485         "$root_gen_dir/extensions/extensions_browser_resources_${percent}_percent.pak",
486       ]
487     }
489     output = repack_output_file
490   }
492   copy(copy_name) {
493     visibility = [ ":*" ]
494     deps = [ ":$repack_name" ]
495     sources = [ repack_output_file ]
496     outputs = [ "$root_build_dir/chrome_${percent}_percent.pak" ]
497   }
500 chrome_repack_percent("repack_chrome_100_percent") {
501   percent = "100"
504 if (enable_hidpi) {
505   chrome_repack_percent("repack_chrome_200_percent") {
506     percent = "200"
507   }
510 # GYP version: chrome/chrome_resources.gyp:chrome_strings
511 group("strings") {
512   deps = [
513     "//chrome/app:chromium_strings",
514     "//chrome/app:generated_resources",
515     "//chrome/app:google_chrome_strings",
516     "//chrome/app/resources:locale_settings",
517   ]