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 # Includes files needed for correctness fuzzing. 10 v8_correctness_fuzzer = false 11 12 # Adds additional compile target for building multiple architectures at once. 13 v8_multi_arch_build = false 14 15 # Indicate if valgrind was fetched as a custom deps to make it available on 16 # swarming. 17 v8_has_valgrind = false 18 19 # Indicate if gcmole was fetched as a hook to make it available on swarming. 20 v8_gcmole = false 21 22 # Turns on compiler optimizations in V8 in Debug build. 23 v8_optimized_debug = true 24 25 # Support for backtrace_symbols on linux. 26 v8_enable_backtrace = "" 27 28 # Enable the snapshot feature, for fast context creation. 29 # http://v8project.blogspot.com/2015/09/custom-startup-snapshots.html 30 v8_use_snapshot = true 31 32 # Use external files for startup data blobs: 33 # the JS builtins sources and the start snapshot. 34 v8_use_external_startup_data = "" 35 36 # Enable ECMAScript Internationalization API. Enabling this feature will 37 # add a dependency on the ICU library. 38 v8_enable_i18n_support = true 39 40 # Enable inspector. See include/v8-inspector.h. 41 v8_enable_inspector = true 42 43 # Use static libraries instead of source_sets. 44 v8_static_library = false 45} 46 47if (v8_use_external_startup_data == "") { 48 # If not specified as a gn arg, use external startup data by default if 49 # a snapshot is used and if we're not on ios. 50 v8_use_external_startup_data = v8_use_snapshot && !is_ios 51} 52 53if (v8_enable_backtrace == "") { 54 v8_enable_backtrace = is_debug && !v8_optimized_debug 55} 56 57# Points to // in v8 stand-alone or to //v8/ in chromium. We need absolute 58# paths for all configs in templates as they are shared in different 59# subdirectories. 60v8_path_prefix = get_path_info("../", "abspath") 61 62v8_inspector_js_protocol = v8_path_prefix + "/src/inspector/js_protocol.json" 63 64############################################################################### 65# Templates 66# 67 68# Common configs to remove or add in all v8 targets. 69v8_remove_configs = [ "//build/config/compiler:chromium_code" ] 70v8_add_configs = [ 71 "//build/config/compiler:no_chromium_code", 72 v8_path_prefix + ":features", 73 v8_path_prefix + ":toolchain", 74] 75 76if (is_debug && !v8_optimized_debug) { 77 v8_remove_configs += [ "//build/config/compiler:default_optimization" ] 78 v8_add_configs += [ "//build/config/compiler:no_optimize" ] 79} else { 80 v8_remove_configs += [ "//build/config/compiler:default_optimization" ] 81 82 # TODO(crbug.com/621335) Rework this so that we don't have the confusion 83 # between "optimize_speed" and "optimize_max". 84 if (is_posix && !is_android && !using_sanitizer) { 85 v8_add_configs += [ "//build/config/compiler:optimize_speed" ] 86 } else { 87 v8_add_configs += [ "//build/config/compiler:optimize_max" ] 88 } 89} 90 91if (is_posix && v8_enable_backtrace) { 92 v8_remove_configs += [ "//build/config/gcc:symbol_visibility_hidden" ] 93 v8_add_configs += [ "//build/config/gcc:symbol_visibility_default" ] 94} 95 96# All templates should be kept in sync. 97template("v8_source_set") { 98 if (defined(v8_static_library) && v8_static_library) { 99 static_library(target_name) { 100 forward_variables_from(invoker, "*", [ "configs" ]) 101 configs += invoker.configs 102 configs -= v8_remove_configs 103 configs += v8_add_configs 104 } 105 } else { 106 source_set(target_name) { 107 forward_variables_from(invoker, "*", [ "configs" ]) 108 configs += invoker.configs 109 configs -= v8_remove_configs 110 configs += v8_add_configs 111 } 112 } 113} 114 115template("v8_header_set") { 116 source_set(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 124template("v8_executable") { 125 executable(target_name) { 126 forward_variables_from(invoker, 127 "*", 128 [ 129 "configs", 130 "remove_configs", 131 ]) 132 if (defined(invoker.remove_configs)) { 133 configs -= invoker.remove_configs 134 } 135 configs += invoker.configs 136 configs -= v8_remove_configs 137 configs += v8_add_configs 138 if (is_linux) { 139 # For enabling ASLR. 140 ldflags = [ "-pie" ] 141 } 142 } 143} 144 145template("v8_component") { 146 component(target_name) { 147 forward_variables_from(invoker, "*", [ "configs" ]) 148 configs += invoker.configs 149 configs -= v8_remove_configs 150 configs += v8_add_configs 151 } 152} 153