diff --git a/.gitignore b/.gitignore index 1684afe3..0344d749 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ build/ .waf* .lock-waf* __pycache__ +*.pyc diff --git a/appframework/sdlmgr.cpp b/appframework/sdlmgr.cpp index f9bb6866..64d7bb08 100644 --- a/appframework/sdlmgr.cpp +++ b/appframework/sdlmgr.cpp @@ -56,6 +56,11 @@ COpenGLEntryPoints *gGL = NULL; const int kBogusSwapInterval = INT_MAX; +#ifdef ANDROID +static void *gl4es = NULL; +void *(*_eglGetProcAddress)( 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( _eglGetProcAddress ) + retval = _eglGetProcAddress(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; } @@ -475,25 +492,13 @@ InitReturnVal_t CSDLMgr::Init() SDL_GL_SetAttribute( SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG ); } -#ifdef ANDROID - if (SDL_GL_LoadLibrary("libGL4ES.so") == -1) -#else if (SDL_GL_LoadLibrary(NULL) == -1) -#endif Error( "SDL_GL_LoadLibrary(NULL) failed: %s", SDL_GetError() ); #endif } fprintf(stderr, "SDL video target is '%s'\n", SDL_GetCurrentVideoDriver()); Msg("SDL video target is '%s'\n", SDL_GetCurrentVideoDriver()); - - SDL_version compiled; - SDL_version linked; - - SDL_VERSION(&compiled); - SDL_GetVersion(&linked); - - Msg("SDL compiled version: %d.%d.%d, linked: %d.%d.%d\n", compiled.major, compiled.minor, compiled.patch, linked.major, linked.minor, linked.patch); m_bForbidMouseGrab = true; if ( !CommandLine()->FindParm("-nomousegrab") && CommandLine()->FindParm("-mousegrab") ) @@ -754,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 ) + { + _eglGetProcAddress = dlsym(gl4es, "eglGetProcAddress" ); + 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! @@ -774,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! diff --git a/common/sse2neon.h b/common/sse2neon.h index 8474e9ef..9e512acf 100644 --- a/common/sse2neon.h +++ b/common/sse2neon.h @@ -106,7 +106,20 @@ * __ARM_NEON is defined to a value indicating the Advanced SIMD (NEON) * architecture supported. */ - +#if !defined(__ARM_NEON) || !defined(__ARM_NEON__) +#error "You must enable NEON instructions (e.g. -mfpu=neon) to use SSE2NEON." +#endif +#if !defined(__clang__) +#pragma GCC push_options +#pragma GCC target("fpu=neon") +#endif +#elif defined(__aarch64__) +#if !defined(__clang__) +#pragma GCC push_options +#pragma GCC target("+simd") +#endif +#else +#error "Unsupported target. Must be either ARMv7-A+NEON or ARMv8-A." #endif #endif diff --git a/datacache/wscript b/datacache/wscript index fe0e2022..3cb9a277 100755 --- a/datacache/wscript +++ b/datacache/wscript @@ -33,7 +33,10 @@ def build(bld): defines = [] - libs = ['tier0','tier1','tier2','tier3','iconv'] + libs = ['tier0','tier1','tier2','tier3'] + + if bld.env.DEST_OS == 'android': + libs += ['ANDROID_SUPPORT'] install_path = bld.env.LIBDIR diff --git a/engine/sys_dll2.cpp b/engine/sys_dll2.cpp index bce0f923..e6742211 100644 --- a/engine/sys_dll2.cpp +++ b/engine/sys_dll2.cpp @@ -1006,26 +1006,18 @@ bool CEngineAPI::Connect( CreateInterfaceFn factory ) // Store off the app system factory... g_AppSystemFactory = factory; - Warning( "CEngineAPI::Connect\n" ); - if ( !BaseClass::Connect( factory ) ) return false; - Warning( "CEngineAPI::Connect2\n" ); - g_pFileSystem = g_pFullFileSystem; if ( !g_pFileSystem ) return false; - Warning( "CEngineAPI::Connect3\n" ); - g_pFileSystem->SetWarningFunc( Warning ); if ( !Shader_Connect( true ) ) return false; - Warning( "CEngineAPI::Connect4\n" ); - g_pPhysics = (IPhysics*)factory( VPHYSICS_INTERFACE_VERSION, NULL ); if ( !g_pStudioRender || !g_pDataCache || !g_pPhysics || !g_pMDLCache || !g_pMatSystemSurface || !g_pInputSystem /* || !g_pVideo */ ) diff --git a/engine/wscript b/engine/wscript index 1fa9dbf3..29a03ad8 100755 --- a/engine/wscript +++ b/engine/wscript @@ -324,14 +324,14 @@ def build(bld): 'audio', 'audio/public', 'audio/private', - '../thirdparty/openal-soft-android/include', - '../thirdparty/curl/include' ] 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'] linux - libs = ['tier0','vgui_controls','dmxloader','tier1','tier2','tier3','bitmap','vstdlib','appframework','datamodel','vtf','mathlib','steam_api','matsys_controls','BZ2','sdl2','jpeg','zlib','openal','curl','ssl','crypto'] + 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 diff --git a/filesystem/basefilesystem.cpp b/filesystem/basefilesystem.cpp index 4bd5dfbd..c33b9582 100644 --- a/filesystem/basefilesystem.cpp +++ b/filesystem/basefilesystem.cpp @@ -5068,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; } diff --git a/game/client/mumble.cpp b/game/client/mumble.cpp index 9d16acc5..73c03647 100644 --- a/game/client/mumble.cpp +++ b/game/client/mumble.cpp @@ -99,7 +99,7 @@ void CMumbleSystem::LevelInitPostEntity() return; } #elif defined( ANDROID ) - return; // TODO: implement + return; // TODO(JusicP): implement #elif defined( POSIX ) char memname[256]; V_sprintf_safe( memname, "/MumbleLink.%d", getuid() ); diff --git a/game/client/wscript b/game/client/wscript index b4f81d2f..db939982 100755 --- a/game/client/wscript +++ b/game/client/wscript @@ -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, diff --git a/game/server/wscript b/game/server/wscript index f22a0a42..ff4e2b09 100755 --- a/game/server/wscript +++ b/game/server/wscript @@ -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, diff --git a/gameui/wscript b/gameui/wscript index a37190c0..76473ce2 100755 --- a/gameui/wscript +++ b/gameui/wscript @@ -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','zlib'] + libs = ['tier0','vgui_controls','tier1','tier2','tier3','vstdlib','vtf','bitmap','mathlib','SDL2','steam_api','matsys_controls','JPEG','PNG','ZLIB'] install_path = bld.env.LIBDIR diff --git a/inputsystem/wscript b/inputsystem/wscript index 680bb5d0..fe090fbf 100755 --- a/inputsystem/wscript +++ b/inputsystem/wscript @@ -32,7 +32,7 @@ def build(bld): defines = [] - libs = ['tier0','tier1','tier2','vstdlib','sdl2','steam_api'] + libs = ['tier0','tier1','tier2','vstdlib','SDL2','steam_api'] install_path = bld.env.LIBDIR diff --git a/launcher/android.cpp b/launcher/android.cpp new file mode 100644 index 00000000..fe0ec805 --- /dev/null +++ b/launcher/android.cpp @@ -0,0 +1,103 @@ +#ifdef ANDROID + +#include +#include +#include +#include +#include +#include +#include + +#include "tier0/threadtools.h" + +char *LauncherArgv[512]; +char java_args[4096]; +int iLastArgs = 0; + +#define MAX_PATH 2048 + +#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" ); +} + +typedef void (*t_egl_init)(); +t_egl_init egl_init; + +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[MAX_PATH]; + snprintf(binPath, MAX_PATH, "%s/hl2_linux", getenv("APP_DATA_PATH") ); + LogPrintf(binPath); + D(binPath); + + parseArgs(java_args); + + A("-game", "hl2"); + D("-window"); + D("-nosteam"); + D("-insecure"); +} + +DLLEXPORT int LauncherMainAndroid( int argc, char **argv ) +{ + + SetLauncherArgs(); + + void *glHandle = dlopen("libgl4es.so", 0); + egl_init = (t_egl_init)dlsym(glHandle, "egl_init"); + if( egl_init ) + egl_init(); + + DeclareCurrentThreadIsMainThread(); // Init thread propertly on Android + + return LauncherMain(iLastArgs, LauncherArgv); +} + +#endif diff --git a/launcher/launcher.cpp b/launcher/launcher.cpp index 2c11f0b3..5ba0ab18 100644 --- a/launcher/launcher.cpp +++ b/launcher/launcher.cpp @@ -253,7 +253,11 @@ bool GetExecutableName( char *out, int outSize ) //----------------------------------------------------------------------------- char *GetBaseDirectory( void ) { +#ifdef ANDROID + return getenv("VALVE_GAME_PATH"); +#else return g_szBasedir; +#endif } //----------------------------------------------------------------------------- @@ -1172,294 +1176,6 @@ static const char *BuildCommand() return (const char *)build.Base(); } -#ifdef ANDROID -char dataDir[512]; - -const char *LauncherArgv[512]; -char javaArgv[2048]; -char gameName[512]; -char startArgs[256][128]; -char language[1024] = "english"; -int iLastArgs = 0; -static int scr_width,scr_height; - -bool bClient_loaded = false; -bool bShowTouch = true; -void *libclient; - -static struct jnimethods_s -{ - jclass actcls; - JavaVM *vm; - JNIEnv *env; - jmethodID enableTextInput; -} jni; - - -DLL_EXPORT int Java_com_valvesoftware_ValveActivity2_setMainPackFilePath(JNIEnv *env, jclass *clazz, jstring str) -{ - __android_log_print( ANDROID_LOG_DEBUG, "SourceSDK2013", "Java_com_valvesoftware_ValveActivity_setMainPackFilePath" ); - return setenv( "VALVE_PAK0_PATH", env->GetStringUTFChars(str, NULL), 1 ); -} -DLL_EXPORT int Java_com_valvesoftware_ValveActivity2_setPatchPackFilePath(JNIEnv *env, jclass *clazz, jstring str) -{ - __android_log_print( ANDROID_LOG_DEBUG, "SourceSDK2013", "Java_com_valvesoftware_ValveActivity_setPatchPackFilePath" ); - return setenv( "VALVE_PAK1_PATH", env->GetStringUTFChars(str, NULL), 1 ); -} -DLL_EXPORT void Java_com_valvesoftware_ValveActivity2_setCacheDirectoryPath(JNIEnv *env, jclass *clazz, jstring str) -{ - __android_log_print( ANDROID_LOG_DEBUG, "SourceSDK2013", "Java_com_valvesoftware_ValveActivity_setCacheDirectoryPath" ); - //return setenv( "VALVE_CACHE_PATH", env->GetStringUTFChars(str, NULL), 1 ); -} -DLL_EXPORT void Java_com_valvesoftware_ValveActivity2_gpgsStart() -{ - __android_log_print( ANDROID_LOG_DEBUG, "SourceSDK2013", "Java_com_valvesoftware_ValveActivity_gpgsStart" ); -} -DLL_EXPORT void Java_com_valvesoftware_ValveActivity2_nativeOnActivityResult() -{ - __android_log_print( ANDROID_LOG_DEBUG, "SourceSDK2013", "Java_com_valvesoftware_ValveActivity_nativeOnActivityResult" ); -} - -DLL_EXPORT void Java_com_valvesoftware_ValveActivity2_setNativeLibPath(JNIEnv *env, jclass *clazz, jstring str) -{ - __android_log_print( ANDROID_LOG_DEBUG, "SourceSDK2013", "Java_com_valvesoftware_ValveActivity_setNativeLibPath" ); -// snprintf(dataDir, sizeof dataDir, env->GetStringUTFChars(str, NULL)); -} -DLL_EXPORT void Java_com_valvesoftware_ValveActivity2_setLanguage(JNIEnv *env, jclass *clazz, jstring str) -{ - snprintf(language, sizeof language, "%s", env->GetStringUTFChars(str, NULL)); - __android_log_print( ANDROID_LOG_DEBUG, "SourceSDK2013", "Java_com_valvesoftware_ValveActivity_setLanguage" ); -} -DLL_EXPORT int Java_com_valvesoftware_ValveActivity2_setDocumentDirectoryPath(JNIEnv *env, jclass *clazz, jstring str) -{ - __android_log_print( ANDROID_LOG_DEBUG, "SourceSDK2013", "Java_com_valvesoftware_ValveActivity_setDocumentDirectoryPath" ); - setenv( "HOME", env->GetStringUTFChars(str, NULL), 1); - return setenv( "VALVE_CACHE_PATH", env->GetStringUTFChars(str, NULL), 1 ); -} -DLL_EXPORT int Java_com_valvesoftware_ValveActivity2_setDropMip(int a1, int a2, signed int a3) -{ - __android_log_print( ANDROID_LOG_DEBUG, "SourceSDK2013", "Java_com_valvesoftware_ValveActivity_setDropMip" ); -} - -DLL_EXPORT int Java_com_valvesoftware_ValveActivity2_saveGame() -{ - __android_log_print( ANDROID_LOG_DEBUG, "SourceSDK2013", "Java_com_valvesoftware_ValveActivity_saveGame" ); -} - -DLL_EXPORT int Java_com_valvesoftware_ValveActivity2_setDataDirectoryPath(JNIEnv *env, jclass *clazz, jstring str) -{ - __android_log_print( ANDROID_LOG_DEBUG, "SourceSDK2013", "Java_com_valvesoftware_ValveActivity_setDataDirectoryPath" ); - snprintf(dataDir, sizeof dataDir, env->GetStringUTFChars(str, NULL)); -} - -DLL_EXPORT int Java_com_valvesoftware_ValveActivity2_setExtrasPackFilePath(JNIEnv *env, jclass *clazz, jstring str) -{ - __android_log_print( ANDROID_LOG_DEBUG, "SourceSDK2013", "Java_com_valvesoftware_ValveActivity2_setExtrasPackFilePath" ); - return setenv( "VALVE_PAK2_PATH", env->GetStringUTFChars(str, NULL), 1 ); -} - -DLL_EXPORT int Java_com_valvesoftware_ValveActivity2_setenv(JNIEnv *jenv, jclass *jclass, jstring env, jstring value, jint over) -{ - __android_log_print( ANDROID_LOG_DEBUG, "SourceSDK2013", "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 ); -} - -DLL_EXPORT int Java_com_valvesoftware_ValveActivity2_setGame(JNIEnv *jenv, jclass *jclass, jstring game) -{ - snprintf(gameName, sizeof dataDir, "-game %s", jenv->GetStringUTFChars(game, NULL)); - return setenv( "VALVE_MOD", jenv->GetStringUTFChars(game, NULL), 1); -} - -typedef void (*t_TouchEvent)(int finger, int x, int y, int act); -t_TouchEvent TouchEvent; - -DLL_EXPORT void clientLoaded( void ) -{ - bClient_loaded = true; - libclient = dlopen("libclient.so",0); - TouchEvent = (t_TouchEvent)dlsym(libclient, "TouchEvent"); - ((void (*)(bool, int, int))dlsym(libclient, "showTouch"))(bShowTouch, scr_width, scr_height); -} - -DLL_EXPORT void showKeyboard( int show ) -{ - jni.env->CallStaticVoidMethod( jni.actcls, jni.enableTextInput, show ); -} - -DLL_EXPORT void JNICALL Java_com_valvesoftware_ValveActivity2_showTouch(JNIEnv *env, jobject obj, jboolean show_touch, jint width, jint height) -{ - scr_width = width; - scr_height = height; - bShowTouch = show_touch; -} - -DLL_EXPORT void JNICALL Java_com_valvesoftware_ValveActivity2_TouchEvent(JNIEnv *env, jobject obj, jint fingerid, jint x, jint y, jint action) -{ - if( !bClient_loaded ) - return; - - TouchEvent( fingerid, x, y, action ); -} - -DLL_EXPORT const char* getSystemLanguage() -{ - return language; -} - -typedef void (*t_SDL_Android_Init)(JNIEnv* env, jclass cls); -t_SDL_Android_Init SDL_Android_Init; - -//typedef void *(*t_SDL_StartTextInput)(); -//t_SDL_StartTextInput SDL_StartTextInput; - -typedef void (*t_egl_init)(); -t_egl_init egl_init; - -bool bUseGL; - -void SetRenderer() -{ - if ( bUseGL ) - { - //setenv("USE_BIG_GL", "1", 1); - } - else - { - setenv("REGAL_LOG", "0", 1); - setenv("REGAL_LOG_ERROR", "0", 1); - setenv("REGAL_LOG_WARNING", "0", 1); - setenv("REGAL_LOG_INFO", "0", 1); - setenv("REGAL_LOG_HTTP", "0", 1); - setenv("REGAL_LOG_JSON", "0", 1); - setenv("REGAL_LOG_CALLBACK", "0", 1); - setenv("REGAL_LOG_ONCE", "0", 1); - setenv("REGAL_LOG_POINTERS", "0", 1); - setenv("REGAL_LOG_THREAD", "0", 1); - setenv("REGAL_LOG_PROCESS", "0", 1); - setenv("REGAL_LOG_ALL", "0", 1); - setenv("REGAL_DEBUG", "0", 1); - setenv("REGAL_ERROR", "0", 1); - setenv("REGAL_LOG_FILE", "/dev/null", 1); - setenv("REGAL_EMU_SO", "0", 1); - setenv("REGAL_THREAD_LOCKING", "0", 1); - setenv("REGAL_FORCE_ES2_PROFILE", "1", 1); - setenv("REGAL_SYS_GLX", "0", 1); - setenv("REGAL_SYS_ES2", "1", 1); - setenv("REGAL_SYS_EGL", "1", 1); - setenv("REGAL_SYS_GL", "0", 1); - setenv("REGAL_GL_VERSION", "2.1", 1); - setenv("REGAL_GL_EXTENSIONS", "GL_EXT_framebuffer_object GL_EXT_framebuffer_blit GL_OES_mapbuffer GL_EXT_texture_sRGB_decode GL_EXT_texture_compression_s3tc GL_EXT_texture_compression_dxt1", 1); - } -} - -void SetArg( const char *arg ) -{ - char *pch; - char str[1024]; - strncpy( str, arg, sizeof str ); - pch = strtok (str," "); - while (pch != NULL) - { - strncpy( startArgs[iLastArgs], pch, sizeof startArgs[0] ); - LauncherArgv[iLastArgs] = startArgs[iLastArgs]; - iLastArgs++; - pch = strtok (NULL, " "); - } -} - -DLL_EXPORT int Java_com_valvesoftware_ValveActivity2_setArgs(JNIEnv *env, jclass *clazz, jstring str) -{ - snprintf( javaArgv, sizeof javaArgv, env->GetStringUTFChars(str, NULL) ); -} - -void SetStartArgs() -{ - char lang[2048]; - snprintf(lang, sizeof lang, "-language %s +cc_lang %s", language, language); - - SetArg(dataDir); - SetArg(lang); - SetArg(gameName); - SetArg(javaArgv); - SetArg("-window " - "-nosteam " - "-nouserclip " - "+sv_unlockedchapters 99 " - "+mat_queue_mode 2 " - "-ignoredxsupportcfg " - "-regal " - "+gl_rt_forcergba 1 " - "+mat_antialias 1 " - "-mat_antialias 1 " - "+r_flashlightdepthtexture 1 " - "+gl_dropmips 1 " - "-insecure"); - - if( bUseGL ) - SetArg("-userclip " - "-gl_disablesamplerobjects " -// "-egl " - "+gl_enabletexsubimage 1 " - "+gl_blitmode 1 " - "+gl_supportMapBuffer 0 " - "-gl_separatedepthstencil 0 " - "-gl_nodepthtexture 0 " - "+r_flashlight_version2 0 " - "+gl_emurgba16 0 " - "+gl_emunooverwrite 0"); - else - SetArg("-nouserclip " - "-gl_disablesamplerobjects " - "+gl_enabletexsubimage 0 " - "+mat_reducefillrate 1 " - "+gl_blitmode 1 " - "+gl_supportMapBuffer 1 " - "-gl_separatedepthstencil 0 "// default is 1 - "-gl_nodepthtexture 1 " - "+r_flashlight_version2 1 " - "+gl_emurgba16 1 " - "+gl_emunooverwrite 1"); -} - -DLL_EXPORT int LauncherMain( int argc, char **argv ); - -DLL_EXPORT int LauncherMainAndroid( int argc, char **argv ) -{ - //void *sdlHandle = dlopen("libSDL2.so", 0); - - //SDL_Android_Init = (t_SDL_Android_Init)dlsym(sdlHandle, "SDL_Android_Init"); - //SDL_Android_Init(env, cls); - - //SDL_StartTextInput = (t_SDL_StartTextInput)dlsym(sdlHandle, "SDL_StartTextInput"); - //SDL_StartTextInput(); - - // unused? - chdir(dataDir); - getcwd(dataDir, sizeof dataDir); - setenv( "VALVE_GAME_PATH", dataDir, 1 ); - snprintf(dataDir, sizeof dataDir, "%s/hl2_linux", dataDir); - - bUseGL = false; - - SetRenderer(); - SetStartArgs(); - -//#ifdef GL4ES - void *glHandle = dlopen("libGL4ES.so", 0); - egl_init = (t_egl_init)dlsym(glHandle, "egl_init"); - if( egl_init ) - egl_init(); -//#endif - - //jni.env = env; - //jni.actcls = env->FindClass("org/libsdl/app/SDLActivity"); - //jni.enableTextInput = env->GetStaticMethodID(jni.actcls, "showKeyboard", "(I)V"); - - return LauncherMain(iLastArgs, LauncherArgv); -} - -#endif - //----------------------------------------------------------------------------- // Purpose: The real entry point for the application // Input : hInstance - @@ -1742,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; diff --git a/launcher/wscript b/launcher/wscript index 2dceef8f..5beb4f91 100755 --- a/launcher/wscript +++ b/launcher/wscript @@ -19,6 +19,7 @@ def build(bld): '../public/filesystem_init.cpp', 'launcher.cpp', 'reslistgenerator.cpp', + 'android.cpp' ] includes = [ @@ -31,7 +32,7 @@ def build(bld): defines = [] - libs = ['tier0','tier1','tier2','tier3','vstdlib','steam_api','appframework','sdl2','togl','LOG'] + libs = ['tier0','tier1','tier2','tier3','vstdlib','steam_api','appframework','SDL2','togl'] install_path = bld.env.LIBDIR diff --git a/launcher_main/wscript b/launcher_main/wscript index 37f52564..11f105b0 100755 --- a/launcher_main/wscript +++ b/launcher_main/wscript @@ -15,6 +15,8 @@ def configure(conf): return def build(bld): + if bld.env.DEST_OS == 'android': + return source = ['main.cpp'] includes = ['../public'] diff --git a/lib/android/armeabi-v7a/libSDL2.so b/lib/android/armeabi-v7a/libSDL2.so new file mode 100755 index 00000000..fccfb169 Binary files /dev/null and b/lib/android/armeabi-v7a/libSDL2.so differ diff --git a/lib/android/armeabi-v7a/libandroid_support.a b/lib/android/armeabi-v7a/libandroid_support.a new file mode 100644 index 00000000..30a81d72 Binary files /dev/null and b/lib/android/armeabi-v7a/libandroid_support.a differ diff --git a/lib/public/android/armeabi-v7a/libbz2.a b/lib/android/armeabi-v7a/libbz2.a similarity index 100% rename from lib/public/android/armeabi-v7a/libbz2.a rename to lib/android/armeabi-v7a/libbz2.a diff --git a/lib/common/android/armeabi-v7a/libcrypto.a b/lib/android/armeabi-v7a/libcrypto.a similarity index 100% rename from lib/common/android/armeabi-v7a/libcrypto.a rename to lib/android/armeabi-v7a/libcrypto.a diff --git a/lib/common/android/armeabi-v7a/libcurl.a b/lib/android/armeabi-v7a/libcurl.a similarity index 100% rename from lib/common/android/armeabi-v7a/libcurl.a rename to lib/android/armeabi-v7a/libcurl.a diff --git a/lib/public/android/armeabi-v7a/libexpat.a b/lib/android/armeabi-v7a/libexpat.a similarity index 100% rename from lib/public/android/armeabi-v7a/libexpat.a rename to lib/android/armeabi-v7a/libexpat.a diff --git a/lib/public/android/armeabi-v7a/libfontconfig.a b/lib/android/armeabi-v7a/libfontconfig.a similarity index 100% rename from lib/public/android/armeabi-v7a/libfontconfig.a rename to lib/android/armeabi-v7a/libfontconfig.a diff --git a/lib/public/android/armeabi-v7a/libfreetype2.a b/lib/android/armeabi-v7a/libfreetype2.a similarity index 100% rename from lib/public/android/armeabi-v7a/libfreetype2.a rename to lib/android/armeabi-v7a/libfreetype2.a diff --git a/lib/common/android/armeabi-v7a/libjpeg.a b/lib/android/armeabi-v7a/libjpeg.a similarity index 100% rename from lib/common/android/armeabi-v7a/libjpeg.a rename to lib/android/armeabi-v7a/libjpeg.a diff --git a/lib/common/android/armeabi-v7a/libopenal.a b/lib/android/armeabi-v7a/libopenal.a similarity index 100% rename from lib/common/android/armeabi-v7a/libopenal.a rename to lib/android/armeabi-v7a/libopenal.a diff --git a/lib/public/android/armeabi-v7a/libpng.a b/lib/android/armeabi-v7a/libpng.a similarity index 100% rename from lib/public/android/armeabi-v7a/libpng.a rename to lib/android/armeabi-v7a/libpng.a diff --git a/lib/common/android/armeabi-v7a/libssl.a b/lib/android/armeabi-v7a/libssl.a similarity index 100% rename from lib/common/android/armeabi-v7a/libssl.a rename to lib/android/armeabi-v7a/libssl.a diff --git a/lib/android/x86/libandroid_support.a b/lib/android/x86/libandroid_support.a new file mode 100644 index 00000000..5d405f85 Binary files /dev/null and b/lib/android/x86/libandroid_support.a differ diff --git a/lib/public/android/armeabi-v7a/libSDL2.so b/lib/public/android/armeabi-v7a/libSDL2.so deleted file mode 100755 index 76bfe924..00000000 Binary files a/lib/public/android/armeabi-v7a/libSDL2.so and /dev/null differ diff --git a/lib/public/android/armeabi-v7a/libjpeg.a b/lib/public/android/armeabi-v7a/libjpeg.a deleted file mode 100755 index 95f1be07..00000000 Binary files a/lib/public/android/armeabi-v7a/libjpeg.a and /dev/null differ diff --git a/materialsystem/shaderapidx9/wscript b/materialsystem/shaderapidx9/wscript index 21c89915..d1126bb9 100755 --- a/materialsystem/shaderapidx9/wscript +++ b/materialsystem/shaderapidx9/wscript @@ -56,7 +56,10 @@ def build(bld): defines = [] - libs = ['tier0','tier1','tier2','vstdlib','togl','bitmap','mathlib','iconv'] + libs = ['tier0','tier1','tier2','vstdlib','togl','bitmap','mathlib'] + + if bld.env.DEST_OS == 'android': + libs += ['ANDROID_SUPPORT'] install_path = bld.env.LIBDIR diff --git a/materialsystem/stdshaders/wscript b/materialsystem/stdshaders/wscript index a5f6073e..66ec1c06 100644 --- a/materialsystem/stdshaders/wscript +++ b/materialsystem/stdshaders/wscript @@ -148,7 +148,10 @@ def build(bld): defines = [] - libs = ['tier0','shaderlib','tier1','mathlib','iconv'] + libs = ['tier0','shaderlib','tier1','mathlib'] + + if bld.env.DEST_OS == 'android': + libs += ['ANDROID_SUPPORT'] install_path = bld.env.LIBDIR diff --git a/output b/output deleted file mode 100644 index 6006933b..00000000 --- a/output +++ /dev/null @@ -1,285 +0,0 @@ - - - - - - - -Build commands will be stored in build/compile_commands.json -Waf: Entering directory `/home/jusic/source-engine/build' - - - - - - - -[ 31/2159] Linking build/tier0/libtier0.so -[ 32/2159] Compiling tier1/utlstring.cpp -[ 33/2159] Compiling tier1/utlbufferutil.cpp -[ 35/2159] Compiling tier1/utlbuffer.cpp -[ 36/2159] Compiling tier1/uniqueid.cpp -[ 37/2159] Compiling tier1/tokenreader.cpp -../tier1/pathmatch.cpp:416: error: undefined reference to '__cxa_end_cleanup' -../tier1/pathmatch.cpp:492: error: undefined reference to '__cxa_end_cleanup' -../tier1/pathmatch.cpp:508: error: undefined reference to '__cxa_guard_acquire' -../tier1/pathmatch.cpp:508: error: undefined reference to '__cxa_guard_release' -../tier1/pathmatch.cpp:512: error: undefined reference to '__cxa_guard_acquire' -../tier1/pathmatch.cpp:512: error: undefined reference to '__cxa_guard_release' -../tier1/pathmatch.cpp:751: error: undefined reference to '__cxa_end_cleanup' -../tier1/pathmatch.cpp:760: error: undefined reference to '__cxa_end_cleanup' -../tier1/pathmatch.cpp:770: error: undefined reference to 'fopen64' -../tier1/pathmatch.cpp:821: error: undefined reference to '__xstat' -../tier1/pathmatch.cpp:826: error: undefined reference to '__lxstat' -../tier1/pathmatch.cpp:831: error: undefined reference to '__xstat64' -../tier1/pathmatch.cpp:836: error: undefined reference to '__lxstat64' -tier1/pathmatch.cpp.31.o(.ARM.extab.text._ZN7CDirPtrD2Ev+0x0): error: undefined reference to '__gxx_personality_v0' -tier1/pathmatch.cpp.31.o(.ARM.extab+0x0): error: undefined reference to '__gxx_personality_v0' -tier1/pathmatch.cpp.31.o(.ARM.extab+0x58): error: undefined reference to '__gxx_personality_v0' -tier1/pathmatch.cpp.31.o(.ARM.extab+0x78): error: undefined reference to '__gxx_personality_v0' -../tier0/assert_dialog.cpp:109: error: undefined reference to '__cxa_guard_acquire' -../tier0/assert_dialog.cpp:109: error: undefined reference to '__cxa_guard_release' -../tier0/assert_dialog.cpp:109: error: undefined reference to '__cxa_guard_abort' -../tier0/assert_dialog.cpp:115: error: undefined reference to '__cxa_guard_acquire' -../tier0/assert_dialog.cpp:115: error: undefined reference to '__cxa_guard_release' -../tier0/assert_dialog.cpp:115: error: undefined reference to '__cxa_guard_abort' -../tier0/assert_dialog.cpp:148: error: undefined reference to 'operator delete(void*)' -../tier0/assert_dialog.cpp:166: error: undefined reference to 'operator new(unsigned int)' -../tier0/assert_dialog.cpp:376: error: undefined reference to '__cxa_guard_abort' -../tier0/commandline.cpp:116: error: undefined reference to 'operator delete[](void*)' -../tier0/commandline.cpp:117: error: undefined reference to 'operator delete(void*)' -../tier0/commandline.cpp:117: error: undefined reference to 'operator delete(void*)' -../tier0/commandline.cpp:231: error: undefined reference to 'operator delete[](void*)' -../tier0/commandline.cpp:273: error: undefined reference to 'operator new[](unsigned int)' -../tier0/commandline.cpp:420: error: undefined reference to 'operator new[](unsigned int)' -../tier0/commandline.cpp:437: error: undefined reference to 'operator new[](unsigned int)' -../tier0/commandline.cpp:450: error: undefined reference to 'operator delete[](void*)' -../tier0/commandline.cpp:512: error: undefined reference to 'operator new[](unsigned int)' -../tier0/commandline.cpp:589: error: undefined reference to 'operator delete[](void*)' -tier0/commandline.cpp.31.o:commandline.cpp:vtable for ICommandLine: error: undefined reference to '__cxa_pure_virtual' -tier0/commandline.cpp.31.o:commandline.cpp:vtable for ICommandLine: error: undefined reference to '__cxa_pure_virtual' -tier0/commandline.cpp.31.o:commandline.cpp:vtable for ICommandLine: error: undefined reference to '__cxa_pure_virtual' -tier0/commandline.cpp.31.o:commandline.cpp:vtable for ICommandLine: error: undefined reference to '__cxa_pure_virtual' -tier0/commandline.cpp.31.o:commandline.cpp:typeinfo for CCommandLine: error: undefined reference to 'vtable for __cxxabiv1::__si_class_type_info' -/home/jusic/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/ld: the vtable symbol may be undefined because the class is missing its key function -tier0/commandline.cpp.31.o:commandline.cpp:typeinfo for ICommandLine: error: undefined reference to 'vtable for __cxxabiv1::__class_type_info' -/home/jusic/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/ld: the vtable symbol may be undefined because the class is missing its key function -../tier0/dynfunction.cpp:59: error: undefined reference to 'operator delete(void*)' -../tier0/dynfunction.cpp:80: error: undefined reference to 'operator new(unsigned int)' -tier0/memstd.cpp.31.o:memstd.cpp:typeinfo for CStdMemAlloc: error: undefined reference to 'vtable for __cxxabiv1::__si_class_type_info' -/home/jusic/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/ld: the vtable symbol may be undefined because the class is missing its key function -tier0/memstd.cpp.31.o:memstd.cpp:typeinfo for IMemAlloc: error: undefined reference to 'vtable for __cxxabiv1::__class_type_info' -/home/jusic/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/ld: the vtable symbol may be undefined because the class is missing its key function -../tier0/threadtools.cpp:153: error: undefined reference to 'operator new(unsigned int)' -../tier0/threadtools.cpp:460: error: undefined reference to '__cxa_guard_abort' -../tier0/threadtools.cpp:1751: error: undefined reference to 'operator new(unsigned int)' -../tier0/threadtools.cpp:1896: error: undefined reference to '__cxa_allocate_exception' -../tier0/threadtools.cpp:1896: error: undefined reference to '__cxa_throw' -../tier0/threadtools.cpp:1900: error: undefined reference to 'typeinfo for int' -../tier0/threadtools.cpp:2143: error: undefined reference to '__cxa_end_catch' -../tier0/threadtools.cpp:2143: error: undefined reference to '__cxa_begin_catch' -../tier0/threadtools.cpp:2146: error: undefined reference to '__cxa_rethrow' -../tier0/threadtools.cpp:2162: error: undefined reference to '__cxa_begin_catch' -../tier0/threadtools.cpp:2162: error: undefined reference to '__cxa_end_catch' -tier0/threadtools.cpp.31.o:threadtools.cpp:typeinfo for CThread: error: undefined reference to 'vtable for __cxxabiv1::__class_type_info' -/home/jusic/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/ld: the vtable symbol may be undefined because the class is missing its key function -tier0/threadtools.cpp.31.o:threadtools.cpp:typeinfo for CWorkerThread: error: undefined reference to 'vtable for __cxxabiv1::__si_class_type_info' -/home/jusic/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/ld: the vtable symbol may be undefined because the class is missing its key function -/home/jusic/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_list.h:1697: error: undefined reference to 'std::__detail::_List_node_base::_M_unhook()' -/home/jusic/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_list.h:1689: error: undefined reference to 'std::__detail::_List_node_base::_M_hook(std::__detail::_List_node_base*)' -/home/jusic/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_list.h:1689: error: undefined reference to 'std::__detail::_List_node_base::_M_hook(std::__detail::_List_node_base*)' -/home/jusic/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_list.h:517: error: undefined reference to '__cxa_end_catch' -/home/jusic/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_list.h:517: error: undefined reference to '__cxa_begin_catch' -/home/jusic/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_list.h:520: error: undefined reference to '__cxa_rethrow' -/home/jusic/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_list.h:517: error: undefined reference to '__cxa_end_catch' -/home/jusic/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_list.h:517: error: undefined reference to '__cxa_begin_catch' -/home/jusic/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_list.h:520: error: undefined reference to '__cxa_rethrow' -/home/jusic/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/ext/new_allocator.h:102: error: undefined reference to 'std::__throw_bad_alloc()' -tier0/tslist.cpp.31.o:tslist.cpp:typeinfo for TSListTests::CListOps: error: undefined reference to 'vtable for __cxxabiv1::__si_class_type_info' -/home/jusic/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/ld: the vtable symbol may be undefined because the class is missing its key function -tier0/tslist.cpp.31.o:tslist.cpp:typeinfo for TSListTests::CTestOps: error: undefined reference to 'vtable for __cxxabiv1::__class_type_info' -/home/jusic/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/ld: the vtable symbol may be undefined because the class is missing its key function -/home/jusic/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/vector.tcc:470: error: undefined reference to '__cxa_rethrow' -/home/jusic/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_tree.h:1185: error: undefined reference to 'std::_Rb_tree_insert_and_rebalance(bool, std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)' -/home/jusic/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_tree.h:1185: error: undefined reference to 'std::_Rb_tree_insert_and_rebalance(bool, std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)' -/home/jusic/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_vector.h:1585: error: undefined reference to 'std::__throw_length_error(char const*)' -/home/jusic/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_tree.h:218: error: undefined reference to 'std::_Rb_tree_decrement(std::_Rb_tree_node_base*)' -/home/jusic/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_tree.h:218: error: undefined reference to 'std::_Rb_tree_decrement(std::_Rb_tree_node_base*)' -/home/jusic/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/ext/new_allocator.h:102: error: undefined reference to 'std::__throw_bad_alloc()' -/home/jusic/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/ext/new_allocator.h:102: error: undefined reference to 'std::__throw_bad_alloc()' -/home/jusic/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/ext/new_allocator.h:102: error: undefined reference to 'std::__throw_bad_alloc()' -collect2: error: ld returned 1 exit status - -In file included from ../public/mathlib/vector.h:32:0, - from ../public/mathlib/mathlib.h:14, - from ../public/tier1/utlmemory.h:20, - from ../public/tier1/utlstring.h:14, - from ../tier1/utlstring.cpp:10: -../public/tier0/threadtools.h: In member function 'bool CThreadSpinRWLock::AssignIf(const CThreadSpinRWLock::LockInfo_t&, const CThreadSpinRWLock::LockInfo_t&)': -../public/tier0/threadtools.h:1743:48: warning: cast from 'volatile CThreadSpinRWLock::LockInfo_t*' to 'int64* {aka long long int*}' increases required alignment of target type [-Wcast-align] - return ThreadInterlockedAssignIf64( (int64 *)&m_lockInfo, *((int64 *)&newValue), *((int64 *)&comperand) ); - ^ -../public/tier0/threadtools.h:1743:72: warning: cast from 'const CThreadSpinRWLock::LockInfo_t*' to 'int64* {aka long long int*}' increases required alignment of target type [-Wcast-align] - return ThreadInterlockedAssignIf64( (int64 *)&m_lockInfo, *((int64 *)&newValue), *((int64 *)&comperand) ); - ^ -../public/tier0/threadtools.h:1743:95: warning: cast from 'const CThreadSpinRWLock::LockInfo_t*' to 'int64* {aka long long int*}' increases required alignment of target type [-Wcast-align] - return ThreadInterlockedAssignIf64( (int64 *)&m_lockInfo, *((int64 *)&newValue), *((int64 *)&comperand) ); - ^ -In file included from ../public/tier1/utlmemory.h:22:0, - from ../public/tier1/utlstring.h:14, - from ../tier1/utlstring.cpp:10: -../public/tier0/memalloc.h: In function 'void* MemAlloc_AllocAligned(size_t, size_t)': -../public/tier0/memalloc.h:190:28: warning: cast from 'unsigned char*' to 'unsigned char**' increases required alignment of target type [-Wcast-align] - ((unsigned char**)(pResult))[-1] = pAlloc; - ^ -../public/tier0/memalloc.h: In function 'void* MemAlloc_AllocAligned(size_t, size_t, const char*, int)': -../public/tier0/memalloc.h:208:28: warning: cast from 'unsigned char*' to 'unsigned char**' increases required alignment of target type [-Wcast-align] - ((unsigned char**)(pResult))[-1] = pAlloc; - ^ -../public/tier0/memalloc.h: In function 'void* MemAlloc_AllocAlignedUnattributed(size_t, size_t)': -../public/tier0/memalloc.h:226:28: warning: cast from 'unsigned char*' to 'unsigned char**' increases required alignment of target type [-Wcast-align] - ((unsigned char**)(pResult))[-1] = pAlloc; - ^ -../public/tier0/memalloc.h: In function 'void* MemAlloc_AllocAlignedFileLine(size_t, size_t, const char*, int)': -../public/tier0/memalloc.h:244:28: warning: cast from 'unsigned char*' to 'unsigned char**' increases required alignment of target type [-Wcast-align] - ((unsigned char**)(pResult))[-1] = pAlloc; - ^ - -In file included from ../public/tier1/utlvector.h:23:0, - from ../public/tier1/uniqueid.h:17, - from ../tier1/uniqueid.cpp:17: -../public/tier0/threadtools.h: In member function 'bool CThreadSpinRWLock::AssignIf(const CThreadSpinRWLock::LockInfo_t&, const CThreadSpinRWLock::LockInfo_t&)': -../public/tier0/threadtools.h:1743:48: warning: cast from 'volatile CThreadSpinRWLock::LockInfo_t*' to 'int64* {aka long long int*}' increases required alignment of target type [-Wcast-align] - return ThreadInterlockedAssignIf64( (int64 *)&m_lockInfo, *((int64 *)&newValue), *((int64 *)&comperand) ); - ^ -../public/tier0/threadtools.h:1743:72: warning: cast from 'const CThreadSpinRWLock::LockInfo_t*' to 'int64* {aka long long int*}' increases required alignment of target type [-Wcast-align] - return ThreadInterlockedAssignIf64( (int64 *)&m_lockInfo, *((int64 *)&newValue), *((int64 *)&comperand) ); - ^ -../public/tier0/threadtools.h:1743:95: warning: cast from 'const CThreadSpinRWLock::LockInfo_t*' to 'int64* {aka long long int*}' increases required alignment of target type [-Wcast-align] - return ThreadInterlockedAssignIf64( (int64 *)&m_lockInfo, *((int64 *)&newValue), *((int64 *)&comperand) ); - ^ -In file included from ../public/tier1/utlmemory.h:22:0, - from ../public/tier1/utlvector.h:24, - from ../public/tier1/uniqueid.h:17, - from ../tier1/uniqueid.cpp:17: -../public/tier0/memalloc.h: In function 'void* MemAlloc_AllocAligned(size_t, size_t)': -../public/tier0/memalloc.h:190:28: warning: cast from 'unsigned char*' to 'unsigned char**' increases required alignment of target type [-Wcast-align] - ((unsigned char**)(pResult))[-1] = pAlloc; - ^ -../public/tier0/memalloc.h: In function 'void* MemAlloc_AllocAligned(size_t, size_t, const char*, int)': -../public/tier0/memalloc.h:208:28: warning: cast from 'unsigned char*' to 'unsigned char**' increases required alignment of target type [-Wcast-align] - ((unsigned char**)(pResult))[-1] = pAlloc; - ^ -../public/tier0/memalloc.h: In function 'void* MemAlloc_AllocAlignedUnattributed(size_t, size_t)': -../public/tier0/memalloc.h:226:28: warning: cast from 'unsigned char*' to 'unsigned char**' increases required alignment of target type [-Wcast-align] - ((unsigned char**)(pResult))[-1] = pAlloc; - ^ -../public/tier0/memalloc.h: In function 'void* MemAlloc_AllocAlignedFileLine(size_t, size_t, const char*, int)': -../public/tier0/memalloc.h:244:28: warning: cast from 'unsigned char*' to 'unsigned char**' increases required alignment of target type [-Wcast-align] - ((unsigned char**)(pResult))[-1] = pAlloc; - ^ - -../tier1/utlbufferutil.cpp:9:0: warning: ignoring #pragma warning [-Wunknown-pragmas] - #pragma warning (disable : 4514) - ^ -In file included from ../public/tier1/utlvector.h:23:0, - from ../public/tier1/utlbufferutil.h:17, - from ../tier1/utlbufferutil.cpp:11: -../public/tier0/threadtools.h: In member function 'bool CThreadSpinRWLock::AssignIf(const CThreadSpinRWLock::LockInfo_t&, const CThreadSpinRWLock::LockInfo_t&)': -../public/tier0/threadtools.h:1743:48: warning: cast from 'volatile CThreadSpinRWLock::LockInfo_t*' to 'int64* {aka long long int*}' increases required alignment of target type [-Wcast-align] - return ThreadInterlockedAssignIf64( (int64 *)&m_lockInfo, *((int64 *)&newValue), *((int64 *)&comperand) ); - ^ -../public/tier0/threadtools.h:1743:72: warning: cast from 'const CThreadSpinRWLock::LockInfo_t*' to 'int64* {aka long long int*}' increases required alignment of target type [-Wcast-align] - return ThreadInterlockedAssignIf64( (int64 *)&m_lockInfo, *((int64 *)&newValue), *((int64 *)&comperand) ); - ^ -../public/tier0/threadtools.h:1743:95: warning: cast from 'const CThreadSpinRWLock::LockInfo_t*' to 'int64* {aka long long int*}' increases required alignment of target type [-Wcast-align] - return ThreadInterlockedAssignIf64( (int64 *)&m_lockInfo, *((int64 *)&newValue), *((int64 *)&comperand) ); - ^ -In file included from ../public/tier1/utlmemory.h:22:0, - from ../public/tier1/utlvector.h:24, - from ../public/tier1/utlbufferutil.h:17, - from ../tier1/utlbufferutil.cpp:11: -../public/tier0/memalloc.h: In function 'void* MemAlloc_AllocAligned(size_t, size_t)': -../public/tier0/memalloc.h:190:28: warning: cast from 'unsigned char*' to 'unsigned char**' increases required alignment of target type [-Wcast-align] - ((unsigned char**)(pResult))[-1] = pAlloc; - ^ -../public/tier0/memalloc.h: In function 'void* MemAlloc_AllocAligned(size_t, size_t, const char*, int)': -../public/tier0/memalloc.h:208:28: warning: cast from 'unsigned char*' to 'unsigned char**' increases required alignment of target type [-Wcast-align] - ((unsigned char**)(pResult))[-1] = pAlloc; - ^ -../public/tier0/memalloc.h: In function 'void* MemAlloc_AllocAlignedUnattributed(size_t, size_t)': -../public/tier0/memalloc.h:226:28: warning: cast from 'unsigned char*' to 'unsigned char**' increases required alignment of target type [-Wcast-align] - ((unsigned char**)(pResult))[-1] = pAlloc; - ^ -../public/tier0/memalloc.h: In function 'void* MemAlloc_AllocAlignedFileLine(size_t, size_t, const char*, int)': -../public/tier0/memalloc.h:244:28: warning: cast from 'unsigned char*' to 'unsigned char**' increases required alignment of target type [-Wcast-align] - ((unsigned char**)(pResult))[-1] = pAlloc; - ^ -In file included from ../tier1/utlbufferutil.cpp:17:0: -../public/Color.h: In constructor 'Color::Color()': -../public/Color.h:25:12: warning: cast from 'Color*' to 'int*' increases required alignment of target type [-Wcast-align] - *((int *)this) = 0; - ^ -../public/Color.h: In member function 'void Color::SetRawColor(int)': -../public/Color.h:59:12: warning: cast from 'Color*' to 'int*' increases required alignment of target type [-Wcast-align] - *((int *)this) = color32; - ^ -../public/Color.h: In member function 'int Color::GetRawColor() const': -../public/Color.h:64:19: warning: cast from 'const Color*' to 'int*' increases required alignment of target type [-Wcast-align] - return *((int *)this); - ^ -../public/Color.h: In member function 'bool Color::operator==(const Color&) const': -../public/Color.h:84:21: warning: cast from 'const Color*' to 'int*' increases required alignment of target type [-Wcast-align] - return ( *((int *)this) == *((int *)&rhs) ); - ^ -../public/Color.h:84:40: warning: cast from 'const Color*' to 'int*' increases required alignment of target type [-Wcast-align] - return ( *((int *)this) == *((int *)&rhs) ); - ^ - -../tier1/utlbuffer.cpp:9:0: warning: ignoring #pragma warning [-Wunknown-pragmas] - #pragma warning (disable : 4514) - ^ -../tier1/utlbuffer.cpp:908:0: warning: ignoring #pragma warning [-Wunknown-pragmas] - #pragma warning ( disable : 4706 ) - ^ -../tier1/utlbuffer.cpp:1079:0: warning: ignoring #pragma warning [-Wunknown-pragmas] - #pragma warning ( default : 4706 ) - ^ -In file included from ../public/mathlib/vector.h:32:0, - from ../public/mathlib/mathlib.h:14, - from ../public/tier1/utlmemory.h:20, - from ../public/tier1/utlbuffer.h:17, - from ../tier1/utlbuffer.cpp:11: -../public/tier0/threadtools.h: In member function 'bool CThreadSpinRWLock::AssignIf(const CThreadSpinRWLock::LockInfo_t&, const CThreadSpinRWLock::LockInfo_t&)': -../public/tier0/threadtools.h:1743:48: warning: cast from 'volatile CThreadSpinRWLock::LockInfo_t*' to 'int64* {aka long long int*}' increases required alignment of target type [-Wcast-align] - return ThreadInterlockedAssignIf64( (int64 *)&m_lockInfo, *((int64 *)&newValue), *((int64 *)&comperand) ); - ^ -../public/tier0/threadtools.h:1743:72: warning: cast from 'const CThreadSpinRWLock::LockInfo_t*' to 'int64* {aka long long int*}' increases required alignment of target type [-Wcast-align] - return ThreadInterlockedAssignIf64( (int64 *)&m_lockInfo, *((int64 *)&newValue), *((int64 *)&comperand) ); - ^ -../public/tier0/threadtools.h:1743:95: warning: cast from 'const CThreadSpinRWLock::LockInfo_t*' to 'int64* {aka long long int*}' increases required alignment of target type [-Wcast-align] - return ThreadInterlockedAssignIf64( (int64 *)&m_lockInfo, *((int64 *)&newValue), *((int64 *)&comperand) ); - ^ -In file included from ../public/tier1/utlmemory.h:22:0, - from ../public/tier1/utlbuffer.h:17, - from ../tier1/utlbuffer.cpp:11: -../public/tier0/memalloc.h: In function 'void* MemAlloc_AllocAligned(size_t, size_t)': -../public/tier0/memalloc.h:190:28: warning: cast from 'unsigned char*' to 'unsigned char**' increases required alignment of target type [-Wcast-align] - ((unsigned char**)(pResult))[-1] = pAlloc; - ^ -../public/tier0/memalloc.h: In function 'void* MemAlloc_AllocAligned(size_t, size_t, const char*, int)': -../public/tier0/memalloc.h:208:28: warning: cast from 'unsigned char*' to 'unsigned char**' increases required alignment of target type [-Wcast-align] - ((unsigned char**)(pResult))[-1] = pAlloc; - ^ -../public/tier0/memalloc.h: In function 'void* MemAlloc_AllocAlignedUnattributed(size_t, size_t)': -../public/tier0/memalloc.h:226:28: warning: cast from 'unsigned char*' to 'unsigned char**' increases required alignment of target type [-Wcast-align] - ((unsigned char**)(pResult))[-1] = pAlloc; - ^ -../public/tier0/memalloc.h: In function 'void* MemAlloc_AllocAlignedFileLine(size_t, size_t, const char*, int)': -../public/tier0/memalloc.h:244:28: warning: cast from 'unsigned char*' to 'unsigned char**' increases required alignment of target type [-Wcast-align] - ((unsigned char**)(pResult))[-1] = pAlloc; - ^ - -Waf: Leaving directory `/home/jusic/source-engine/build' -Build failed - -> task in 'tier0' failed with exit status 1 (run with -v to display more information) diff --git a/public/filesystem_init.cpp b/public/filesystem_init.cpp index 10006487..2b2c2ee6 100644 --- a/public/filesystem_init.cpp +++ b/public/filesystem_init.cpp @@ -357,19 +357,24 @@ bool FileSystem_GetExecutableDir( char *exedir, int exeDirLen ) 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() @@ -549,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 ) ); diff --git a/public/tier0/memoverride.cpp b/public/tier0/memoverride.cpp index c0f8e2af..57d3f4cb 100644 --- a/public/tier0/memoverride.cpp +++ b/public/tier0/memoverride.cpp @@ -390,9 +390,7 @@ extern "C" // ensures they are here even when linking against debug or release static libs //----------------------------------------------------------------------------- #ifndef NO_MEMOVERRIDE_NEW_DELETE -#ifdef OSX -void *__cdecl operator new( size_t nSize ) throw (std::bad_alloc) -#elif ANDROID +#if defined (OSX) || defined (ANDROID) void *__cdecl operator new( size_t nSize ) throw (std::bad_alloc) #else void *__cdecl operator new( size_t nSize ) @@ -406,9 +404,7 @@ void *__cdecl operator new( size_t nSize, int nBlockUse, const char *pFileName, return g_pMemAlloc->Alloc(nSize, pFileName, nLine); } -#ifdef OSX -void __cdecl operator delete( void *pMem ) throw() -#elif ANDROID +#if defined (OSX) || defined (ANDROID) void __cdecl operator delete( void *pMem ) throw() #else void __cdecl operator delete( void *pMem ) @@ -416,10 +412,7 @@ void __cdecl operator delete( void *pMem ) { g_pMemAlloc->Free( pMem ); } - -#ifdef OSX -void operator delete(void*pMem, std::size_t) -#elif ANDROID +#if defined (OSX) || defined (ANDROID) void operator delete(void*pMem, std::size_t) #else void operator delete(void*pMem, std::size_t) throw() @@ -428,9 +421,7 @@ void operator delete(void*pMem, std::size_t) throw() g_pMemAlloc->Free( pMem ); } -#ifdef OSX -void *__cdecl operator new[]( size_t nSize ) throw (std::bad_alloc) -#elif ANDROID +#if defined (OSX) || defined (ANDROID) void *__cdecl operator new[]( size_t nSize ) throw (std::bad_alloc) #else void *__cdecl operator new[]( size_t nSize ) @@ -444,9 +435,7 @@ void *__cdecl operator new[] ( size_t nSize, int nBlockUse, const char *pFileNam return g_pMemAlloc->Alloc(nSize, pFileName, nLine); } -#ifdef OSX -void __cdecl operator delete[]( void *pMem ) throw() -#elif ANDROID +#if defined (OSX) || defined (ANDROID) void __cdecl operator delete[]( void *pMem ) throw() #else void __cdecl operator delete[]( void *pMem ) diff --git a/scenefilecache/wscript b/scenefilecache/wscript index b9205736..828c06d9 100755 --- a/scenefilecache/wscript +++ b/scenefilecache/wscript @@ -30,7 +30,10 @@ def build(bld): defines = [] - libs = ['tier0','tier1','iconv'] + libs = ['tier0','tier1'] + + if bld.env.DEST_OS == 'android': + libs += ['ANDROID_SUPPORT'] install_path = bld.env.LIBDIR diff --git a/scripts/waifulib/compiler_optimizations.pyc b/scripts/waifulib/compiler_optimizations.pyc deleted file mode 100644 index a7c091c8..00000000 Binary files a/scripts/waifulib/compiler_optimizations.pyc and /dev/null differ diff --git a/scripts/waifulib/fwgslib.pyc b/scripts/waifulib/fwgslib.pyc deleted file mode 100644 index dd6ac017..00000000 Binary files a/scripts/waifulib/fwgslib.pyc and /dev/null differ diff --git a/scripts/waifulib/reconfigure.py b/scripts/waifulib/reconfigure.py index 5a122341..5c130422 100644 --- a/scripts/waifulib/reconfigure.py +++ b/scripts/waifulib/reconfigure.py @@ -1,9 +1,7 @@ #!/usr/bin/env python # encoding: utf-8 # Copyright (c) 2019 mittorn -CC=../android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc CXX=../android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc LD=../android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld AR=../android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ar LINK=../android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld STRIP=../android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-strip ./waf configure -T debug -../android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -DDX_TO_GL_ABSTRACTION -DGL_GLEXT_PROTOTYPES -DBINK_VIDEO -DUSE_SDL=1 -DANDROID=1 -D_ANDROID=1 -DLINUX=1 -D_LINUX=1 -DPOSIX=1 -D_POSIX=1 -DGNUC -DNDEBUG -DNO_HOOK_MALLOC -D_DLL_EXT=.so /home/jusic/source-engine/main.c -c -o/home/jusic/source-engine/build/test.c.1.o ''' Reconfigure diff --git a/scripts/waifulib/xcompile.py b/scripts/waifulib/xcompile.py index a7818911..fc5ab628 100644 --- a/scripts/waifulib/xcompile.py +++ b/scripts/waifulib/xcompile.py @@ -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 diff --git a/scripts/waifulib/xcompile.pyc b/scripts/waifulib/xcompile.pyc deleted file mode 100644 index 0011ff37..00000000 Binary files a/scripts/waifulib/xcompile.pyc and /dev/null differ diff --git a/thirdparty b/thirdparty index ecce0cec..c397ca05 160000 --- a/thirdparty +++ b/thirdparty @@ -1 +1 @@ -Subproject commit ecce0cecc39b32bdf704542e3cb870ba4e2e8e42 +Subproject commit c397ca0520de10f8bf9c85fadc9fcc3055c60b0f diff --git a/tier0/assert_dialog.cpp b/tier0/assert_dialog.cpp index 419d2a6d..e13b47e0 100644 --- a/tier0/assert_dialog.cpp +++ b/tier0/assert_dialog.cpp @@ -23,7 +23,7 @@ #include #endif -#if defined( LINUX ) || defined( USE_SDL ) +#if defined( USE_SDL ) // We lazily load the SDL shared object, and only reference functions if it's // available, so this can be included on the dedicated server too. diff --git a/tier0/dbg.cpp b/tier0/dbg.cpp index 9bbe1348..931ea21f 100644 --- a/tier0/dbg.cpp +++ b/tier0/dbg.cpp @@ -313,14 +313,14 @@ 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; -#ifdef ANDROID - __android_log_print( ANDROID_LOG_INFO, "SRCENGINE", "%s", pTempBuffer ); -#endif - switch (ret) { // Asserts put the break into the macro so it occurs in the right place @@ -911,10 +911,6 @@ void COM_TimestampedLog( char const *fmt, ... ) XBX_rTimeStampLog( curStamp, string ); #endif -#ifdef ANDROID - __android_log_print( ANDROID_LOG_INFO, "SRCENGINE", "%s", string ); -#endif - if ( IsPC() ) { // If ETW profiling is enabled then do it only. diff --git a/tier0/wscript b/tier0/wscript index 72841393..0e9faed4 100755 --- a/tier0/wscript +++ b/tier0/wscript @@ -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', 'm', 'LOG'] + libs = ['DL', 'M', 'LOG'] install_path = bld.env.LIBDIR diff --git a/tier1/interface.cpp b/tier1/interface.cpp index 45ba5c90..96dd90c9 100644 --- a/tier1/interface.cpp +++ b/tier1/interface.cpp @@ -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,31 +303,34 @@ CSysModule *Sys_LoadModule( const char *pModuleName, Sys_Flags flags /* = SYS_NO size_t cCwd = strlen( szCwd ); bool bUseLibPrefix = false; - -#ifdef POSIX - struct stat statBuf; + #ifdef ANDROID - Q_snprintf(szModuleName, sizeof(szModuleName), "lib/lib%s", pModuleName); + 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); -#endif 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); -#ifdef ANDROID - char* szModulePath = "%s/lib/lib%s"; - if (!bUseLibPrefix) - szModulePath = "%s/lib/%s"; -#else - char* szModulePath = "%s/bin/lib%s"; - if (!bUseLibPrefix) - szModulePath = "%s/bin/%s"; -#endif - - Q_snprintf( szAbsoluteModuleName, sizeof(szAbsoluteModuleName), szModulePath, szCwd, pModuleName ); - hDLL = Sys_LoadLibrary( szAbsoluteModuleName, flags ); } + else + Msg("LoadLibrary: path: %s\n", pModuleName); + if ( !hDLL ) { diff --git a/tier1/strtools.cpp b/tier1/strtools.cpp index 09a95cba..cfef6b13 100644 --- a/tier1/strtools.cpp +++ b/tier1/strtools.cpp @@ -47,11 +47,7 @@ #include #ifdef POSIX -#ifdef ANDROID -#include <../thirdparty/libiconv-1.14/include/iconv.h> -#else #include -#endif #include #include #include diff --git a/tier1/wscript b/tier1/wscript index e381ecf4..80a32f69 100755 --- a/tier1/wscript +++ b/tier1/wscript @@ -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] @@ -74,9 +74,7 @@ def build(bld): defines = [] - libs = [ - 'libgnustl_static.a' - ] + libs = [] bld.stlib( source = source, diff --git a/togl/linuxwin/glentrypoints.cpp b/togl/linuxwin/glentrypoints.cpp index fad300d7..ef1f01ff 100644 --- a/togl/linuxwin/glentrypoints.cpp +++ b/togl/linuxwin/glentrypoints.cpp @@ -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) diff --git a/vgui2/src/wscript b/vgui2/src/wscript index 02599257..f4e5547c 100644 --- a/vgui2/src/wscript +++ b/vgui2/src/wscript @@ -50,7 +50,7 @@ def build(bld): defines = [] - libs = ['tier0','tier1','tier2','tier3','vstdlib','sdl2'] + libs = ['tier0','tier1','tier2','tier3','vstdlib','SDL2'] install_path = bld.env.LIBDIR diff --git a/vgui2/vgui_surfacelib/linuxfont.cpp b/vgui2/vgui_surfacelib/linuxfont.cpp index b80d908c..7366bcd0 100644 --- a/vgui2/vgui_surfacelib/linuxfont.cpp +++ b/vgui2/vgui_surfacelib/linuxfont.cpp @@ -502,7 +502,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 ) diff --git a/vgui2/vgui_surfacelib/wscript b/vgui2/vgui_surfacelib/wscript index 5d5cf846..0de65a46 100644 --- a/vgui2/vgui_surfacelib/wscript +++ b/vgui2/vgui_surfacelib/wscript @@ -32,8 +32,6 @@ def build(bld): '../../public/tier0', '../../public/tier1', '../../common', - '../../thirdparty/freetype2-android/include', # [$ANDROID] - '../../thirdparty/fontconfig' # [$ANDROID] ] + bld.env.INCLUDES_FT2 defines = [] diff --git a/vguimatsurface/wscript b/vguimatsurface/wscript index 220501ec..7359a3ab 100644 --- a/vguimatsurface/wscript +++ b/vguimatsurface/wscript @@ -39,13 +39,14 @@ def build(bld): '../public/tier0', '../public/tier1', '../common', - '../../thirdparty/freetype2-android/include', # [$ANDROID] - '../../thirdparty/fontconfig' # [$ANDROID] - ] + bld.env.INCLUDES_SDL2 + bld.env.INCLUDES_FREETYPE + ] defines = [] - libs = ['bitmap','mathlib','tier0','vgui_controls','tier1','vstdlib','tier2','tier3','vgui_surfacelib','FT2','FC','sdl2','EXPAT'] + 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 diff --git a/vstdlib/wscript b/vstdlib/wscript index 855ffb28..3e2547af 100755 --- a/vstdlib/wscript +++ b/vstdlib/wscript @@ -38,7 +38,10 @@ def build(bld): defines = [] - libs = ['tier0','tier1','iconv'] + libs = ['tier0','tier1'] + + if bld.env.DEST_OS == 'android': + libs += ['ANDROID_SUPPORT'] install_path = bld.env.LIBDIR diff --git a/wafandroid b/wafandroid deleted file mode 100755 index 25b6acd3..00000000 --- a/wafandroid +++ /dev/null @@ -1,8 +0,0 @@ -export CC=/home/jusic/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -export CXX=/home/jusic/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -export LD=/home/jusic/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld -export AR=/home/jusic/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ar -export LINK=/home/jusic/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld -export STRIP=/home/jusic/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-strip -export OBJCOPY=/home/jusic/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-objcopy -./waf configure -T debug diff --git a/wscript b/wscript index 9803fe36..b49ad41a 100644 --- a/wscript +++ b/wscript @@ -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 @@ -154,8 +154,6 @@ 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', [ @@ -226,20 +224,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', @@ -247,48 +231,56 @@ def configure(conf): '-Wuninitialized', '-Winit-self', '-Wstrict-aliasing', - '-Wextra', - '-w', - #'-faligned-new' + '-faligned-new' ] c_compiler_optional_flags = [ - #'-fnonconst-initializers' # owcc + '-fnonconst-initializers' # owcc ] cflags, linkflags = conf.get_optimization_flags() 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', '-mfloat-abi=softfp', '-fsigned-char', '--sysroot=/home/jusic/android-ndk-r10e/platforms/android-21/arch-arm', '-I/home/jusic/android-ndk-r10e/sources/cxx-stl/stlport/stlport', '-I/home/jusic/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a-hard/include', '-I/home/jusic/android-ndk-r10e/sources/android/support/include'] + flags += ['-mfpu=neon', '-mfloat-abi=hard', '-fsigned-char'] else: flags += ['-march=pentium4','-mtune=core2','-mfpmath=387'] - - flags += ['-I/home/jusic/source-engine-android/thirdparty/SDL/include', '-L/home/jusic/android-ndk-r10e/sources/cxx-stl/stlport/libs/armeabi-v7a-hard/thumb', '-L/home/jusic/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9', '-lstlport_shared', '-lm', '-L/home/jusic/source-engine-android/lib/common/android/armeabi-v7a', '-L/home/jusic/source-engine-android/lib/public/android/armeabi-v7a'] cflags += flags linkflags += flags - - # And here C++ flags starts to be treated separately + + # And here C++ flags starts to be treated separately cxxflags = list(cflags) + ['-std=c++11','-fpermissive'] if conf.env.COMPILER_CC == 'gcc': - wrapfunctions = ['freopen','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') linkflags += ['-pthread'] - conf.env.append_unique('CFLAGS', cflags) conf.env.append_unique('CXXFLAGS', cxxflags) conf.env.append_unique('LINKFLAGS', linkflags) @@ -296,26 +288,38 @@ def configure(conf): cxxflags += conf.filter_cxxflags(compiler_optional_flags, cflags) cflags += conf.filter_cflags(compiler_optional_flags + c_compiler_optional_flags, cflags) - conf.env.append_unique('CFLAGS', cflags) conf.env.append_unique('CXXFLAGS', cxxflags) conf.env.append_unique('LINKFLAGS', linkflags) conf.env.append_unique('INCLUDES', [os.path.abspath('common/')]) - conf.check(lib='iconv', uselib_store='iconv') - conf.check(lib='curl', uselib_store='curl') - conf.check(lib='jpeg', uselib_store='jpeg') - conf.check(lib='z', uselib_store='zlib') - conf.check(lib='crypto', uselib_store='crypto') - conf.check(lib='ssl', uselib_store='ssl') - conf.check(lib='openal', uselib_store='openal') - conf.check(lib='SDL2', uselib_store='sdl2') - conf.check(lib='png', uselib_store='png') - conf.check(lib='fontconfig', uselib_store='FT2') - conf.check(lib='freetype2', uselib_store='FC') - conf.check(lib='expat', uselib_store='EXPAT') - conf.check(lib='log', uselib_store='LOG') - + 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='fontconfig', uselib_store='FC') + 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) @@ -355,6 +359,9 @@ def configure(conf): conf.env.BINDIR = conf.env.PREFIX else: conf.env.LIBDIR = conf.env.BINDIR = conf.env.PREFIX + print(conf.env.PREFIX) + + if conf.options.DEDICATED: conf.add_subproject(projects['dedicated'])