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