summaryrefslogtreecommitdiffstats
path: root/chrome/BUILD.gn
blob: d49ff3db1e649e68d0fd86d9161c3e835ffa2a86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/config/features.gni")
import("//build/config/locales.gni")
import("//build/config/ui.gni")
import("//chrome/chrome_repack_locales.gni")
import("//chrome/version.gni")

# TODO(GYP) for Windows need to the the reorder-imports step which probably
# means adding another target and renaming this to chrome_initial like in GYP.
executable("chrome") {
  # Because the sources list varies so significantly per-platform, generally
  # each platform lists its own files rather than relying on filtering or
  # removing unused files.
  sources = [
    "app/chrome_exe_resource.h",
  ]
  deps = []
  datadeps = []

  # TODO(GYP) mac_bundle_resources, xcode_settings

  # TODO(GYP) order_profiling, order_text_section

  if (is_win) {
    sources += [
      "app/chrome_exe_main_win.cc",
      "app/client_util.cc",
      "app/client_util.h",
      "app/signature_validator_win.cc",
      "app/signature_validator_win.h",
      "//content/app/startup_helper_win.cc",
    ]
    deps += [ "//ui/gfx" ]
  } else if (use_aura) {
    # Non-Windows aura entrypoint.
    sources += [ "app/chrome_exe_main_aura.cc" ]
  }

  if (is_linux) {
    # TODO(GYP) manpage action

    sources += [
      "app/chrome_dll_resource.h",
      "app/chrome_main.cc",
      "app/chrome_main_delegate.cc",
      "app/chrome_main_delegate.h",
    ]

    deps += [
      # On Linux, link the dependencies (libraries) that make up actual
      # Chromium functionality directly into the executable.
      ":browser_dependencies",
      ":child_dependencies",

      "//base/allocator",
      # Needed to use the master_preferences functions
      "//chrome/installer/util",
      "//content/public/app:both",
    ]

    # Needed for chrome_main.cc initialization of libraries.
    configs += [ "//build/config/linux:pangocairo" ]

    # TODO(GYP) ['profiling==0 and linux_disable_pie==0', {
    #   'ldflags': [
    #      '-pie',
    #   ],
    #}],

    if (use_x11) {
      configs += [
        "//build/config/linux:x11",
        "//build/config/linux:xext",
      ]
    }
  }

  if (is_mac) {
    sources += [
      "app/chrome_exe_main_mac.cc",
    ]
    # TODO(GYP) lots more stuff in the is_mac block.
  } else {  # Non-Mac.
    deps += [
      ":packed_extra_resources",
      ":packed_resources",

      # Copy Flash Player files to PRODUCT_DIR if applicable. Let the .gyp
      # file decide what to do on a per-OS basis; on Mac, internal plugins
      # go inside the framework, so this dependency is in chrome_dll.gypi.
      #'../third_party/adobe/flash/flash_player.gyp:flapper_binaries',  TODO(GYP)

      # Copy CDM files to PRODUCT_DIR if applicable. Let the .gyp
      # file decide what to do on a per-OS basis; on Mac, internal plugins
      # go inside the framework, so this dependency is in chrome_dll.gypi.
      #'../third_party/widevine/cdm/widevine_cdm.gyp:widevinecdmadapter',  TODO(GYP)
    ]

    # TODO(GYP) some stuff from GYP including chrome_multiple_dll.

  }


  if (!is_mac && !is_android) {
    # On Mac this is done in chrome_dll.gypi. Android doesn't use pdfium.
    datadeps += [ "//pdf" ]

    # TODO(GYP) pdf linux symbols
  }
}

shared_library("main_dll") {
  configs += [ "//build/config/compiler:wexit_time_destructors" ]

  deps = [
    ":browser_dependencies",
    "//base/allocator",
  ]
  if (is_win) {
    output_name = "chrome"

    sources = [
      "app/chrome_command_ids.h",
      "app/chrome_dll.rc",
      "app/chrome_dll_resource.h",
      "app/chrome_main.cc",
      "app/chrome_main_delegate.cc",
      "app/chrome_main_delegate.h",
      "app/close_handle_hook_win.cc",
      "app/close_handle_hook_win.h",
      "app/delay_load_hook_win.cc",
      "app/delay_load_hook_win.h",
      "//base/win/dllmain.cc",
    ]

    deps += [
      # On Windows, link the dependencies (libraries) that make up actual
      # Chromium functionality into this .dll.
      #'chrome_version_resources',  TODO(GYP)
      "//chrome/app/theme:chrome_unscaled_resources",
      "//content/app/resources",
      "//crypto",
      "//net:net_resources",
      "//third_party/wtl",
      "//ui/views",
      #'<(DEPTH)/chrome_elf/chrome_elf.gyp:chrome_elf' ]  TODO(GYP)
    ]
    if (enable_configuration_policy) {
      deps += [ "//components/policy" ]
    }
    if (cpu_arch == "x86") {
      # Add a dependency to custom import library for user32 delay imports only
      # in x86 builds.
      #deps += [ 'chrome_user32_delay_imports' ]  TODO(GYP)
    }

    # TODO(GYP) incremental linking flags in debug builds
    #'LinkIncremental': '<(msvs_large_module_debug_link_mode)',

    # TODO(GYP) Lots of VCLinkerTool stuff on Windows.

    # TODO(GYP) chrome_pgo_phase on Windows.
  }

  if (use_aura) {
    deps += [ "//ui/compositor" ]
  }

  #TODO(GYP) add chrome_multiple_dll support
  if (false) {  #chrome_multiple_dll) {
    defines = [ "CHROME_MULTIPLE_DLL_BROWSER" ]
    deps += [
      "//content/app:browser",
    ]
  } else {
    deps += [
      ":child_dependencies",
      "//content/app:both",
    ]
  }

  if (cld_version == 0 || cld_version == 2) {
    deps += [
      "//third_party/cld_2",
    ]
  }

  if (is_mac) {
    #['OS=="mac" and component!="shared_library"', {  TODO(GYP)
    #  'includes': [ 'chrome_dll_bundle.gypi' ],
    #}],

    # TODO(GYP) Lots of other stuff in the OS=="mac" block.
  }
}

# GYP version: chromium_browser_dependencies variable in chrome.gyp
group("browser_dependencies") {
  deps = [
    "//chrome/browser",
    "//chrome/common",
    "//sync",
  ]
  if (!is_ios) {
    deps += [
      "//ppapi:ppapi_host",
    ]
  }

  if (printing_mode != 0) {
    deps += [ "//printing" ]
    if (printing_mode == 1) {
      deps += [ "//chrome/service" ]
    }
  }
}

# GYP version: chromium_child_dependencies variable in chrome.gyp
group("child_dependencies") {
  deps = [
    "//chrome/common",
    "//sync",
  ]
  if (!is_ios) {
    deps += [
      "//chrome/browser/devtools",
      "//chrome/plugin",
      "//chrome/renderer",
      "//chrome/utility",
      "//content/gpu",
      "//content/ppapi_plugin",
      "//third_party/WebKit/public:blink_devtools_frontend_resources",
    ]
  }
}

if (is_win) {
  # TODO(brettw) this duplicates "//chrome/common:version" which applies to
  # Linux.
  process_version("version_header") {
    # TODO(brettW) this should have more reduced visibility, but chrome/browser
    # currently depends on this.
    #visibility = ":*"
    source = "version.h.in"
    # TODO(brettw) this should move to $target_gen_dir/version.h and
    # source files including it should reference it via "chrome/version.h"
    output = "$root_gen_dir/version.h"
  }
}

# GYP version: chrome/chrome_resources.gyp:chrome_resources
group("resources") {
  deps = [
    # Note: GYP lists some dependencies in addition to these actions. However,
    # these are just dependencies for the actions themselves, which our actions
    # list individually when needed.
    "//chrome/browser:resources",
    "//chrome/common:resources",
    "//chrome/renderer:resources",
  ]

  if (enable_extensions) {
    deps += [ "//chrome/common:extensions_api_resources" ]
  }
}

# GYP version: chrome/chrome_resources.gyp:chrome_extra_resources
group("extra_resources") {
  deps = [
    "//chrome/browser/resources:invalidations_resources",
    "//chrome/browser/resources:memory_internals_resources",
    "//chrome/browser/resources:net_internals_resources",
    "//chrome/browser/resources:password_manager_internals_resources",
    "//chrome/browser/resources:signin_internals_resources",
    "//chrome/browser/resources:sync_internals_resources",
    "//chrome/browser/resources:translate_internals_resources",
  ]
  if (!is_ios) {
    deps += [
      "//chrome/browser/resources:component_extension_resources",
      "//chrome/browser/resources:options_resources",
    ]
  }

  if (enable_chromevox_next) {
    deps += [
      #'browser/resources/chromeos/chromevox2/chromevox.gyp:chromevox2',  TODO(GYP)
    ]
  } else {
    deps += [
      #'browser/resources/chromeos/chromevox/chromevox.gyp:chromevox',  TODO(GYP)
    ]
  }

  if (enable_extensions) {
    deps += [
      "//chrome/browser/resources:quota_internals_resources",
      "//chrome/browser/resources:sync_file_system_internals_resources",
    ]
  }
}

group("packed_resources") {
  deps = [
    ":repack_locales_pack",
    ":repack_pseudo_locales_pack",
    ":repack_chrome_100_percent",
  ]

  # TODO(GYP) if (is_chrome_branded) {
  # ... copy default_apps from default_apps_list

  if (enable_hidpi) {
    deps += [ ":repack_chrome_200_percent" ]
  }
}

repack("packed_extra_resources") {
  visibility = [ ":*" ]
  sources = [
    "$root_gen_dir/chrome/browser_resources.pak",
    "$root_gen_dir/chrome/app/theme/chrome_unscaled_resources.pak",
    "$root_gen_dir/chrome/common_resources.pak",
    "$root_gen_dir/chrome/browser/resources/invalidations_resources.pak",
    "$root_gen_dir/chrome/browser/resources/memory_internals_resources.pak",
    "$root_gen_dir/chrome/browser/resources/net_internals_resources.pak",
    "$root_gen_dir/chrome/browser/resources/password_manager_internals_resources.pak",
    "$root_gen_dir/chrome/browser/resources/signin_internals_resources.pak",
    "$root_gen_dir/chrome/browser/resources/sync_internals_resources.pak",
    "$root_gen_dir/chrome/browser/resources/translate_internals_resources.pak",
    "$root_gen_dir/components/resources/component_resources.pak",
    "$root_gen_dir/net/net_resources.pak",
    "$root_gen_dir/ui/resources/webui_resources.pak",
  ]
  deps = [
    "//chrome/browser:resources",
    "//chrome/app/theme:chrome_unscaled_resources",
    "//chrome/common:resources",
    "//chrome/browser/resources:invalidations_resources",
    "//chrome/browser/resources:memory_internals_resources",
    "//chrome/browser/resources:net_internals_resources",
    "//chrome/browser/resources:password_manager_internals_resources",
    "//chrome/browser/resources:signin_internals_resources",
    "//chrome/browser/resources:sync_internals_resources",
    "//chrome/browser/resources:translate_internals_resources",
    "//components/resources",
    "//net:net_resources",
    "//ui/resources",
  ]

  if (!is_ios && !is_android) {
    # New paks should be added here by default.
    sources += [
      "$root_gen_dir/webkit/devtools_resources.pak",
      "$root_gen_dir/chrome/browser/resources/component_extension_resources.pak",
      "$root_gen_dir/chrome/browser/resources/options_resources.pak",
      "$root_gen_dir/chrome/browser/resources/quota_internals_resources.pak",
      "$root_gen_dir/chrome/browser/resources/sync_file_system_internals_resources.pak",
    ]
    deps += [
      "//content/browser/devtools:devtools_resources",
      "//chrome/browser/resources:component_extension_resources",
      "//chrome/browser/resources:options_resources",
      "//chrome/browser/resources:quota_internals_resources",
      "//chrome/browser/resources:sync_file_system_internals_resources",
    ]
  }
  if (!is_ios) {
    sources += [
      "$root_gen_dir/blink/public/resources/blink_resources.pak",
      "$root_gen_dir/content/browser/tracing/tracing_resources.pak",
      "$root_gen_dir/content/content_resources.pak",
      "$root_gen_dir/extensions/extensions_renderer_resources.pak", 
      "$root_gen_dir/extensions/extensions_resources.pak",
    ]
  }
  if (is_chromeos) {
    sources += [ "$root_gen_dir/ui/file_manager/file_manager_resources.pak" ]
    deps += [ "//ui/file_manager:resources" ]
  }
  if (enable_extensions) {
    sources += [ "$root_gen_dir/chrome/extensions_api_resources.pak" ]
    deps += [ "//chrome/common:extensions_api_resources" ]
  }

  # GYP outputs the file in the gen/repack directory. On non-Mac/iOS platforms
  # it them copies it. This skipes the copy step and writes it to the final
  # location.
  if (is_mac || is_ios) {
    output = "$root_gen_dir/repack/resources.pak"
  } else {
    output = "$root_out_dir/resources.pak"
  }
}

# Collects per-locale grit files from many sources into global per-locale files.
chrome_repack_locales("repack_locales_pack") {
  visibility = ":*"

  input_locales = locales

  if (is_mac) {
    output_locales = locales_as_mac_outputs
  } else {
    output_locales = locales
  }
}

chrome_repack_locales("repack_pseudo_locales_pack") {
  visibility = ":*"

  input_locales = [ "fake-bidi" ]

  if (is_mac) {
    output_locales = [ "fake_bidi" ]  # Mac uses underscores.
  } else {
    output_locales = [ "fake-bidi" ]
  }
}

# Generates a rule to repack a set of resources, substituting a given string
# in for the percentage (e.g. "100", "200"). It generates the repacked files in
# the "gen" directory, and then introduces a copy rule to copy it to the root
# build directory.
#
# It's not clear why this two-step dance is necessary as opposed to just
# generating the file in the destination. However, this is what the GYP build
# does, and for maintenance purposes, this keeps the same files in the same
# place between the two builds when possible.
#
# Argument:
#   percent [required]
#      String to substitute for the percentage.
template("chrome_repack_percent") {
  percent = invoker.percent

  repack_name = "${target_name}_repack"
  repack_output_file = "$root_gen_dir/repack/chrome_${percent}_percent.pak"

  copy_name = target_name

  repack(repack_name) {
    visibility = ":$copy_name"
    # All sources should also have deps for completeness.
    sources = [
      "$root_gen_dir/components/resources/component_resources_${percent}_percent.pak",
      "$root_gen_dir/ui/resources/ui_resources_${percent}_percent.pak",
      "$root_gen_dir/chrome/renderer_resources_${percent}_percent.pak",
      "$root_gen_dir/chrome/app/theme/theme_resources_${percent}_percent.pak",
    ]

    deps = [
      "//chrome/app/theme:theme_resources",
      "//chrome/renderer:resources",
      "//components/strings",
      "//net:net_resources",
    ]

    if (!is_ios) {
      sources += [
        "$root_gen_dir/content/app/resources/content_resources_${percent}_percent.pak",
      ]
      deps += [ "//content:resources" ]
    }
    if (use_ash) {
      sources += [ "$root_gen_dir/ash/resources/ash_resources_${percent}_percent.pak" ]
      deps += [ "//ash/resources" ]
    }
    if (use_athena) {
      sources += [
        "$root_gen_dir/athena/resources/athena_resources_${percent}_percent.pak",
      ]
      deps += [ "//athena/resources" ]
    }
    if (is_chromeos) {
      sources += [
        "$root_gen_dir/ui/chromeos/resources/ui_chromeos_resources_${percent}_percent.pak",
      ]
      deps += [ "//ui/chromeos/resources" ]
    }

    output = repack_output_file
  }

  copy(copy_name) {
    visibility = ":*"
    deps = [ ":$repack_name" ]
    sources = [ repack_output_file ]
    outputs = [ "$root_build_dir/chrome_${percent}_percent.pak" ]
  }
}

chrome_repack_percent("repack_chrome_100_percent") {
  percent = "100"
}

if (enable_hidpi) {
  chrome_repack_percent("repack_chrome_200_percent") {
    percent = "200"
  }
}

# GYP version: chrome/chrome_resources.gyp:chrome_strings
group("strings") {
  deps = [
    "//chrome/app:chromium_strings",
    "//chrome/app:generated_resources",
    "//chrome/app:google_chrome_strings",
    "//chrome/app/resources:locale_settings",
  ]
}