Skip to content

Commit e275489

Browse files
authored
[libc++] Don't commit libcxx.imp (#89391)
We can instead generate it on-the-fly when we install the headers. This reduces the amount of boilerplate we have to re-generate whenever we add, remove or relocate header files. Fixes #88529
1 parent 346d2c0 commit e275489

File tree

4 files changed

+37
-873
lines changed

4 files changed

+37
-873
lines changed

libcxx/include/CMakeLists.txt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,6 @@ set(files
957957
istream
958958
iterator
959959
latch
960-
libcxx.imp
961960
limits
962961
list
963962
locale
@@ -1036,6 +1035,15 @@ foreach(f ${files})
10361035
list(APPEND _all_includes "${dst}")
10371036
endforeach()
10381037

1038+
# Generate the IWYU mapping. This depends on all header files but it's also considered as an
1039+
# "include" for dependency tracking.
1040+
add_custom_command(OUTPUT "${LIBCXX_GENERATED_INCLUDE_DIR}/libcxx.imp"
1041+
COMMAND "${Python3_EXECUTABLE}" "${LIBCXX_SOURCE_DIR}/utils/generate_iwyu_mapping.py" "-o" "${LIBCXX_GENERATED_INCLUDE_DIR}/libcxx.imp"
1042+
DEPENDS ${_all_includes}
1043+
COMMENT "Generate the mapping file for include-what-you-use"
1044+
)
1045+
list(APPEND _all_includes "${LIBCXX_GENERATED_INCLUDE_DIR}/libcxx.imp")
1046+
10391047
add_custom_target(generate-cxx-headers ALL DEPENDS ${_all_includes})
10401048

10411049
add_library(cxx-headers INTERFACE)
@@ -1074,6 +1082,12 @@ if (LIBCXX_INSTALL_HEADERS)
10741082
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
10751083
COMPONENT cxx-headers)
10761084

1085+
# Install the generated IWYU file to the generic include dir.
1086+
install(FILES "${LIBCXX_GENERATED_INCLUDE_DIR}/libcxx.imp"
1087+
DESTINATION "${LIBCXX_INSTALL_INCLUDE_DIR}"
1088+
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
1089+
COMPONENT cxx-headers)
1090+
10771091
if (NOT CMAKE_CONFIGURATION_TYPES)
10781092
add_custom_target(install-cxx-headers
10791093
DEPENDS cxx-headers

0 commit comments

Comments
 (0)