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