Browse Source

Initial android support (#17)

* Upload Android armv7 libs

* Fix debug build

* utlvector: fix undefined behavior

* wscript: add --use-ccache option

* wscript: store ccache in a separate directory

* Propertly use gl4es

* fontconfig: fix font detection

* [android]remove fontconfig dependency

* Add build guide for other platforms

Co-authored-by: JusicP <slender87844@gmail.com>
Co-authored-by: nillerusr <nillerusr@users.noreply.github.com>
pull/19/head
nillerusr 3 years ago committed by GitHub
parent
commit
2c6669f5e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      .gitignore
  2. 12
      README.md
  3. 31
      appframework/sdlmgr.cpp
  4. 4
      common/freetype/config/ftconfig.h
  5. 3
      datacache/wscript
  6. 2
      datamodel/dmattribute.cpp
  7. 7
      engine/wscript
  8. 20
      filesystem/basefilesystem.cpp
  9. 4
      filesystem/filesystem_stdio.cpp
  10. 12
      filesystem/packfile.cpp
  11. 2
      game/client/mumble.cpp
  12. 4
      game/client/wscript
  13. 4
      game/server/wscript
  14. 2
      gameui/wscript
  15. 145
      launcher/android.cpp
  16. 17
      launcher/launcher.cpp
  17. 1
      launcher/wscript
  18. 1
      launcher_main/main.cpp
  19. 4
      launcher_main/wscript
  20. BIN
      lib/android/armeabi-v7a/libSDL2.so
  21. BIN
      lib/android/armeabi-v7a/libandroid_support.a
  22. BIN
      lib/android/armeabi-v7a/libbz2.a
  23. BIN
      lib/android/armeabi-v7a/libcrypto.a
  24. BIN
      lib/android/armeabi-v7a/libcurl.a
  25. BIN
      lib/android/armeabi-v7a/libexpat.a
  26. BIN
      lib/android/armeabi-v7a/libfreetype2.a
  27. BIN
      lib/android/armeabi-v7a/libjpeg.a
  28. BIN
      lib/android/armeabi-v7a/libopenal.a
  29. BIN
      lib/android/armeabi-v7a/libpng.a
  30. BIN
      lib/android/armeabi-v7a/libssl.a
  31. BIN
      lib/android/x86/libandroid_support.a
  32. 5
      materialsystem/shaderapidx9/wscript
  33. 3
      materialsystem/stdshaders/wscript
  34. 2
      materialsystem/wscript
  35. 17
      public/filesystem_init.cpp
  36. 2
      public/tier0/memdbgon.h
  37. 11
      public/tier0/memoverride.cpp
  38. 41
      public/tier1/utlvector.h
  39. 5
      scenefilecache/wscript
  40. 12
      scripts/waifulib/xcompile.py
  41. 2
      soundemittersystem/wscript
  42. 2
      studiorender/wscript
  43. 2
      thirdparty
  44. 8
      tier0/dbg.cpp
  45. 3
      tier0/platform_posix.cpp
  46. 5
      tier0/threadtools.cpp
  47. 4
      tier0/wscript
  48. 18
      tier1/interface.cpp
  49. 7
      tier1/pathmatch.cpp
  50. 2
      tier1/wscript
  51. 6
      togl/linuxwin/glentrypoints.cpp
  52. 1
      togl/wscript
  53. 74
      vgui2/vgui_surfacelib/linuxfont.cpp
  54. 2
      vgui2/vgui_surfacelib/wscript
  55. 9
      vguimatsurface/wscript
  56. 3
      vstdlib/wscript
  57. 93
      wscript

3
.gitignore vendored

@ -1,11 +1,10 @@
*.mak *.mak
*.mak.vpc_crc *.mak.vpc_crc
*.vpc_crc *.vpc_crc
*.a
*.project *.project
lib/
*obj_* *obj_*
build/ build/
.waf* .waf*
.lock-waf* .lock-waf*
__pycache__ __pycache__
*.pyc

12
README.md

@ -11,11 +11,19 @@ The main purpose of this repository is to port the engine for other platforms.
* replace current buildsystem with waf * replace current buildsystem with waf
* rewrite achivement system( to work without steam ) * rewrite achivement system( to work without steam )
# How to Build? # How to Build?
On Linux:
1. Clone repo ( ```git clone https://github.com/nillerusr/source-engine```) 1. Clone repo ( ```git clone https://github.com/nillerusr/source-engine```)
2. Run ```git submodule init && git submodule update``` 2. Run ```git submodule init && git submodule update```
3. Build
On Linux:
``` ```
./waf configure -T debug ./waf configure -T debug
./waf build ./waf build
``` ```
On Linux for Android(**Note: only Android NDK r10e is supported**):
```
export ANDROID_NDK=/path/to/ndk
./waf configure -T debug --android=armeabi-v7a,4.9,21
./waf build
```
On Windows:
**TODO(WAF is not configured for Windows. Use VPC as temporary solution)**

31
appframework/sdlmgr.cpp

@ -56,6 +56,11 @@ COpenGLEntryPoints *gGL = NULL;
const int kBogusSwapInterval = INT_MAX; const int kBogusSwapInterval = INT_MAX;
#ifdef ANDROID
static void *gl4es = NULL;
void *(*_glGetProcAddress)( const char * );
#endif
/* /*
From Ryan Gordon: From Ryan Gordon:
@ -174,7 +179,19 @@ void *VoidFnPtrLookup_GlMgr(const char *fn, bool &okay, const bool bRequired, vo
return NULL; return NULL;
// The SDL path would work on all these platforms, if we were using SDL there, too... // The SDL path would work on all these platforms, if we were using SDL there, too...
#if defined( USE_SDL )
#ifdef ANDROID
// SDL does the right thing, so we never need to use tier0 in this case.
if( _glGetProcAddress )
retval = _glGetProcAddress(fn);
//printf("CDynamicFunctionOpenGL: SDL_GL_GetProcAddress(\"%s\") returned %p\n", fn, retval);
if ((retval == NULL) && (fallback != NULL))
{
//printf("CDynamicFunctionOpenGL: Using fallback %p for \"%s\"\n", fallback, fn);
retval = fallback;
}
#elif defined( USE_SDL )
// SDL does the right thing, so we never need to use tier0 in this case. // SDL does the right thing, so we never need to use tier0 in this case.
retval = SDL_GL_GetProcAddress(fn); retval = SDL_GL_GetProcAddress(fn);
//printf("CDynamicFunctionOpenGL: SDL_GL_GetProcAddress(\"%s\") returned %p\n", fn, retval); //printf("CDynamicFunctionOpenGL: SDL_GL_GetProcAddress(\"%s\") returned %p\n", fn, retval);
@ -742,6 +759,18 @@ bool CSDLMgr::CreateHiddenGameWindow( const char *pTitle, int width, int height
SDL_GL_MakeCurrent(m_Window, m_GLContext); SDL_GL_MakeCurrent(m_Window, m_GLContext);
#ifdef ANDROID
gl4es = dlopen("libgl4es.so", RTLD_LAZY);
if( gl4es )
{
_glGetProcAddress = dlsym(gl4es, "gl4es_GetProcAddress" );
void (*initialize_gl4es)( );
initialize_gl4es = dlsym(gl4es, "initialize_gl4es" );
initialize_gl4es();
}
#endif
// !!! FIXME: note for later...we never delete this context anywhere, I think. // !!! FIXME: note for later...we never delete this context anywhere, I think.
// !!! FIXME: when we do get around to that, don't forget to delete/NULL gGL! // !!! FIXME: when we do get around to that, don't forget to delete/NULL gGL!

4
common/freetype/config/ftconfig.h

@ -1,7 +1,11 @@
#ifndef __FTCONFIG_H__MULTILIB #ifndef __FTCONFIG_H__MULTILIB
#define __FTCONFIG_H__MULTILIB #define __FTCONFIG_H__MULTILIB
#ifdef ANDROID
#include <sys/cdefs.h>
#else
#include <bits/wordsize.h> #include <bits/wordsize.h>
#endif
#if __WORDSIZE == 32 #if __WORDSIZE == 32
# include "ftconfig-32.h" # include "ftconfig-32.h"

3
datacache/wscript vendored

@ -35,6 +35,9 @@ def build(bld):
libs = ['tier0','tier1','tier2','tier3'] libs = ['tier0','tier1','tier2','tier3']
if bld.env.DEST_OS == 'android':
libs += ['ANDROID_SUPPORT']
install_path = bld.env.LIBDIR install_path = bld.env.LIBDIR
bld.shlib( bld.shlib(

2
datamodel/dmattribute.cpp

@ -2898,7 +2898,7 @@ void CDmaDecorator<T,B>::Init( CDmElement *pOwner, const char *pAttributeName, i
{ {
Assert( pOwner ); Assert( pOwner );
this->m_pAttribute = pOwner->AddExternalAttribute( pAttributeName, CDmAttributeInfo<CUtlVector<T> >::AttributeType(), &Value() ); this->m_pAttribute = pOwner->AddExternalAttribute( pAttributeName, CDmAttributeInfo<CUtlVector<T> >::AttributeType(), &Value() );
Assert( m_pAttribute ); Assert( this->m_pAttribute );
if ( nFlags ) if ( nFlags )
{ {
this->m_pAttribute->AddFlag( nFlags ); this->m_pAttribute->AddFlag( nFlags );

7
engine/wscript

@ -323,12 +323,15 @@ def build(bld):
'../common', '../common',
'audio', 'audio',
'audio/public', 'audio/public',
'audio/private' 'audio/private',
] ]
defines = [] defines = []
libs = ['tier0','vgui_controls','dmxloader','tier1','tier2','tier3','bitmap','vstdlib','appframework','datamodel','vtf','mathlib','steam_api','matsys_controls','BZ2','SDL2','JPEG','ZLIB','OPENAL','CURL'] libs = ['tier0','vgui_controls','dmxloader','tier1','tier2','tier3','bitmap','vstdlib','appframework','datamodel','vtf','mathlib','steam_api','matsys_controls','BZ2','SDL2','JPEG','ZLIB','OPENAL','CURL' ]
if bld.env.DEST_OS == 'android':
libs += ['SSL', 'CRYPTO'] # android curl was built with openssl
install_path = bld.env.LIBDIR install_path = bld.env.LIBDIR

20
filesystem/basefilesystem.cpp

@ -3770,8 +3770,10 @@ bool CBaseFileSystem::IsFileWritable( char const *pFileName, char const *pPathID
{ {
#ifdef WIN32 #ifdef WIN32
if( buf.st_mode & _S_IWRITE ) if( buf.st_mode & _S_IWRITE )
#elif LINUX #elif defined (LINUX) && !defined (ANDROID)
if( buf.st_mode & S_IWRITE ) if( buf.st_mode & S_IWRITE )
#elif ANDROID
if( buf.st_mode & S_IWUSR )
#else #else
if( buf.st_mode & S_IWRITE ) if( buf.st_mode & S_IWRITE )
#endif #endif
@ -3792,8 +3794,10 @@ bool CBaseFileSystem::IsFileWritable( char const *pFileName, char const *pPathID
{ {
#ifdef WIN32 #ifdef WIN32
if ( buf.st_mode & _S_IWRITE ) if ( buf.st_mode & _S_IWRITE )
#elif LINUX #elif defined (LINUX) && !defined (ANDROID)
if ( buf.st_mode & S_IWRITE ) if ( buf.st_mode & S_IWRITE )
#elif ANDROID
if ( buf.st_mode & S_IWUSR )
#else #else
if ( buf.st_mode & S_IWRITE ) if ( buf.st_mode & S_IWRITE )
#endif #endif
@ -3812,6 +3816,8 @@ bool CBaseFileSystem::SetFileWritable( char const *pFileName, bool writable, con
#ifdef _WIN32 #ifdef _WIN32
int pmode = writable ? ( _S_IWRITE | _S_IREAD ) : ( _S_IREAD ); int pmode = writable ? ( _S_IWRITE | _S_IREAD ) : ( _S_IREAD );
#elif ANDROID
int pmode = writable ? ( S_IWUSR | S_IRUSR ) : ( S_IRUSR );
#else #else
int pmode = writable ? ( S_IWRITE | S_IREAD ) : ( S_IREAD ); int pmode = writable ? ( S_IWRITE | S_IREAD ) : ( S_IREAD );
#endif #endif
@ -5062,13 +5068,15 @@ CSysModule *CBaseFileSystem::LoadModule( const char *pFileName, const char *pPat
#ifdef POSIX #ifdef POSIX
Q_snprintf( tempPathID, sizeof(tempPathID), "lib%s", pFileName );
pModule = Sys_LoadModule( tempPathID );
if( !pModule ) if( !pModule )
#endif
{ {
pModule = Sys_LoadModule( pFileName ); Q_snprintf( tempPathID, sizeof(tempPathID), "lib%s", pFileName );
pModule = Sys_LoadModule( tempPathID );
} }
#endif
if( !pModule )
pModule = Sys_LoadModule( pFileName );
return pModule; return pModule;
} }

4
filesystem/filesystem_stdio.cpp

@ -972,7 +972,11 @@ void CStdioFile::FS_fclose()
AUTO_LOCK( m_MutexLockedFD ); AUTO_LOCK( m_MutexLockedFD );
struct _stat buf; struct _stat buf;
#ifdef ANDROID
int fd = fileno( m_pFile ); // need to test this
#else
int fd = fileno_unlocked( m_pFile ); int fd = fileno_unlocked( m_pFile );
#endif
fstat( fd, &buf ); fstat( fd, &buf );
fflush( m_pFile ); fflush( m_pFile );

12
filesystem/packfile.cpp

@ -879,10 +879,10 @@ int64 CZipPackFileHandle::AbsoluteBaseOffset()
return m_pOwner->GetPackFileBaseOffset() + m_nBase; return m_pOwner->GetPackFileBaseOffset() + m_nBase;
} }
#if defined( _DEBUG ) && !defined( OSX ) #if defined( _DEBUG ) && !defined( OSX ) && !defined( ANDROID )
#include <atomic> #include <atomic>
static std::atomic<int> sLZMAPackFileHandles( 0 ); static std::atomic<int> sLZMAPackFileHandles( 0 );
#endif // defined( _DEBUG ) && !defined( OSX ) #endif // defined( _DEBUG ) && !defined( OSX ) && !defined( ANDROID )
CLZMAZipPackFileHandle::CLZMAZipPackFileHandle( CZipPackFile* pOwner, int64 nBase, unsigned int nOriginalSize, unsigned int nCompressedSize, CLZMAZipPackFileHandle::CLZMAZipPackFileHandle( CZipPackFile* pOwner, int64 nBase, unsigned int nOriginalSize, unsigned int nCompressedSize,
unsigned int nIndex, unsigned int nFilePointer ) unsigned int nIndex, unsigned int nFilePointer )
@ -892,7 +892,7 @@ CLZMAZipPackFileHandle::CLZMAZipPackFileHandle( CZipPackFile* pOwner, int64 nBas
m_pLZMAStream( NULL ), m_nSeekPosition( 0 ), m_nOriginalSize( nOriginalSize ) m_pLZMAStream( NULL ), m_nSeekPosition( 0 ), m_nOriginalSize( nOriginalSize )
{ {
Reset(); Reset();
#if defined( _DEBUG ) && !defined( OSX ) #if defined( _DEBUG ) && !defined( OSX ) && !defined( ANDROID )
if ( ++sLZMAPackFileHandles == PACKFILE_COMPRESSED_FILE_HANDLES_WARNING ) if ( ++sLZMAPackFileHandles == PACKFILE_COMPRESSED_FILE_HANDLES_WARNING )
{ {
// By my count a live filehandle is currently around 270k, mostly due to the LZMA dictionary (256k) with the // By my count a live filehandle is currently around 270k, mostly due to the LZMA dictionary (256k) with the
@ -901,17 +901,17 @@ CLZMAZipPackFileHandle::CLZMAZipPackFileHandle( CZipPackFile* pOwner, int64 nBas
"These carry large buffers around, and can cause high memory usage\n", "These carry large buffers around, and can cause high memory usage\n",
PACKFILE_COMPRESSED_FILE_HANDLES_WARNING ); PACKFILE_COMPRESSED_FILE_HANDLES_WARNING );
} }
#endif // defined( _DEBUG ) && !defined( OSX ) #endif // defined( _DEBUG ) && !defined( OSX ) && !defined( ANDROID )
} }
CLZMAZipPackFileHandle::~CLZMAZipPackFileHandle() CLZMAZipPackFileHandle::~CLZMAZipPackFileHandle()
{ {
delete m_pLZMAStream; delete m_pLZMAStream;
m_pLZMAStream = NULL; m_pLZMAStream = NULL;
#if defined( _DEBUG ) && !defined( OSX ) #if defined( _DEBUG ) && !defined( OSX ) && !defined( ANDROID )
sLZMAPackFileHandles--; sLZMAPackFileHandles--;
Assert( sLZMAPackFileHandles >= 0 ); Assert( sLZMAPackFileHandles >= 0 );
#endif // defined( _DEBUG ) && !defined( OSX ) #endif // defined( _DEBUG ) && !defined( OSX ) && !defined( ANDROID )
} }
int CLZMAZipPackFileHandle::Read( void* pBuffer, int nDestSize, int nBytes ) int CLZMAZipPackFileHandle::Read( void* pBuffer, int nDestSize, int nBytes )

2
game/client/mumble.cpp

@ -98,6 +98,8 @@ void CMumbleSystem::LevelInitPostEntity()
g_hMapObject = NULL; g_hMapObject = NULL;
return; return;
} }
#elif defined( ANDROID )
return; // TODO(JusicP): implement
#elif defined( POSIX ) #elif defined( POSIX )
char memname[256]; char memname[256];
V_sprintf_safe( memname, "/MumbleLink.%d", getuid() ); V_sprintf_safe( memname, "/MumbleLink.%d", getuid() );

4
game/client/wscript

@ -559,7 +559,9 @@ def build(bld):
'RT' 'RT'
] ]
install_path = bld.env.PREFIX+'/hl2/bin' install_path = bld.env.PREFIX
if bld.env.DEST_OS != 'android':
install_path += '/hl2/bin'
bld.shlib( bld.shlib(
source = source, source = source,

4
game/server/wscript

@ -602,7 +602,9 @@ def build(bld):
libs = ['tier0','particles','dmxloader','tier1','tier2','tier3','mathlib','vstdlib','choreoobjects','steam_api'] libs = ['tier0','particles','dmxloader','tier1','tier2','tier3','mathlib','vstdlib','choreoobjects','steam_api']
install_path = bld.env.PREFIX+'/hl2/bin' install_path = bld.env.PREFIX
if bld.env.DEST_OS != 'android':
install_path += '/hl2/bin'
bld.shlib( bld.shlib(
source = source, source = source,

2
gameui/wscript

@ -107,7 +107,7 @@ def build(bld):
defines = [] defines = []
libs = ['tier0','vgui_controls','tier1','tier2','tier3','vstdlib','vtf','bitmap','mathlib','SDL2','steam_api','matsys_controls','JPEG','PNG'] libs = ['tier0','vgui_controls','tier1','tier2','tier3','vstdlib','vtf','bitmap','mathlib','SDL2','steam_api','matsys_controls','JPEG','PNG','ZLIB']
install_path = bld.env.LIBDIR install_path = bld.env.LIBDIR

145
launcher/android.cpp

@ -0,0 +1,145 @@
#ifdef ANDROID
#include <android/log.h>
#include <jni.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdio.h>
#include <dlfcn.h>
#include "tier0/threadtools.h"
char *LauncherArgv[512];
char java_args[4096];
int iLastArgs = 0;
#define TAG "SRCENG"
#define PRIO ANDROID_LOG_DEBUG
#define LogPrintf(...) do { __android_log_print(PRIO, TAG, __VA_ARGS__); printf( __VA_ARGS__); } while( 0 );
#define DLLEXPORT extern "C" __attribute__((visibility("default")))
DLLEXPORT void Java_com_valvesoftware_ValveActivity2_setDataDirectoryPath(JNIEnv *env, jclass *clazz, jstring path)
{
setenv( "APP_DATA_PATH", env->GetStringUTFChars(path, NULL), 1);
LogPrintf( "Java_com_valvesoftware_ValveActivity2_setDataDirectoryPath: %s", getenv("APP_DATA_PATH") );
}
DLLEXPORT void Java_com_valvesoftware_ValveActivity2_setGameDirectoryPath(JNIEnv *env, jclass *clazz, jstring path)
{
LogPrintf( "Java_com_valvesoftware_ValveActivity2_setGameDirectoryPath" );
setenv( "VALVE_GAME_PATH", env->GetStringUTFChars(path, NULL), 1 );
}
DLLEXPORT int Java_com_valvesoftware_ValveActivity2_setenv(JNIEnv *jenv, jclass *jclass, jstring env, jstring value, jint over)
{
LogPrintf( "Java_com_valvesoftware_ValveActivity2_setenv %s=%s", jenv->GetStringUTFChars(env, NULL), jenv->GetStringUTFChars(value, NULL) );
return setenv( jenv->GetStringUTFChars(env, NULL), jenv->GetStringUTFChars(value, NULL), over );
}
DLLEXPORT void Java_com_valvesoftware_ValveActivity2_nativeOnActivityResult()
{
LogPrintf( "Java_com_valvesoftware_ValveActivity_nativeOnActivityResult" );
}
void parseArgs( char *args )
{
char *pch;
pch = strtok (args," ");
while (pch != NULL)
{
LauncherArgv[iLastArgs++] = pch;
pch = strtok (NULL, " ");
}
}
DLLEXPORT void Java_com_valvesoftware_ValveActivity2_setArgs(JNIEnv *env, jclass *clazz, jstring str)
{
strncpy( java_args, env->GetStringUTFChars(str, NULL), sizeof java_args );
}
DLLEXPORT int LauncherMain( int argc, char **argv );
#define A(a,b) LauncherArgv[iLastArgs++] = (char*)a; \
LauncherArgv[iLastArgs++] = (char*)b
#define D(a) LauncherArgv[iLastArgs++] = (char*)a
void SetLauncherArgs()
{
static char binPath[2048];
snprintf(binPath, sizeof binPath, "%s/hl2_linux", getenv("APP_DATA_PATH") );
LogPrintf(binPath);
D(binPath);
parseArgs(java_args);
A("-game", "hl2");
D("-window");
D("-nosteam");
D("-insecure");
}
static void *lgles;
typedef void (*t_set_getprocaddress)(void *(*new_proc_address)(const char *));
t_set_getprocaddress gl4es_set_getprocaddress;
typedef void *(*t_eglGetProcAddress)( const char * );
t_eglGetProcAddress eglGetProcAddress;
void *GetProcAddress( const char *procname )
{
void *result = dlsym(lgles, procname);
if(result)
return result;
else
return eglGetProcAddress(procname);
}
DLLEXPORT int LauncherMainAndroid( int argc, char **argv )
{
SetLauncherArgs();
void *lgl4es = dlopen("libgl4es.so", 0);
if( !lgl4es )
{
LogPrintf("Failed to dlopen library libgl4es.so: %s\n", dlerror());
return 1;
}
void *lEGL = dlopen("libEGL.so", 0);
if( !lEGL )
{
LogPrintf("Failed to dlopen library libEGL.so: %s\n", dlerror());
return 1;
}
lgles = dlopen("libGLESv2.so", 0);
if( !lgles )
{
LogPrintf("Failed to dlopen library libGLESv2.so: %s\n", dlerror());
return 1;
}
gl4es_set_getprocaddress = (t_set_getprocaddress)dlsym(lgl4es, "set_getprocaddress");
eglGetProcAddress = (t_eglGetProcAddress)dlsym(lEGL, "eglGetProcAddress");
if( gl4es_set_getprocaddress && eglGetProcAddress )
{
gl4es_set_getprocaddress( &GetProcAddress );
}
else
{
LogPrintf("Failed to call set_getprocaddress\n");
return 1;
}
DeclareCurrentThreadIsMainThread(); // Init thread propertly on Android
return LauncherMain(iLastArgs, LauncherArgv);
}
#endif

17
launcher/launcher.cpp

@ -82,6 +82,11 @@ int MessageBox( HWND hWnd, const char *message, const char *header, unsigned uTy
#define RELAUNCH_FILE "/tmp/hl2_relaunch" #define RELAUNCH_FILE "/tmp/hl2_relaunch"
#endif #endif
#if defined ( ANDROID )
#include <android/log.h>
#include "jni.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"
@ -248,7 +253,11 @@ bool GetExecutableName( char *out, int outSize )
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
char *GetBaseDirectory( void ) char *GetBaseDirectory( void )
{ {
#ifdef ANDROID
return getenv("VALVE_GAME_PATH");
#else
return g_szBasedir; return g_szBasedir;
#endif
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -681,7 +690,6 @@ bool CSourceAppSystemGroup::Create()
if ( !AddSystems( appSystems ) ) if ( !AddSystems( appSystems ) )
return false; return false;
// This will be NULL for games that don't support VR. That's ok. Just don't load the DLL // This will be NULL for games that don't support VR. That's ok. Just don't load the DLL
AppModule_t sourceVRModule = LoadModule( "sourcevr" DLL_EXT_STRING ); AppModule_t sourceVRModule = LoadModule( "sourcevr" DLL_EXT_STRING );
if( sourceVRModule != APP_MODULE_INVALID ) if( sourceVRModule != APP_MODULE_INVALID )
@ -934,7 +942,9 @@ bool GrabSourceMutex()
CRC32_ProcessBuffer( &gameCRC, (void *)pchGameParam, Q_strlen( pchGameParam ) ); CRC32_ProcessBuffer( &gameCRC, (void *)pchGameParam, Q_strlen( pchGameParam ) );
CRC32_Final( &gameCRC ); CRC32_Final( &gameCRC );
#ifdef LINUX #ifdef ANDROID
return true;
#elif defined (LINUX)
/* /*
* Linux * Linux
*/ */
@ -1175,7 +1185,7 @@ static const char *BuildCommand()
// Output : int APIENTRY // Output : int APIENTRY
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#ifdef WIN32 #ifdef WIN32
extern "C" __declspec(dllexport) int LauncherMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) extern "C" __declspec(DLL_EXPORT) int LauncherMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
#else #else
DLL_EXPORT int LauncherMain( int argc, char **argv ) DLL_EXPORT int LauncherMain( int argc, char **argv )
#endif #endif
@ -1448,6 +1458,7 @@ DLL_EXPORT int LauncherMain( int argc, char **argv )
// Figure out the directory the executable is running from // Figure out the directory the executable is running from
// and make that be the current working directory // and make that be the current working directory
_chdir( GetBaseDirectory() ); _chdir( GetBaseDirectory() );
g_LeakDump.m_bCheckLeaks = CommandLine()->CheckParm( "-leakcheck" ) ? true : false; g_LeakDump.m_bCheckLeaks = CommandLine()->CheckParm( "-leakcheck" ) ? true : false;

1
launcher/wscript

@ -19,6 +19,7 @@ def build(bld):
'../public/filesystem_init.cpp', '../public/filesystem_init.cpp',
'launcher.cpp', 'launcher.cpp',
'reslistgenerator.cpp', 'reslistgenerator.cpp',
'android.cpp'
] ]
includes = [ includes = [

1
launcher_main/main.cpp

@ -146,6 +146,7 @@ int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdL
#if defined( LINUX ) #if defined( LINUX )
#include <fcntl.h> #include <fcntl.h>
#include <sys/stat.h>
static bool IsDebuggerPresent( int time ) static bool IsDebuggerPresent( int time )
{ {

4
launcher_main/wscript

@ -15,6 +15,8 @@ def configure(conf):
return return
def build(bld): def build(bld):
if bld.env.DEST_OS == 'android':
return
source = ['main.cpp'] source = ['main.cpp']
includes = ['../public'] includes = ['../public']
@ -22,7 +24,7 @@ def build(bld):
libs = [] libs = []
if bld.env.DEST_OS != 'win32': if bld.env.DEST_OS != 'win32':
libs += [ 'DL' ] libs += [ 'DL', 'LOG' ]
else: else:
libs += ['USER32', 'SHELL32'] libs += ['USER32', 'SHELL32']
source += ['launcher_main.rc'] source += ['launcher_main.rc']

BIN
lib/android/armeabi-v7a/libSDL2.so

Binary file not shown.

BIN
lib/android/armeabi-v7a/libandroid_support.a

Binary file not shown.

BIN
lib/android/armeabi-v7a/libbz2.a

Binary file not shown.

BIN
lib/android/armeabi-v7a/libcrypto.a

Binary file not shown.

BIN
lib/android/armeabi-v7a/libcurl.a

Binary file not shown.

BIN
lib/android/armeabi-v7a/libexpat.a

Binary file not shown.

BIN
lib/android/armeabi-v7a/libfreetype2.a

Binary file not shown.

BIN
lib/android/armeabi-v7a/libjpeg.a

Binary file not shown.

BIN
lib/android/armeabi-v7a/libopenal.a

Binary file not shown.

BIN
lib/android/armeabi-v7a/libpng.a

Binary file not shown.

BIN
lib/android/armeabi-v7a/libssl.a

Binary file not shown.

BIN
lib/android/x86/libandroid_support.a

Binary file not shown.

5
materialsystem/shaderapidx9/wscript

@ -15,7 +15,7 @@ def configure(conf):
conf.env.append_unique('DEFINES',[ conf.env.append_unique('DEFINES',[
'SHADERAPIDX9', 'SHADERAPIDX9',
'SHADER_DLL_EXPORT', 'SHADER_DLL_EXPORT',
'PROTECTED_THINGS_ENABLE', #'PROTECTED_THINGS_ENABLE', # conflicts with stlport
'strncpy=use_Q_strncpy_instead', 'strncpy=use_Q_strncpy_instead',
'_snprintf=use_Q_snprintf_instead', '_snprintf=use_Q_snprintf_instead',
'GL_GLEXT_PROTOTYPES', 'GL_GLEXT_PROTOTYPES',
@ -58,6 +58,9 @@ def build(bld):
libs = ['tier0','tier1','tier2','vstdlib','togl','bitmap','mathlib'] libs = ['tier0','tier1','tier2','vstdlib','togl','bitmap','mathlib']
if bld.env.DEST_OS == 'android':
libs += ['ANDROID_SUPPORT']
install_path = bld.env.LIBDIR install_path = bld.env.LIBDIR
bld.shlib( bld.shlib(

3
materialsystem/stdshaders/wscript

@ -150,6 +150,9 @@ def build(bld):
libs = ['tier0','shaderlib','tier1','mathlib'] libs = ['tier0','shaderlib','tier1','mathlib']
if bld.env.DEST_OS == 'android':
libs += ['ANDROID_SUPPORT']
install_path = bld.env.LIBDIR install_path = bld.env.LIBDIR
bld.shlib( bld.shlib(

2
materialsystem/wscript

@ -15,7 +15,7 @@ def configure(conf):
conf.env.append_unique('DEFINES',[ conf.env.append_unique('DEFINES',[
'DEFINE_MATERIALSYSTEM_INTERFACE', 'DEFINE_MATERIALSYSTEM_INTERFACE',
'MATERIALSYSTEM_EXPORTS', 'MATERIALSYSTEM_EXPORTS',
'PROTECTED_THINGS_ENABLE', #'PROTECTED_THINGS_ENABLE', # conflicts with stlport
'strncpy=use_Q_strncpy_instead', 'strncpy=use_Q_strncpy_instead',
'_snprintf=use_Q_snprintf_instead' '_snprintf=use_Q_snprintf_instead'
]) ])

17
public/filesystem_init.cpp

@ -341,14 +341,20 @@ bool FileSystem_GetExecutableDir( char *exedir, int exeDirLen )
Q_FixSlashes( exedir ); Q_FixSlashes( exedir );
#ifdef ANDROID
const char* libDir = "lib";
#else
const char* libDir = "bin";
#endif
// Return the bin directory as the executable dir if it's not in there // Return the bin directory as the executable dir if it's not in there
// because that's really where we're running from... // because that's really where we're running from...
char ext[MAX_PATH]; char ext[MAX_PATH];
Q_StrRight( exedir, 4, ext, sizeof( ext ) ); Q_StrRight( exedir, 4, ext, sizeof( ext ) );
if ( ext[0] != CORRECT_PATH_SEPARATOR || Q_stricmp( ext+1, "bin" ) != 0 ) 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, CORRECT_PATH_SEPARATOR_S, exeDirLen, COPY_ALL_CHARACTERS );
Q_strncat( exedir, "bin", exeDirLen, COPY_ALL_CHARACTERS ); Q_strncat( exedir, libDir, exeDirLen, COPY_ALL_CHARACTERS );
Q_FixSlashes( exedir ); Q_FixSlashes( exedir );
} }
@ -357,6 +363,10 @@ bool FileSystem_GetExecutableDir( char *exedir, int exeDirLen )
static bool FileSystem_GetBaseDir( char *baseDir, int baseDirLen ) static bool FileSystem_GetBaseDir( char *baseDir, int baseDirLen )
{ {
#ifdef ANDROID
strncpy(baseDir, getenv("VALVE_GAME_PATH"), baseDirLen);
return true;
#else
if ( FileSystem_GetExecutableDir( baseDir, baseDirLen ) ) if ( FileSystem_GetExecutableDir( baseDir, baseDirLen ) )
{ {
Q_StripFilename( baseDir ); Q_StripFilename( baseDir );
@ -364,6 +374,7 @@ static bool FileSystem_GetBaseDir( char *baseDir, int baseDirLen )
} }
return false; return false;
#endif
} }
void LaunchVConfig() void LaunchVConfig()
@ -543,6 +554,8 @@ FSReturnCode_t FileSystem_LoadSearchPaths( CFSSearchPathsInit &initInfo )
if ( !FileSystem_GetBaseDir( baseDir, sizeof( baseDir ) ) ) if ( !FileSystem_GetBaseDir( baseDir, sizeof( baseDir ) ) )
return SetupFileSystemError( false, FS_INVALID_PARAMETERS, "FileSystem_GetBaseDir failed." ); return SetupFileSystemError( false, FS_INVALID_PARAMETERS, "FileSystem_GetBaseDir failed." );
Msg("filesystem BaseDir: %s\n", baseDir);
// The MOD directory is always the one that contains gameinfo.txt // The MOD directory is always the one that contains gameinfo.txt
Q_strncpy( initInfo.m_ModPath, initInfo.m_pDirectoryName, sizeof( initInfo.m_ModPath ) ); Q_strncpy( initInfo.m_ModPath, initInfo.m_pDirectoryName, sizeof( initInfo.m_ModPath ) );

2
public/tier0/memdbgon.h

@ -39,7 +39,9 @@
#define _NORMAL_BLOCK 1 #define _NORMAL_BLOCK 1
#include <cstddef> #include <cstddef>
#ifndef ANDROID
#include <glob.h> #include <glob.h>
#endif
#include <new> #include <new>
#include <sys/types.h> #include <sys/types.h>
#if !defined( DID_THE_OPERATOR_NEW ) #if !defined( DID_THE_OPERATOR_NEW )

11
public/tier0/memoverride.cpp

@ -390,7 +390,7 @@ extern "C"
// ensures they are here even when linking against debug or release static libs // ensures they are here even when linking against debug or release static libs
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#ifndef NO_MEMOVERRIDE_NEW_DELETE #ifndef NO_MEMOVERRIDE_NEW_DELETE
#ifdef OSX #if defined (OSX) || defined (ANDROID)
void *__cdecl operator new( size_t nSize ) throw (std::bad_alloc) void *__cdecl operator new( size_t nSize ) throw (std::bad_alloc)
#else #else
void *__cdecl operator new( size_t nSize ) void *__cdecl operator new( size_t nSize )
@ -404,7 +404,7 @@ void *__cdecl operator new( size_t nSize, int nBlockUse, const char *pFileName,
return g_pMemAlloc->Alloc(nSize, pFileName, nLine); return g_pMemAlloc->Alloc(nSize, pFileName, nLine);
} }
#ifdef OSX #if defined (OSX) || defined (ANDROID)
void __cdecl operator delete( void *pMem ) throw() void __cdecl operator delete( void *pMem ) throw()
#else #else
void __cdecl operator delete( void *pMem ) void __cdecl operator delete( void *pMem )
@ -412,8 +412,7 @@ void __cdecl operator delete( void *pMem )
{ {
g_pMemAlloc->Free( pMem ); g_pMemAlloc->Free( pMem );
} }
#if defined (OSX) || defined (ANDROID)
#ifdef OSX
void operator delete(void*pMem, std::size_t) void operator delete(void*pMem, std::size_t)
#else #else
void operator delete(void*pMem, std::size_t) throw() void operator delete(void*pMem, std::size_t) throw()
@ -422,7 +421,7 @@ void operator delete(void*pMem, std::size_t) throw()
g_pMemAlloc->Free( pMem ); g_pMemAlloc->Free( pMem );
} }
#ifdef OSX #if defined (OSX) || defined (ANDROID)
void *__cdecl operator new[]( size_t nSize ) throw (std::bad_alloc) void *__cdecl operator new[]( size_t nSize ) throw (std::bad_alloc)
#else #else
void *__cdecl operator new[]( size_t nSize ) void *__cdecl operator new[]( size_t nSize )
@ -436,7 +435,7 @@ void *__cdecl operator new[] ( size_t nSize, int nBlockUse, const char *pFileNam
return g_pMemAlloc->Alloc(nSize, pFileName, nLine); return g_pMemAlloc->Alloc(nSize, pFileName, nLine);
} }
#ifdef OSX #if defined (OSX) || defined (ANDROID)
void __cdecl operator delete[]( void *pMem ) throw() void __cdecl operator delete[]( void *pMem ) throw()
#else #else
void __cdecl operator delete[]( void *pMem ) void __cdecl operator delete[]( void *pMem )

41
public/tier1/utlvector.h

@ -182,6 +182,7 @@ public:
// Purges the list and calls delete on each element in it. // Purges the list and calls delete on each element in it.
void PurgeAndDeleteElements(); void PurgeAndDeleteElements();
void PurgeAndDeleteElementsArray();
// Compacts the vector to the number of elements actually in use // Compacts the vector to the number of elements actually in use
void Compact(); void Compact();
@ -475,6 +476,18 @@ public:
} }
} }
void PurgeAndDeleteElementsArray()
{
if ( m_pData != StaticData() )
{
for( int i=0; i < m_pData->m_Size; i++ )
{
delete[] Element(i);
}
RemoveAll();
}
}
void FastRemove( int elem ) void FastRemove( int elem )
{ {
Assert( IsValidIndex(elem) ); Assert( IsValidIndex(elem) );
@ -1413,6 +1426,17 @@ inline void CUtlVector<T, A>::PurgeAndDeleteElements()
Purge(); Purge();
} }
template< typename T, class A >
inline void CUtlVector<T, A>::PurgeAndDeleteElementsArray()
{
for( int i=0; i < m_Size; i++ )
{
delete[] Element(i);
}
RemoveAll();
}
template< typename T, class A > template< typename T, class A >
inline void CUtlVector<T, A>::Compact() inline void CUtlVector<T, A>::Compact()
{ {
@ -1441,23 +1465,16 @@ void CUtlVector<T, A>::Validate( CValidator &validator, char *pchName )
} }
#endif // DBGFLAG_VALIDATE #endif // DBGFLAG_VALIDATE
// A vector class for storing pointers, so that the elements pointed to by the pointers are deleted // easy string list class with dynamically allocated strings. For use with V_SplitString, etc.
// on exit. // Frees the dynamic strings in destructor.
template<class T> class CUtlVectorAutoPurge : public CUtlVector< T, CUtlMemory< T, int> > class CUtlStringList : public CUtlVector< char*, CUtlMemory< char*, int > >
{ {
public: public:
~CUtlVectorAutoPurge( void ) ~CUtlStringList( void )
{ {
this->PurgeAndDeleteElements(); PurgeAndDeleteElementsArray();
} }
};
// easy string list class with dynamically allocated strings. For use with V_SplitString, etc.
// Frees the dynamic strings in destructor.
class CUtlStringList : public CUtlVectorAutoPurge< char *>
{
public:
void CopyAndAddToTail( char const *pString ) // clone the string and add to the end void CopyAndAddToTail( char const *pString ) // clone the string and add to the end
{ {
char *pNewStr = new char[1 + strlen( pString )]; char *pNewStr = new char[1 + strlen( pString )];

5
scenefilecache/wscript vendored

@ -13,7 +13,7 @@ def options(opt):
def configure(conf): def configure(conf):
conf.define('_WINDOWS',1) # WTF? this defined in original vpc file conf.define('_WINDOWS',1) # WTF? this defined in original vpc file
conf.define('PROTECTED_THINGS_ENABLE',1) #conf.define('PROTECTED_THINGS_ENABLE',1) # conflicts with stlport
def build(bld): def build(bld):
source = [ source = [
@ -32,6 +32,9 @@ def build(bld):
libs = ['tier0','tier1'] libs = ['tier0','tier1']
if bld.env.DEST_OS == 'android':
libs += ['ANDROID_SUPPORT']
install_path = bld.env.LIBDIR install_path = bld.env.LIBDIR
bld.shlib( bld.shlib(

12
scripts/waifulib/xcompile.py

@ -213,7 +213,11 @@ class Android:
def system_stl(self): def system_stl(self):
# TODO: proper STL support # TODO: proper STL support
return os.path.abspath(os.path.join(self.ndk_home, 'sources', 'cxx-stl', 'system', 'include')) return [
#os.path.abspath(os.path.join(self.ndk_home, 'sources', 'cxx-stl', 'system', 'include')),
os.path.abspath(os.path.join(self.ndk_home, 'sources', 'cxx-stl', 'stlport', 'stlport')),
os.path.abspath(os.path.join(self.ndk_home, 'sources', 'android', 'support', 'include'))
]
def libsysroot(self): def libsysroot(self):
arch = self.arch arch = self.arch
@ -243,7 +247,7 @@ class Android:
'-isystem', '%s/usr/include/' % (self.sysroot()) '-isystem', '%s/usr/include/' % (self.sysroot())
] ]
cflags += ['-I%s' % (self.system_stl()), '-DANDROID', '-D__ANDROID__'] cflags += ['-I%s'%i for i in self.system_stl()]+['-DANDROID', '-D__ANDROID__']
if cxx and not self.is_clang() and self.toolchain not in ['4.8','4.9']: if cxx and not self.is_clang() and self.toolchain not in ['4.8','4.9']:
cflags += ['-fno-sized-deallocation'] cflags += ['-fno-sized-deallocation']
@ -335,13 +339,15 @@ def configure(conf):
conf.env.CXXFLAGS += android.cflags(True) conf.env.CXXFLAGS += android.cflags(True)
conf.env.LINKFLAGS += android.linkflags() conf.env.LINKFLAGS += android.linkflags()
conf.env.LDFLAGS += android.ldflags() conf.env.LDFLAGS += android.ldflags()
conf.env.STLIBPATH += [os.path.abspath(os.path.join(android.ndk_home, 'sources','cxx-stl','stlport','libs',values[0]))]
conf.env.LDFLAGS += ['-lstlport_static']
conf.env.HAVE_M = True conf.env.HAVE_M = True
if android.is_hardfp(): if android.is_hardfp():
conf.env.LIB_M = ['m_hard'] conf.env.LIB_M = ['m_hard']
else: conf.env.LIB_M = ['m'] else: conf.env.LIB_M = ['m']
conf.env.PREFIX = '/lib/%s' % android.apk_arch() conf.env.PREFIX += '/lib/%s' % android.apk_arch()
conf.msg('Selected Android NDK', '%s, version: %d' % (android.ndk_home, android.ndk_rev)) conf.msg('Selected Android NDK', '%s, version: %d' % (android.ndk_home, android.ndk_rev))
# no need to print C/C++ compiler, as it would be printed by compiler_c/cxx # no need to print C/C++ compiler, as it would be printed by compiler_c/cxx

2
soundemittersystem/wscript

@ -14,7 +14,7 @@ def options(opt):
def configure(conf): def configure(conf):
conf.define('SOUNDEMITTERSYSTEM_EXPORTS',1) conf.define('SOUNDEMITTERSYSTEM_EXPORTS',1)
conf.define('_WINDOWS',1) conf.define('_WINDOWS',1)
conf.define('PROTECTED_THINGS_ENABLE',1) #conf.define('PROTECTED_THINGS_ENABLE',1) # conflicts with stlport
#conf.define('fopen','dont_use_fopen') # WINDOWS #conf.define('fopen','dont_use_fopen') # WINDOWS
def build(bld): def build(bld):

2
studiorender/wscript

@ -14,7 +14,7 @@ def options(opt):
def configure(conf): def configure(conf):
conf.env.append_unique('DEFINES',[ conf.env.append_unique('DEFINES',[
'STUDIORENDER_EXPORTS', 'STUDIORENDER_EXPORTS',
'PROTECTED_THINGS_ENABLE' #'PROTECTED_THINGS_ENABLE' # conflicts with stlport
]) ])
def build(bld): def build(bld):

2
thirdparty

@ -1 +1 @@
Subproject commit ecce0cecc39b32bdf704542e3cb870ba4e2e8e42 Subproject commit c397ca0520de10f8bf9c85fadc9fcc3055c60b0f

8
tier0/dbg.cpp

@ -31,6 +31,10 @@
#include "xbox/xbox_console.h" #include "xbox/xbox_console.h"
#endif #endif
#ifdef ANDROID
#include <android/log.h>
#endif
#include "tier0/etwprof.h" #include "tier0/etwprof.h"
#ifndef STEAM #ifndef STEAM
@ -309,6 +313,10 @@ static SpewRetval_t _SpewMessage( SpewType_t spewType, const char *pGroupName, i
nLevel nLevel
}; };
#ifdef ANDROID
__android_log_print( ANDROID_LOG_INFO, "SRCENG", "%s", pTempBuffer );
#endif
g_pSpewInfo = &spewInfo; g_pSpewInfo = &spewInfo;
ret = s_SpewOutputFunc( spewType, pTempBuffer ); ret = s_SpewOutputFunc( spewType, pTempBuffer );
g_pSpewInfo = (int)NULL; g_pSpewInfo = (int)NULL;

3
tier0/platform_posix.cpp

@ -28,6 +28,9 @@
#include <time.h> #include <time.h>
#include <fcntl.h> #include <fcntl.h>
#endif #endif
#ifdef ANDROID
#include <linux/stat.h>
#endif
#include "tier0/memdbgon.h" #include "tier0/memdbgon.h"
// Benchmark mode uses this heavy-handed method // Benchmark mode uses this heavy-handed method

5
tier0/threadtools.cpp

@ -23,8 +23,13 @@
#elif defined(POSIX) #elif defined(POSIX)
#if !defined(OSX) #if !defined(OSX)
#if defined(ANDROID)
#include <fcntl.h>
#include <unistd.h>
#else
#include <sys/fcntl.h> #include <sys/fcntl.h>
#include <sys/unistd.h> #include <sys/unistd.h>
#endif
#define sem_unlink( arg ) #define sem_unlink( arg )
#define OS_TO_PTHREAD(x) (x) #define OS_TO_PTHREAD(x) (x)
#else #else

4
tier0/wscript

@ -54,7 +54,7 @@ def build(bld):
'vcrmode_posix.cpp', #[$POSIX] 'vcrmode_posix.cpp', #[$POSIX]
'vprof.cpp', 'vprof.cpp',
# 'win32consoleio.cpp', [$WINDOWS] # 'win32consoleio.cpp', [$WINDOWS]
'../tier1/pathmatch.cpp' # [$LINUXALL] #'../tier1/pathmatch.cpp' # [$LINUXALL]
] ]
includes = [ includes = [
@ -65,7 +65,7 @@ def build(bld):
defines = [] defines = []
libs = ['DL'] libs = ['DL', 'M', 'LOG']
install_path = bld.env.LIBDIR install_path = bld.env.LIBDIR

18
tier1/interface.cpp

@ -247,8 +247,10 @@ HMODULE Sys_LoadLibrary( const char *pLibraryName, Sys_Flags flags )
#elif POSIX #elif POSIX
int dlopen_mode = RTLD_NOW; int dlopen_mode = RTLD_NOW;
#ifndef ANDROID
if ( flags & SYS_NOLOAD ) if ( flags & SYS_NOLOAD )
dlopen_mode |= RTLD_NOLOAD; dlopen_mode |= RTLD_NOLOAD;
#endif
HMODULE ret = ( HMODULE )dlopen( str, dlopen_mode ); HMODULE ret = ( HMODULE )dlopen( str, dlopen_mode );
if ( !ret && !( flags & SYS_NOLOAD ) ) if ( !ret && !( flags & SYS_NOLOAD ) )
@ -302,19 +304,33 @@ CSysModule *Sys_LoadModule( const char *pModuleName, Sys_Flags flags /* = SYS_NO
bool bUseLibPrefix = false; bool bUseLibPrefix = false;
#ifdef ANDROID
struct stat statBuf;
char *dataPath = getenv("APP_DATA_PATH");
Q_snprintf(szAbsoluteModuleName, sizeof(szAbsoluteModuleName), "%s/lib/lib%s", dataPath ,pModuleName);
if( stat(szAbsoluteModuleName, &statBuf) != 0 )
Q_snprintf(szAbsoluteModuleName, sizeof(szAbsoluteModuleName), "%s/lib/%s", dataPath ,pModuleName);
#else
#ifdef POSIX #ifdef POSIX
struct stat statBuf; struct stat statBuf;
Q_snprintf(szModuleName, sizeof(szModuleName), "bin/lib%s", pModuleName); Q_snprintf(szModuleName, sizeof(szModuleName), "bin/lib%s", pModuleName);
bUseLibPrefix |= stat(szModuleName, &statBuf) == 0; bUseLibPrefix |= stat(szModuleName, &statBuf) == 0;
#endif #endif
if( bUseLibPrefix ) if( bUseLibPrefix )
Q_snprintf( szAbsoluteModuleName, sizeof(szAbsoluteModuleName), "%s/bin/lib%s", szCwd, pModuleName ); 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 );
#endif // ANDROID
Msg("LoadLibrary: pModule: %s, path: %s\n", pModuleName, szAbsoluteModuleName);
hDLL = Sys_LoadLibrary( szAbsoluteModuleName, flags ); hDLL = Sys_LoadLibrary( szAbsoluteModuleName, flags );
} }
else
Msg("LoadLibrary: path: %s\n", pModuleName);
if ( !hDLL ) if ( !hDLL )
{ {

7
tier1/pathmatch.cpp

@ -750,7 +750,7 @@ extern "C" {
return CALL(freopen)( mpath, mode, stream ); return CALL(freopen)( mpath, mode, stream );
} }
#ifndef ANDROID
WRAP(fopen, FILE *, const char *path, const char *mode) WRAP(fopen, FILE *, const char *path, const char *mode)
{ {
// if mode does not have w, a, or +, it's open for read. // if mode does not have w, a, or +, it's open for read.
@ -788,7 +788,7 @@ extern "C" {
{ {
return __wrap_open( pathname, O_CREAT|O_WRONLY|O_TRUNC, mode ); return __wrap_open( pathname, O_CREAT|O_WRONLY|O_TRUNC, mode );
} }
#endif
int __wrap_access(const char *pathname, int mode) int __wrap_access(const char *pathname, int mode)
{ {
return __real_access( CWrap( pathname, false ), mode ); return __real_access( CWrap( pathname, false ), mode );
@ -815,6 +815,7 @@ extern "C" {
{ {
return CALL(opendir)( CWrap( name, false ) ); return CALL(opendir)( CWrap( name, false ) );
} }
#ifndef ANDROID
WRAP(__xstat, int, int __ver, __const char *__filename, struct stat *__stat_buf) WRAP(__xstat, int, int __ver, __const char *__filename, struct stat *__stat_buf)
{ {
@ -835,7 +836,7 @@ extern "C" {
{ {
return CALL(__lxstat64)( __ver, CWrap( __filename, false), __stat_buf ); return CALL(__lxstat64)( __ver, CWrap( __filename, false), __stat_buf );
} }
#endif
WRAP(chmod, int, const char *path, mode_t mode) WRAP(chmod, int, const char *path, mode_t mode)
{ {
return CALL(chmod)( CWrap( path, false), mode ); return CALL(chmod)( CWrap( path, false), mode );

2
tier1/wscript

@ -40,7 +40,7 @@ def build(bld):
'memstack.cpp', 'memstack.cpp',
'NetAdr.cpp', 'NetAdr.cpp',
'newbitbuf.cpp', 'newbitbuf.cpp',
'pathmatch.cpp', # [$LINUXALL] # 'pathmatch.cpp', # [$LINUXALL]
# 'processor_detect.cpp', # [$WINDOWS||$X360] # 'processor_detect.cpp', # [$WINDOWS||$X360]
'processor_detect_linux.cpp', # [$POSIX] 'processor_detect_linux.cpp', # [$POSIX]
'qsort_s.cpp', # [$LINUXALL||$PS3] 'qsort_s.cpp', # [$LINUXALL||$PS3]

6
togl/linuxwin/glentrypoints.cpp

@ -43,7 +43,7 @@
#include "tier1.h" #include "tier1.h"
#include "tier2/tier2.h" #include "tier2/tier2.h"
#ifdef _LINUX #if defined(_LINUX) && !defined(__ANDROID__)
#include <GL/glx.h> #include <GL/glx.h>
#endif #endif
@ -296,7 +296,7 @@ static bool CheckOpenGLExtension_internal(const char *ext, const int coremajor,
return false; return false;
} }
} }
#elif !defined ( OSX ) #elif !defined ( OSX ) && !defined( __ANDROID__ )
if (!ptr) if (!ptr)
{ {
static CDynamicFunctionOpenGL< true, Display *( APIENTRY *)( ), Display* > glXGetCurrentDisplay("glXGetCurrentDisplay"); static CDynamicFunctionOpenGL< true, Display *( APIENTRY *)( ), Display* > glXGetCurrentDisplay("glXGetCurrentDisplay");
@ -377,10 +377,12 @@ COpenGLEntryPoints::COpenGLEntryPoints()
// !!! FIXME: hint Apple's drivers and not because we rely on the // !!! FIXME: hint Apple's drivers and not because we rely on the
// !!! FIXME: functionality. If so, just remove this check (and the // !!! FIXME: functionality. If so, just remove this check (and the
// !!! FIXME: GL_NV_fence code entirely). // !!! FIXME: GL_NV_fence code entirely).
#ifndef ANDROID // HACK
if ((m_bHave_OpenGL) && ((!m_bHave_GL_NV_fence) && (!m_bHave_GL_ARB_sync) && (!m_bHave_GL_APPLE_fence))) if ((m_bHave_OpenGL) && ((!m_bHave_GL_NV_fence) && (!m_bHave_GL_ARB_sync) && (!m_bHave_GL_APPLE_fence)))
{ {
Error( "Required OpenGL extension \"GL_NV_fence\", \"GL_ARB_sync\", or \"GL_APPLE_fence\" is not supported. Please upgrade your OpenGL driver." ); Error( "Required OpenGL extension \"GL_NV_fence\", \"GL_ARB_sync\", or \"GL_APPLE_fence\" is not supported. Please upgrade your OpenGL driver." );
} }
#endif
// same extension, different name. // same extension, different name.
if (m_bHave_GL_EXT_vertex_array_bgra || m_bHave_GL_ARB_vertex_array_bgra) if (m_bHave_GL_EXT_vertex_array_bgra || m_bHave_GL_ARB_vertex_array_bgra)

1
togl/wscript

@ -13,7 +13,6 @@ def options(opt):
def configure(conf): def configure(conf):
conf.define('TOGL_DLL_EXPORT',1) conf.define('TOGL_DLL_EXPORT',1)
conf.define('PROTECTED_THINGS_ENABLE',1)
conf.env.append_unique('DEFINES',['strncpy=use_Q_strncpy_instead', conf.env.append_unique('DEFINES',['strncpy=use_Q_strncpy_instead',
'_snprintf=use_Q_snprintf_instead']) '_snprintf=use_Q_snprintf_instead'])

74
vgui2/vgui_surfacelib/linuxfont.cpp

@ -92,6 +92,7 @@ void CLinuxFont::CreateFontList()
if ( m_FriendlyNameCache.Count() > 0 ) if ( m_FriendlyNameCache.Count() > 0 )
return; return;
#ifndef ANDROID
if(!FcInit()) if(!FcInit())
return; return;
FcConfig *config; FcConfig *config;
@ -160,8 +161,11 @@ void CLinuxFont::CreateFontList()
FcFontSetDestroy(fontset); FcFontSetDestroy(fontset);
FcObjectSetDestroy(os); FcObjectSetDestroy(os);
FcPatternDestroy(pat); FcPatternDestroy(pat);
#endif
} }
#ifndef ANDROID
static FcPattern* FontMatch(const char* type, FcType vtype, const void* value, static FcPattern* FontMatch(const char* type, FcType vtype, const void* value,
...) ...)
{ {
@ -204,6 +208,7 @@ static FcPattern* FontMatch(const char* type, FcType vtype, const void* value,
return match; return match;
} }
#endif
bool CLinuxFont::CreateFromMemory(const char *windowsFontName, void *data, int datasize, int tall, int weight, int blur, int scanlines, int flags) bool CLinuxFont::CreateFromMemory(const char *windowsFontName, void *data, int datasize, int tall, int weight, int blur, int scanlines, int flags)
{ {
@ -400,6 +405,52 @@ bool CLinuxFont::CreateFromMemory(const char *windowsFontName, void *data, int d
return true; return true;
} }
#ifdef ANDROID
char *FindFontAndroid(bool bBold, int italic)
{
const char *fontFileName, *fontFileNamePost = NULL;
fontFileName = "Roboto";
if( bBold )
{
if( italic )
fontFileNamePost = "BoldItalic";
else
fontFileNamePost = "Bold";
}
else if( italic )
fontFileNamePost = "Italic";
else
fontFileName = "Regular";
char dataFile[MAX_PATH];
if( fontFileNamePost )
snprintf( dataFile, sizeof dataFile, "/system/fonts/%s-%s.ttf", fontFileName, fontFileNamePost );
else
snprintf( dataFile, sizeof dataFile, "/system/fonts/%s.ttf", fontFileName );
if( access( dataFile, R_OK ) != 0 )
{
fontFileNamePost = NULL;
fontFileName = "DroidSans";
if( bBold > 500 )
fontFileNamePost = "Bold";
if( fontFileNamePost )
snprintf( dataFile, sizeof dataFile, "/system/fonts/%s-%s.ttf", fontFileName, fontFileNamePost );
else
snprintf( dataFile, sizeof dataFile, "/system/fonts/%s.ttf", fontFileName );
if( access( dataFile, R_OK ) != 0 )
return NULL;
}
return dataFile;
}
#endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: Given a font name from windows, match it to the filename and return that. // Purpose: Given a font name from windows, match it to the filename and return that.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -413,18 +464,24 @@ char *CLinuxFont::GetFontFileName( const char *windowsFontName, int flags )
else if ( !Q_stricmp( pchFontName, "Arial Black" ) || Q_stristr( pchFontName, "bold" ) ) else if ( !Q_stricmp( pchFontName, "Arial Black" ) || Q_stristr( pchFontName, "bold" ) )
bBold = true; bBold = true;
const int italic = ( flags & vgui::ISurface::FONTFLAG_ITALIC ) ? FC_SLANT_ITALIC : FC_SLANT_ROMAN; const int italic = ( flags & vgui::ISurface::FONTFLAG_ITALIC ) ? FC_SLANT_ITALIC : FC_SLANT_ROMAN;
const int nFcWeight = bBold ? FC_WEIGHT_BOLD : FC_WEIGHT_NORMAL;
FcPattern *match = FontMatch( FC_FAMILY, FcTypeString, pchFontName, #ifdef ANDROID
char *filename = FindFontAndroid( bBold, italic );
Msg("Android font: %s", filename);
if( !filename ) return NULL;
return strdup( filename );
#else
const int nFcWeight = bBold ? FC_WEIGHT_BOLD : FC_WEIGHT_NORMAL;
FcPattern *match = FontMatch( FC_FAMILY, FcTypeString, pchFontName,
FC_WEIGHT, FcTypeInteger, nFcWeight, FC_WEIGHT, FcTypeInteger, nFcWeight,
FC_SLANT, FcTypeInteger, italic, FC_SLANT, FcTypeInteger, italic,
NULL); NULL);
if ( !match ) if ( !match )
{ {
AssertMsg1( false, "Unable to find font named %s\n", windowsFontName ); AssertMsg1( false, "Unable to find font named %s\n", windowsFontName );
return NULL; return NULL;
} }
else else
{ {
char *filenameret = NULL; char *filenameret = NULL;
@ -440,8 +497,11 @@ char *CLinuxFont::GetFontFileName( const char *windowsFontName, int flags )
} }
FcPatternDestroy( match ); FcPatternDestroy( match );
Msg("Android font fc: %s", filenameret);
return filenameret; return filenameret;
} }
#endif
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -502,7 +562,7 @@ void CLinuxFont::GetCharRGBA( wchar_t ch, int rgbaWide, int rgbaTall, unsigned c
if( error == 0 ) if( error == 0 )
{ {
uint32 alpha_scale = 1; uint32 alpha_scale = 1;
int Width = min( rgbaWide, bitmap.width ); int Width = MIN( rgbaWide, bitmap.width );
unsigned char *rgba = prgba + ( nSkipRows * rgbaWide * 4 ); unsigned char *rgba = prgba + ( nSkipRows * rgbaWide * 4 );
switch( m_face->glyph->bitmap.pixel_mode ) switch( m_face->glyph->bitmap.pixel_mode )

2
vgui2/vgui_surfacelib/wscript

@ -31,7 +31,7 @@ def build(bld):
'../../public', '../../public',
'../../public/tier0', '../../public/tier0',
'../../public/tier1', '../../public/tier1',
'../../common' '../../common',
] + bld.env.INCLUDES_FT2 ] + bld.env.INCLUDES_FT2
defines = [] defines = []

9
vguimatsurface/wscript

@ -15,7 +15,7 @@ def configure(conf):
conf.define('VGUIMATSURFACE_DLL_EXPORT',1) conf.define('VGUIMATSURFACE_DLL_EXPORT',1)
conf.define('GAMEUI_EXPORTS',1) conf.define('GAMEUI_EXPORTS',1)
conf.define('DONT_PROTECT_FILEIO_FUNCTIONS',1) conf.define('DONT_PROTECT_FILEIO_FUNCTIONS',1)
conf.define('PROTECTED_THINGS_ENABLE',1) #conf.define('PROTECTED_THINGS_ENABLE',1) # conflicts with stlport
def build(bld): def build(bld):
@ -38,13 +38,16 @@ def build(bld):
'../public', '../public',
'../public/tier0', '../public/tier0',
'../public/tier1', '../public/tier1',
'../common' '../common',
] + bld.env.INCLUDES_SDL2 + bld.env.INCLUDES_FREETYPE ]
defines = [] defines = []
libs = ['bitmap','mathlib','tier0','vgui_controls','tier1','vstdlib','tier2','tier3','vgui_surfacelib','FT2','FC','SDL2'] libs = ['bitmap','mathlib','tier0','vgui_controls','tier1','vstdlib','tier2','tier3','vgui_surfacelib','FT2','FC','SDL2']
if bld.env.DEST_OS == 'android':
libs += ['EXPAT']
install_path = bld.env.LIBDIR install_path = bld.env.LIBDIR
bld.shlib( bld.shlib(

3
vstdlib/wscript

@ -40,6 +40,9 @@ def build(bld):
libs = ['tier0','tier1'] libs = ['tier0','tier1']
if bld.env.DEST_OS == 'android':
libs += ['ANDROID_SUPPORT']
install_path = bld.env.LIBDIR install_path = bld.env.LIBDIR
bld.shlib( bld.shlib(

93
wscript

@ -1,6 +1,6 @@
#! /usr/bin/env python #! /usr/bin/env python
# encoding: utf-8 # encoding: utf-8
# a1batross, mittorn, nillerusr # nillerusr
from __future__ import print_function from __future__ import print_function
from waflib import Logs, Context, Configure from waflib import Logs, Context, Configure
@ -86,7 +86,7 @@ projects={
'dedicated_main', 'dedicated_main',
'dmxloader', 'dmxloader',
'engine', 'engine',
# 'game/server', 'game/server',
'ivp/havana', 'ivp/havana',
'ivp/havana/havok/hk_base', 'ivp/havana/havok/hk_base',
'ivp/havana/havok/hk_math', 'ivp/havana/havok/hk_math',
@ -154,15 +154,12 @@ def define_platform(conf):
if conf.options.SDL: if conf.options.SDL:
conf.define('USE_SDL', 1) conf.define('USE_SDL', 1)
print(conf.env.DEST_OS)
if conf.env.DEST_OS == 'linux': if conf.env.DEST_OS == 'linux':
conf.define('_GLIBCXX_USE_CXX11_ABI',0) conf.define('_GLIBCXX_USE_CXX11_ABI',0)
conf.env.append_unique('DEFINES', [ conf.env.append_unique('DEFINES', [
'LINUX=1', '_LINUX=1', 'LINUX=1', '_LINUX=1',
'POSIX=1', '_POSIX=1', 'POSIX=1', '_POSIX=1',
'GNUC', 'GNUC',
'NDEBUG',
'NO_HOOK_MALLOC', 'NO_HOOK_MALLOC',
'_DLL_EXT=.so' '_DLL_EXT=.so'
]) ])
@ -173,11 +170,19 @@ def define_platform(conf):
'LINUX=1', '_LINUX=1', 'LINUX=1', '_LINUX=1',
'POSIX=1', '_POSIX=1', 'POSIX=1', '_POSIX=1',
'GNUC', 'GNUC',
'NDEBUG',
'NO_HOOK_MALLOC', 'NO_HOOK_MALLOC',
'_DLL_EXT=.so' '_DLL_EXT=.so'
]) ])
if conf.options.DEBUG_ENGINE:
conf.env.append_unique('DEFINES', [
'DEBUG', '_DEBUG'
])
else:
conf.env.append_unique('DEFINES', [
'NDEBUG'
])
def options(opt): def options(opt):
grp = opt.add_option_group('Common options') grp = opt.add_option_group('Common options')
@ -187,12 +192,18 @@ def options(opt):
grp.add_option('-d', '--dedicated', action = 'store_true', dest = 'DEDICATED', default = False, grp.add_option('-d', '--dedicated', action = 'store_true', dest = 'DEDICATED', default = False,
help = 'build dedicated server [default: %default]') help = 'build dedicated server [default: %default]')
grp.add_option('-D', '--debug-engine', action = 'store_true', dest = 'DEBUG_ENGINE', default = False,
help = 'build with -DDEBUG [default: %default]')
grp.add_option('--use-sdl', action = 'store', dest = 'SDL', type = 'int', default = True, grp.add_option('--use-sdl', action = 'store', dest = 'SDL', type = 'int', default = True,
help = 'build engine with SDL [default: %default]') help = 'build engine with SDL [default: %default]')
grp.add_option('--use-togl', action = 'store', dest = 'GL', type = 'int', default = True, grp.add_option('--use-togl', action = 'store', dest = 'GL', type = 'int', default = True,
help = 'build engine with ToGL [default: %default]') help = 'build engine with ToGL [default: %default]')
grp.add_option('--use-ccache', action = 'store_true', dest = 'CCACHE', default = False,
help = 'build using ccache [default: %default]')
opt.load('compiler_optimizations subproject') opt.load('compiler_optimizations subproject')
# opt.add_subproject(projects['game']) # opt.add_subproject(projects['game'])
@ -226,20 +237,6 @@ def configure(conf):
conf.load('force_32bit') conf.load('force_32bit')
if conf.options.SDL:
conf.check_cfg(package='sdl2', uselib_store='SDL2', args=['--cflags', '--libs'])
if conf.options.DEDICATED:
conf.check_cfg(package='libedit', uselib_store='EDIT', args=['--cflags', '--libs'])
else:
conf.check_pkg('freetype2', 'FT2', FT2_CHECK)
conf.check_pkg('fontconfig', 'FC', FC_CHECK)
conf.check_cfg(package='openal', uselib_store='OPENAL', args=['--cflags', '--libs'])
conf.check_cfg(package='libjpeg', uselib_store='JPEG', args=['--cflags', '--libs'])
conf.check_cfg(package='libpng', uselib_store='PNG', args=['--cflags', '--libs'])
conf.check_cfg(package='libcurl', uselib_store='CURL', args=['--cflags', '--libs'])
conf.check_cfg(package='zlib', uselib_store='ZLIB', args=['--cflags', '--libs'])
compiler_optional_flags = [ compiler_optional_flags = [
'-Wall', '-Wall',
'-fdiagnostics-color=always', '-fdiagnostics-color=always',
@ -258,6 +255,17 @@ def configure(conf):
flags = ['-fPIC'] flags = ['-fPIC']
if conf.env.DEST_OS == 'android':
flags += [
'-L'+os.path.abspath('.')+'/lib/android/armeabi-v7a/',
'-I'+os.path.abspath('.')+'/thirdparty/curl/include',
'-I'+os.path.abspath('.')+'/thirdparty/SDL',
'-I'+os.path.abspath('.')+'/thirdparty/openal-soft/include/',
'-I'+os.path.abspath('.')+'/thirdparty/fontconfig',
'-I'+os.path.abspath('.')+'/thirdparty/freetype/include',
'-llog'
]
if conf.env.DEST_CPU == 'arm': if conf.env.DEST_CPU == 'arm':
flags += ['-mfpu=neon', '-fsigned-char'] flags += ['-mfpu=neon', '-fsigned-char']
else: else:
@ -270,15 +278,17 @@ def configure(conf):
cxxflags = list(cflags) + ['-std=c++11','-fpermissive'] cxxflags = list(cflags) + ['-std=c++11','-fpermissive']
if conf.env.COMPILER_CC == 'gcc': if conf.env.COMPILER_CC == 'gcc':
wrapfunctions = ['freopen','fopen','open','creat','access','__xstat','stat','lstat','fopen64','open64', # wrapfunctions = ['freopen','creat','access','__xstat','stat','lstat','fopen64','open64',
'opendir','__lxstat','chmod','chown','lchown','symlink','link','__lxstat64','mknod', # 'opendir','__lxstat','chmod','chown','lchown','symlink','link','__lxstat64','mknod',
'utimes','unlink','rename','utime','__xstat64','mount','mkfifo','mkdir','rmdir','scandir','realpath'] # 'utimes','unlink','rename','utime','__xstat64','mount','mkdir','rmdir','scandir','realpath','mkfifo']
# for func in wrapfunctions:
# linkflags += ['-Wl,--wrap='+func]
for func in wrapfunctions:
linkflags += ['-Wl,--wrap='+func]
conf.define('COMPILER_GCC', 1) conf.define('COMPILER_GCC', 1)
if conf.env.COMPILER_CC != 'msvc': if conf.env.COMPILER_CC != 'msvc':
conf.check_cc(cflags=cflags, linkflags=linkflags, msg='Checking for required C flags') conf.check_cc(cflags=cflags, linkflags=linkflags, msg='Checking for required C flags')
conf.check_cxx(cxxflags=cxxflags, linkflags=linkflags, msg='Checking for required C++ flags') conf.check_cxx(cxxflags=cxxflags, linkflags=linkflags, msg='Checking for required C++ flags')
@ -296,6 +306,32 @@ def configure(conf):
conf.env.append_unique('LINKFLAGS', linkflags) conf.env.append_unique('LINKFLAGS', linkflags)
conf.env.append_unique('INCLUDES', [os.path.abspath('common/')]) conf.env.append_unique('INCLUDES', [os.path.abspath('common/')])
if conf.env.DEST_OS != 'android':
if conf.options.SDL:
conf.check_cfg(package='sdl2', uselib_store='SDL2', args=['--cflags', '--libs'])
if conf.options.DEDICATED:
conf.check_cfg(package='libedit', uselib_store='EDIT', args=['--cflags', '--libs'])
else:
conf.check_pkg('freetype2', 'FT2', FT2_CHECK)
conf.check_pkg('fontconfig', 'FC', FC_CHECK)
conf.check_cfg(package='openal', uselib_store='OPENAL', args=['--cflags', '--libs'])
conf.check_cfg(package='libjpeg', uselib_store='JPEG', args=['--cflags', '--libs'])
conf.check_cfg(package='libpng', uselib_store='PNG', args=['--cflags', '--libs'])
conf.check_cfg(package='libcurl', uselib_store='CURL', args=['--cflags', '--libs'])
conf.check_cfg(package='zlib', uselib_store='ZLIB', args=['--cflags', '--libs'])
else:
conf.check(lib='SDL2', uselib_store='SDL2')
conf.check(lib='freetype2', uselib_store='FT2')
conf.check(lib='openal', uselib_store='OPENAL')
conf.check(lib='jpeg', uselib_store='JPEG')
conf.check(lib='png', uselib_store='PNG')
conf.check(lib='curl', uselib_store='CURL')
conf.check(lib='z', uselib_store='ZLIB')
conf.check(lib='crypto', uselib_store='CRYPTO')
conf.check(lib='ssl', uselib_store='SSL')
conf.check(lib='expat', uselib_store='EXPAT')
conf.check(lib='android_support', uselib_store='ANDROID_SUPPORT')
if conf.env.DEST_OS != 'win32': if conf.env.DEST_OS != 'win32':
conf.check_cc(lib='dl', mandatory=False) conf.check_cc(lib='dl', mandatory=False)
conf.check_cc(lib='bz2', mandatory=False) conf.check_cc(lib='bz2', mandatory=False)
@ -336,12 +372,19 @@ def configure(conf):
else: else:
conf.env.LIBDIR = conf.env.BINDIR = conf.env.PREFIX conf.env.LIBDIR = conf.env.BINDIR = conf.env.PREFIX
if conf.options.CCACHE:
conf.env.CC.insert(0, 'ccache')
conf.env.CXX.insert(0, 'ccache')
print( conf.env )
if conf.options.DEDICATED: if conf.options.DEDICATED:
conf.add_subproject(projects['dedicated']) conf.add_subproject(projects['dedicated'])
else: else:
conf.add_subproject(projects['game']) conf.add_subproject(projects['game'])
def build(bld): def build(bld):
os.environ["CCACHE_DIR"] = os.path.abspath('.ccache/'+bld.env.COMPILER_CC+'/'+bld.env.DEST_OS+'/'+bld.env.DEST_CPU)
if bld.env.DEDICATED: if bld.env.DEDICATED:
bld.add_subproject(projects['dedicated']) bld.add_subproject(projects['dedicated'])
else: else:

Loading…
Cancel
Save