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>
This commit is contained in:
nillerusr
2021-09-02 20:33:03 +03:00
committed by GitHub
co-authored by JusicP nillerusr
parent 2a490d398c
commit 2c6669f5e3
57 changed files with 524 additions and 111 deletions
+1 -2
View File
@@ -1,11 +1,10 @@
*.mak
*.mak.vpc_crc
*.vpc_crc
*.a
*.project
lib/
*obj_*
build/
.waf*
.lock-waf*
__pycache__
*.pyc
+10 -2
View File
@@ -11,11 +11,19 @@ The main purpose of this repository is to port the engine for other platforms.
* replace current buildsystem with waf
* rewrite achivement system( to work without steam )
# How to Build?
On Linux:
1. Clone repo ( ```git clone https://github.com/nillerusr/source-engine```)
2. Run ```git submodule init && git submodule update```
3. Build
On Linux:
```
./waf configure -T debug
./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)**
+32 -3
View File
@@ -56,6 +56,11 @@ COpenGLEntryPoints *gGL = NULL;
const int kBogusSwapInterval = INT_MAX;
#ifdef ANDROID
static void *gl4es = NULL;
void *(*_glGetProcAddress)( const char * );
#endif
/*
From Ryan Gordon:
@@ -174,7 +179,19 @@ void *VoidFnPtrLookup_GlMgr(const char *fn, bool &okay, const bool bRequired, vo
return NULL;
// 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.
retval = SDL_GL_GetProcAddress(fn);
//printf("CDynamicFunctionOpenGL: SDL_GL_GetProcAddress(\"%s\") returned %p\n", fn, retval);
@@ -196,7 +213,7 @@ void *VoidFnPtrLookup_GlMgr(const char *fn, bool &okay, const bool bRequired, vo
// We can't continue execution, because one or more GL function pointers will be NULL.
Error( "Could not find required OpenGL entry point '%s'! Either your video card is unsupported, or your OpenGL driver needs to be updated.\n", fn);
}
return retval;
}
@@ -742,6 +759,18 @@ bool CSDLMgr::CreateHiddenGameWindow( const char *pTitle, int width, int height
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: when we do get around to that, don't forget to delete/NULL gGL!
@@ -762,7 +791,7 @@ bool CSDLMgr::CreateHiddenGameWindow( const char *pTitle, int width, int height
#endif // DBGFLAG_ASSERT
gGL = GetOpenGLEntryPoints(VoidFnPtrLookup_GlMgr);
// It is now safe to call any base GL entry point that's supplied by gGL.
// You still need to explicitly test for extension entry points, though!
+4
View File
@@ -1,7 +1,11 @@
#ifndef __FTCONFIG_H__MULTILIB
#define __FTCONFIG_H__MULTILIB
#ifdef ANDROID
#include <sys/cdefs.h>
#else
#include <bits/wordsize.h>
#endif
#if __WORDSIZE == 32
# include "ftconfig-32.h"
+3
View File
@@ -35,6 +35,9 @@ def build(bld):
libs = ['tier0','tier1','tier2','tier3']
if bld.env.DEST_OS == 'android':
libs += ['ANDROID_SUPPORT']
install_path = bld.env.LIBDIR
bld.shlib(
+1 -1
View File
@@ -2898,7 +2898,7 @@ void CDmaDecorator<T,B>::Init( CDmElement *pOwner, const char *pAttributeName, i
{
Assert( pOwner );
this->m_pAttribute = pOwner->AddExternalAttribute( pAttributeName, CDmAttributeInfo<CUtlVector<T> >::AttributeType(), &Value() );
Assert( m_pAttribute );
Assert( this->m_pAttribute );
if ( nFlags )
{
this->m_pAttribute->AddFlag( nFlags );
+5 -2
View File
@@ -323,12 +323,15 @@ def build(bld):
'../common',
'audio',
'audio/public',
'audio/private'
'audio/private',
]
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
+14 -6
View File
@@ -3770,8 +3770,10 @@ bool CBaseFileSystem::IsFileWritable( char const *pFileName, char const *pPathID
{
#ifdef WIN32
if( buf.st_mode & _S_IWRITE )
#elif LINUX
#elif defined (LINUX) && !defined (ANDROID)
if( buf.st_mode & S_IWRITE )
#elif ANDROID
if( buf.st_mode & S_IWUSR )
#else
if( buf.st_mode & S_IWRITE )
#endif
@@ -3792,8 +3794,10 @@ bool CBaseFileSystem::IsFileWritable( char const *pFileName, char const *pPathID
{
#ifdef WIN32
if ( buf.st_mode & _S_IWRITE )
#elif LINUX
#elif defined (LINUX) && !defined (ANDROID)
if ( buf.st_mode & S_IWRITE )
#elif ANDROID
if ( buf.st_mode & S_IWUSR )
#else
if ( buf.st_mode & S_IWRITE )
#endif
@@ -3812,6 +3816,8 @@ bool CBaseFileSystem::SetFileWritable( char const *pFileName, bool writable, con
#ifdef _WIN32
int pmode = writable ? ( _S_IWRITE | _S_IREAD ) : ( _S_IREAD );
#elif ANDROID
int pmode = writable ? ( S_IWUSR | S_IRUSR ) : ( S_IRUSR );
#else
int pmode = writable ? ( S_IWRITE | S_IREAD ) : ( S_IREAD );
#endif
@@ -5062,13 +5068,15 @@ CSysModule *CBaseFileSystem::LoadModule( const char *pFileName, const char *pPat
#ifdef POSIX
Q_snprintf( tempPathID, sizeof(tempPathID), "lib%s", pFileName );
pModule = Sys_LoadModule( tempPathID );
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;
}
+4
View File
@@ -972,7 +972,11 @@ void CStdioFile::FS_fclose()
AUTO_LOCK( m_MutexLockedFD );
struct _stat buf;
#ifdef ANDROID
int fd = fileno( m_pFile ); // need to test this
#else
int fd = fileno_unlocked( m_pFile );
#endif
fstat( fd, &buf );
fflush( m_pFile );
+6 -6
View File
@@ -879,10 +879,10 @@ int64 CZipPackFileHandle::AbsoluteBaseOffset()
return m_pOwner->GetPackFileBaseOffset() + m_nBase;
}
#if defined( _DEBUG ) && !defined( OSX )
#if defined( _DEBUG ) && !defined( OSX ) && !defined( ANDROID )
#include <atomic>
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,
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 )
{
Reset();
#if defined( _DEBUG ) && !defined( OSX )
#if defined( _DEBUG ) && !defined( OSX ) && !defined( ANDROID )
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
@@ -901,17 +901,17 @@ CLZMAZipPackFileHandle::CLZMAZipPackFileHandle( CZipPackFile* pOwner, int64 nBas
"These carry large buffers around, and can cause high memory usage\n",
PACKFILE_COMPRESSED_FILE_HANDLES_WARNING );
}
#endif // defined( _DEBUG ) && !defined( OSX )
#endif // defined( _DEBUG ) && !defined( OSX ) && !defined( ANDROID )
}
CLZMAZipPackFileHandle::~CLZMAZipPackFileHandle()
{
delete m_pLZMAStream;
m_pLZMAStream = NULL;
#if defined( _DEBUG ) && !defined( OSX )
#if defined( _DEBUG ) && !defined( OSX ) && !defined( ANDROID )
sLZMAPackFileHandles--;
Assert( sLZMAPackFileHandles >= 0 );
#endif // defined( _DEBUG ) && !defined( OSX )
#endif // defined( _DEBUG ) && !defined( OSX ) && !defined( ANDROID )
}
int CLZMAZipPackFileHandle::Read( void* pBuffer, int nDestSize, int nBytes )
+2
View File
@@ -98,6 +98,8 @@ void CMumbleSystem::LevelInitPostEntity()
g_hMapObject = NULL;
return;
}
#elif defined( ANDROID )
return; // TODO(JusicP): implement
#elif defined( POSIX )
char memname[256];
V_sprintf_safe( memname, "/MumbleLink.%d", getuid() );
+3 -1
View File
@@ -559,7 +559,9 @@ def build(bld):
'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(
source = source,
+3 -1
View File
@@ -602,7 +602,9 @@ def build(bld):
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(
source = source,
+1 -1
View File
@@ -107,7 +107,7 @@ def build(bld):
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
+145
View File
@@ -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
+16 -5
View File
@@ -82,6 +82,11 @@ int MessageBox( HWND hWnd, const char *message, const char *header, unsigned uTy
#define RELAUNCH_FILE "/tmp/hl2_relaunch"
#endif
#if defined ( ANDROID )
#include <android/log.h>
#include "jni.h"
#endif
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
@@ -248,7 +253,11 @@ bool GetExecutableName( char *out, int outSize )
//-----------------------------------------------------------------------------
char *GetBaseDirectory( void )
{
#ifdef ANDROID
return getenv("VALVE_GAME_PATH");
#else
return g_szBasedir;
#endif
}
//-----------------------------------------------------------------------------
@@ -680,8 +689,7 @@ bool CSourceAppSystemGroup::Create()
if ( !AddSystems( appSystems ) )
return false;
// 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 );
if( sourceVRModule != APP_MODULE_INVALID )
@@ -934,7 +942,9 @@ bool GrabSourceMutex()
CRC32_ProcessBuffer( &gameCRC, (void *)pchGameParam, Q_strlen( pchGameParam ) );
CRC32_Final( &gameCRC );
#ifdef LINUX
#ifdef ANDROID
return true;
#elif defined (LINUX)
/*
* Linux
*/
@@ -1175,7 +1185,7 @@ static const char *BuildCommand()
// Output : int APIENTRY
//-----------------------------------------------------------------------------
#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
DLL_EXPORT int LauncherMain( int argc, char **argv )
#endif
@@ -1229,7 +1239,7 @@ DLL_EXPORT int LauncherMain( int argc, char **argv )
{
return -1;
}
const char *filename;
#ifdef WIN32
CommandLine()->CreateCmdLine( IsPC() ? VCRHook_GetCommandLine() : lpCmdLine );
@@ -1448,6 +1458,7 @@ DLL_EXPORT int LauncherMain( int argc, char **argv )
// Figure out the directory the executable is running from
// and make that be the current working directory
_chdir( GetBaseDirectory() );
g_LeakDump.m_bCheckLeaks = CommandLine()->CheckParm( "-leakcheck" ) ? true : false;
+1
View File
@@ -19,6 +19,7 @@ def build(bld):
'../public/filesystem_init.cpp',
'launcher.cpp',
'reslistgenerator.cpp',
'android.cpp'
]
includes = [
+1
View File
@@ -146,6 +146,7 @@ int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdL
#if defined( LINUX )
#include <fcntl.h>
#include <sys/stat.h>
static bool IsDebuggerPresent( int time )
{
+3 -1
View File
@@ -15,6 +15,8 @@ def configure(conf):
return
def build(bld):
if bld.env.DEST_OS == 'android':
return
source = ['main.cpp']
includes = ['../public']
@@ -22,7 +24,7 @@ def build(bld):
libs = []
if bld.env.DEST_OS != 'win32':
libs += [ 'DL' ]
libs += [ 'DL', 'LOG' ]
else:
libs += ['USER32', 'SHELL32']
source += ['launcher_main.rc']
BIN
View File
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
+4 -1
View File
@@ -15,7 +15,7 @@ def configure(conf):
conf.env.append_unique('DEFINES',[
'SHADERAPIDX9',
'SHADER_DLL_EXPORT',
'PROTECTED_THINGS_ENABLE',
#'PROTECTED_THINGS_ENABLE', # conflicts with stlport
'strncpy=use_Q_strncpy_instead',
'_snprintf=use_Q_snprintf_instead',
'GL_GLEXT_PROTOTYPES',
@@ -58,6 +58,9 @@ def build(bld):
libs = ['tier0','tier1','tier2','vstdlib','togl','bitmap','mathlib']
if bld.env.DEST_OS == 'android':
libs += ['ANDROID_SUPPORT']
install_path = bld.env.LIBDIR
bld.shlib(
+3
View File
@@ -150,6 +150,9 @@ def build(bld):
libs = ['tier0','shaderlib','tier1','mathlib']
if bld.env.DEST_OS == 'android':
libs += ['ANDROID_SUPPORT']
install_path = bld.env.LIBDIR
bld.shlib(
+1 -1
View File
@@ -15,7 +15,7 @@ def configure(conf):
conf.env.append_unique('DEFINES',[
'DEFINE_MATERIALSYSTEM_INTERFACE',
'MATERIALSYSTEM_EXPORTS',
'PROTECTED_THINGS_ENABLE',
#'PROTECTED_THINGS_ENABLE', # conflicts with stlport
'strncpy=use_Q_strncpy_instead',
'_snprintf=use_Q_snprintf_instead'
])
+17 -4
View File
@@ -341,29 +341,40 @@ bool FileSystem_GetExecutableDir( char *exedir, int exeDirLen )
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
// 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, "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, "bin", exeDirLen, COPY_ALL_CHARACTERS );
Q_strncat( exedir, libDir, exeDirLen, COPY_ALL_CHARACTERS );
Q_FixSlashes( exedir );
}
return true;
}
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 ) )
{
Q_StripFilename( baseDir );
return true;
}
return false;
#endif
}
void LaunchVConfig()
@@ -543,6 +554,8 @@ FSReturnCode_t FileSystem_LoadSearchPaths( CFSSearchPathsInit &initInfo )
if ( !FileSystem_GetBaseDir( baseDir, sizeof( baseDir ) ) )
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
Q_strncpy( initInfo.m_ModPath, initInfo.m_pDirectoryName, sizeof( initInfo.m_ModPath ) );
+2
View File
@@ -39,7 +39,9 @@
#define _NORMAL_BLOCK 1
#include <cstddef>
#ifndef ANDROID
#include <glob.h>
#endif
#include <new>
#include <sys/types.h>
#if !defined( DID_THE_OPERATOR_NEW )
+5 -6
View File
@@ -390,7 +390,7 @@ extern "C"
// ensures they are here even when linking against debug or release static libs
//-----------------------------------------------------------------------------
#ifndef NO_MEMOVERRIDE_NEW_DELETE
#ifdef OSX
#if defined (OSX) || defined (ANDROID)
void *__cdecl operator new( size_t nSize ) throw (std::bad_alloc)
#else
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);
}
#ifdef OSX
#if defined (OSX) || defined (ANDROID)
void __cdecl operator delete( void *pMem ) throw()
#else
void __cdecl operator delete( void *pMem )
@@ -412,8 +412,7 @@ void __cdecl operator delete( void *pMem )
{
g_pMemAlloc->Free( pMem );
}
#ifdef OSX
#if defined (OSX) || defined (ANDROID)
void operator delete(void*pMem, std::size_t)
#else
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 );
}
#ifdef OSX
#if defined (OSX) || defined (ANDROID)
void *__cdecl operator new[]( size_t nSize ) throw (std::bad_alloc)
#else
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);
}
#ifdef OSX
#if defined (OSX) || defined (ANDROID)
void __cdecl operator delete[]( void *pMem ) throw()
#else
void __cdecl operator delete[]( void *pMem )
+30 -13
View File
@@ -182,6 +182,7 @@ public:
// Purges the list and calls delete on each element in it.
void PurgeAndDeleteElements();
void PurgeAndDeleteElementsArray();
// Compacts the vector to the number of elements actually in use
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 )
{
Assert( IsValidIndex(elem) );
@@ -1413,6 +1426,17 @@ inline void CUtlVector<T, A>::PurgeAndDeleteElements()
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 >
inline void CUtlVector<T, A>::Compact()
{
@@ -1441,23 +1465,16 @@ void CUtlVector<T, A>::Validate( CValidator &validator, char *pchName )
}
#endif // DBGFLAG_VALIDATE
// A vector class for storing pointers, so that the elements pointed to by the pointers are deleted
// on exit.
template<class T> class CUtlVectorAutoPurge : public CUtlVector< T, CUtlMemory< T, int> >
{
public:
~CUtlVectorAutoPurge( void )
{
this->PurgeAndDeleteElements();
}
};
// 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 *>
class CUtlStringList : public CUtlVector< char*, CUtlMemory< char*, int > >
{
public:
~CUtlStringList( void )
{
PurgeAndDeleteElementsArray();
}
void CopyAndAddToTail( char const *pString ) // clone the string and add to the end
{
char *pNewStr = new char[1 + strlen( pString )];
+4 -1
View File
@@ -13,7 +13,7 @@ def options(opt):
def configure(conf):
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):
source = [
@@ -32,6 +32,9 @@ def build(bld):
libs = ['tier0','tier1']
if bld.env.DEST_OS == 'android':
libs += ['ANDROID_SUPPORT']
install_path = bld.env.LIBDIR
bld.shlib(
+9 -3
View File
@@ -213,7 +213,11 @@ class Android:
def system_stl(self):
# 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):
arch = self.arch
@@ -243,7 +247,7 @@ class Android:
'-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']:
cflags += ['-fno-sized-deallocation']
@@ -335,13 +339,15 @@ def configure(conf):
conf.env.CXXFLAGS += android.cflags(True)
conf.env.LINKFLAGS += android.linkflags()
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
if android.is_hardfp():
conf.env.LIB_M = ['m_hard']
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))
# no need to print C/C++ compiler, as it would be printed by compiler_c/cxx
+1 -1
View File
@@ -14,7 +14,7 @@ def options(opt):
def configure(conf):
conf.define('SOUNDEMITTERSYSTEM_EXPORTS',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
def build(bld):
+1 -1
View File
@@ -14,7 +14,7 @@ def options(opt):
def configure(conf):
conf.env.append_unique('DEFINES',[
'STUDIORENDER_EXPORTS',
'PROTECTED_THINGS_ENABLE'
#'PROTECTED_THINGS_ENABLE' # conflicts with stlport
])
def build(bld):
+8
View File
@@ -31,6 +31,10 @@
#include "xbox/xbox_console.h"
#endif
#ifdef ANDROID
#include <android/log.h>
#endif
#include "tier0/etwprof.h"
#ifndef STEAM
@@ -309,6 +313,10 @@ static SpewRetval_t _SpewMessage( SpewType_t spewType, const char *pGroupName, i
nLevel
};
#ifdef ANDROID
__android_log_print( ANDROID_LOG_INFO, "SRCENG", "%s", pTempBuffer );
#endif
g_pSpewInfo = &spewInfo;
ret = s_SpewOutputFunc( spewType, pTempBuffer );
g_pSpewInfo = (int)NULL;
+3
View File
@@ -28,6 +28,9 @@
#include <time.h>
#include <fcntl.h>
#endif
#ifdef ANDROID
#include <linux/stat.h>
#endif
#include "tier0/memdbgon.h"
// Benchmark mode uses this heavy-handed method
+5
View File
@@ -23,8 +23,13 @@
#elif defined(POSIX)
#if !defined(OSX)
#if defined(ANDROID)
#include <fcntl.h>
#include <unistd.h>
#else
#include <sys/fcntl.h>
#include <sys/unistd.h>
#endif
#define sem_unlink( arg )
#define OS_TO_PTHREAD(x) (x)
#else
+2 -2
View File
@@ -54,7 +54,7 @@ def build(bld):
'vcrmode_posix.cpp', #[$POSIX]
'vprof.cpp',
# 'win32consoleio.cpp', [$WINDOWS]
'../tier1/pathmatch.cpp' # [$LINUXALL]
#'../tier1/pathmatch.cpp' # [$LINUXALL]
]
includes = [
@@ -65,7 +65,7 @@ def build(bld):
defines = []
libs = ['DL']
libs = ['DL', 'M', 'LOG']
install_path = bld.env.LIBDIR
+18 -2
View File
@@ -247,8 +247,10 @@ HMODULE Sys_LoadLibrary( const char *pLibraryName, Sys_Flags flags )
#elif POSIX
int dlopen_mode = RTLD_NOW;
#ifndef ANDROID
if ( flags & SYS_NOLOAD )
dlopen_mode |= RTLD_NOLOAD;
#endif
HMODULE ret = ( HMODULE )dlopen( str, dlopen_mode );
if ( !ret && !( flags & SYS_NOLOAD ) )
@@ -301,20 +303,34 @@ CSysModule *Sys_LoadModule( const char *pModuleName, Sys_Flags flags /* = SYS_NO
size_t cCwd = strlen( szCwd );
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
struct stat statBuf;
Q_snprintf(szModuleName, sizeof(szModuleName), "bin/lib%s", pModuleName);
bUseLibPrefix |= stat(szModuleName, &statBuf) == 0;
#endif
if( bUseLibPrefix )
Q_snprintf( szAbsoluteModuleName, sizeof(szAbsoluteModuleName), "%s/bin/lib%s", szCwd, pModuleName );
else
Q_snprintf( szAbsoluteModuleName, sizeof(szAbsoluteModuleName), "%s/bin/%s", szCwd, pModuleName );
#endif // ANDROID
Msg("LoadLibrary: pModule: %s, path: %s\n", pModuleName, szAbsoluteModuleName);
hDLL = Sys_LoadLibrary( szAbsoluteModuleName, flags );
}
else
Msg("LoadLibrary: path: %s\n", pModuleName);
if ( !hDLL )
{
+4 -3
View File
@@ -750,7 +750,7 @@ extern "C" {
return CALL(freopen)( mpath, mode, stream );
}
#ifndef ANDROID
WRAP(fopen, FILE *, const char *path, const char *mode)
{
// 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 );
}
#endif
int __wrap_access(const char *pathname, int mode)
{
return __real_access( CWrap( pathname, false ), mode );
@@ -815,6 +815,7 @@ extern "C" {
{
return CALL(opendir)( CWrap( name, false ) );
}
#ifndef ANDROID
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 );
}
#endif
WRAP(chmod, int, const char *path, mode_t mode)
{
return CALL(chmod)( CWrap( path, false), mode );
+1 -1
View File
@@ -40,7 +40,7 @@ def build(bld):
'memstack.cpp',
'NetAdr.cpp',
'newbitbuf.cpp',
'pathmatch.cpp', # [$LINUXALL]
# 'pathmatch.cpp', # [$LINUXALL]
# 'processor_detect.cpp', # [$WINDOWS||$X360]
'processor_detect_linux.cpp', # [$POSIX]
'qsort_s.cpp', # [$LINUXALL||$PS3]
+4 -2
View File
@@ -43,7 +43,7 @@
#include "tier1.h"
#include "tier2/tier2.h"
#ifdef _LINUX
#if defined(_LINUX) && !defined(__ANDROID__)
#include <GL/glx.h>
#endif
@@ -296,7 +296,7 @@ static bool CheckOpenGLExtension_internal(const char *ext, const int coremajor,
return false;
}
}
#elif !defined ( OSX )
#elif !defined ( OSX ) && !defined( __ANDROID__ )
if (!ptr)
{
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: functionality. If so, just remove this check (and the
// !!! 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)))
{
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.
if (m_bHave_GL_EXT_vertex_array_bgra || m_bHave_GL_ARB_vertex_array_bgra)
-1
View File
@@ -13,7 +13,6 @@ def options(opt):
def configure(conf):
conf.define('TOGL_DLL_EXPORT',1)
conf.define('PROTECTED_THINGS_ENABLE',1)
conf.env.append_unique('DEFINES',['strncpy=use_Q_strncpy_instead',
'_snprintf=use_Q_snprintf_instead'])
+68 -8
View File
@@ -92,7 +92,8 @@ void CLinuxFont::CreateFontList()
if ( m_FriendlyNameCache.Count() > 0 )
return;
if(!FcInit())
#ifndef ANDROID
if(!FcInit())
return;
FcConfig *config;
FcPattern *pat;
@@ -160,8 +161,11 @@ void CLinuxFont::CreateFontList()
FcFontSetDestroy(fontset);
FcObjectSetDestroy(os);
FcPatternDestroy(pat);
#endif
}
#ifndef ANDROID
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;
}
#endif
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;
}
#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.
//-----------------------------------------------------------------------------
@@ -413,18 +464,24 @@ char *CLinuxFont::GetFontFileName( const char *windowsFontName, int flags )
else if ( !Q_stricmp( pchFontName, "Arial Black" ) || Q_stristr( pchFontName, "bold" ) )
bBold = true;
const int italic = ( flags & vgui::ISurface::FONTFLAG_ITALIC ) ? FC_SLANT_ITALIC : FC_SLANT_ROMAN;
const int nFcWeight = bBold ? FC_WEIGHT_BOLD : FC_WEIGHT_NORMAL;
const int italic = ( flags & vgui::ISurface::FONTFLAG_ITALIC ) ? FC_SLANT_ITALIC : FC_SLANT_ROMAN;
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_SLANT, FcTypeInteger, italic,
NULL);
if ( !match )
{
{
AssertMsg1( false, "Unable to find font named %s\n", windowsFontName );
return NULL;
}
return NULL;
}
else
{
char *filenameret = NULL;
@@ -440,8 +497,11 @@ char *CLinuxFont::GetFontFileName( const char *windowsFontName, int flags )
}
FcPatternDestroy( match );
Msg("Android font fc: %s", filenameret);
return filenameret;
}
#endif
}
//-----------------------------------------------------------------------------
@@ -502,7 +562,7 @@ void CLinuxFont::GetCharRGBA( wchar_t ch, int rgbaWide, int rgbaTall, unsigned c
if( error == 0 )
{
uint32 alpha_scale = 1;
int Width = min( rgbaWide, bitmap.width );
int Width = MIN( rgbaWide, bitmap.width );
unsigned char *rgba = prgba + ( nSkipRows * rgbaWide * 4 );
switch( m_face->glyph->bitmap.pixel_mode )
+1 -1
View File
@@ -31,7 +31,7 @@ def build(bld):
'../../public',
'../../public/tier0',
'../../public/tier1',
'../../common'
'../../common',
] + bld.env.INCLUDES_FT2
defines = []
+6 -3
View File
@@ -15,7 +15,7 @@ def configure(conf):
conf.define('VGUIMATSURFACE_DLL_EXPORT',1)
conf.define('GAMEUI_EXPORTS',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):
@@ -38,13 +38,16 @@ def build(bld):
'../public',
'../public/tier0',
'../public/tier1',
'../common'
] + bld.env.INCLUDES_SDL2 + bld.env.INCLUDES_FREETYPE
'../common',
]
defines = []
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
bld.shlib(
+3
View File
@@ -40,6 +40,9 @@ def build(bld):
libs = ['tier0','tier1']
if bld.env.DEST_OS == 'android':
libs += ['ANDROID_SUPPORT']
install_path = bld.env.LIBDIR
bld.shlib(
+68 -25
View File
@@ -1,6 +1,6 @@
#! /usr/bin/env python
# encoding: utf-8
# a1batross, mittorn, nillerusr
# nillerusr
from __future__ import print_function
from waflib import Logs, Context, Configure
@@ -86,7 +86,7 @@ projects={
'dedicated_main',
'dmxloader',
'engine',
# 'game/server',
'game/server',
'ivp/havana',
'ivp/havana/havok/hk_base',
'ivp/havana/havok/hk_math',
@@ -154,15 +154,12 @@ def define_platform(conf):
if conf.options.SDL:
conf.define('USE_SDL', 1)
print(conf.env.DEST_OS)
if conf.env.DEST_OS == 'linux':
conf.define('_GLIBCXX_USE_CXX11_ABI',0)
conf.env.append_unique('DEFINES', [
'LINUX=1', '_LINUX=1',
'POSIX=1', '_POSIX=1',
'GNUC',
'NDEBUG',
'NO_HOOK_MALLOC',
'_DLL_EXT=.so'
])
@@ -173,11 +170,19 @@ def define_platform(conf):
'LINUX=1', '_LINUX=1',
'POSIX=1', '_POSIX=1',
'GNUC',
'NDEBUG',
'NO_HOOK_MALLOC',
'_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):
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,
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,
help = 'build engine with SDL [default: %default]')
grp.add_option('--use-togl', action = 'store', dest = 'GL', type = 'int', default = True,
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.add_subproject(projects['game'])
@@ -226,20 +237,6 @@ def configure(conf):
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 = [
'-Wall',
'-fdiagnostics-color=always',
@@ -258,6 +255,17 @@ def configure(conf):
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':
flags += ['-mfpu=neon', '-fsigned-char']
else:
@@ -270,15 +278,17 @@ def configure(conf):
cxxflags = list(cflags) + ['-std=c++11','-fpermissive']
if conf.env.COMPILER_CC == 'gcc':
wrapfunctions = ['freopen','fopen','open','creat','access','__xstat','stat','lstat','fopen64','open64',
'opendir','__lxstat','chmod','chown','lchown','symlink','link','__lxstat64','mknod',
'utimes','unlink','rename','utime','__xstat64','mount','mkfifo','mkdir','rmdir','scandir','realpath']
# wrapfunctions = ['freopen','creat','access','__xstat','stat','lstat','fopen64','open64',
# 'opendir','__lxstat','chmod','chown','lchown','symlink','link','__lxstat64','mknod',
# '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)
if conf.env.COMPILER_CC != 'msvc':
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')
@@ -296,6 +306,32 @@ def configure(conf):
conf.env.append_unique('LINKFLAGS', linkflags)
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':
conf.check_cc(lib='dl', mandatory=False)
conf.check_cc(lib='bz2', mandatory=False)
@@ -336,12 +372,19 @@ def configure(conf):
else:
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:
conf.add_subproject(projects['dedicated'])
else:
conf.add_subproject(projects['game'])
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:
bld.add_subproject(projects['dedicated'])
else: