Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow installation to global directories. #246

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion appframework/posixapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ bool CSteamApplication::Create( )
m_pFileSystem = (IFileSystem*)AddSystem( fileSystemModule, FILESYSTEM_INTERFACE_VERSION );
if ( !m_pFileSystem )
{
Error( "Unable to load %s", pFileSystemDLL );
Error( "Unable to load %s\n", pFileSystemDLL );
return false;
}

Expand Down
9 changes: 3 additions & 6 deletions dedicated/sys_ded.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,12 +360,9 @@ void CDedicatedAppSystemGroup::Destroy()
bool GetExecutableName( char *out, int nMaxLen )
{
#ifdef _WIN32
if ( !::GetModuleFileName( ( HINSTANCE )GetModuleHandle( NULL ), out, nMaxLen ) )
return false;
return true;
#elif POSIX
Q_strncpy( out, g_szEXEName, nMaxLen );
return true;
return !!::GetModuleFileName( ( HINSTANCE )GetModuleHandle( NULL ), out, nMaxLen );
#else
return false;
#endif
}

Expand Down
31 changes: 5 additions & 26 deletions dedicated_main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,33 +188,13 @@ static void WaitForDebuggerConnect( int argc, char *argv[], int time )

int main( int argc, char *argv[] )
{
// Must add 'bin' to the path....
char* pPath = getenv("LD_LIBRARY_PATH");
char szBuffer[4096];
char cwd[ MAX_PATH ];
if ( !getcwd( cwd, sizeof(cwd)) )
{
printf( "getcwd failed (%s)", strerror(errno));
}

snprintf( szBuffer, sizeof( szBuffer ) - 1, "LD_LIBRARY_PATH=%s/bin:%s", cwd, pPath );
int ret = putenv( szBuffer );
if ( ret )
{
printf( "%s\n", strerror(errno) );
}
void *tier0 = dlopen( "libtier0" DLL_EXT_STRING, RTLD_NOW );
void *vstdlib = dlopen( "libvstdlib" DLL_EXT_STRING, RTLD_NOW );

const char *pBinaryName = "bin/dedicated" DLL_EXT_STRING;

void *dedicated = dlopen( pBinaryName, RTLD_NOW );
void *dedicated = dlopen( "libdedicated" DLL_EXT_STRING, RTLD_NOW );
if ( !dedicated )
dedicated = dlopen( "bin/libdedicated" DLL_EXT_STRING, RTLD_NOW );
dedicated = dlopen( "dedicated" DLL_EXT_STRING, RTLD_NOW );

if ( !dedicated )
{
printf( "Failed to open %s (%s)\n", pBinaryName, dlerror());
printf( "Failed to open dedicated" DLL_EXT_STRING " (%s)\n", dlerror());
return -1;
}
DedicatedMain_t dedicated_main = (DedicatedMain_t)dlsym( dedicated, "DedicatedMain" );
Expand All @@ -226,9 +206,8 @@ int main( int argc, char *argv[] )

WaitForDebuggerConnect( argc, argv, 30 );

ret = dedicated_main( argc,argv );
int ret = dedicated_main( argc,argv );
dlclose( dedicated );
dlclose( vstdlib );
dlclose( tier0 );
return ret;
}
#endif
58 changes: 29 additions & 29 deletions engine/sys_dll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,33 +342,34 @@ bool Sys_MessageBox(const char *title, const char *info, bool bShowOkAndCancel)
return true;
}
return false;

#elif defined( USE_SDL )

int buttonid = 0;
SDL_MessageBoxData messageboxdata = { 0 };
SDL_MessageBoxButtonData buttondata[] =
{
{ SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 1, "OK" },
{ SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, 0, "Cancel" },
};

messageboxdata.window = GetAssertDialogParent();
messageboxdata.title = title;
messageboxdata.message = info;
messageboxdata.numbuttons = bShowOkAndCancel ? 2 : 1;
messageboxdata.buttons = buttondata;

SDL_ShowMessageBox( &messageboxdata, &buttonid );
return ( buttonid == 1 );

#elif defined( POSIX )

Warning( "%s\n", info );
return true;

#else
#error "implement me"
#if defined( USE_SDL )
SDL_Window *dialogParent = GetAssertDialogParent();
if (dialogParent)
{
int buttonid = 0;
SDL_MessageBoxData messageboxdata = { 0 };
SDL_MessageBoxButtonData buttondata[] =
{
{ SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 1, "OK" },
{ SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, 0, "Cancel" },
};

messageboxdata.window = GetAssertDialogParent();
messageboxdata.title = title;
messageboxdata.message = info;
messageboxdata.numbuttons = bShowOkAndCancel ? 2 : 1;
messageboxdata.buttons = buttondata;

SDL_ShowMessageBox( &messageboxdata, &buttonid );
return ( buttonid == 1 );
}
else
#endif
{
Warning( "%s\n", info );
return true;
}
#endif
}

Expand Down Expand Up @@ -464,7 +465,7 @@ void Sys_Error_Internal( bool bMinidump, const char *error, va_list argsList )
// Doing this doesn't quite work the way we want because there is no "crashing" thread
// and we see "No thread was identified as the cause of the crash; No signature could be created because we do not know which thread crashed" on the back end
//SteamAPI_WriteMiniDump( 0, NULL, build_number() );
printf("\n ##### Sys_Error: %s", text );
printf("\n ##### Sys_Error: %s\n", text );
fflush(stdout );

raise(SIGTRAP);
Expand Down Expand Up @@ -1117,7 +1118,6 @@ void Sys_ShutdownGame( void )

CreateInterfaceFn g_ServerFactory;


#pragma optimize( "g", off )
static bool LoadThisDll( char *szDllFilename, bool bIsServerOnly )
{
Expand Down Expand Up @@ -1255,7 +1255,7 @@ void LoadEntityDLLs( const char *szBaseDir, bool bIsServerOnly )

if ( serverGameDLL )
{
Msg("server%s loaded for \"%s\"\n", DLL_EXT_STRING, (char *)serverGameDLL->GetGameDescription());
Msg("server" DLL_EXT_STRING " loaded for \"%s\"\n", (char *)serverGameDLL->GetGameDescription());
}
}

Expand Down
13 changes: 5 additions & 8 deletions filesystem/basefilesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5057,20 +5057,17 @@ CSysModule *CBaseFileSystem::LoadModule( const char *pFileName, const char *pPat
if ( FilterByPathID( &m_SearchPaths[i], lookup ) )
continue;

Q_snprintf( tempPathID, sizeof(tempPathID), "%s%s", m_SearchPaths[i].GetPathString(), pFileName ); // append the path to this dir.
pModule = Sys_LoadModule( tempPathID );
if ( pModule )
{
// we found the binary in one of our search paths
return pModule;
}

#ifdef POSIX
Q_snprintf( tempPathID, sizeof(tempPathID), "%slib%s", m_SearchPaths[i].GetPathString(), pFileName ); // append the path to this dir.
pModule = Sys_LoadModule( tempPathID );
if ( pModule )
return pModule;
#endif

Q_snprintf( tempPathID, sizeof(tempPathID), "%s%s", m_SearchPaths[i].GetPathString(), pFileName ); // append the path to this dir.
pModule = Sys_LoadModule( tempPathID );
if ( pModule )
return pModule;
}
#endif

Expand Down
4 changes: 2 additions & 2 deletions game/client/wscript
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ def build(bld):
'ZLIB'
]

install_path = bld.env.PREFIX
install_path = bld.env.LIBDIR
if bld.env.DEST_OS != 'android':
install_path += '/'+bld.env.GAMES+'/bin'
install_path += '/'+bld.env.GAMES
Comment on lines +68 to +70
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ебанутый или да?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

да


source = [ 'in_touch.cpp' ]
if bld.env.DEST_OS == 'win32':
Expand Down
4 changes: 2 additions & 2 deletions game/server/wscript
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ def build(bld):
if bld.env.DEST_OS == 'win32':
libs += ['USER32']

install_path = bld.env.PREFIX
install_path = bld.env.LIBDIR
if bld.env.DEST_OS != 'android':
install_path += '/'+bld.env.GAMES+'/bin'
install_path += '/'+bld.env.GAMES
Comment on lines +62 to +64
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ебанутый или да?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

самоходная пизда


source = game["sources"] + ['../../public/tier0/memoverride.cpp']
includes += game["includes"]
Expand Down
6 changes: 1 addition & 5 deletions launcher/launcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,7 @@ void SetGameDirectory( const char *game )
bool GetExecutableName( char *out, int outSize )
{
#ifdef WIN32
if ( !::GetModuleFileName( ( HINSTANCE )GetModuleHandle( NULL ), out, outSize ) )
{
return false;
}
return true;
return !!::GetModuleFileName( ( HINSTANCE )GetModuleHandle( NULL ), out, outSize );
#else
return false;
#endif
Expand Down
27 changes: 4 additions & 23 deletions launcher_main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,31 +216,12 @@ static void WaitForDebuggerConnect( int argc, char *argv[], int time )

int main( int argc, char *argv[] )
{
char ld_path[4196];
char *path = "bin/";
char *ld_env;

if( (ld_env = getenv("LD_LIBRARY_PATH")) != NULL )
{
snprintf(ld_path, sizeof(ld_path), "%s:bin/", ld_env);
path = ld_path;
}

setenv("LD_LIBRARY_PATH", path, 1);

extern char** environ;
if( getenv("NO_EXECVE_AGAIN") == NULL )
{
setenv("NO_EXECVE_AGAIN", "1", 1);
execve(argv[0], argv, environ);
}

void *launcher = dlopen( "bin/liblauncher" DLL_EXT_STRING, RTLD_NOW );
void *launcher = dlopen( "liblauncher" DLL_EXT_STRING, RTLD_NOW );
if ( !launcher )
{
fprintf( stderr, "%s\nFailed to load the launcher\n", dlerror() );

if( !launcher )
launcher = dlopen( "bin/launcher" DLL_EXT_STRING, RTLD_NOW );
launcher = dlopen( "launcher" DLL_EXT_STRING, RTLD_NOW );
}

if ( !launcher )
{
Expand Down
4 changes: 1 addition & 3 deletions materialsystem/cmaterialsystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ bool CMaterialSystem::Connect( CreateInterfaceFn factory )
g_pLauncherMgr = (ILauncherMgr *)factory( "SDLMgrInterface001" /*SDL_MGR_INTERFACE_VERSION*/, NULL );
if ( !g_pLauncherMgr )
{
return false;
Warning("Cannot connect SDL\n");
}
#endif // USE_SDL
#endif // !DEDICATED
Expand Down Expand Up @@ -3102,8 +3102,6 @@ void CMaterialSystem::ResetTempHWMemory( bool bExitingLevel )
//-----------------------------------------------------------------------------
void CMaterialSystem::CacheUsedMaterials( )
{
printf("Cache materials\n");

g_pShaderAPI->EvictManagedResources();

for (MaterialHandle_t i = FirstMaterial(); i != InvalidMaterial(); i = NextMaterial(i) )
Expand Down
86 changes: 25 additions & 61 deletions public/filesystem_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,54 +308,13 @@ static bool Sys_GetExecutableName( char *out, int len )
bool FileSystem_GetExecutableDir( char *exedir, int exeDirLen )
{
#ifdef ANDROID
Q_snprintf( exedir, exeDirLen, "%s", getenv("APP_LIB_PATH") );
Q_strncpy( exedir, getenv("APP_LIB_PATH"), exeDirLen );
#else
exedir[0] = 0;

if ( s_bUseVProjectBinDir )
{
const char *pProject = GetVProjectCmdLineValue();
if ( !pProject )
{
// Check their registry.
pProject = getenv( GAMEDIR_TOKEN );
}
if ( pProject )
{
Q_snprintf( exedir, exeDirLen, "%s%c..%cbin", pProject, CORRECT_PATH_SEPARATOR, CORRECT_PATH_SEPARATOR );
return true;
}
return false;
}

if ( !Sys_GetExecutableName( exedir, exeDirLen ) )
return false;
Q_StripFilename( exedir );

if ( IsX360() )
{
// The 360 can have its exe and dlls reside on different volumes
// use the optional basedir as the exe dir
if ( CommandLine()->FindParm( "-basedir" ) )
{
strcpy( exedir, CommandLine()->ParmValue( "-basedir", "" ) );
}
}

Q_FixSlashes( exedir );

const char* libDir = "bin";

// Return the bin directory as the executable dir if it's not in there
// because that's really where we're running from...
char ext[MAX_PATH];
Q_StrRight( exedir, 4, ext, sizeof( ext ) );
if ( ext[0] != CORRECT_PATH_SEPARATOR || Q_stricmp( ext+1, libDir ) != 0 )
{
Q_strncat( exedir, CORRECT_PATH_SEPARATOR_S, exeDirLen, COPY_ALL_CHARACTERS );
Q_strncat( exedir, libDir, exeDirLen, COPY_ALL_CHARACTERS );
Q_FixSlashes( exedir );
}
# ifdef _WIN32
Q_strncpy( exedir, "./bin", exeDirLen );
# else
Q_strncpy( exedir, LIBDIR, exeDirLen );
# endif
#endif

return true;
Expand All @@ -364,17 +323,15 @@ bool FileSystem_GetExecutableDir( char *exedir, int exeDirLen )
static bool FileSystem_GetBaseDir( char *baseDir, int baseDirLen )
{
#ifdef ANDROID
strncpy(baseDir, getenv("VALVE_GAME_PATH"), baseDirLen);
return true;
Q_strncpy(baseDir, getenv("VALVE_GAME_PATH"), baseDirLen);
#else
if ( FileSystem_GetExecutableDir( baseDir, baseDirLen ) )
{
Q_StripFilename( baseDir );
return true;
}

return false;
// get relative base dir which appends to other paths
// allows to run from everywhere
// "hl2/portal" -> "hl2"; "hl2" -> ""
Q_strncpy( baseDir, CommandLine()->ParmValue("-game", ""), baseDirLen );
Q_StripFilename( baseDir );
#endif
return true;
}

void LaunchVConfig()
Expand Down Expand Up @@ -1094,16 +1051,23 @@ FSReturnCode_t FileSystem_SetBasePaths( IFileSystem *pFileSystem )
{
pFileSystem->RemoveSearchPaths( "EXECUTABLE_PATH" );

char executablePath[MAX_PATH];
if ( !FileSystem_GetExecutableDir( executablePath, sizeof( executablePath ) ) )
char path[MAX_PATH];
if ( !FileSystem_GetExecutableDir( path, MAX_PATH ) )
return SetupFileSystemError( false, FS_INVALID_PARAMETERS, "FileSystem_GetExecutableDir failed." );

pFileSystem->AddSearchPath( executablePath, "EXECUTABLE_PATH" );
pFileSystem->AddSearchPath( path, "EXECUTABLE_PATH" );

if ( !FileSystem_GetBaseDir( executablePath, sizeof( executablePath ) ) )
if ( !FileSystem_GetBaseDir( path, MAX_PATH ) )
return SetupFileSystemError( false, FS_INVALID_PARAMETERS, "FileSystem_GetBaseDir failed." );

pFileSystem->AddSearchPath( executablePath, "BASE_PATH" );
pFileSystem->AddSearchPath( path, "BASE_PATH" );

// path for client/server libraries
// "hl2/portal" -> "LIBDIR/portal"; "hl2" -> "LIBDIR/hl2"
char gamePath[MAX_PATH];
V_FileBase( CommandLine()->ParmValue("-game"), gamePath, MAX_PATH );
Q_snprintf( path, MAX_PATH, "%s/%s", LIBDIR, gamePath );
pFileSystem->AddSearchPath( path, "GAMEBIN" );

return FS_OK;
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/tests-macos-amd64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ git submodule init && git submodule update
./waf configure -T release --sanitize=address,undefined --disable-warns --tests -8 --prefix=out/ $* &&
./waf install &&
cd out &&
DYLD_LIBRARY_PATH=bin/ ./unittest || exit 1
./bin/unittest || exit 1
Loading