blob: e76ec39fbbc8448ce23b1799618cca8426699e5a [file] [log] [blame]
import("//libcxx/config.gni")
import("//llvm/utils/gn/build/write_cmake_config.gni")
libcxx_generated_include_dir = "$root_build_dir/include/c++/v1"
# This is a bit weird. For now, we assume that __config_site is identical
# in all toolchains, and only copy it (and all other libcxx headers)
# to 'include' in the root build dir, so that it's the same for all toolchains.
# Maybe we want to make this per-toolchain eventually (and then use root_out_dir
# in libcxx_generated_include_dir) -- e.g. for cross-builds that for example
# use for-linux-configured libc++ for the host build but for-windows-configured
# libc++ for the target build.
if (current_toolchain == default_toolchain) {
write_cmake_config("write_config_site") {
input = "__config_site.in"
output = "$libcxx_generated_include_dir/__config_site"
values = [
"_LIBCPP_ABI_FORCE_ITANIUM=",
"_LIBCPP_ABI_FORCE_MICROSOFT=",
"_LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT=",
"_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY=",
"_LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE=",
"_LIBCPP_HAS_NO_STDIN=",
"_LIBCPP_HAS_NO_STDOUT=",
"_LIBCPP_HAS_NO_THREADS=",
"_LIBCPP_HAS_NO_MONOTONIC_CLOCK=",
"_LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS=",
"_LIBCPP_HAS_MUSL_LIBC=",
"_LIBCPP_HAS_THREAD_API_PTHREAD=",
"_LIBCPP_HAS_THREAD_API_EXTERNAL=",
"_LIBCPP_HAS_THREAD_API_WIN32=",
"_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL=",
"_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS=",
"_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS=1",
"_LIBCPP_NO_VCRUNTIME=",
"_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION=",
"_LIBCPP_HAS_PARALLEL_ALGORITHMS=",
"_LIBCPP_HAS_NO_RANDOM_DEVICE=",
"_LIBCPP_HAS_NO_LOCALIZATION=",
"_LIBCPP_ABI_DEFINES=",
]
if (libcxx_abi_version != 1) {
values += [ "_LIBCPP_ABI_VERSION=$libcxx_abi_version" ]
} else {
values += [ "_LIBCPP_ABI_VERSION=" ]
}
if (libcxx_abi_namespace != "") {
values += [ "_LIBCPP_ABI_NAMESPACE=$libcxx_abi_namespace" ]
} else {
values += [ "_LIBCPP_ABI_NAMESPACE=" ]
}
if (libcxx_abi_unstable) {
values += [ "_LIBCPP_ABI_UNSTABLE=1" ]
} else {
values += [ "_LIBCPP_ABI_UNSTABLE=" ]
}
}
copy("copy_headers") {
sources = [
"__availability",
"__bit_reference",
"__bits",
"__bsd_locale_defaults.h",
"__bsd_locale_fallbacks.h",
"__config",
"__debug",
"__errc",
"__functional_03",
"__functional_base",
"__functional_base_03",
"__hash_table",
"__iterator/concepts.h",
"__iterator/incrementable_traits.h",
"__iterator/iter_move.h",
"__iterator/iterator_traits.h",
"__iterator/readable_traits.h",
"__libcpp_version",
"__locale",
"__memory/addressof.h",
"__memory/allocation_guard.h",
"__memory/allocator.h",
"__memory/allocator_traits.h",
"__memory/auto_ptr.h",
"__memory/compressed_pair.h",
"__memory/construct_at.h",
"__memory/pointer_safety.h",
"__memory/pointer_traits.h",
"__memory/raw_storage_iterator.h",
"__memory/shared_ptr.h",
"__memory/temporary_buffer.h",
"__memory/uninitialized_algorithms.h",
"__memory/unique_ptr.h",
"__mutex_base",
"__node_handle",
"__nullptr",
"__ranges/access.h",
"__ranges/concepts.h",
"__ranges/enable_borrowed_range.h",
"__ranges/size.h",
"__ranges/view.h",
"__split_buffer",
"__sso_allocator",
"__std_stream",
"__string",
"__support/android/locale_bionic.h",
"__support/fuchsia/xlocale.h",
"__support/ibm/gettod_zos.h",
"__support/ibm/limits.h",
"__support/ibm/locale_mgmt_aix.h",
"__support/ibm/locale_mgmt_zos.h",
"__support/ibm/nanosleep.h",
"__support/ibm/support.h",
"__support/ibm/xlocale.h",
"__support/musl/xlocale.h",
"__support/newlib/xlocale.h",
"__support/nuttx/xlocale.h",
"__support/openbsd/xlocale.h",
"__support/solaris/floatingpoint.h",
"__support/solaris/wchar.h",
"__support/solaris/xlocale.h",
"__support/win32/limits_msvc_win32.h",
"__support/win32/locale_win32.h",
"__support/xlocale/__nop_locale_mgmt.h",
"__support/xlocale/__posix_l_fallback.h",
"__support/xlocale/__strtonum_fallback.h",
"__threading_support",
"__tree",
"__tuple",
"__undef_macros",
"__utility/to_underlying.h",
"algorithm",
"any",
"array",
"atomic",
"barrier",
"bit",
"bitset",
"cassert",
"ccomplex",
"cctype",
"cerrno",
"cfenv",
"cfloat",
"charconv",
"chrono",
"cinttypes",
"ciso646",
"climits",
"clocale",
"cmath",
"codecvt",
"compare",
"complex",
"complex.h",
"concepts",
"condition_variable",
"csetjmp",
"csignal",
"cstdarg",
"cstdbool",
"cstddef",
"cstdint",
"cstdio",
"cstdlib",
"cstring",
"ctgmath",
"ctime",
"ctype.h",
"cwchar",
"cwctype",
"deque",
"errno.h",
"exception",
"execution",
"experimental/__config",
"experimental/__memory",
"experimental/algorithm",
"experimental/coroutine",
"experimental/deque",
"experimental/filesystem",
"experimental/forward_list",
"experimental/functional",
"experimental/iterator",
"experimental/list",
"experimental/map",
"experimental/memory_resource",
"experimental/propagate_const",
"experimental/regex",
"experimental/set",
"experimental/simd",
"experimental/string",
"experimental/type_traits",
"experimental/unordered_map",
"experimental/unordered_set",
"experimental/utility",
"experimental/vector",
"ext/__hash",
"ext/hash_map",
"ext/hash_set",
"fenv.h",
"filesystem",
"float.h",
"format",
"forward_list",
"fstream",
"functional",
"future",
"initializer_list",
"inttypes.h",
"iomanip",
"ios",
"iosfwd",
"iostream",
"istream",
"iterator",
"latch",
"limits",
"limits.h",
"list",
"locale",
"locale.h",
"map",
"math.h",
"memory",
"module.modulemap",
"mutex",
"new",
"numbers",
"numeric",
"optional",
"ostream",
"queue",
"random",
"ratio",
"regex",
"scoped_allocator",
"semaphore",
"set",
"setjmp.h",
"shared_mutex",
"span",
"sstream",
"stack",
"stdbool.h",
"stddef.h",
"stdexcept",
"stdint.h",
"stdio.h",
"stdlib.h",
"streambuf",
"string",
"string.h",
"string_view",
"strstream",
"system_error",
"tgmath.h",
"thread",
"tuple",
"type_traits",
"typeindex",
"typeinfo",
"unordered_map",
"unordered_set",
"utility",
"valarray",
"variant",
"vector",
"version",
"wchar.h",
"wctype.h",
]
deps = [ ":write_config_site" ]
if (target_os != "mac" && target_os != "win") {
# libcxx/cmake/Modules/HandleLibCXXABI.cmake sets
# LIBCXX_CXX_ABI_HEADER_TARGET if the libcxx abi library either of
# "libstdc++", "libsupc++", "libcxxabi", "libcxxrt", but not if it's "none",
# "default", or "vcruntime". So on Windows, these don't get copied due to
# LIBCXX_CXX_ABI_HEADER_TARGET not being set.
# On macOS, libcxx/CMakeLists.txt sets LIBCXX_CXX_ABI_SYSTEM to 1, which
# causes an empty header list to be passed to setup_abi_lib, so these
# don't get copied on macOS due to that.
deps += [ "//libcxxabi/include" ]
}
outputs = [ "$root_build_dir/include/c++/v1/{{source_target_relative}}" ]
}
}
config("include_config") {
include_dirs = [ libcxx_generated_include_dir ]
}
group("include") {
deps = [ ":copy_headers($default_toolchain)" ]
public_configs = [ ":include_config" ]
}