# 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/dawn_overrides_with_defaults.gni")
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_msl_writer) {
  libtint_source_set("writer") {
    sources = [
      "output.cc",
      "output.h",
      "writer.cc",
      "writer.h",
    ]
    deps = [
      "${dawn_root}/src/utils:utils",
      "${tint_src_dir}/api/common",
      "${tint_src_dir}/lang/core",
      "${tint_src_dir}/lang/core/common",
      "${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/features",
      "${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/generator",
      "${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_msl_writer) {
      deps += [
        "${tint_src_dir}/lang/msl/writer/ast_printer",
        "${tint_src_dir}/lang/msl/writer/common",
        "${tint_src_dir}/lang/msl/writer/printer",
        "${tint_src_dir}/lang/msl/writer/raise",
      ]
    }
  }
}
if (tint_build_unittests) {
  if (tint_build_msl_writer) {
    tint_unittests_source_set("unittests") {
      sources = [
        "binary_test.cc",
        "constant_test.cc",
        "discard_test.cc",
        "function_test.cc",
        "helper_test.h",
        "if_test.cc",
        "let_test.cc",
        "loop_test.cc",
        "return_test.cc",
        "type_test.cc",
        "var_test.cc",
        "writer_test.cc",
      ]
      deps = [
        "${dawn_root}/src/utils:utils",
        "${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_msl_writer) {
        deps += [
          "${tint_src_dir}/lang/msl/validate",
          "${tint_src_dir}/lang/msl/writer",
          "${tint_src_dir}/lang/msl/writer/common",
        ]
      }
    }
  }
}
if (tint_build_benchmarks) {
  if (tint_build_msl_writer && tint_build_wgsl_reader) {
    tint_benchmarks_source_set("bench") {
      sources = [ "writer_bench.cc" ]
      deps = [
        "${dawn_root}/src/utils:utils",
        "${tint_src_dir}:google_benchmark",
        "${tint_src_dir}/api/common",
        "${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/common",
        "${tint_src_dir}/lang/wgsl/features",
        "${tint_src_dir}/lang/wgsl/helpers",
        "${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_msl_writer) {
        deps += [
          "${tint_src_dir}/lang/msl/writer",
          "${tint_src_dir}/lang/msl/writer/common",
          "${tint_src_dir}/lang/msl/writer/helpers",
        ]
      }

      if (tint_build_wgsl_reader) {
        deps += [
          "${tint_src_dir}/cmd/bench:bench",
          "${tint_src_dir}/lang/wgsl/reader",
        ]
      }
    }
  }
}
if (tint_build_msl_writer) {
  tint_fuzz_source_set("fuzz") {
    sources = [ "writer_fuzz.cc" ]
    deps = [
      "${dawn_root}/src/utils:utils",
      "${tint_src_dir}/api/common",
      "${tint_src_dir}/cmd/fuzz/ir:fuzz",
      "${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/features",
      "${tint_src_dir}/lang/wgsl/program",
      "${tint_src_dir}/lang/wgsl/sem",
      "${tint_src_dir}/utils/bytes",
      "${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_msl_writer) {
      deps += [
        "${tint_src_dir}/lang/msl/writer",
        "${tint_src_dir}/lang/msl/writer/common",
        "${tint_src_dir}/lang/msl/writer/helpers",
      ]
    }

    if (tint_build_wgsl_reader) {
      sources += [ "writer_ast_fuzz.cc" ]
      deps += [ "${tint_src_dir}/cmd/fuzz/wgsl:fuzz" ]
    }
  }
}
