[clang-tools-extra] Fix Default Asset File locator for clang docs (PR #97505)

Joshua Batista via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 2 18:45:39 PDT 2024


https://github.com/bob80905 updated https://github.com/llvm/llvm-project/pull/97505

>From 1c190c9c6b55aec23bab6d7b2a0f489c59285dc7 Mon Sep 17 00:00:00 2001
From: Joshua Batista <jbatista at microsoft.com>
Date: Tue, 2 Jul 2024 18:38:24 -0700
Subject: [PATCH 1/2] if debug exists, go up an extra dir

---
 clang-tools-extra/clang-doc/tool/ClangDocMain.cpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
index 6198a6e0cdcc3..b97fa715f9e67 100644
--- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -167,7 +167,13 @@ llvm::Error getDefaultAssetFiles(const char *Argv0,
 
   llvm::SmallString<128> AssetsPath;
   AssetsPath = llvm::sys::path::parent_path(NativeClangDocPath);
-  llvm::sys::path::append(AssetsPath, "..", "share", "clang-doc");
+  llvm::sys::path::append(AssetsPath, "..");
+  llvm::SmallString<128> tempCopyDbg = AssetsPath;
+  llvm::sys::path::append(tempCopyDbg, "Debug");
+  // index.js may be in the debug
+  if (!llvm::sys::fs::is_directory(tempCopyDbg))
+    llvm::sys::path::append(AssetsPath, "..");
+  llvm::sys::path::append(AssetsPath, "share", "clang-doc");
   llvm::SmallString<128> DefaultStylesheet;
   llvm::sys::path::native(AssetsPath, DefaultStylesheet);
   llvm::sys::path::append(DefaultStylesheet,

>From 07662a63e1b3ab2886871f3960246be8219c6ecd Mon Sep 17 00:00:00 2001
From: Joshua Batista <jbatista at microsoft.com>
Date: Tue, 2 Jul 2024 18:45:23 -0700
Subject: [PATCH 2/2] cleanup comment

---
 clang-tools-extra/clang-doc/tool/ClangDocMain.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
index b97fa715f9e67..ebd0675cd5501 100644
--- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -170,7 +170,7 @@ llvm::Error getDefaultAssetFiles(const char *Argv0,
   llvm::sys::path::append(AssetsPath, "..");
   llvm::SmallString<128> tempCopyDbg = AssetsPath;
   llvm::sys::path::append(tempCopyDbg, "Debug");
-  // index.js may be in the debug
+  // The executable that ran clangDoc may be in the Debug directory.
   if (!llvm::sys::fs::is_directory(tempCopyDbg))
     llvm::sys::path::append(AssetsPath, "..");
   llvm::sys::path::append(AssetsPath, "share", "clang-doc");



More information about the cfe-commits mailing list