[clang-tools-extra] [clang-doc][cmake] Copy assets to build directory (PR #95187)

Paul Kirth via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 11 18:18:14 PDT 2024


https://github.com/ilovepi created https://github.com/llvm/llvm-project/pull/95187

While we copy the asset files, like index.js, into the correct location in the install step, tests do not have access to those resources in the build directory.

This patch copies the contents of the clang-doc/assets directory into the build folder, so that they can be used in testing.

Pull Request: https://github.com/llvm/llvm-project/pull/95185

>From 753c6d43e44911cc7478738f1fc5d95d5780dbda Mon Sep 17 00:00:00 2001
From: Paul Kirth <paulkirth at google.com>
Date: Wed, 12 Jun 2024 01:05:59 +0000
Subject: [PATCH] [clang-doc][cmake] Copy assets to build directory

While we copy the asset files, like index.js, into the
correct location in the install step, tests do not have
access to those resources in the build directory.

This patch copies the contents of the clang-doc/assets
directory into the build folder, so that they can be
used in testing.

Pull Request: https://github.com/llvm/llvm-project/pull/95185
---
 clang-tools-extra/clang-doc/tool/CMakeLists.txt | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/clang-tools-extra/clang-doc/tool/CMakeLists.txt b/clang-tools-extra/clang-doc/tool/CMakeLists.txt
index fb8317b272932..c2425747562b9 100644
--- a/clang-tools-extra/clang-doc/tool/CMakeLists.txt
+++ b/clang-tools-extra/clang-doc/tool/CMakeLists.txt
@@ -25,3 +25,11 @@ install(FILES ../assets/clang-doc-default-stylesheet.css
 install(FILES ../assets/index.js
   DESTINATION "${CMAKE_INSTALL_DATADIR}/clang"
   COMPONENT clang-doc)
+
+add_custom_target(copy-clang-doc-assets
+  COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different "${CMAKE_CURRENT_SOURCE_DIR}/../assets" "${CMAKE_BINARY_DIR}/share/clang"
+  DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/../assets"
+  COMMENT "Copying Clang-Doc Assets"
+  )
+set_target_properties(copy-clang-doc-assets PROPERTIES FOLDER "Clang-Doc/Assets")
+add_dependencies(clang-doc copy-clang-doc-assets)



More information about the cfe-commits mailing list