1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
# Copyright 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/module_args/v8.gni")
template("js2gtest") {
assert(defined(invoker.test_type) &&
(invoker.test_type == "webui" || invoker.test_type == "unit" ||
invoker.test_type == "extension"))
action_name = target_name + "_action"
source_set_name = target_name
action_foreach(action_name) {
testonly = true
visibility = [ ":$source_set_name" ]
script = "//tools/gypv8sh.py"
sources = invoker.sources
d8_path = get_label_info("//v8:d8($host_toolchain)", "root_out_dir") + "/d8"
if (is_win) {
d8_path += ".exe"
}
input_js = [
"//chrome/third_party/mock4js/mock4js.js",
"//chrome/test/data/webui/test_api.js",
"//chrome/test/base/js2gtest.js",
]
inputs = [ d8_path ] + input_js
if (defined(invoker.deps_js)) {
inputs += [ invoker.deps_js ]
}
outputs = [
"$target_gen_dir/{{source_name_part}}-gen.cc",
"$root_out_dir/test_data/{{source_root_relative_dir}}/{{source_file_part}}",
]
args = []
if (defined(invoker.deps_js)) {
args += [
"--deps_js",
rebase_path(invoker.deps_js, root_build_dir),
]
}
args += [
# Need "./" for script to find binary (cur dir is not on path).
"./" + rebase_path(d8_path, root_build_dir),
]
args += rebase_path(input_js, root_build_dir) + [ invoker.test_type ]
if (v8_use_external_startup_data) {
args += [ "--external=y" ]
} else {
args += [ "--external=n" ]
}
args += [
"{{source}}",
"{{source_root_relative_dir}}/{{source_file_part}}",
]
args += rebase_path(outputs, root_build_dir)
deps = [
"//v8:d8($host_toolchain)",
]
if (defined(invoker.deps)) {
deps += invoker.deps
}
}
if (defined(invoker.extra_js_files)) {
copy_target_name = target_name + "_copy"
copy(copy_target_name) {
visibility = [ ":$source_set_name" ]
sources = invoker.extra_js_files
outputs = [
"$root_out_dir/test_data/{{source_root_relative_dir}}/{{source_file_part}}",
]
}
}
source_set(source_set_name) {
testonly = true
if (defined(invoker.visibility)) {
visibility = invoker.visibility
}
sources = get_target_outputs(":$action_name")
if (defined(invoker.defines)) {
defines = invoker.defines
}
deps = [
":$action_name",
# The generator implicitly makes includes from these targets.
"//chrome/test:test_support",
"//testing/gmock",
"//testing/gtest",
"//url",
]
if (defined(invoker.deps)) {
deps += invoker.deps
}
if (defined(invoker.extra_js_files)) {
data_deps = [ ":$copy_target_name" ]
}
}
}
|