# Copyright 2023 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.

################################################################################
# File generated by 'tools/src/cmd/gen' using the template:
#   tools/src/cmd/gen/build/BUILD.gn.tmpl
#
# To regenerate run: './tools/run gen'
#
#                       Do not modify this file directly
################################################################################

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

import("${tint_src_dir}/tint.gni")

if (tint_build_unittests || tint_build_benchmarks) {
  import("//testing/test.gni")
}
if (tint_build_spv_writer) {
  libtint_source_set("writer") {
    sources = [
      "output.h",
      "writer.cc",
      "writer.h",
    ]
    deps = [
      "${tint_src_dir}/api/common",
      "${tint_src_dir}/api/options",
      "${tint_src_dir}/lang/core",
      "${tint_src_dir}/lang/core/constant",
      "${tint_src_dir}/lang/core/ir",
      "${tint_src_dir}/lang/core/type",
      "${tint_src_dir}/lang/wgsl",
      "${tint_src_dir}/lang/wgsl/ast",
      "${tint_src_dir}/lang/wgsl/program",
      "${tint_src_dir}/lang/wgsl/reader/lower",
      "${tint_src_dir}/lang/wgsl/sem",
      "${tint_src_dir}/utils/containers",
      "${tint_src_dir}/utils/diagnostic",
      "${tint_src_dir}/utils/ice",
      "${tint_src_dir}/utils/id",
      "${tint_src_dir}/utils/macros",
      "${tint_src_dir}/utils/math",
      "${tint_src_dir}/utils/memory",
      "${tint_src_dir}/utils/reflection",
      "${tint_src_dir}/utils/result",
      "${tint_src_dir}/utils/rtti",
      "${tint_src_dir}/utils/symbol",
      "${tint_src_dir}/utils/text",
      "${tint_src_dir}/utils/traits",
    ]

    if (tint_build_spv_reader || tint_build_spv_writer) {
      deps += [ "${tint_spirv_headers_dir}:spv_headers" ]
    }

    if (tint_build_spv_writer) {
      deps += [
        "${tint_src_dir}/lang/spirv/writer/ast_printer",
        "${tint_src_dir}/lang/spirv/writer/common",
        "${tint_src_dir}/lang/spirv/writer/printer",
        "${tint_src_dir}/lang/spirv/writer/raise",
      ]
    }

    if (tint_build_wgsl_reader) {
      deps += [ "${tint_src_dir}/lang/wgsl/reader/program_to_ir" ]
    }
  }
}
if (tint_build_unittests) {
  if (tint_build_spv_writer) {
    tint_unittests_source_set("unittests") {
      sources = [
        "access_test.cc",
        "atomic_builtin_test.cc",
        "binary_test.cc",
        "bitcast_test.cc",
        "builtin_test.cc",
        "constant_test.cc",
        "construct_test.cc",
        "convert_test.cc",
        "discard_test.cc",
        "function_test.cc",
        "if_test.cc",
        "let_test.cc",
        "loop_test.cc",
        "switch_test.cc",
        "swizzle_test.cc",
        "texture_builtin_test.cc",
        "type_test.cc",
        "unary_test.cc",
        "var_test.cc",
        "writer_test.cc",
      ]
      deps = [
        "${tint_src_dir}:gmock_and_gtest",
        "${tint_src_dir}/api/common",
        "${tint_src_dir}/lang/core",
        "${tint_src_dir}/lang/core/constant",
        "${tint_src_dir}/lang/core/intrinsic",
        "${tint_src_dir}/lang/core/ir",
        "${tint_src_dir}/lang/core/type",
        "${tint_src_dir}/utils/containers",
        "${tint_src_dir}/utils/diagnostic",
        "${tint_src_dir}/utils/ice",
        "${tint_src_dir}/utils/id",
        "${tint_src_dir}/utils/macros",
        "${tint_src_dir}/utils/math",
        "${tint_src_dir}/utils/memory",
        "${tint_src_dir}/utils/reflection",
        "${tint_src_dir}/utils/result",
        "${tint_src_dir}/utils/rtti",
        "${tint_src_dir}/utils/symbol",
        "${tint_src_dir}/utils/text",
        "${tint_src_dir}/utils/traits",
      ]

      if (tint_build_spv_reader || tint_build_spv_writer) {
        deps += [
          "${tint_spirv_headers_dir}:spv_headers",
          "${tint_spirv_tools_dir}:spvtools_headers",
          "${tint_spirv_tools_dir}:spvtools_val",
        ]
      }

      if (tint_build_spv_writer) {
        deps += [
          "${tint_src_dir}/lang/spirv/writer/common",
          "${tint_src_dir}/lang/spirv/writer/common:unittests",
          "${tint_src_dir}/lang/spirv/writer/printer",
          "${tint_src_dir}/lang/spirv/writer/raise",
        ]
      }
    }
  }
}
if (tint_build_benchmarks) {
  if (tint_build_spv_writer) {
    tint_unittests_source_set("bench") {
      sources = [ "writer_bench.cc" ]
      deps = [
        "${tint_src_dir}:google_benchmark",
        "${tint_src_dir}/api/common",
        "${tint_src_dir}/cmd/bench:bench",
        "${tint_src_dir}/lang/core",
        "${tint_src_dir}/lang/core/constant",
        "${tint_src_dir}/lang/core/type",
        "${tint_src_dir}/lang/wgsl",
        "${tint_src_dir}/lang/wgsl/ast",
        "${tint_src_dir}/lang/wgsl/program",
        "${tint_src_dir}/lang/wgsl/sem",
        "${tint_src_dir}/utils/containers",
        "${tint_src_dir}/utils/diagnostic",
        "${tint_src_dir}/utils/ice",
        "${tint_src_dir}/utils/id",
        "${tint_src_dir}/utils/macros",
        "${tint_src_dir}/utils/math",
        "${tint_src_dir}/utils/memory",
        "${tint_src_dir}/utils/reflection",
        "${tint_src_dir}/utils/result",
        "${tint_src_dir}/utils/rtti",
        "${tint_src_dir}/utils/symbol",
        "${tint_src_dir}/utils/text",
        "${tint_src_dir}/utils/traits",
      ]

      if (tint_build_spv_writer) {
        deps += [
          "${tint_src_dir}/lang/spirv/writer",
          "${tint_src_dir}/lang/spirv/writer/common",
        ]
      }
    }
  }
}
