Skip to content

Commit acea470

Browse files
committed
[gn build] Reorganize libcxx/include/BUILD.gn a bit
- Merge 6706342 -- no more libcxx_needs_site_config, we now always need it - Since it was always off in practice, write_config bitrot. Unbitrot it so that it works - Remove copy step and let concat step write to final location immediately -- and fix copy destination directory As a side effect, libcxx/include/BUILD.gn now has only a single sources list, which means the cmake sync script should be able to automatically sync additions and removals of .h files. On the flipside, this means this file now must be updated after most changes to libcxx/include/__config_site.in, and looking through the last few months of changes this looks like it's going to be a wash.
1 parent 6f0f022 commit acea470

File tree

1 file changed

+57
-46
lines changed
  • llvm/utils/gn/secondary/libcxx/include

1 file changed

+57
-46
lines changed

llvm/utils/gn/secondary/libcxx/include/BUILD.gn

Lines changed: 57 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,68 @@
1-
import("//clang/resource_dir.gni")
21
import("//libcxx/config.gni")
32
import("//llvm/utils/gn/build/write_cmake_config.gni")
43

5-
libcxx_needs_site_config =
6-
libcxx_abi_version != 1 || libcxx_abi_namespace != "" || libcxx_abi_unstable
4+
write_cmake_config("write_config") {
5+
input = "__config_site.in"
6+
output = "$target_gen_dir/__config_site"
77

8-
if (libcxx_needs_site_config) {
9-
write_cmake_config("write_config") {
10-
input = "__config_site.in"
11-
output = "$target_gen_dir/__config_site"
12-
13-
values = []
14-
if (libcxx_abi_version != 1) {
15-
values += [ "_LIBCPP_ABI_VERSION=$libcxx_abi_version" ]
16-
}
17-
if (libcxx_abi_namespace != "") {
18-
values += [ "_LIBCPP_ABI_NAMESPACE=$libcxx_abi_namespace" ]
19-
}
20-
if (libcxx_abi_unstable) {
21-
values += [ "_LIBCPP_ABI_UNSTABLE=1" ]
22-
}
8+
values = [
9+
"_LIBCPP_ABI_FORCE_ITANIUM=",
10+
"_LIBCPP_ABI_FORCE_MICROSOFT=",
11+
"_LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT=",
12+
"_LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE=",
13+
"_LIBCPP_HAS_NO_STDIN=",
14+
"_LIBCPP_HAS_NO_STDOUT=",
15+
"_LIBCPP_HAS_NO_THREADS=",
16+
"_LIBCPP_HAS_NO_MONOTONIC_CLOCK=",
17+
"_LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS=",
18+
"_LIBCPP_HAS_MUSL_LIBC=",
19+
"_LIBCPP_HAS_THREAD_API_PTHREAD=",
20+
"_LIBCPP_HAS_THREAD_API_EXTERNAL=",
21+
"_LIBCPP_HAS_THREAD_API_WIN32=",
22+
"_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL=",
23+
"_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS=",
24+
"_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS=1",
25+
"_LIBCPP_NO_VCRUNTIME=",
26+
"_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION=",
27+
"_LIBCPP_ABI_NAMESPACE=",
28+
"_LIBCPP_HAS_PARALLEL_ALGORITHMS=",
29+
"_LIBCPP_HAS_NO_RANDOM_DEVICE=",
30+
"_LIBCPP_HAS_NO_LOCALIZATION=",
31+
"_LIBCPP_ABI_DEFINES=",
32+
]
33+
if (libcxx_abi_version != 1) {
34+
values += [ "_LIBCPP_ABI_VERSION=$libcxx_abi_version" ]
35+
} else {
36+
values += [ "_LIBCPP_ABI_VERSION=" ]
2337
}
24-
25-
# Generate a custom __config header. The new header is created
26-
# by prepending __config_site to the current __config header.
27-
action("concat_config") {
28-
script = "//libcxx/utils/cat_files.py"
29-
inputs = [
30-
"$target_gen_dir/__config_site",
31-
"__config",
32-
]
33-
outputs = [ "$target_gen_dir/__config" ]
34-
args = [
35-
"$target_gen_dir/__config_site",
36-
"__config",
37-
"-o",
38-
"$target_gen_dir/__config",
39-
]
40-
deps = [ ":write_config" ]
38+
if (libcxx_abi_namespace != "") {
39+
values += [ "_LIBCPP_ABI_NAMESPACE=$libcxx_abi_namespace" ]
4140
}
42-
43-
copy("copy_config") {
44-
sources = [ "$target_gen_dir/__config" ]
45-
outputs = [ "$clang_resource_dir/include/c++/v1/{{source_file_part}}" ]
46-
deps = [ ":concat_config" ]
41+
if (libcxx_abi_unstable) {
42+
values += [ "_LIBCPP_ABI_UNSTABLE=1" ]
43+
} else {
44+
values += [ "_LIBCPP_ABI_UNSTABLE=" ]
4745
}
4846
}
4947

48+
# Generate a custom __config header. The new header is created
49+
# by prepending __config_site to the current __config header.
50+
action("concat_config") {
51+
script = "//libcxx/utils/cat_files.py"
52+
inputs = [
53+
"$target_gen_dir/__config_site",
54+
"__config",
55+
]
56+
outputs = [ "$root_build_dir/include/c++/v1/__config" ]
57+
args = [
58+
rebase_path("$target_gen_dir/__config_site", root_build_dir),
59+
rebase_path("__config", root_build_dir),
60+
"-o",
61+
rebase_path(outputs[0], root_build_dir)
62+
]
63+
deps = [ ":write_config" ]
64+
}
65+
5066
copy("include") {
5167
sources = [
5268
"__availability",
@@ -235,7 +251,7 @@ copy("include") {
235251
"wchar.h",
236252
"wctype.h",
237253
]
238-
deps = []
254+
deps = [ ":concat_config" ]
239255
if (target_os != "mac" && target_os != "win") {
240256
# libcxx/cmake/Modules/HandleLibCXXABI.cmake sets
241257
# LIBCXX_CXX_ABI_HEADER_TARGET if the libcxx abi library either of
@@ -247,10 +263,5 @@ copy("include") {
247263
# don't get copied on macOS due to that.
248264
deps += [ "//libcxxabi/include" ]
249265
}
250-
if (!libcxx_needs_site_config) {
251-
sources += [ "__config" ]
252-
} else {
253-
deps += [ ":copy_config" ]
254-
}
255266
outputs = [ "$root_build_dir/include/c++/v1/{{source_target_relative}}" ]
256267
}

0 commit comments

Comments
 (0)