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
3 # found in the LICENSE file.
5 import("//build/module_args/v8.gni")
8 assert(defined(invoker.test_type) &&
9 (invoker.test_type == "webui" || invoker.test_type == "unit" ||
10 invoker.test_type == "extension"))
11 action_name = target_name + "_action"
12 source_set_name = target_name
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}}"
17 action_foreach(action_name) {
19 visibility = [ ":$source_set_name" ]
20 script = "//tools/gypv8sh.py"
22 sources = invoker.sources
24 d8_path = get_label_info("//v8:d8($host_toolchain)", "root_out_dir") + "/d8"
30 "//chrome/third_party/mock4js/mock4js.js",
31 "//chrome/test/data/webui/test_api.js",
32 "//chrome/test/base/js2gtest.js",
34 inputs = [ d8_path ] + input_js
35 if (defined(invoker.deps_js)) {
36 inputs += [ invoker.deps_js ]
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.
43 "$target_gen_dir/{{source_name_part}}-gen.cc",
44 copied_source_pattern,
46 data = process_file_template(sources, [ copied_source_pattern ])
49 if (defined(invoker.deps_js)) {
52 rebase_path(invoker.deps_js, root_build_dir),
56 # Need "./" for script to find binary (cur dir is not on path).
57 "./" + rebase_path(d8_path, root_build_dir),
59 args += rebase_path(input_js, root_build_dir) + [ invoker.test_type ]
60 if (v8_use_external_startup_data) {
61 args += [ "--external=y" ]
63 args += [ "--external=n" ]
67 "{{source_root_relative_dir}}/{{source_file_part}}",
69 args += rebase_path(outputs, root_build_dir)
72 "//v8:d8($host_toolchain)",
74 if (defined(invoker.deps)) {
79 if (defined(invoker.extra_js_files)) {
80 copy_target_name = target_name + "_copy"
81 copy(copy_target_name) {
82 visibility = [ ":$source_set_name" ]
83 sources = invoker.extra_js_files
85 copied_source_pattern,
90 source_set(source_set_name) {
92 forward_variables_from(invoker,
97 sources = get_target_outputs(":$action_name")
101 # The generator implicitly makes includes from these targets.
102 "//chrome/test:test_support",
107 if (defined(invoker.deps)) {
110 if (defined(invoker.extra_js_files)) {
111 data_deps = [ ":$copy_target_name" ]