• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2016 the V8 project 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/sanitizers/sanitizers.gni")
6import("//build/config/v8_target_cpu.gni")
7
8declare_args() {
9  # Indicate if valgrind was fetched as a custom deps to make it available on
10  # swarming.
11  v8_has_valgrind = false
12
13  # Indicate if gcmole was fetched as a hook to make it available on swarming.
14  v8_gcmole = false
15
16  # Turns on compiler optimizations in V8 in Debug build.
17  v8_optimized_debug = true
18
19  # Support for backtrace_symbols on linux.
20  v8_enable_backtrace = ""
21
22  # Enable the snapshot feature, for fast context creation.
23  # http://v8project.blogspot.com/2015/09/custom-startup-snapshots.html
24  v8_use_snapshot = true
25
26  # Use external files for startup data blobs:
27  # the JS builtins sources and the start snapshot.
28  v8_use_external_startup_data = ""
29
30  # Enable ECMAScript Internationalization API. Enabling this feature will
31  # add a dependency on the ICU library.
32  v8_enable_i18n_support = true
33}
34
35if (v8_use_external_startup_data == "") {
36  # If not specified as a gn arg, use external startup data by default if
37  # a snapshot is used and if we're not on ios.
38  v8_use_external_startup_data = v8_use_snapshot && !is_ios
39}
40
41if (v8_enable_backtrace == "") {
42  v8_enable_backtrace = is_debug && !v8_optimized_debug
43}
44
45# Points to // in v8 stand-alone or to //v8/ in chromium. We need absolute
46# paths for all configs in templates as they are shared in different
47# subdirectories.
48v8_path_prefix = get_path_info("../", "abspath")
49
50v8_inspector_js_protocol = v8_path_prefix + "/src/inspector/js_protocol.json"
51
52###############################################################################
53# Templates
54#
55
56# Common configs to remove or add in all v8 targets.
57v8_remove_configs = [ "//build/config/compiler:chromium_code" ]
58v8_add_configs = [
59  "//build/config/compiler:no_chromium_code",
60  v8_path_prefix + ":features",
61  v8_path_prefix + ":toolchain",
62]
63
64if (is_debug && !v8_optimized_debug) {
65  v8_remove_configs += [ "//build/config/compiler:default_optimization" ]
66  v8_add_configs += [ "//build/config/compiler:no_optimize" ]
67} else {
68  v8_remove_configs += [ "//build/config/compiler:default_optimization" ]
69
70  # TODO(crbug.com/621335) Rework this so that we don't have the confusion
71  # between "optimize_speed" and "optimize_max".
72  if (is_posix && !is_android && !using_sanitizer) {
73    v8_add_configs += [ "//build/config/compiler:optimize_speed" ]
74  } else {
75    v8_add_configs += [ "//build/config/compiler:optimize_max" ]
76  }
77}
78
79if (is_posix && v8_enable_backtrace) {
80  v8_remove_configs += [ "//build/config/gcc:symbol_visibility_hidden" ]
81  v8_add_configs += [ "//build/config/gcc:symbol_visibility_default" ]
82}
83
84# All templates should be kept in sync.
85template("v8_source_set") {
86  source_set(target_name) {
87    forward_variables_from(invoker, "*", [ "configs" ])
88    configs += invoker.configs
89    configs -= v8_remove_configs
90    configs += v8_add_configs
91  }
92}
93
94template("v8_executable") {
95  executable(target_name) {
96    forward_variables_from(invoker,
97                           "*",
98                           [
99                             "configs",
100                             "remove_configs",
101                           ])
102    if (defined(invoker.remove_configs)) {
103      configs -= invoker.remove_configs
104    }
105    configs += invoker.configs
106    configs -= v8_remove_configs
107    configs += v8_add_configs
108    if (is_linux) {
109      # For enabling ASLR.
110      ldflags = [ "-pie" ]
111    }
112  }
113}
114
115template("v8_component") {
116  component(target_name) {
117    forward_variables_from(invoker, "*", [ "configs" ])
118    configs += invoker.configs
119    configs -= v8_remove_configs
120    configs += v8_add_configs
121  }
122}
123