From 56dc1319c1dbb310d192fabaab7af20261b6373e Mon Sep 17 00:00:00 2001 From: jyelon Date: Wed, 25 Feb 2026 17:22:26 -0500 Subject: [PATCH] Eliminate lpx-paths.hpp, which contains hardwired paths. --- .gitignore | 1 - Source/Integration/LockedWrapper.cpp | 10 ++++++++-- Source/Integration/LuprexGameModeBase.cpp | 5 +++-- build.py | 14 -------------- 4 files changed, 11 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index c283f688..9a607fc2 100644 --- a/.gitignore +++ b/.gitignore @@ -37,7 +37,6 @@ Binaries/** User/** .vs/** -Source/Integration/lpx-paths.hpp luprex/build/** diff --git a/Source/Integration/LockedWrapper.cpp b/Source/Integration/LockedWrapper.cpp index ccc90e3d..a3e73021 100644 --- a/Source/Integration/LockedWrapper.cpp +++ b/Source/Integration/LockedWrapper.cpp @@ -1,7 +1,7 @@ #include "LockedWrapper.h" #include "lpx-drvutil.hpp" -#include "lpx-paths.hpp" +#include "Misc/Paths.h" using namespace LpxCommonTypes; @@ -17,7 +17,13 @@ void FlxLockedWrapper::InitWrapper() { // Already initialized. return; } - FString dll((const UTF8CHAR*)LUPREX_DLL_PATH); +#if PLATFORM_LINUX + FString dll = FPaths::Combine(FPaths::ProjectDir(), TEXT("luprex/build/Linux/luprexlib.so")); +#elif PLATFORM_WINDOWS + FString dll = FPaths::Combine(FPaths::ProjectDir(), TEXT("luprex/build/Windows/luprexlib.dll")); +#else + #error "Unsupported platform" +#endif UE_LOG(LogLuprex, Verbose, TEXT("Luprex DLL Path: %s"), *dll); void* DLL = FPlatformProcess::GetDllHandle(*dll); if (DLL != nullptr) { diff --git a/Source/Integration/LuprexGameModeBase.cpp b/Source/Integration/LuprexGameModeBase.cpp index df5e5a4d..b36c03a3 100644 --- a/Source/Integration/LuprexGameModeBase.cpp +++ b/Source/Integration/LuprexGameModeBase.cpp @@ -2,7 +2,7 @@ #include "LuprexGameModeBase.h" #include "lpx-drvutil.hpp" -#include "lpx-paths.hpp" +#include "Misc/Paths.h" #include "Tangible.h" #include "TangibleManager.h" #include "LuaCall.h" @@ -41,7 +41,8 @@ uint32 ALuprexGameModeBase::Run() { if (lockedwrap->get_rescan_lua_source(lockedwrap.Get())) { drvutil::ostringstream srcpak; - std::string srcpakerr = drvutil::package_lua_source(LUPREX_ROOT_PATH, &srcpak); + FString LuprexRoot = FPaths::Combine(FPaths::ProjectDir(), TEXT("luprex")); + std::string srcpakerr = drvutil::package_lua_source(TCHAR_TO_UTF8(*LuprexRoot), &srcpak); if (!srcpakerr.empty()) { FString FMessage((const UTF8CHAR *)(srcpakerr.c_str())); diff --git a/build.py b/build.py index f98b5aa9..cdab8927 100755 --- a/build.py +++ b/build.py @@ -247,19 +247,6 @@ def generate_buildconfiguration_xml(): target2.write_text(template) -def generate_lpx_paths(): - """ - Unreal needs to be able to find the Luprex DLL, and it also needs to find the - Lua source code. For now, we just compile some hardwired paths into the - binary. Someday we'll do something more sophisticated. - """ - target = Path(f"{INTEGRATION}/Source/Integration/lpx-paths.hpp") - line1 = f'#define LUPREX_DLL_PATH "{INTEGRATION}/luprex/build/{OS}/luprexlib.{DLL}"' - line2 = f'#define LUPREX_ROOT_PATH "{INTEGRATION}/luprex"' - code = line1 + "\n" + line2 + "\n" - target.unlink(missing_ok=True) - target.write_text(code) - def generate_integration_uproject(): """ @@ -406,7 +393,6 @@ if MODE == "code-workspace": if MODE == "all": unzip_unreal_engine_and_apply_patch() generate_buildconfiguration_xml() - generate_lpx_paths() generate_integration_uproject() run_unrealengine_setup_bat_replacement() run_generateprojectfiles_in_sandbox()