Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame] | 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 | |
| 5 | import("//build/config/v8_target_cpu.gni") |
| 6 | import("//build/config/sanitizers/sanitizers.gni") |
| 7 | |
| 8 | declare_args() { |
| 9 | # Turns on compiler optimizations in V8 in Debug build. |
| 10 | v8_optimized_debug = true |
| 11 | |
| 12 | # Enable the snapshot feature, for fast context creation. |
| 13 | # http://v8project.blogspot.com/2015/09/custom-startup-snapshots.html |
| 14 | v8_use_snapshot = true |
| 15 | |
| 16 | # Use external files for startup data blobs: |
| 17 | # the JS builtins sources and the start snapshot. |
| 18 | v8_use_external_startup_data = !is_ios |
| 19 | } |
| 20 | |
| 21 | ############################################################################### |
| 22 | # Templates |
| 23 | # |
| 24 | |
| 25 | # Points to // in v8 stand-alone or to //v8/ in chromium. We need absolute |
| 26 | # paths for all configs in templates as they are shared in different |
| 27 | # subdirectories. |
| 28 | path_prefix = get_path_info("../", "abspath") |
| 29 | |
| 30 | # Common configs to remove or add in all v8 targets. |
| 31 | remove_configs = [ "//build/config/compiler:chromium_code" ] |
| 32 | add_configs = [ |
| 33 | "//build/config/compiler:no_chromium_code", |
| 34 | path_prefix + ":features", |
| 35 | path_prefix + ":toolchain", |
| 36 | ] |
| 37 | |
| 38 | if (is_debug && !v8_optimized_debug) { |
| 39 | remove_configs += [ "//build/config/compiler:default_optimization" ] |
| 40 | add_configs += [ "//build/config/compiler:no_optimize" ] |
| 41 | } else { |
| 42 | remove_configs += [ "//build/config/compiler:default_optimization" ] |
| 43 | |
| 44 | # TODO(crbug.com/621335) Rework this so that we don't have the confusion |
| 45 | # between "optimize_speed" and "optimize_max". |
| 46 | if (is_posix && !is_android && !is_nacl && !using_sanitizer) { |
| 47 | add_configs += [ "//build/config/compiler:optimize_speed" ] |
| 48 | } else { |
| 49 | add_configs += [ "//build/config/compiler:optimize_max" ] |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | # All templates should be kept in sync. |
| 54 | template("v8_source_set") { |
| 55 | source_set(target_name) { |
| 56 | forward_variables_from(invoker, "*", [ "configs" ]) |
| 57 | configs += invoker.configs |
| 58 | configs -= remove_configs |
| 59 | configs += add_configs |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | template("v8_executable") { |
| 64 | executable(target_name) { |
| 65 | forward_variables_from(invoker, "*", [ "configs" ]) |
| 66 | configs += invoker.configs |
| 67 | configs -= remove_configs |
| 68 | configs += add_configs |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | template("v8_component") { |
| 73 | component(target_name) { |
| 74 | forward_variables_from(invoker, "*", [ "configs" ]) |
| 75 | configs += invoker.configs |
| 76 | configs -= remove_configs |
| 77 | configs += add_configs |
| 78 | } |
| 79 | } |