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