# Copyright 2020 The Tint Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import("//build_overrides/tint.gni")

# This file contains Tint-related build flags.

if (!defined(tint_has_build)) {
  tint_has_build = true
}

tint_has_fuzzers = tint_has_build

declare_args() {
  # Path to tint checkout
  if (!defined(tint_root_dir)) {
    tint_root_dir = "//"
  }

  # Path to spirv-tools checkout
  if (!defined(tint_spirv_tools_dir)) {
    tint_spirv_tools_dir = "//third_party/vulkan-deps/spirv-tools/src"
  }

  # Path to glslang checkout
  if (!defined(tint_glslang_dir)) {
    tint_glslang_dir = "//third_party/vulkan-deps/glslang/src"
  }

  # Path to googletest checkout
  if (!defined(tint_googletest_dir)) {
    tint_googletest_dir = "//third_party/googletest"
  }

  # Path to spirv-headers checkout
  if (!defined(tint_spirv_headers_dir)) {
    tint_spirv_headers_dir = "//third_party/vulkan-deps/spirv-headers/src"
  }

  # Build the SPIR-V input reader
  if (!defined(tint_build_spv_reader)) {
    tint_build_spv_reader = true
  }

  # Build the SPIR-V output writer
  if (!defined(tint_build_spv_writer)) {
    tint_build_spv_writer = true
  }

  # Build the WGSL input reader
  if (!defined(tint_build_wgsl_reader)) {
    tint_build_wgsl_reader = true
  }

  # Build the WGSL output writer
  if (!defined(tint_build_wgsl_writer)) {
    tint_build_wgsl_writer = true
  }

  # Build the MSL output writer
  if (!defined(tint_build_msl_writer)) {
    tint_build_msl_writer = true
  }

  # Build the HLSL output writer
  if (!defined(tint_build_hlsl_writer)) {
    tint_build_hlsl_writer = true
  }

  # Build the GLSL output writer
  if (!defined(tint_build_glsl_writer)) {
    tint_build_glsl_writer = true
  }

  # Build the Syntax Tree writer
  if (!defined(tint_build_syntax_tree_writer)) {
    tint_build_syntax_tree_writer = false
  }

  # Build unittests
  if (!defined(tint_build_unittests)) {
    tint_build_unittests = true
  }

  # Build benchmarks
  if (!defined(tint_build_benchmarks)) {
    tint_build_benchmarks = true
  }
}

declare_args() {
  # Directory holding tint source
  if (!defined(tint_src_dir)) {
    tint_src_dir = "${tint_root_dir}/src/tint"
  }
}
