fix loading libraries with lib prefix

This commit is contained in:
nillerusr 2021-04-08 22:40:26 +03:00
parent 597f9da3b0
commit e794dbcbb1
9 changed files with 173 additions and 30 deletions

View File

@ -5020,6 +5020,7 @@ void CBaseFileSystem::CSearchPathsIterator::CopySearchPaths( const CUtlVector<CS
CSysModule *CBaseFileSystem::LoadModule( const char *pFileName, const char *pPathID, bool bValidatedDllOnly ) CSysModule *CBaseFileSystem::LoadModule( const char *pFileName, const char *pPathID, bool bValidatedDllOnly )
{ {
CHECK_DOUBLE_SLASHES( pFileName ); CHECK_DOUBLE_SLASHES( pFileName );
CSysModule *pModule = NULL;
LogFileAccess( pFileName ); LogFileAccess( pFileName );
if ( !pPathID ) if ( !pPathID )
@ -5044,16 +5045,33 @@ CSysModule *CBaseFileSystem::LoadModule( const char *pFileName, const char *pPat
continue; continue;
Q_snprintf( tempPathID, sizeof(tempPathID), "%s%s", m_SearchPaths[i].GetPathString(), pFileName ); // append the path to this dir. Q_snprintf( tempPathID, sizeof(tempPathID), "%s%s", m_SearchPaths[i].GetPathString(), pFileName ); // append the path to this dir.
CSysModule *pModule = Sys_LoadModule( tempPathID ); pModule = Sys_LoadModule( tempPathID );
if ( pModule ) if ( pModule )
{ {
// we found the binary in one of our search paths // we found the binary in one of our search paths
return pModule; return pModule;
} }
#ifdef POSIX
Q_snprintf( tempPathID, sizeof(tempPathID), "%slib%s", m_SearchPaths[i].GetPathString(), pFileName ); // append the path to this dir.
printf(tempPathID);
pModule = Sys_LoadModule( tempPathID );
if ( pModule )
return pModule;
#endif
} }
// couldn't load it from any of the search paths, let LoadLibrary try
return Sys_LoadModule( pFileName ); #ifdef POSIX
Q_snprintf( tempPathID, sizeof(tempPathID), "lib%s", pFileName );
pModule = Sys_LoadModule( tempPathID );
if( !pModule )
#endif
{
pModule = Sys_LoadModule( pFileName );
}
return pModule;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@ -215,7 +215,10 @@ static void WaitForDebuggerConnect( int argc, char *argv[], int time )
int main( int argc, char *argv[] ) int main( int argc, char *argv[] )
{ {
void *launcher = dlopen( "bin/liblauncher" DLL_EXT_STRING, RTLD_NOW );
if( !launcher )
void *launcher = dlopen( "bin/launcher" DLL_EXT_STRING, RTLD_NOW ); void *launcher = dlopen( "bin/launcher" DLL_EXT_STRING, RTLD_NOW );
if ( !launcher ) if ( !launcher )
{ {
fprintf( stderr, "Failed to load the launcher\n" ); fprintf( stderr, "Failed to load the launcher\n" );

View File

@ -1084,6 +1084,7 @@ FSReturnCode_t FileSystem_SetBasePaths( IFileSystem *pFileSystem )
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
FSReturnCode_t FileSystem_GetFileSystemDLLName( char *pFileSystemDLL, int nMaxLen, bool &bSteam ) FSReturnCode_t FileSystem_GetFileSystemDLLName( char *pFileSystemDLL, int nMaxLen, bool &bSteam )
{ {
#if 0
bSteam = false; bSteam = false;
// Inside of here, we don't have a filesystem yet, so we have to assume that the filesystem_stdio or filesystem_steam // Inside of here, we don't have a filesystem yet, so we have to assume that the filesystem_stdio or filesystem_steam
@ -1112,6 +1113,31 @@ FSReturnCode_t FileSystem_GetFileSystemDLLName( char *pFileSystemDLL, int nMaxLe
bSteam = true; bSteam = true;
} }
#endif #endif
#else
char executablePath[MAX_PATH];
if ( !FileSystem_GetExecutableDir( executablePath, sizeof( executablePath ) ) )
return SetupFileSystemError( false, FS_INVALID_PARAMETERS, "FileSystem_GetExecutableDir failed." );
// Assume we'll use local files
Q_snprintf( pFileSystemDLL, nMaxLen, "%s%clibfilesystem_stdio" DLL_EXT_STRING, executablePath, CORRECT_PATH_SEPARATOR );
#if !defined( _X360 )
// Use filsystem_steam if it exists?
#if defined( OSX ) || defined( LINUX )
struct stat statBuf;
#endif
if (
#if defined( OSX ) || defined( LINUX )
stat( pFileSystemDLL, &statBuf ) != 0
#else
_access( pFileSystemDLL, 0 ) != 0
#endif
) {
Q_snprintf( pFileSystemDLL, nMaxLen, "%s%cfilesystem_stdio" DLL_EXT_STRING, executablePath, CORRECT_PATH_SEPARATOR );
}
#endif
#endif
return FS_OK; return FS_OK;
} }

View File

@ -1,15 +0,0 @@
##################################
#
# GitHub Releases
#
##################################
set +x
# Disabled until GitHub sends prereleases to email
wget -O upload.sh "https://raw.githubusercontent.com/FWGS/uploadtool/master/upload.sh"
chmod +x upload.sh
export GITHUB_TOKEN=$GH_TOKEN
./upload.sh $*

View File

@ -49,7 +49,7 @@ CFLAGS = {
# disable thread-safe local static initialization for C++11 code, as it cause crashes on Windows XP # disable thread-safe local static initialization for C++11 code, as it cause crashes on Windows XP
'msvc': ['/D_USING_V110_SDK71_', '/Zi', '/FS', '/Zc:threadSafeInit-', '/MT'], 'msvc': ['/D_USING_V110_SDK71_', '/Zi', '/FS', '/Zc:threadSafeInit-', '/MT'],
'clang': ['-g', '-gdwarf-2', '-fvisibility=hidden'], 'clang': ['-g', '-gdwarf-2', '-fvisibility=hidden'],
'gcc': ['-fvisibility=hidden'], 'gcc': ['-g', '-fvisibility=hidden'],
'owcc': ['-fno-short-enum', '-ffloat-store', '-g3'] 'owcc': ['-fno-short-enum', '-ffloat-store', '-g3']
}, },
'fast': { 'fast': {
@ -70,7 +70,7 @@ CFLAGS = {
'release': { 'release': {
'msvc': ['/O2'], 'msvc': ['/O2'],
'owcc': ['-O3', '-foptimize-sibling-calls', '-fomit-leaf-frame-pointer', '-fomit-frame-pointer', '-fschedule-insns', '-funsafe-math-optimizations', '-funroll-loops', '-frerun-optimizer', '-finline-functions', '-finline-limit=512', '-fguess-branch-probability', '-fno-strict-aliasing', '-floop-optimize'], 'owcc': ['-O3', '-foptimize-sibling-calls', '-fomit-leaf-frame-pointer', '-fomit-frame-pointer', '-fschedule-insns', '-funsafe-math-optimizations', '-funroll-loops', '-frerun-optimizer', '-finline-functions', '-finline-limit=512', '-fguess-branch-probability', '-fno-strict-aliasing', '-floop-optimize'],
'default': ['-O0'] 'default': ['-O3']
}, },
'debug': { 'debug': {
'msvc': ['/Od'], 'msvc': ['/Od'],

View File

@ -5,7 +5,7 @@ from waflib import Utils
import os import os
top = '.' top = '.'
PROJECT_NAME = 'SoundEmitterSystem' PROJECT_NAME = 'soundemittersystem'
def options(opt): def options(opt):
# stub # stub

View File

@ -5,7 +5,7 @@ from waflib import Utils
import os import os
top = '.' top = '.'
PROJECT_NAME = 'StudioRender' PROJECT_NAME = 'studiorender'
def options(opt): def options(opt):
# stub # stub

View File

@ -36,6 +36,9 @@
#include "xbox/xbox_win32stubs.h" #include "xbox/xbox_win32stubs.h"
#endif #endif
#ifdef POSIX
#include <sys/stat.h>
#endif
// memdbgon must be the last include file in a .cpp file!!! // memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h" #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 // file in the depot (MFP) or a filesystem GetLocalCopy() call must be made
// prior to the call to this routine. // prior to the call to this routine.
char szCwd[1024]; char szCwd[1024];
char szModuleName[1024];
HMODULE hDLL = NULL; HMODULE hDLL = NULL;
if ( !Q_IsAbsolutePath( pModuleName ) ) 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 ) ); V_strcpy_safe( szCwd, CommandLine()->GetParm( i + 1 ) );
} }
} }
if (szCwd[strlen(szCwd) - 1] == '/' || szCwd[strlen(szCwd) - 1] == '\\' ) if (szCwd[strlen(szCwd) - 1] == '/' || szCwd[strlen(szCwd) - 1] == '\\' )
{ {
szCwd[strlen(szCwd) - 1] = 0; szCwd[strlen(szCwd) - 1] = 0;
@ -294,15 +299,20 @@ CSysModule *Sys_LoadModule( const char *pModuleName, Sys_Flags flags /* = SYS_NO
char szAbsoluteModuleName[1024]; char szAbsoluteModuleName[1024];
size_t cCwd = strlen( szCwd ); size_t cCwd = strlen( szCwd );
if ( strstr( pModuleName, "bin/") == pModuleName || ( szCwd[ cCwd - 1 ] == 'n' && szCwd[ cCwd - 2 ] == 'i' && szCwd[ cCwd - 3 ] == 'b' ) )
{ bool bUseLibPrefix = false;
// don't make bin/bin path
Q_snprintf( szAbsoluteModuleName, sizeof(szAbsoluteModuleName), "%s/%s", szCwd, pModuleName ); #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 else
{
Q_snprintf( szAbsoluteModuleName, sizeof(szAbsoluteModuleName), "%s/bin/%s", szCwd, pModuleName ); Q_snprintf( szAbsoluteModuleName, sizeof(szAbsoluteModuleName), "%s/bin/%s", szCwd, pModuleName );
}
hDLL = Sys_LoadLibrary( szAbsoluteModuleName, flags ); hDLL = Sys_LoadLibrary( szAbsoluteModuleName, flags );
} }

101
waf.bat Normal file
View File

@ -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%