Skip to content

Commit e794dbc

Browse files
committed
fix loading libraries with lib prefix
1 parent 597f9da commit e794dbc

File tree

9 files changed

+173
-30
lines changed

9 files changed

+173
-30
lines changed

filesystem/basefilesystem.cpp

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5020,6 +5020,7 @@ void CBaseFileSystem::CSearchPathsIterator::CopySearchPaths( const CUtlVector<CS
50205020
CSysModule *CBaseFileSystem::LoadModule( const char *pFileName, const char *pPathID, bool bValidatedDllOnly )
50215021
{
50225022
CHECK_DOUBLE_SLASHES( pFileName );
5023+
CSysModule *pModule = NULL;
50235024

50245025
LogFileAccess( pFileName );
50255026
if ( !pPathID )
@@ -5044,16 +5045,33 @@ CSysModule *CBaseFileSystem::LoadModule( const char *pFileName, const char *pPat
50445045
continue;
50455046

50465047
Q_snprintf( tempPathID, sizeof(tempPathID), "%s%s", m_SearchPaths[i].GetPathString(), pFileName ); // append the path to this dir.
5047-
CSysModule *pModule = Sys_LoadModule( tempPathID );
5048+
pModule = Sys_LoadModule( tempPathID );
50485049
if ( pModule )
50495050
{
50505051
// we found the binary in one of our search paths
50515052
return pModule;
50525053
}
5054+
5055+
#ifdef POSIX
5056+
Q_snprintf( tempPathID, sizeof(tempPathID), "%slib%s", m_SearchPaths[i].GetPathString(), pFileName ); // append the path to this dir.
5057+
printf(tempPathID);
5058+
pModule = Sys_LoadModule( tempPathID );
5059+
if ( pModule )
5060+
return pModule;
5061+
#endif
5062+
}
5063+
5064+
5065+
#ifdef POSIX
5066+
Q_snprintf( tempPathID, sizeof(tempPathID), "lib%s", pFileName );
5067+
pModule = Sys_LoadModule( tempPathID );
5068+
if( !pModule )
5069+
#endif
5070+
{
5071+
pModule = Sys_LoadModule( pFileName );
50535072
}
50545073

5055-
// couldn't load it from any of the search paths, let LoadLibrary try
5056-
return Sys_LoadModule( pFileName );
5074+
return pModule;
50575075
}
50585076

50595077
//-----------------------------------------------------------------------------

launcher_main/main.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,10 @@ static void WaitForDebuggerConnect( int argc, char *argv[], int time )
215215

216216
int main( int argc, char *argv[] )
217217
{
218-
void *launcher = dlopen( "bin/launcher" DLL_EXT_STRING, RTLD_NOW );
218+
void *launcher = dlopen( "bin/liblauncher" DLL_EXT_STRING, RTLD_NOW );
219+
if( !launcher )
220+
void *launcher = dlopen( "bin/launcher" DLL_EXT_STRING, RTLD_NOW );
221+
219222
if ( !launcher )
220223
{
221224
fprintf( stderr, "Failed to load the launcher\n" );

public/filesystem_init.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,6 +1084,7 @@ FSReturnCode_t FileSystem_SetBasePaths( IFileSystem *pFileSystem )
10841084
//-----------------------------------------------------------------------------
10851085
FSReturnCode_t FileSystem_GetFileSystemDLLName( char *pFileSystemDLL, int nMaxLen, bool &bSteam )
10861086
{
1087+
#if 0
10871088
bSteam = false;
10881089

10891090
// 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
11121113
bSteam = true;
11131114
}
11141115
#endif
1116+
#else
1117+
char executablePath[MAX_PATH];
1118+
if ( !FileSystem_GetExecutableDir( executablePath, sizeof( executablePath ) ) )
1119+
return SetupFileSystemError( false, FS_INVALID_PARAMETERS, "FileSystem_GetExecutableDir failed." );
1120+
1121+
// Assume we'll use local files
1122+
Q_snprintf( pFileSystemDLL, nMaxLen, "%s%clibfilesystem_stdio" DLL_EXT_STRING, executablePath, CORRECT_PATH_SEPARATOR );
1123+
1124+
#if !defined( _X360 )
1125+
// Use filsystem_steam if it exists?
1126+
#if defined( OSX ) || defined( LINUX )
1127+
struct stat statBuf;
1128+
#endif
1129+
if (
1130+
#if defined( OSX ) || defined( LINUX )
1131+
stat( pFileSystemDLL, &statBuf ) != 0
1132+
#else
1133+
_access( pFileSystemDLL, 0 ) != 0
1134+
#endif
1135+
) {
1136+
Q_snprintf( pFileSystemDLL, nMaxLen, "%s%cfilesystem_stdio" DLL_EXT_STRING, executablePath, CORRECT_PATH_SEPARATOR );
1137+
}
1138+
#endif
1139+
1140+
#endif
11151141

11161142
return FS_OK;
11171143
}

scripts/continious_upload.sh

Lines changed: 0 additions & 15 deletions
This file was deleted.

scripts/waifulib/compiler_optimizations.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
# disable thread-safe local static initialization for C++11 code, as it cause crashes on Windows XP
5050
'msvc': ['/D_USING_V110_SDK71_', '/Zi', '/FS', '/Zc:threadSafeInit-', '/MT'],
5151
'clang': ['-g', '-gdwarf-2', '-fvisibility=hidden'],
52-
'gcc': ['-fvisibility=hidden'],
52+
'gcc': ['-g', '-fvisibility=hidden'],
5353
'owcc': ['-fno-short-enum', '-ffloat-store', '-g3']
5454
},
5555
'fast': {
@@ -70,7 +70,7 @@
7070
'release': {
7171
'msvc': ['/O2'],
7272
'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'],
73-
'default': ['-O0']
73+
'default': ['-O3']
7474
},
7575
'debug': {
7676
'msvc': ['/Od'],

soundemittersystem/wscript

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ from waflib import Utils
55
import os
66

77
top = '.'
8-
PROJECT_NAME = 'SoundEmitterSystem'
8+
PROJECT_NAME = 'soundemittersystem'
99

1010
def options(opt):
1111
# stub

studiorender/wscript

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ from waflib import Utils
55
import os
66

77
top = '.'
8-
PROJECT_NAME = 'StudioRender'
8+
PROJECT_NAME = 'studiorender'
99

1010
def options(opt):
1111
# stub

tier1/interface.cpp

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
#include "xbox/xbox_win32stubs.h"
3737
#endif
3838

39+
#ifdef POSIX
40+
#include <sys/stat.h>
41+
#endif
3942

4043
// memdbgon must be the last include file in a .cpp file!!!
4144
#include "tier0/memdbgon.h"
@@ -273,6 +276,7 @@ CSysModule *Sys_LoadModule( const char *pModuleName, Sys_Flags flags /* = SYS_NO
273276
// file in the depot (MFP) or a filesystem GetLocalCopy() call must be made
274277
// prior to the call to this routine.
275278
char szCwd[1024];
279+
char szModuleName[1024];
276280
HMODULE hDLL = NULL;
277281

278282
if ( !Q_IsAbsolutePath( pModuleName ) )
@@ -287,22 +291,28 @@ CSysModule *Sys_LoadModule( const char *pModuleName, Sys_Flags flags /* = SYS_NO
287291
V_strcpy_safe( szCwd, CommandLine()->GetParm( i + 1 ) );
288292
}
289293
}
294+
290295
if (szCwd[strlen(szCwd) - 1] == '/' || szCwd[strlen(szCwd) - 1] == '\\' )
291296
{
292297
szCwd[strlen(szCwd) - 1] = 0;
293298
}
294299

295300
char szAbsoluteModuleName[1024];
296301
size_t cCwd = strlen( szCwd );
297-
if ( strstr( pModuleName, "bin/") == pModuleName || ( szCwd[ cCwd - 1 ] == 'n' && szCwd[ cCwd - 2 ] == 'i' && szCwd[ cCwd - 3 ] == 'b' ) )
298-
{
299-
// don't make bin/bin path
300-
Q_snprintf( szAbsoluteModuleName, sizeof(szAbsoluteModuleName), "%s/%s", szCwd, pModuleName );
301-
}
302+
303+
bool bUseLibPrefix = false;
304+
305+
#ifdef POSIX
306+
struct stat statBuf;
307+
Q_snprintf(szModuleName, sizeof(szModuleName), "bin/lib%s", pModuleName);
308+
bUseLibPrefix |= stat(szModuleName, &statBuf) == 0;
309+
#endif
310+
311+
if( bUseLibPrefix )
312+
Q_snprintf( szAbsoluteModuleName, sizeof(szAbsoluteModuleName), "%s/bin/lib%s", szCwd, pModuleName );
302313
else
303-
{
304314
Q_snprintf( szAbsoluteModuleName, sizeof(szAbsoluteModuleName), "%s/bin/%s", szCwd, pModuleName );
305-
}
315+
306316
hDLL = Sys_LoadLibrary( szAbsoluteModuleName, flags );
307317
}
308318

waf.bat

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
@echo off
2+
3+
rem try fix py2 build
4+
chcp 1252
5+
set PYTHONIOENCODING=UTF-8
6+
rem from issue #964
7+
8+
Setlocal EnableDelayedExpansion
9+
10+
rem Check Windows Version
11+
set TOKEN=tokens=3*
12+
ver | findstr /i "5\.0\." > nul
13+
if %ERRORLEVEL% EQU 0 SET TOKEN=tokens=3*
14+
ver | findstr /i "5\.1\." > nul
15+
if %ERRORLEVEL% EQU 0 SET TOKEN=tokens=3*
16+
ver | findstr /i "5\.2\." > nul
17+
if %ERRORLEVEL% EQU 0 SET TOKEN=tokens=3*
18+
ver | findstr /i "6\.0\." > nul
19+
if %ERRORLEVEL% EQU 0 SET TOKEN=tokens=2*
20+
ver | findstr /i "6\.1\." > nul
21+
if %ERRORLEVEL% EQU 0 SET TOKEN=tokens=2*
22+
23+
rem Start calculating PYTHON and PYTHON_DIR
24+
set PYTHON=
25+
set PYTHON_DIR=
26+
27+
Setlocal EnableDelayedExpansion
28+
29+
set PYTHON_DIR_OK=FALSE
30+
set REGPATH=
31+
32+
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 (
33+
for %%j in (HKCU HKLM) do (
34+
for %%k in (SOFTWARE\Wow6432Node SOFTWARE) do (
35+
for %%l in (Python\PythonCore IronPython) do (
36+
set REG_PYTHON_EXE=python.exe
37+
if "%%l"=="IronPython" (
38+
set REG_PYTHON_EXE=ipy.exe
39+
)
40+
41+
@echo on
42+
43+
set REGPATH=%%j\%%k\%%l\%%i\InstallPath
44+
rem @echo Regpath !REGPATH!
45+
REG QUERY "!REGPATH!" /ve 1>nul 2>nul
46+
if !ERRORLEVEL! equ 0 (
47+
for /F "%TOKEN% delims= " %%A IN ('REG QUERY "!REGPATH!" /ve') do @set REG_PYTHON_DIR=%%B
48+
if exist !REG_PYTHON_DIR! (
49+
IF NOT "!REG_PYTHON_DIR:~-1!"=="\" SET REG_PYTHON_DIR=!REG_PYTHON_DIR!\
50+
set REG_PYTHON=!REG_PYTHON_DIR!!REG_PYTHON_EXE!
51+
rem set PYTHON_DIR_OK=TRUE
52+
if "!PYTHON_DIR_OK!"=="FALSE" (
53+
set PYTHON_DIR=!REG_PYTHON_DIR!
54+
set PYTHON=!REG_PYTHON!
55+
set PYTHON_DIR_OK=TRUE
56+
)
57+
58+
rem set PYTHON_DIR_OK=FALSE
59+
rem @echo Find !REG_PYTHON!
60+
rem goto finished
61+
)
62+
)
63+
64+
echo off
65+
66+
)
67+
rem for l
68+
)
69+
rem for k
70+
)
71+
rem for j
72+
)
73+
rem for i
74+
75+
76+
77+
:finished
78+
79+
Endlocal & SET PYTHON_DIR=%PYTHON_DIR% & SET PYTHON=%PYTHON%
80+
81+
if "%PYTHON_DIR%" == "" (
82+
rem @echo No Python dir
83+
set PYTHON=python
84+
goto running
85+
)
86+
87+
rem @echo %PYTHON_DIR%
88+
89+
if "%PYTHON%" == "" (
90+
rem @echo No Python
91+
set PYTHON=python
92+
goto running
93+
)
94+
95+
:running
96+
97+
@echo Using %PYTHON%
98+
99+
"%PYTHON%" -x "%~dp0waf" %*
100+
Endlocal
101+
exit /b %ERRORLEVEL%

0 commit comments

Comments
 (0)