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