From e794dbcbb199d8ae94419c0c1d5664c8b27eca97 Mon Sep 17 00:00:00 2001 From: nillerusr Date: Thu, 8 Apr 2021 22:40:26 +0300 Subject: [PATCH] fix loading libraries with lib prefix --- filesystem/basefilesystem.cpp | 24 ++++- launcher_main/main.cpp | 5 +- public/filesystem_init.cpp | 26 ++++++ scripts/continious_upload.sh | 15 --- scripts/waifulib/compiler_optimizations.py | 4 +- soundemittersystem/wscript | 2 +- studiorender/wscript | 2 +- tier1/interface.cpp | 24 +++-- waf.bat | 101 +++++++++++++++++++++ 9 files changed, 173 insertions(+), 30 deletions(-) delete mode 100644 scripts/continious_upload.sh create mode 100644 waf.bat diff --git a/filesystem/basefilesystem.cpp b/filesystem/basefilesystem.cpp index b6998365..b154b70e 100644 --- a/filesystem/basefilesystem.cpp +++ b/filesystem/basefilesystem.cpp @@ -5020,6 +5020,7 @@ void CBaseFileSystem::CSearchPathsIterator::CopySearchPaths( const CUtlVector +#endif // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -273,6 +276,7 @@ CSysModule *Sys_LoadModule( const char *pModuleName, Sys_Flags flags /* = SYS_NO // file in the depot (MFP) or a filesystem GetLocalCopy() call must be made // prior to the call to this routine. char szCwd[1024]; + char szModuleName[1024]; HMODULE hDLL = NULL; if ( !Q_IsAbsolutePath( pModuleName ) ) @@ -287,6 +291,7 @@ CSysModule *Sys_LoadModule( const char *pModuleName, Sys_Flags flags /* = SYS_NO V_strcpy_safe( szCwd, CommandLine()->GetParm( i + 1 ) ); } } + if (szCwd[strlen(szCwd) - 1] == '/' || szCwd[strlen(szCwd) - 1] == '\\' ) { szCwd[strlen(szCwd) - 1] = 0; @@ -294,15 +299,20 @@ CSysModule *Sys_LoadModule( const char *pModuleName, Sys_Flags flags /* = SYS_NO char szAbsoluteModuleName[1024]; size_t cCwd = strlen( szCwd ); - if ( strstr( pModuleName, "bin/") == pModuleName || ( szCwd[ cCwd - 1 ] == 'n' && szCwd[ cCwd - 2 ] == 'i' && szCwd[ cCwd - 3 ] == 'b' ) ) - { - // don't make bin/bin path - Q_snprintf( szAbsoluteModuleName, sizeof(szAbsoluteModuleName), "%s/%s", szCwd, pModuleName ); - } + + bool bUseLibPrefix = false; + +#ifdef POSIX + struct stat statBuf; + Q_snprintf(szModuleName, sizeof(szModuleName), "bin/lib%s", pModuleName); + bUseLibPrefix |= stat(szModuleName, &statBuf) == 0; +#endif + + if( bUseLibPrefix ) + Q_snprintf( szAbsoluteModuleName, sizeof(szAbsoluteModuleName), "%s/bin/lib%s", szCwd, pModuleName ); else - { Q_snprintf( szAbsoluteModuleName, sizeof(szAbsoluteModuleName), "%s/bin/%s", szCwd, pModuleName ); - } + hDLL = Sys_LoadLibrary( szAbsoluteModuleName, flags ); } diff --git a/waf.bat b/waf.bat new file mode 100644 index 00000000..dac6143c --- /dev/null +++ b/waf.bat @@ -0,0 +1,101 @@ +@echo off + +rem try fix py2 build +chcp 1252 +set PYTHONIOENCODING=UTF-8 +rem from issue #964 + +Setlocal EnableDelayedExpansion + +rem Check Windows Version +set TOKEN=tokens=3* +ver | findstr /i "5\.0\." > nul +if %ERRORLEVEL% EQU 0 SET TOKEN=tokens=3* +ver | findstr /i "5\.1\." > nul +if %ERRORLEVEL% EQU 0 SET TOKEN=tokens=3* +ver | findstr /i "5\.2\." > nul +if %ERRORLEVEL% EQU 0 SET TOKEN=tokens=3* +ver | findstr /i "6\.0\." > nul +if %ERRORLEVEL% EQU 0 SET TOKEN=tokens=2* +ver | findstr /i "6\.1\." > nul +if %ERRORLEVEL% EQU 0 SET TOKEN=tokens=2* + +rem Start calculating PYTHON and PYTHON_DIR +set PYTHON= +set PYTHON_DIR= + +Setlocal EnableDelayedExpansion + +set PYTHON_DIR_OK=FALSE +set REGPATH= + +for %%i in (3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0 2.7 2.6 2.5) do ( +for %%j in (HKCU HKLM) do ( +for %%k in (SOFTWARE\Wow6432Node SOFTWARE) do ( +for %%l in (Python\PythonCore IronPython) do ( +set REG_PYTHON_EXE=python.exe +if "%%l"=="IronPython" ( +set REG_PYTHON_EXE=ipy.exe +) + +@echo on + +set REGPATH=%%j\%%k\%%l\%%i\InstallPath +rem @echo Regpath !REGPATH! +REG QUERY "!REGPATH!" /ve 1>nul 2>nul +if !ERRORLEVEL! equ 0 ( + for /F "%TOKEN% delims= " %%A IN ('REG QUERY "!REGPATH!" /ve') do @set REG_PYTHON_DIR=%%B + if exist !REG_PYTHON_DIR! ( + IF NOT "!REG_PYTHON_DIR:~-1!"=="\" SET REG_PYTHON_DIR=!REG_PYTHON_DIR!\ + set REG_PYTHON=!REG_PYTHON_DIR!!REG_PYTHON_EXE! + rem set PYTHON_DIR_OK=TRUE + if "!PYTHON_DIR_OK!"=="FALSE" ( + set PYTHON_DIR=!REG_PYTHON_DIR! + set PYTHON=!REG_PYTHON! + set PYTHON_DIR_OK=TRUE + ) + + rem set PYTHON_DIR_OK=FALSE + rem @echo Find !REG_PYTHON! + rem goto finished + ) +) + +echo off + +) +rem for l +) +rem for k +) +rem for j +) +rem for i + + + +:finished + +Endlocal & SET PYTHON_DIR=%PYTHON_DIR% & SET PYTHON=%PYTHON% + +if "%PYTHON_DIR%" == "" ( +rem @echo No Python dir +set PYTHON=python +goto running +) + +rem @echo %PYTHON_DIR% + +if "%PYTHON%" == "" ( +rem @echo No Python +set PYTHON=python +goto running +) + +:running + +@echo Using %PYTHON% + +"%PYTHON%" -x "%~dp0waf" %* +Endlocal +exit /b %ERRORLEVEL%