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
+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 )];