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

import("//build/config/gclient_args.gni")

declare_args() {
  # In standalone Dawn builds, don't try to use the hermetic install of Xcode
  # that Chromium uses
  use_system_xcode = ""

  # Android 32-bit non-component, non-clang builds cannot have symbol_level=2
  # due to 4GiB file size limit, see https://crbug.com/648948.
  ignore_elf32_limitations = false
}

# Enables assertions on safety checks in libc++.
enable_safe_libcxx = true

perfetto_build_with_embedder = true
perfetto_build_standalone = false
is_perfetto_build_generator = false

# Detect whether we can use the hermetic XCode like in Chromium and do so if
# possible.
if (host_os == "mac" && use_system_xcode == "") {
  _result = exec_script("//build/mac/should_use_hermetic_xcode.py",
                        [ target_os ],
                        "value")

  assert(_result != 2,
         "Do not allow building targets with the default" +
             "hermetic toolchain if the minimum OS version is not met.")
  assert(_result != 3,
         "iOS does not support building with a hermetic toolchain. " +
             "Please install Xcode.")

  use_system_xcode = _result != 1
} else if (host_os != "mac") {
  use_system_xcode = false
}

if (is_android) {
  limit_android_deps = true
  enable_java_templates = true
}
