================ @@ -131,12 +137,55 @@ std::string GetExecutablePath(const char *Argv0, void *MainAddr) { return llvm::sys::fs::getMainExecutable(Argv0, MainAddr); } +void GetAssetFiles(clang::doc::ClangDocContext &CDCtx) { + std::error_code Code; + for (auto DirIt = llvm::sys::fs::directory_iterator( + std::string(UserAssetPath), Code), + dir_end = llvm::sys::fs::directory_iterator(); + !Code && DirIt != dir_end; DirIt.increment(Code)) { + llvm::SmallString<128> filePath = llvm::SmallString<128>(DirIt->path()); + if (llvm::sys::fs::is_regular_file(filePath)) { + if (filePath.ends_with(".css")) { + CDCtx.UserStylesheets.insert(CDCtx.UserStylesheets.begin(), + std::string(filePath)); + } else if (filePath.ends_with(".js")) { + CDCtx.FilesToCopy.emplace_back(filePath.str()); + } + } + } +} + +void GetDefaultAssetFiles(const char *Argv0, + clang::doc::ClangDocContext &CDCtx) { + void *MainAddr = (void *)(intptr_t)GetExecutablePath; + std::string ClangDocPath = GetExecutablePath(Argv0, MainAddr); + llvm::SmallString<128> NativeClangDocPath; + llvm::sys::path::native(ClangDocPath, NativeClangDocPath); + + llvm::SmallString<128> AssetsPath; + AssetsPath = llvm::sys::path::parent_path(NativeClangDocPath); + llvm::sys::path::append(AssetsPath, "..", "share", "clang"); + llvm::SmallString<128> DefaultStylesheet; + llvm::sys::path::native(AssetsPath, DefaultStylesheet); + llvm::sys::path::append(DefaultStylesheet, + "clang-doc-default-stylesheet.css"); + llvm::SmallString<128> IndexJS; + llvm::sys::path::native(AssetsPath, IndexJS); + llvm::sys::path::append(IndexJS, "index.js"); ---------------- ilovepi wrote:
so we did need to check, and you've added one now https://github.com/llvm/llvm-project/pull/94717 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits