summaryrefslogtreecommitdiff
path: root/deps/v8/gni/v8.gni
blob: 7ff7f6fb89ac3634a2c7ff64030805582d8c8fb9 (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
# Copyright 2016 the V8 project 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/sanitizers/sanitizers.gni")
import("//build/config/v8_target_cpu.gni")

declare_args() {
  # Indicate if valgrind was fetched as a custom deps to make it available on
  # swarming.
  v8_has_valgrind = false

  # Indicate if gcmole was fetched as a hook to make it available on swarming.
  v8_gcmole = false

  # Turns on compiler optimizations in V8 in Debug build.
  v8_optimized_debug = true

  # Support for backtrace_symbols on linux.
  v8_enable_backtrace = ""

  # Enable the snapshot feature, for fast context creation.
  # http://v8project.blogspot.com/2015/09/custom-startup-snapshots.html
  v8_use_snapshot = true

  # Use external files for startup data blobs:
  # the JS builtins sources and the start snapshot.
  v8_use_external_startup_data = ""
}

if (v8_use_external_startup_data == "") {
  # If not specified as a gn arg, use external startup data by default if
  # a snapshot is used and if we're not on ios.
  v8_use_external_startup_data = v8_use_snapshot && !is_ios
}

if (v8_enable_backtrace == "") {
  v8_enable_backtrace = is_debug && !v8_optimized_debug
}

###############################################################################
# Templates
#

# Points to // in v8 stand-alone or to //v8/ in chromium. We need absolute
# paths for all configs in templates as they are shared in different
# subdirectories.
v8_path_prefix = get_path_info("../", "abspath")

# Common configs to remove or add in all v8 targets.
v8_remove_configs = [ "//build/config/compiler:chromium_code" ]
v8_add_configs = [
  "//build/config/compiler:no_chromium_code",
  v8_path_prefix + ":features",
  v8_path_prefix + ":toolchain",
]

if (is_debug && !v8_optimized_debug) {
  v8_remove_configs += [ "//build/config/compiler:default_optimization" ]
  v8_add_configs += [ "//build/config/compiler:no_optimize" ]
} else {
  v8_remove_configs += [ "//build/config/compiler:default_optimization" ]

  # TODO(crbug.com/621335) Rework this so that we don't have the confusion
  # between "optimize_speed" and "optimize_max".
  if (is_posix && !is_android && !using_sanitizer) {
    v8_add_configs += [ "//build/config/compiler:optimize_speed" ]
  } else {
    v8_add_configs += [ "//build/config/compiler:optimize_max" ]
  }
}

if (is_posix && v8_enable_backtrace) {
  v8_remove_configs += [ "//build/config/gcc:symbol_visibility_hidden" ]
  v8_add_configs += [ "//build/config/gcc:symbol_visibility_default" ]
}

# All templates should be kept in sync.
template("v8_source_set") {
  source_set(target_name) {
    forward_variables_from(invoker, "*", [ "configs" ])
    configs += invoker.configs
    configs -= v8_remove_configs
    configs += v8_add_configs
  }
}

template("v8_executable") {
  executable(target_name) {
    forward_variables_from(invoker, "*", [ "configs" ])
    configs += invoker.configs
    configs -= v8_remove_configs
    configs += v8_add_configs
    if (is_linux) {
      # For enabling ASLR.
      ldflags = [ "-pie" ]
    }
  }
}

template("v8_component") {
  component(target_name) {
    forward_variables_from(invoker, "*", [ "configs" ])
    configs += invoker.configs
    configs -= v8_remove_configs
    configs += v8_add_configs
  }
}