diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2024-07-02 12:09:59 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2024-07-02 12:09:59 -0400 |
commit | f8357732a108e579c285a76a53c550b8b5c0a153 (patch) | |
tree | 0e9f95b04256dde40d5c21822b5e78583d062f82 /indra/newview/llluamanager.cpp | |
parent | 212868a8c3f803b387da602b6440f69c2c617e40 (diff) |
Make require() implementation honor LuaRequirePath setting.
Remove LL_TEST special case from require() code (to search in the viewer's
source tree). Instead, make llluamanager_test.cpp append to LuaRequirePath to
get the same effect.
Diffstat (limited to 'indra/newview/llluamanager.cpp')
-rw-r--r-- | indra/newview/llluamanager.cpp | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/indra/newview/llluamanager.cpp b/indra/newview/llluamanager.cpp index c95ce9c57b..ccfa08078e 100644 --- a/indra/newview/llluamanager.cpp +++ b/indra/newview/llluamanager.cpp @@ -32,6 +32,7 @@ #include "llcoros.h" #include "llerror.h" #include "lleventcoro.h" +#include "llsdutil.h" #include "llviewercontrol.h" #include "lua_function.h" #include "lualistener.h" @@ -338,18 +339,13 @@ void LLRequireResolver::findModule() fail(); } - std::vector<fsyspath> lib_paths + LLSD lib_paths(gSavedSettings.getLLSD("LuaRequirePath")); + LL_DEBUGS("Lua") << "LuaRequirePath = " << lib_paths << LL_ENDL; + for (const auto& path : llsd::inArray(lib_paths)) { - gDirUtilp->getExpandedFilename(LL_PATH_SCRIPTS, "lua", "require"), -#ifdef LL_TEST - // Build-time tests don't have the app bundle - use source tree. - fsyspath(__FILE__).parent_path() / "scripts" / "lua" / "require", -#endif - }; - - for (const auto& path : lib_paths) - { - std::string absolutePathOpt = (path / mPathToResolve).u8string(); + // if path is already absolute, operator/() preserves it + auto abspath(fsyspath(gDirUtilp->getAppRODataDir()) / path.asString()); + std::string absolutePathOpt = (abspath / mPathToResolve).u8string(); if (absolutePathOpt.empty()) luaL_error(L, "error requiring module '%s'", mPathToResolve.u8string().data()); |