llvm/llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn

import("//clang/lib/ARCMigrate/enable.gni")
import("//clang/lib/StaticAnalyzer/Frontend/enable.gni")
import("//llvm/utils/gn/build/libs/xml/enable.gni")
import("//llvm/utils/gn/build/write_cmake_config.gni")
import("//llvm/version.gni")

write_cmake_config("Config") {
  input = "config.h.cmake"
  output = "$target_gen_dir/config.h"
  values = [
    "BUG_REPORT_URL=https://github.com/llvm/llvm-project/issues/",
    "CLANG_DEFAULT_PIE_ON_LINUX=1",
    "CLANG_DEFAULT_LINKER=",
    "CLANG_DEFAULT_CXX_STDLIB=",
    "CLANG_DEFAULT_RTLIB=",
    "CLANG_DEFAULT_OBJCOPY=objcopy",
    "CLANG_DEFAULT_OPENMP_RUNTIME=libomp",
    "CLANG_DEFAULT_UNWINDLIB=",
    "CLANG_INSTALL_LIBDIR_BASENAME=lib",
    "CLANG_RESOURCE_DIR=",
    "C_INCLUDE_DIRS=",
    "CLANG_CONFIG_FILE_SYSTEM_DIR=",
    "CLANG_CONFIG_FILE_USER_DIR=",
    "CLANG_SPAWN_CC1=",
    "DEFAULT_SYSROOT=",
    "GCC_INSTALL_PREFIX=",
    "ENABLE_LINKER_BUILD_ID=",
    "ENABLE_X86_RELAX_RELOCATIONS=1",
    "CLANG_ENABLE_OBJC_REWRITER=1",  # FIXME: flag?
    "CLANG_ENABLE_CIR=",
    "CLANG_SYSTEMZ_DEFAULT_ARCH=z10",
    "PPC_LINUX_DEFAULT_IEEELONGDOUBLE=",
  ]

  if (clang_enable_arcmt) {
    values += [ "CLANG_ENABLE_ARCMT=1" ]
  } else {
    values += [ "CLANG_ENABLE_ARCMT=" ]
  }

  if (clang_enable_static_analyzer) {
    values += [ "CLANG_ENABLE_STATIC_ANALYZER=1" ]
  } else {
    values += [ "CLANG_ENABLE_STATIC_ANALYZER=" ]
  }

  if (host_os != "win") {
    values += [
      "CLANG_HAVE_DLADDR=1",
      "CLANG_HAVE_DLFCN_H=1",
      "CLANG_HAVE_RLIMITS=1",
    ]
  } else {
    values += [
      "CLANG_HAVE_DLADDR=",
      "CLANG_HAVE_DLFCN_H=",
      "CLANG_HAVE_RLIMITS=",
    ]
  }

  if (llvm_enable_libxml2) {
    values += [ "CLANG_HAVE_LIBXML=1" ]
  } else {
    values += [ "CLANG_HAVE_LIBXML=" ]
  }

  if (host_os == "mac") {
    # FIXME: Hardcoding this isn't great, but assuming that the host ld version
    # has anything to do with the ld version where the built clang will run
    # isn't either. Probably want to make this a declare_args.
    values += [ "HOST_LINK_VERSION=305" ]
  } else {
    values += [ "HOST_LINK_VERSION=" ]
  }
}