[clang] [clang][docs] Pass full path of source TD file to gen_rst_from_td. [NFC] (PR #66497)

Francesco Petrogalli via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 15 04:52:13 PDT 2023


https://github.com/fpetrogalli created https://github.com/llvm/llvm-project/pull/66497

This change is needed to be able to refer to TD files that are not stored in ${CMAKE_CURRENT_SOURCE_DIR}.

>From 1887649a491b353f4e6a9a318fa2b150db268868 Mon Sep 17 00:00:00 2001
From: Francesco Petrogalli <francesco.petrogalli at apple.com>
Date: Fri, 15 Sep 2023 10:56:29 +0200
Subject: [PATCH] [clang][docs] Pass full path of source TD file to
 gen_rst_from_td. [NFC]

This change is needed to be able to refer to TD files that are not
stored in ${CMAKE_CURRENT_SOURCE_DIR}.
---
 clang/docs/CMakeLists.txt | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/clang/docs/CMakeLists.txt b/clang/docs/CMakeLists.txt
index 4163dd2d90ad5b3..a63823c63428288 100644
--- a/clang/docs/CMakeLists.txt
+++ b/clang/docs/CMakeLists.txt
@@ -91,10 +91,10 @@ endif()
 endif()
 
 function (gen_rst_file_from_td output_file td_option source docs_targets)
-  if (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${source}")
-    message(FATAL_ERROR "Cannot find source file: ${source} in ${CMAKE_CURRENT_SOURCE_DIR}")
+  if (NOT EXISTS "${source}")
+    message(FATAL_ERROR "Cannot find source file: ${source}")
   endif()
-  get_filename_component(TABLEGEN_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${source}" DIRECTORY)
+  get_filename_component(TABLEGEN_INCLUDE_DIR "${source}" DIRECTORY)
   list(APPEND LLVM_TABLEGEN_FLAGS "-I${TABLEGEN_INCLUDE_DIR}")
   clang_tablegen(${output_file} ${td_option} SOURCE ${source} TARGET "gen-${output_file}")
   foreach(target ${docs_targets})
@@ -138,10 +138,9 @@ if (LLVM_ENABLE_SPHINX)
     endif()
 
     # Generated files
-    gen_rst_file_from_td(AttributeReference.rst -gen-attr-docs ../include/clang/Basic/Attr.td "${docs_targets}")
-    gen_rst_file_from_td(DiagnosticsReference.rst -gen-diag-docs ../include/clang/Basic/Diagnostic.td "${docs_targets}")
-    gen_rst_file_from_td(ClangCommandLineReference.rst -gen-opt-docs ../include/clang/Driver/ClangOptionDocs.td "${docs_targets}")
-
+    gen_rst_file_from_td(AttributeReference.rst -gen-attr-docs ${CMAKE_CURRENT_SOURCE_DIR}/../include/clang/Basic/Attr.td "${docs_targets}")
+    gen_rst_file_from_td(DiagnosticsReference.rst -gen-diag-docs ${CMAKE_CURRENT_SOURCE_DIR}/../include/clang/Basic/Diagnostic.td "${docs_targets}")
+    gen_rst_file_from_td(ClangCommandLineReference.rst -gen-opt-docs ${CMAKE_CURRENT_SOURCE_DIR}/../include/clang/Driver/ClangOptionDocs.td "${docs_targets}")
     foreach(target ${docs_targets})
       add_dependencies(${target} copy-clang-rst-docs)
     endforeach()



More information about the cfe-commits mailing list