# Copyright 2022 The Dawn & Tint Authors
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
#    list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
#    this list of conditions and the following disclaimer in the documentation
#    and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its
#    contributors may be used to endorse or promote products derived from
#    this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# Note: This file is intentionally not used by any other BUILD.gn in Dawn.
# Instead, Chromium depends directly on this file to build the WebGPU CTS.
# Scripts called from this file assume Dawn is checked out inside Chromium.

import("../../../scripts/dawn_overrides_with_defaults.gni")

group("webgpu-cts") {
  public_deps = [
    ":compile_src",
    ":copy_resources",
    ":verify_gen_ts_dep_list",
  ]
  data = [ "test_list.txt" ]
}

list_from_ts_sources_txt = read_file("ts_sources.txt", "list lines")

ts_source_inputs = [ "../../webgpu-cts/tsconfig.json" ]
foreach(file, list_from_ts_sources_txt) {
  ts_source_inputs += [ "../../webgpu-cts/$file" ]
}

js_outputs = []
foreach(ts_file, filter_exclude(list_from_ts_sources_txt, [ "*.d.ts" ])) {
  js_file = string_replace(ts_file, ".ts", ".js")
  js_node_file = string_replace(js_file, "src/", "src-node/")

  js_outputs += [ "$target_gen_dir/../../webgpu-cts/$js_file" ]

  if (js_node_file != "src-node/common/runtime/wpt.js" &&
      js_node_file != "src-node/common/runtime/standalone.js" &&
      js_node_file != "src-node/common/runtime/helper/test_worker.js" &&
      js_node_file !=
      "src-node/webgpu/web_platform/worker/worker_launcher.js") {
    js_outputs += [ "$target_gen_dir/../../webgpu-cts/$js_node_file" ]
  }
}

action("compile_src") {
  script = "${dawn_root}/webgpu-cts/scripts/compile_src.py"

  inputs = [
             "//third_party/node/node_modules/typescript/lib/tsc.js",
             "//third_party/node/node.py",
             "${dawn_root}/webgpu-cts/scripts/tsc_ignore_errors.py",

             # If the only change is that a file is deleted, we still need to
             # rebuild so that listing.js gets updated.
             "ts_sources.txt",
           ] + ts_source_inputs

  outputs = js_outputs
  data = js_outputs

  args = [ rebase_path("$target_gen_dir/../../webgpu-cts", root_build_dir) ]
}

list_from_resource_files_txt = read_file("resource_files.txt", "list lines")
resource_file_inputs = []
foreach(file, list_from_resource_files_txt) {
  resource_file_inputs += [ "$file" ]
}

action("copy_resources") {
  # Note: We use a python script to perform the copy here instead of a "copy"
  # action because of limitations of source expansions. This copy needs to:
  # * move files to outside the target's directory
  # * remove '/src/' from within the path
  # * copy subdirectories.
  # It does not seem possible to do all of these things with a source expansion.
  src_dir = "../../webgpu-cts/src/resources/"
  dst_dir = "$target_gen_dir/../../webgpu-cts/resources/"

  inputs = []
  outputs = [ "$target_out_dir/run_$target_name.stamp" ]
  foreach(resource_file, resource_file_inputs) {
    inputs += [ "$src_dir/$resource_file" ]
    outputs += [ "$dst_dir/$resource_file" ]
  }
  data = outputs

  script = "${dawn_root}/webgpu-cts/scripts/copy_files.py"
  args = [
    "--src_dir",
    rebase_path(src_dir, root_build_dir),
    "--dst_dir",
    rebase_path(dst_dir, root_build_dir),
    "--file_list",
    rebase_path("resource_files.txt", root_build_dir),
    "--stamp",
    rebase_path(outputs[0], root_build_dir),
  ]
}

action("verify_gen_ts_dep_list") {
  script = "${dawn_root}/webgpu-cts/scripts/gen_ts_dep_lists.py"
  inputs = [
    "../../../DEPS",
    "resource_files.txt",
    "ts_sources.txt",
  ]
  outputs = [ "$target_out_dir/run_$target_name.stamp" ]
  args = [
    "--check",
    "--stamp",
    rebase_path(outputs[0], root_build_dir),
  ]
}
