[libcxx-commits] [libcxx] [libc++] Update CMake dependency for generate_iwyu_mapping.py (PR #115387)

via libcxx-commits libcxx-commits at lists.llvm.org
Thu Nov 7 14:47:51 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libcxx

Author: Alexander Richardson (arichardson)

<details>
<summary>Changes</summary>

This script does not depend on the generated headers since those are
already special-cased in header_information.py. Change the dependency
list to depend on header_information.py instead. While looking at this
code also simplify the assignment to libcxx_root inside this script.


---
Full diff: https://github.com/llvm/llvm-project/pull/115387.diff


3 Files Affected:

- (modified) libcxx/include/CMakeLists.txt (+1-1) 
- (modified) libcxx/include/__cxx03/CMakeLists.txt (+1-1) 
- (modified) libcxx/utils/libcxx/header_information.py (+2-2) 


``````````diff
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index ae2e8bcb32aaa4..ebd6eda9ba30f8 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -1059,7 +1059,7 @@ endforeach()
 # "include" for dependency tracking.
 add_custom_command(OUTPUT "${LIBCXX_GENERATED_INCLUDE_DIR}/libcxx.imp"
   COMMAND "${Python3_EXECUTABLE}" "${LIBCXX_SOURCE_DIR}/utils/generate_iwyu_mapping.py" "-o" "${LIBCXX_GENERATED_INCLUDE_DIR}/libcxx.imp"
-  DEPENDS ${_all_includes}
+  DEPENDS "${LIBCXX_SOURCE_DIR}/utils/libcxx/header_information.py"
   COMMENT "Generate the mapping file for include-what-you-use"
 )
 list(APPEND _all_includes "${LIBCXX_GENERATED_INCLUDE_DIR}/libcxx.imp")
diff --git a/libcxx/include/__cxx03/CMakeLists.txt b/libcxx/include/__cxx03/CMakeLists.txt
index 32579272858a8e..b61442da89d4bf 100644
--- a/libcxx/include/__cxx03/CMakeLists.txt
+++ b/libcxx/include/__cxx03/CMakeLists.txt
@@ -1037,7 +1037,7 @@ endforeach()
 # "include" for dependency tracking.
 add_custom_command(OUTPUT "${LIBCXX_GENERATED_INCLUDE_DIR}/libcxx.imp"
   COMMAND "${Python3_EXECUTABLE}" "${LIBCXX_SOURCE_DIR}/utils/generate_iwyu_mapping.py" "-o" "${LIBCXX_GENERATED_INCLUDE_DIR}/libcxx.imp"
-  DEPENDS ${_all_includes}
+  DEPENDS "${LIBCXX_SOURCE_DIR}/utils/libcxx/header_information.py"
   COMMENT "Generate the mapping file for include-what-you-use"
 )
 list(APPEND _all_includes "${LIBCXX_GENERATED_INCLUDE_DIR}/libcxx.imp")
diff --git a/libcxx/utils/libcxx/header_information.py b/libcxx/utils/libcxx/header_information.py
index 7d88b73d0331bb..9a723b61524cd5 100644
--- a/libcxx/utils/libcxx/header_information.py
+++ b/libcxx/utils/libcxx/header_information.py
@@ -6,9 +6,9 @@
 #
 # ===----------------------------------------------------------------------===##
 
-import os, pathlib, functools
+import pathlib, functools
 
-libcxx_root = pathlib.Path(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
+libcxx_root = pathlib.Path(__file__).resolve().parent.parent.parent
 libcxx_include = libcxx_root / "include"
 assert libcxx_root.exists()
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/115387


More information about the libcxx-commits mailing list