This revision was automatically updated to reflect the committed changes. Closed by commit rL355631: [ExpressionParser] Implement ComputeClangResourceDir for Windows (authored by xiaobai, committed by ). Herald added a project: LLVM. Herald added a subscriber: llvm-commits.
Changed prior to commit: https://reviews.llvm.org/D59072?vs=189642&id=189766#toc Repository: rL LLVM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D59072/new/ https://reviews.llvm.org/D59072 Files: lldb/trunk/include/lldb/Host/HostInfoBase.h lldb/trunk/include/lldb/Host/posix/HostInfoPosix.h lldb/trunk/source/Host/common/HostInfoBase.cpp lldb/trunk/source/Host/posix/HostInfoPosix.cpp lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangHost.cpp lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangHost.h lldb/trunk/unittests/Expression/ClangParserTest.cpp
Index: lldb/trunk/unittests/Expression/ClangParserTest.cpp =================================================================== --- lldb/trunk/unittests/Expression/ClangParserTest.cpp +++ lldb/trunk/unittests/Expression/ClangParserTest.cpp @@ -31,7 +31,6 @@ }; } // namespace -#if !defined(_WIN32) static std::string ComputeClangResourceDir(std::string lldb_shlib_path, bool verify = false) { FileSpec clang_dir; @@ -41,8 +40,13 @@ } TEST_F(ClangHostTest, ComputeClangResourceDirectory) { +#if !defined(_WIN32) std::string path_to_liblldb = "/foo/bar/lib/"; std::string path_to_clang_dir = "/foo/bar/lib/clang/" CLANG_VERSION_STRING; +#else + std::string path_to_liblldb = "C:\\foo\\bar\\lib"; + std::string path_to_clang_dir = "C:\\foo\\bar\\lib\\clang\\" CLANG_VERSION_STRING; +#endif EXPECT_EQ(ComputeClangResourceDir(path_to_liblldb), path_to_clang_dir); // The path doesn't really exist, so setting verify to true should make @@ -91,4 +95,3 @@ ComputeClangResourceDir(GetInputFilePath(xcode))); } #endif // __APPLE__ -#endif // !_WIN32 Index: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangHost.cpp =================================================================== --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangHost.cpp +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangHost.cpp @@ -18,9 +18,6 @@ #include "lldb/Host/FileSystem.h" #include "lldb/Host/HostInfo.h" -#if !defined(_WIN32) -#include "lldb/Host/posix/HostInfoPosix.h" -#endif #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" @@ -28,12 +25,6 @@ using namespace lldb_private; -#if defined(_WIN32) -static bool ComputeClangResourceDirectory(FileSpec &lldb_shlib_spec, - FileSpec &file_spec, bool verify) { - return false; -} -#else static bool VerifyClangPath(const llvm::Twine &clang_path) { if (FileSystem::Instance().IsDirectory(clang_path)) return true; @@ -67,7 +58,7 @@ return true; } - return HostInfoPosix::ComputePathRelativeToLibrary(file_spec, relative_path); + return HostInfo::ComputePathRelativeToLibrary(file_spec, relative_path); } bool lldb_private::ComputeClangResourceDirectory(FileSpec &lldb_shlib_spec, @@ -141,7 +132,6 @@ return true; #endif // __APPLE__ } -#endif // _WIN32 FileSpec lldb_private::GetClangResourceDir() { static FileSpec g_cached_resource_dir; Index: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangHost.h =================================================================== --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangHost.h +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangHost.h @@ -13,10 +13,8 @@ class FileSpec; -#if !defined(_WIN32) bool ComputeClangResourceDirectory(FileSpec &lldb_shlib_spec, FileSpec &file_spec, bool verify); -#endif FileSpec GetClangResourceDir(); Index: lldb/trunk/source/Host/posix/HostInfoPosix.cpp =================================================================== --- lldb/trunk/source/Host/posix/HostInfoPosix.cpp +++ lldb/trunk/source/Host/posix/HostInfoPosix.cpp @@ -120,43 +120,6 @@ FileSpec HostInfoPosix::GetDefaultShell() { return FileSpec("/bin/sh"); } -bool HostInfoPosix::ComputePathRelativeToLibrary(FileSpec &file_spec, - llvm::StringRef dir) { - Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST); - - FileSpec lldb_file_spec = GetShlibDir(); - if (!lldb_file_spec) - return false; - - std::string raw_path = lldb_file_spec.GetPath(); - // drop library directory - llvm::StringRef parent_path = llvm::sys::path::parent_path(raw_path); - - // Most Posix systems (e.g. Linux/*BSD) will attempt to replace a */lib with - // */bin as the base directory for helper exe programs. This will fail if - // the /lib and /bin directories are rooted in entirely different trees. - if (log) - log->Printf("HostInfoPosix::ComputePathRelativeToLibrary() attempting to " - "derive the %s path from this path: %s", - dir.data(), raw_path.c_str()); - - if (!parent_path.empty()) { - // Now write in bin in place of lib. - raw_path = (parent_path + dir).str(); - - if (log) - log->Printf("Host::%s() derived the bin path as: %s", __FUNCTION__, - raw_path.c_str()); - } else { - if (log) - log->Printf("Host::%s() failed to find /lib/liblldb within the shared " - "lib path, bailing on bin path construction", - __FUNCTION__); - } - file_spec.GetDirectory().SetString(raw_path); - return (bool)file_spec.GetDirectory(); -} - bool HostInfoPosix::ComputeSupportExeDirectory(FileSpec &file_spec) { return ComputePathRelativeToLibrary(file_spec, "/bin"); } Index: lldb/trunk/source/Host/common/HostInfoBase.cpp =================================================================== --- lldb/trunk/source/Host/common/HostInfoBase.cpp +++ lldb/trunk/source/Host/common/HostInfoBase.cpp @@ -214,6 +214,38 @@ return ArchSpec(normalized_triple); } +bool HostInfoBase::ComputePathRelativeToLibrary(FileSpec &file_spec, + llvm::StringRef dir) { + Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST); + + FileSpec lldb_file_spec = GetShlibDir(); + if (!lldb_file_spec) + return false; + + std::string raw_path = lldb_file_spec.GetPath(); + if (log) + log->Printf("HostInfo::%s() attempting to " + "derive the path %s relative to liblldb install path: %s", + __FUNCTION__, dir.data(), raw_path.c_str()); + + // Drop bin (windows) or lib + llvm::StringRef parent_path = llvm::sys::path::parent_path(raw_path); + if (parent_path.empty()) { + if (log) + log->Printf("HostInfo::%s() failed to find liblldb within the shared " + "lib path", + __FUNCTION__); + return false; + } + + raw_path = (parent_path + dir).str(); + if (log) + log->Printf("HostInfo::%s() derived the path as: %s", __FUNCTION__, + raw_path.c_str()); + file_spec.GetDirectory().SetString(raw_path); + return (bool)file_spec.GetDirectory(); +} + bool HostInfoBase::ComputeSharedLibraryDirectory(FileSpec &file_spec) { // To get paths related to LLDB we get the path to the executable that // contains this function. On MacOSX this will be "LLDB.framework/.../LLDB". Index: lldb/trunk/include/lldb/Host/HostInfoBase.h =================================================================== --- lldb/trunk/include/lldb/Host/HostInfoBase.h +++ lldb/trunk/include/lldb/Host/HostInfoBase.h @@ -99,6 +99,9 @@ //--------------------------------------------------------------------------- static ArchSpec GetAugmentedArchSpec(llvm::StringRef triple); + static bool ComputePathRelativeToLibrary(FileSpec &file_spec, + llvm::StringRef dir); + protected: static bool ComputeSharedLibraryDirectory(FileSpec &file_spec); static bool ComputeSupportExeDirectory(FileSpec &file_spec); Index: lldb/trunk/include/lldb/Host/posix/HostInfoPosix.h =================================================================== --- lldb/trunk/include/lldb/Host/posix/HostInfoPosix.h +++ lldb/trunk/include/lldb/Host/posix/HostInfoPosix.h @@ -32,9 +32,6 @@ static bool GetEnvironmentVar(const std::string &var_name, std::string &var); - static bool ComputePathRelativeToLibrary(FileSpec &file_spec, - llvm::StringRef dir); - static UserIDResolver &GetUserIDResolver(); protected:
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits