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

In `clang-tools-extra\clang-doc\tool\ClangDocMain.cpp`, there is a function, 
`getDefaultAssetFiles` that tries to find the location of 
`<build dir>\share\clang-doc\index.js`, but fails. This is because there are 
alternate configurations in setting up the llvm project, and executables in 
different locations may be run. In some cases, executables are built and run in 
this location:
`<build dir>\bin\<executables>`
and in other cases, this location:
`<build dir>\[Debug | Release]\bin\<executables>`

The locator assumed that the executable that is running was in the first 
example above, and in the case that an executable under Debug / Release was 
run, the index.js file wouldn't be found.
This PR adjusts the locator to be agnostic to either scenario described above, 
and ascends an extra directory if the Debug directory is detected.

>From 1c190c9c6b55aec23bab6d7b2a0f489c59285dc7 Mon Sep 17 00:00:00 2001
From: Joshua Batista <jbati...@microsoft.com>
Date: Tue, 2 Jul 2024 18:38:24 -0700
Subject: [PATCH] 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,

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to