Home | History | Annotate | Download | only in gni
      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/sanitizers/sanitizers.gni")
      6 import("//build_overrides/v8.gni")
      7 import("//third_party/icu/config.gni")
      8 import("v8.gni")
      9 
     10 declare_args() {
     11   # Sets the test isolation mode (noop|prepare|check).
     12   v8_test_isolation_mode = "noop"
     13 }
     14 
     15 template("v8_isolate_run") {
     16   forward_variables_from(invoker,
     17                          "*",
     18                          [
     19                            "deps",
     20                            "isolate",
     21                          ])
     22 
     23   # Remember target name as within the action scope the target name will be
     24   # different.
     25   name = target_name
     26 
     27   assert(defined(invoker.deps))
     28   assert(defined(invoker.isolate))
     29 
     30   if (name != "" && v8_test_isolation_mode != "noop") {
     31     action(name + "_run") {
     32       testonly = true
     33 
     34       deps = invoker.deps
     35 
     36       script = "//tools/isolate_driver.py"
     37 
     38       sources = [
     39         invoker.isolate,
     40       ]
     41 
     42       inputs = [
     43         # Files that are known to be involved in this step.
     44         "//tools/swarming_client/isolate.py",
     45         "//tools/swarming_client/run_isolated.py",
     46       ]
     47 
     48       if (v8_test_isolation_mode == "prepare") {
     49         outputs = [
     50           "$root_out_dir/$name.isolated.gen.json",
     51         ]
     52       } else if (v8_test_isolation_mode == "check") {
     53         outputs = [
     54           "$root_out_dir/$name.isolated",
     55           "$root_out_dir/$name.isolated.state",
     56         ]
     57       }
     58 
     59       # Translate gn to gyp variables.
     60       if (is_asan) {
     61         asan = "1"
     62       } else {
     63         asan = "0"
     64       }
     65       if (is_msan) {
     66         msan = "1"
     67       } else {
     68         msan = "0"
     69       }
     70       if (is_tsan) {
     71         tsan = "1"
     72       } else {
     73         tsan = "0"
     74       }
     75       if (is_cfi) {
     76         cfi_vptr = "1"
     77       } else {
     78         cfi_vptr = "0"
     79       }
     80       if (target_cpu == "x86") {
     81         target_arch = "ia32"
     82       } else {
     83         target_arch = target_cpu
     84       }
     85       if (is_debug) {
     86         configuration_name = "Debug"
     87       } else {
     88         configuration_name = "Release"
     89       }
     90       if (is_component_build) {
     91         component = "shared_library"
     92       } else {
     93         component = "static_library"
     94       }
     95       if (icu_use_data_file) {
     96         icu_use_data_file_flag = "1"
     97       } else {
     98         icu_use_data_file_flag = "0"
     99       }
    100       if (v8_enable_inspector_override) {
    101         enable_inspector = "1"
    102       } else {
    103         enable_inspector = "0"
    104       }
    105       if (v8_use_external_startup_data) {
    106         use_external_startup_data = "1"
    107       } else {
    108         use_external_startup_data = "0"
    109       }
    110       if (v8_use_snapshot) {
    111         use_snapshot = "true"
    112       } else {
    113         use_snapshot = "false"
    114       }
    115       if (v8_has_valgrind) {
    116         has_valgrind = "1"
    117       } else {
    118         has_valgrind = "0"
    119       }
    120       if (v8_gcmole) {
    121         gcmole = "1"
    122       } else {
    123         gcmole = "0"
    124       }
    125 
    126       # Note, all paths will be rebased in isolate_driver.py to be relative to
    127       # the isolate file.
    128       args = [
    129         v8_test_isolation_mode,
    130         "--isolated",
    131         rebase_path("$root_out_dir/$name.isolated", root_build_dir),
    132         "--isolate",
    133         rebase_path(invoker.isolate, root_build_dir),
    134 
    135         # Path variables are used to replace file paths when loading a .isolate
    136         # file
    137         "--path-variable",
    138         "DEPTH",
    139         rebase_path("//", root_build_dir),
    140         "--path-variable",
    141         "PRODUCT_DIR",
    142         rebase_path(root_out_dir, root_build_dir),
    143 
    144         # TODO(machenbach): Set variables for remaining features.
    145         "--config-variable",
    146         "CONFIGURATION_NAME=$configuration_name",
    147         "--config-variable",
    148         "OS=$target_os",
    149         "--config-variable",
    150         "asan=$asan",
    151         "--config-variable",
    152         "cfi_vptr=$cfi_vptr",
    153         "--config-variable",
    154         "gcmole=$gcmole",
    155         "--config-variable",
    156         "has_valgrind=$has_valgrind",
    157         "--config-variable",
    158         "icu_use_data_file_flag=$icu_use_data_file_flag",
    159         "--config-variable",
    160         "is_gn=1",
    161         "--config-variable",
    162         "msan=$msan",
    163         "--config-variable",
    164         "tsan=$tsan",
    165         "--config-variable",
    166         "coverage=0",
    167         "--config-variable",
    168         "sanitizer_coverage=0",
    169         "--config-variable",
    170         "component=$component",
    171         "--config-variable",
    172         "target_arch=$target_arch",
    173         "--config-variable",
    174         "v8_enable_inspector=$enable_inspector",
    175         "--config-variable",
    176         "v8_use_external_startup_data=$use_external_startup_data",
    177         "--config-variable",
    178         "v8_use_snapshot=$use_snapshot",
    179       ]
    180 
    181       if (is_win) {
    182         args += [
    183           "--config-variable",
    184           "msvs_version=2013",
    185         ]
    186       } else {
    187         args += [
    188           "--config-variable",
    189           "msvs_version=0",
    190         ]
    191       }
    192     }
    193   }
    194 }
    195