diff --git a/README.md b/README.md index 3252493e..48be3155 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Source code is based on TF2 2018 leak. Don't use it for commercial purposes. This project is using waf buildsystem. If you have waf-related questions look https://waf.io/book # Features: -- Android, OSX, FreeBSD, Windows support +- Android, OSX, Windows, FreeBSD, Haiku support - Arm support( except windows ) - 64bit support - Modern toolchains support diff --git a/appframework/posixapp.cpp b/appframework/posixapp.cpp index ee4c6953..722675dc 100644 --- a/appframework/posixapp.cpp +++ b/appframework/posixapp.cpp @@ -118,7 +118,7 @@ bool CSteamApplication::Create( ) m_pFileSystem = (IFileSystem*)AddSystem( fileSystemModule, FILESYSTEM_INTERFACE_VERSION ); if ( !m_pFileSystem ) { - Error( "Unable to load %s", pFileSystemDLL ); + Error( "Unable to load %s\n", pFileSystemDLL ); return false; } diff --git a/appframework/sdlmgr.cpp b/appframework/sdlmgr.cpp index bad06f1b..88df7c43 100644 --- a/appframework/sdlmgr.cpp +++ b/appframework/sdlmgr.cpp @@ -270,7 +270,7 @@ public: // Get the next N events. The function returns the number of events that were filled into your array. virtual int GetEvents( CCocoaEvent *pEvents, int nMaxEventsToReturn, bool debugEvents = false ); -#if defined(LINUX) || defined(PLATFORM_BSD) +#if defined(POSIX) && !defined(OSX) virtual int PeekAndRemoveKeyboardEvents( bool *pbEsc, bool *pbReturn, bool *pbSpace, bool debugEvent = false ); #endif @@ -1004,7 +1004,7 @@ int CSDLMgr::GetEvents( CCocoaEvent *pEvents, int nMaxEventsToReturn, bool debug return nToWrite; } -#if defined(LINUX) || defined(PLATFORM_BSD) +#if defined(POSIX) && !defined(OSX) int CSDLMgr::PeekAndRemoveKeyboardEvents( bool *pbEsc, bool *pbReturn, bool *pbSpace, bool debugEvent ) { diff --git a/appframework/wscript b/appframework/wscript index 0fea261a..b3fb423b 100755 --- a/appframework/wscript +++ b/appframework/wscript @@ -42,6 +42,7 @@ def build(bld): includes = [ '.', + '../common', '../public', '../public/tier0', '../public/tier1' diff --git a/common/freetype/config/ftconfig.h b/common/freetype/config/ftconfig.h index b56a4d44..0af86f0a 100644 --- a/common/freetype/config/ftconfig.h +++ b/common/freetype/config/ftconfig.h @@ -3,6 +3,15 @@ #ifdef ANDROID #include +#elif defined(PLATFORM_HAIKU) +#include +# if B_HAIKU_64_BIT +# define __WORDSIZE 64 +# elif B_HAIKU_32_BIT +# define __WORDSIZE 32 +# else +# error "Unknown Haiku bit size" +# endif #elif defined(OSX) || defined(PLATFORM_BSD) #include #else diff --git a/engine/bugreporter.cpp b/engine/bugreporter.cpp index a0fbb4b8..45660e31 100644 --- a/engine/bugreporter.cpp +++ b/engine/bugreporter.cpp @@ -25,7 +25,7 @@ # include # include # define HW_MEMSIZE HW_PHYSMEM -#elif defined(LINUX) +#elif defined(LINUX) || defined(PLATFORM_HAIKU) #include #include #include @@ -110,7 +110,7 @@ #define BUG_REPOSITORY_URL "\\\\fileserver\\bugs" #elif defined(OSX) #define BUG_REPOSITORY_URL "/Volumes/bugs" -#elif defined(LINUX) || defined(PLATFORM_BSD) +#elif defined(POSIX) #define BUG_REPOSITORY_URL "\\\\fileserver\\bugs" #else //#error @@ -345,12 +345,14 @@ void DisplaySystemVersion( char *osversion, int maxlen ) fclose( fpKernelVer ); } +#elif PLATFORM_HAIKU + osversion = (char *)"Haiku OS"; #elif PLATFORM_BSD - #ifdef __FreeBSD__ - osversion = (char *)"FreeBSD"; - #else - osversion = (char *)"*BSD"; - #endif +# ifdef PLATFORM_FBSD + osversion = (char *)"FreeBSD"; +# else + osversion = (char *)"*BSD"; +# endif #endif } @@ -2257,7 +2259,7 @@ void NonFileSystem_CreatePath (const char *path) } } -#if defined(LINUX) || defined(PLATFORM_BSD) +#if defined(POSIX) && !defined(OSX) #define COPYFILE_ALL 0 #define BSIZE 65535 int copyfile( const char *local, const char *remote, void *ignored, int ignoredFlags ) diff --git a/engine/sv_main.cpp b/engine/sv_main.cpp index 1456e44d..342175a9 100644 --- a/engine/sv_main.cpp +++ b/engine/sv_main.cpp @@ -2714,14 +2714,16 @@ bool CGameServer::SpawnServer( const char *szMapName, const char *szMapFile, con event->SetString( "os", "LINUX" ); #elif defined ( OSX ) event->SetString( "os", "OSX" ); +#elif defined(PLATFORM_HAIKU) + event->SetString( "os", "Haiku" ); #elif defined(PLATFORM_BSD) - event->SetString("os", -# ifdef __FreeBSD__ - "FreeBSD" -# else - "BSD" -# endif - ); + event->SetString("os", +# ifdef PLATFORM_FBSD + "FreeBSD" +# else + "BSD" +# endif + ); #else #error #endif diff --git a/engine/sys_dll.cpp b/engine/sys_dll.cpp index c30e0122..68dbc7a3 100644 --- a/engine/sys_dll.cpp +++ b/engine/sys_dll.cpp @@ -16,6 +16,8 @@ #include #include #define HW_MEMSIZE HW_PHYSMEM +#elif defined(PLATFORM_HAIKU) +# include #endif #if defined(LINUX) #include @@ -464,7 +466,7 @@ void Sys_Error_Internal( bool bMinidump, const char *error, va_list argsList ) // Doing this doesn't quite work the way we want because there is no "crashing" thread // and we see "No thread was identified as the cause of the crash; No signature could be created because we do not know which thread crashed" on the back end //SteamAPI_WriteMiniDump( 0, NULL, build_number() ); - printf("\n ##### Sys_Error: %s", text ); + printf("\n ##### Sys_Error: %s\n", text ); fflush(stdout ); raise(SIGTRAP); @@ -677,6 +679,11 @@ void Sys_InitMemory( void ) { memsize = ONE_HUNDRED_TWENTY_EIGHT_MB; } +#elif defined(PLATFORM_HAIKU) + system_info info; + get_system_info(&info); + + memsize = (uint64_t)(info.max_pages * B_PAGE_SIZE); #elif defined(LINUX) const int fd = open("/proc/meminfo", O_RDONLY); if (fd < 0) @@ -1586,14 +1593,14 @@ CON_COMMAND( star_memory, "Dump memory stats" ) struct mstats memstats = mstats( ); Msg( "Available %.2f MB, Used: %.2f MB, #mallocs = %lu\n", memstats.bytes_free / ( 1024.0 * 1024.0), memstats.bytes_used / ( 1024.0 * 1024.0 ), memstats.chunks_used ); -#elif PLATFORM_BSD -# warning TODO: Implement memory stats (peace of sheet of course) -#else // Win32 +#elif _WIN32 MEMORYSTATUS stat; GlobalMemoryStatus( &stat ); Msg( "Available: %.2f MB, Used: %.2f MB, Free: %.2f MB\n", stat.dwTotalPhys/( 1024.0f*1024.0f ) - 32.0f, ( stat.dwTotalPhys - stat.dwAvailPhys )/( 1024.0f*1024.0f ) - 32.0f, stat.dwAvailPhys/( 1024.0f*1024.0f ) ); +#else +# warning TODO: Implement memory stats (peace of sheet of course) #endif } diff --git a/engine/sys_mainwind.cpp b/engine/sys_mainwind.cpp index 6003bf7c..3eea1a1c 100644 --- a/engine/sys_mainwind.cpp +++ b/engine/sys_mainwind.cpp @@ -25,9 +25,7 @@ #elif defined(_X360) // nothing to include for 360 #elif defined(OSX) -#elif defined(LINUX) || defined(PLATFORM_BSD) - #include "tier0/dynfunction.h" -#elif defined(_WIN32) +#elif defined(POSIX) || defined(_WIN32) #include "tier0/dynfunction.h" #else #error @@ -833,7 +831,7 @@ LRESULT CGame::WindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) // return 0 if handled message, 1 if not return lRet; } -#elif defined(OSX) || defined(LINUX) || defined(_WIN32) || defined(PLATFORM_BSD) +#elif defined(POSIX) || defined(_WIN32) #else #error diff --git a/engine/wscript b/engine/wscript index 6ef0bc77..272c88d7 100755 --- a/engine/wscript +++ b/engine/wscript @@ -365,7 +365,9 @@ def build(bld): libs += ['USER32', 'WINMM', 'WININET', 'DSOUND', 'DXGUID', 'GDI32', 'bzip2'] elif bld.env.DEST_OS == 'darwin' and not bld.env.DEDICATED: libs += ['APPKIT', 'COREAUDIO', 'AUDIOTOOLBOX', 'SYSTEMCONFIGURATION'] - + elif bld.env.DEST_OS == 'haiku': + libs += ['NETWORK'] + install_path = bld.env.LIBDIR bld.shlib( diff --git a/gameui/BasePanel.cpp b/gameui/BasePanel.cpp index 41d52d63..34327923 100644 --- a/gameui/BasePanel.cpp +++ b/gameui/BasePanel.cpp @@ -2223,7 +2223,7 @@ void CBasePanel::RunMenuCommand(const char *command) RegCloseKey(hKey); } -#elif defined( OSX ) || defined( LINUX ) || defined(PLATFORM_BSD) +#elif defined( POSIX ) FILE *fp = fopen( "/tmp/hl2_relaunch", "w+" ); if ( fp ) { diff --git a/gameui/VGuiSystemModuleLoader.cpp b/gameui/VGuiSystemModuleLoader.cpp index 003cdbd7..c713520c 100644 --- a/gameui/VGuiSystemModuleLoader.cpp +++ b/gameui/VGuiSystemModuleLoader.cpp @@ -161,7 +161,7 @@ bool CVGuiSystemModuleLoader::LoadPlatformModules(CreateInterfaceFn *factorylist { dllPath = it->GetString("dll_osx"); } - else if ( IsLinux() || IsBSD() ) + else if ( IsPosix() ) { dllPath = it->GetString("dll_linux"); } diff --git a/ivp b/ivp index 960c7228..e96e2ec4 160000 --- a/ivp +++ b/ivp @@ -1 +1 @@ -Subproject commit 960c7228f8e8d710625891991e88b1ec3aa92e45 +Subproject commit e96e2ec4e77354d74f16554a0cbb1eff627e4a63 diff --git a/launcher/launcher.cpp b/launcher/launcher.cpp index b5f4f882..06e60136 100644 --- a/launcher/launcher.cpp +++ b/launcher/launcher.cpp @@ -950,7 +950,7 @@ bool GrabSourceMutex() #ifdef ANDROID return true; -#elif defined (LINUX) || defined(PLATFORM_BSD) +#elif defined (POSIX) && !defined(OSX) /* * Linux */ @@ -1198,7 +1198,7 @@ DLL_EXPORT int LauncherMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR DLL_EXPORT int LauncherMain( int argc, char **argv ) #endif { -#if (defined(LINUX) || defined(PLATFORM_BSD)) && !defined ANDROID +#if (defined(POSIX)) && !defined ANDROID // Temporary fix to stop us from crashing in printf/sscanf functions that don't expect // localization to mess with your "." and "," float seperators. Mac OSX also sets LANG // to en_US.UTF-8 before starting up (in info.plist I believe). @@ -1225,7 +1225,7 @@ DLL_EXPORT int LauncherMain( int argc, char **argv ) Msg("SDL version: %d.%d.%d rev: %s\n", (int)ver.major, (int)ver.minor, (int)ver.patch, SDL_GetRevision()); #endif -#if (defined LINUX || defined PLATFORM_BSD) && defined USE_SDL && defined TOGLES && !defined ANDROID +#if defined POSIX && defined USE_SDL && defined TOGLES && !defined ANDROID SDL_SetHint(SDL_HINT_VIDEO_X11_FORCE_EGL, "1"); #endif @@ -1553,7 +1553,7 @@ DLL_EXPORT int LauncherMain( int argc, char **argv ) RegCloseKey(hKey); } -#elif defined( OSX ) || defined( LINUX ) || defined(PLATFORM_BSD) +#elif defined( POSIX ) struct stat st; if ( stat( RELAUNCH_FILE, &st ) == 0 ) { diff --git a/launcher_main/main.cpp b/launcher_main/main.cpp index bc075b94..00db51f6 100644 --- a/launcher_main/main.cpp +++ b/launcher_main/main.cpp @@ -216,6 +216,7 @@ static void WaitForDebuggerConnect( int argc, char *argv[], int time ) int main( int argc, char *argv[] ) { +#ifndef PLATFORM_HAIKU char ld_path[4196]; char *path = "bin/"; char *ld_env; @@ -234,6 +235,7 @@ int main( int argc, char *argv[] ) setenv("NO_EXECVE_AGAIN", "1", 1); execve(argv[0], argv, environ); } +#endif void *launcher = dlopen( "bin/liblauncher" DLL_EXT_STRING, RTLD_NOW ); if ( !launcher ) diff --git a/materialsystem/stdshaders/wscript b/materialsystem/stdshaders/wscript index 4d82e515..73f9744d 100644 --- a/materialsystem/stdshaders/wscript +++ b/materialsystem/stdshaders/wscript @@ -141,6 +141,7 @@ def build(bld): includes = [ '.', + '../../common', '../../public', '../../public/tier0', '../../public/tier1', diff --git a/mathlib/3dnow.cpp b/mathlib/3dnow.cpp index 88e4ead7..599a22e8 100644 --- a/mathlib/3dnow.cpp +++ b/mathlib/3dnow.cpp @@ -16,7 +16,7 @@ // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" -#if !defined(COMPILER_MSVC64) && !defined(LINUX) && !defined(COMPILER_CLANG) +#if !defined(COMPILER_MSVC64) && !defined(POSIX) && !defined(COMPILER_CLANG) // Implement for 64-bit Windows if needed. // Clang hits "fatal error: error in backend:" and other errors when trying // to compile the inline assembly below. 3DNow support is highly unlikely to diff --git a/mathlib/mathlib_base.cpp b/mathlib/mathlib_base.cpp index 3b8fbe2f..50904802 100644 --- a/mathlib/mathlib_base.cpp +++ b/mathlib/mathlib_base.cpp @@ -3343,7 +3343,7 @@ void MathLib_Init( float gamma, float texGamma, float brightness, int overbright // SSE Generally performs better than 3DNow when present, so this is placed // first to allow SSE to override these settings. -#if !defined( OSX ) && !defined( PLATFORM_WINDOWS_PC64 ) && !defined(LINUX) && !defined(PLATFORM_BSD) +#if !defined( OSX ) && !defined( PLATFORM_WINDOWS_PC64 ) && !defined(POSIX) if ( bAllow3DNow && pi.m_b3DNow ) { s_b3DNowEnabled = true; diff --git a/public/XUnzip.cpp b/public/XUnzip.cpp index bf6310a7..841f6bd2 100644 --- a/public/XUnzip.cpp +++ b/public/XUnzip.cpp @@ -4243,7 +4243,7 @@ ZRESULT TUnzip::Unzip(int index,void *dst,unsigned int len,DWORD flags) { #ifdef _WIN32 SetFileTime(h,&ze.ctime,&ze.atime,&ze.mtime); -#elif defined( ANDROID ) +#elif defined( ANDROID ) || defined(PLATFORM_HAIKU) struct timespec ts[2]; ts[0].tv_sec = ze.atime; ts[0].tv_nsec = 0; diff --git a/public/appframework/AppFramework.h b/public/appframework/AppFramework.h index 4df8a2b8..ad4c5f3e 100644 --- a/public/appframework/AppFramework.h +++ b/public/appframework/AppFramework.h @@ -61,7 +61,7 @@ void AppShutdown( CAppSystemGroup *pAppSystemGroup ); extern int ValveCocoaMain( int argc, char **argv, CAppSystemGroup *pAppSystemGroup ); \ return ValveCocoaMain( argc, argv, &_globalVarName ); \ } -#elif defined( LINUX ) || defined(PLATFORM_BSD) +#elif defined(POSIX) #define DEFINE_WINDOWED_APPLICATION_OBJECT_GLOBALVAR( _globalVarName ) \ int main( int argc, char **argv ) \ { \ diff --git a/public/appframework/ilaunchermgr.h b/public/appframework/ilaunchermgr.h index b7011ca1..4a3e7915 100644 --- a/public/appframework/ilaunchermgr.h +++ b/public/appframework/ilaunchermgr.h @@ -52,7 +52,7 @@ public: // Get the next N events. The function returns the number of events that were filled into your array. virtual int GetEvents( CCocoaEvent *pEvents, int nMaxEventsToReturn, bool debugEvents = false ) = 0; -#if defined(LINUX) || defined(PLATFORM_BSD) +#if defined(POSIX) && !defined(OSX) virtual int PeekAndRemoveKeyboardEvents( bool *pbEsc, bool *pbReturn, bool *pbSpace, bool debugEvents = false ) = 0; #endif diff --git a/public/filesystem_init.cpp b/public/filesystem_init.cpp index 86baacd3..88ddae1d 100644 --- a/public/filesystem_init.cpp +++ b/public/filesystem_init.cpp @@ -344,7 +344,11 @@ bool FileSystem_GetExecutableDir( char *exedir, int exeDirLen ) Q_FixSlashes( exedir ); +#ifdef PLATFORM_HAIKU + 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... diff --git a/common/sse2neon.h b/public/sse2neon.h similarity index 100% rename from common/sse2neon.h rename to public/sse2neon.h diff --git a/public/steam/steamtypes.h b/public/steam/steamtypes.h index c32150e2..449a5fe1 100644 --- a/public/steam/steamtypes.h +++ b/public/steam/steamtypes.h @@ -56,6 +56,9 @@ typedef __int32 intp; typedef unsigned __int32 uintp; #endif +#elif defined(PLATFORM_HAIKU) +// Already defined + #else // _WIN32 typedef short int16; diff --git a/public/tier0/platform.h b/public/tier0/platform.h index 2c912e04..517a6d2b 100644 --- a/public/tier0/platform.h +++ b/public/tier0/platform.h @@ -66,6 +66,8 @@ // need this for _alloca # ifdef PLATFORM_BSD # define va_list __va_list +# elif defined(PLATFORM_HAIKU) +# include # else # include # endif @@ -213,12 +215,14 @@ typedef signed char int8; #else // _WIN32 +#if !defined(PLATFORM_HAIKU) typedef short int16; typedef unsigned short uint16; typedef int int32; typedef unsigned int uint32; typedef long long int64; typedef unsigned long long uint64; +#endif typedef long int lint64; typedef unsigned long int ulint64; @@ -561,7 +565,7 @@ typedef void * HINSTANCE; //----------------------------------------------------------------------------- #if defined( GNUC ) #define stackalloc( _size ) alloca( ALIGN_VALUE( _size, 16 ) ) -#if defined(_LINUX) || defined(PLATFORM_BSD) +#if defined(_LINUX) || defined(PLATFORM_BSD) || defined(PLATFORM_HAIKU) #define mallocsize( _p ) ( malloc_usable_size( _p ) ) #elif defined(OSX) #define mallocsize( _p ) ( malloc_size( _p ) ) @@ -1388,11 +1392,11 @@ PLATFORM_INTERFACE void* Plat_SimpleLog( const tchar* file, int line ); //----------------------------------------------------------------------------- // Returns true if debugger attached, false otherwise //----------------------------------------------------------------------------- -#if defined(_WIN32) || defined(LINUX) || defined(OSX) || defined(PLATFORM_BSD) +#if defined(_WIN32) || defined(POSIX) PLATFORM_INTERFACE bool Plat_IsInDebugSession(); PLATFORM_INTERFACE void Plat_DebugString( const char * ); #else -#warning "Plat_IsInDebugSession isn't working properly" +#error "Plat_IsInDebugSession isn't working properly" inline bool Plat_IsInDebugSession( bool bForceRecheck = false ) { return false; } #define Plat_DebugString(s) ((void)0) #endif diff --git a/public/tier0/threadtools.h b/public/tier0/threadtools.h index b7216193..1077c2d8 100644 --- a/public/tier0/threadtools.h +++ b/public/tier0/threadtools.h @@ -319,7 +319,7 @@ PLATFORM_INTERFACE void ThreadSetAffinity( ThreadHandle_t hThread, int nAffinity #error Every platform needs to define ThreadMemoryBarrier to at least prevent compiler reordering #endif -#if defined( _LINUX ) || defined( _OSX ) || defined(PLATFORM_BSD) +#if defined(POSIX) #define USE_INTRINSIC_INTERLOCKED // linux implementation inline int32 ThreadInterlockedIncrement( int32 volatile *p ) @@ -520,7 +520,7 @@ PLATFORM_INTERFACE void ThreadNotifySyncReleasing(void *p); #ifndef NO_THREAD_LOCAL -#if defined(WIN32) || defined(OSX) || defined( _PS3 ) || ( defined (_LINUX) ) || defined(PLATFORM_BSD) +#if defined(WIN32) || defined(POSIX) || defined( _PS3 ) #ifndef __AFXTLS_H__ // not compatible with some Windows headers #if defined(_PS3) diff --git a/public/tier1/fmtstr.h b/public/tier1/fmtstr.h index 66ea88f5..c279d0d7 100644 --- a/public/tier1/fmtstr.h +++ b/public/tier1/fmtstr.h @@ -304,8 +304,10 @@ public: explicit CNumStr( uint64 un64 ) { SetUint64( un64 ); } #if defined(COMPILER_GCC) && defined(PLATFORM_64BITS) +#if !defined(PLATFORM_HAIKU) explicit CNumStr( lint64 n64 ) { SetInt64( (int64)n64 ); } explicit CNumStr( ulint64 un64 ) { SetUint64( (uint64)un64 ); } +#endif #endif explicit CNumStr( double f ) { SetDouble( f ); } diff --git a/public/tier1/utlbuffer.h b/public/tier1/utlbuffer.h index e71178f9..fe2bd7d0 100644 --- a/public/tier1/utlbuffer.h +++ b/public/tier1/utlbuffer.h @@ -109,7 +109,7 @@ typedef unsigned short ushort; template < class A > static const char *GetFmtStr( int nRadix = 10, bool bPrint = true ) { Assert( 0 ); return ""; } -#if defined( LINUX ) || defined( __clang__ ) || ( defined( _MSC_VER ) && _MSC_VER >= 1900 ) +#if defined( LINUX ) || defined( __clang__ ) || ( defined( _MSC_VER ) && _MSC_VER >= 1900 ) || defined(PLATFORM_HAIKU) template <> const char *GetFmtStr< short > ( int nRadix, bool bPrint ) { Assert( nRadix == 10 ); return "%hd"; } template <> const char *GetFmtStr< ushort > ( int nRadix, bool bPrint ) { Assert( nRadix == 10 ); return "%hu"; } template <> const char *GetFmtStr< int > ( int nRadix, bool bPrint ) { Assert( nRadix == 10 ); return "%d"; } diff --git a/public/togl/linuxwin/cglmtex.h b/public/togl/linuxwin/cglmtex.h index 55321316..3d0898e1 100644 --- a/public/togl/linuxwin/cglmtex.h +++ b/public/togl/linuxwin/cglmtex.h @@ -293,7 +293,7 @@ struct GLMTexSamplingParams m_packed.m_isValid = true; } -#ifndef OSX +#if !defined(OSX) && !defined(PLATFORM_HAIKU) FORCEINLINE void SetToSamplerObject( GLuint nSamplerObject ) const { static const GLenum dxtogl_addressMode[] = { GL_REPEAT, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_BORDER, (GLenum)-1 }; diff --git a/public/togl/linuxwin/glfuncs.h b/public/togl/linuxwin/glfuncs.h index 2a69416f..30acd55c 100644 --- a/public/togl/linuxwin/glfuncs.h +++ b/public/togl/linuxwin/glfuncs.h @@ -126,7 +126,9 @@ GL_FUNC_VOID(OpenGL,true,glDisableClientState,(GLenum a),(a)) GL_FUNC_VOID(OpenGL,true,glClientActiveTexture,(GLenum a),(a)) GL_FUNC_VOID(OpenGL,true,glVertexPointer,(GLint a,GLenum b,GLsizei c,const GLvoid *d),(a,b,c,d)) GL_FUNC_VOID(OpenGL,true,glTexCoordPointer,(GLint a,GLenum b,GLsizei c,const GLvoid *d),(a,b,c,d)) +#ifndef PLATFORM_HAIKU GL_FUNC_VOID(OpenGL,true,glProgramEnvParameters4fvEXT,(GLenum a,GLuint b,GLsizei c,const GLfloat *d),(a,b,c,d)) +#endif GL_FUNC_VOID(OpenGL,true,glColor4sv,(const GLshort *a),(a)) GL_FUNC_VOID(OpenGL,true,glStencilOpSeparate,(GLenum a,GLenum b,GLenum c,GLenum d),(a,b,c,d)) GL_FUNC_VOID(OpenGL,true,glStencilFuncSeparate,(GLenum a,GLenum b,GLint c,GLuint d),(a,b,c,d)) @@ -223,7 +225,7 @@ GL_EXT(GL_EXT_direct_state_access,-1,-1) GL_FUNC_VOID(GL_EXT_direct_state_access,false,glBindMultiTextureEXT,(GLenum a,GLuint b, GLuint c),(a,b,c)) GL_EXT(GL_NV_bindless_texture,-1,-1) -#ifndef OSX +#if !defined(OSX) && !defined(PLATFORM_HAIKU) GL_FUNC_VOID(OpenGL, true, glGenSamplers, (GLuint a, GLuint *b), (a, b)) GL_FUNC_VOID(OpenGL, true, glDeleteSamplers, (GLsizei a, const GLuint *b), (a, b)) GL_FUNC_VOID(OpenGL, true, glBindSampler, (GLuint a, GLuint b), (a, b)) diff --git a/serverbrowser/ServerBrowserDialog.cpp b/serverbrowser/ServerBrowserDialog.cpp index dc2ca162..a48aa583 100644 --- a/serverbrowser/ServerBrowserDialog.cpp +++ b/serverbrowser/ServerBrowserDialog.cpp @@ -25,7 +25,7 @@ #define WIN32_LEAN_AND_MEAN #include #endif -#if defined(LINUX) || defined(PLATFORM_BSD) +#if defined(POSIX) #include #endif diff --git a/tier0/assert_dialog.cpp b/tier0/assert_dialog.cpp index e13b47e0..3c80c380 100644 --- a/tier0/assert_dialog.cpp +++ b/tier0/assert_dialog.cpp @@ -386,7 +386,7 @@ DBG_INTERFACE bool ShouldUseNewAssertDialog() #endif // DBGFLAG_ASSERTDLG } -#if defined( POSIX ) && !defined ( ANDROID ) +#if defined( POSIX ) && !defined ( ANDROID ) && !defined(PLATFORM_HAIKU) #include @@ -441,7 +441,7 @@ DBG_INTERFACE bool DoNewAssertDialog( const tchar *pFilename, int line, const tc pFilename, line, pExpression); if ( getenv( "POSIX_ASSERT_BACKTRACE" ) ) { -#if !defined ( ANDROID ) +#if !defined ( ANDROID ) && !defined(PLATFORM_HAIKU) SpewBacktrace(); #endif } diff --git a/tier0/cpu_posix.cpp b/tier0/cpu_posix.cpp index a86f40a7..51308943 100644 --- a/tier0/cpu_posix.cpp +++ b/tier0/cpu_posix.cpp @@ -9,8 +9,10 @@ #include #ifdef LINUX #include +#elif defined(PLATFORM_HAIKU) +# include #else -#include +# include # ifdef __APPLE__ # define CPUFREQ_SYSCTL "hw.cpufrequency_max" # else @@ -62,6 +64,18 @@ uint64 GetCPUFreqFromPROC() return freq_hz; } +#elif defined(PLATFORM_HAIKU) + +// Haiku and BeOS +uint64 GetCPUFreqFromPROC() +{ + cpu_info *info; + status_t status = get_cpu_info(0, 1, info); + if (status != 0) + return 0; + return info->current_frequency; +} + #else // Linux @@ -101,7 +115,7 @@ uint64 GetCPUFreqFromPROC() uint64 CalculateCPUFreq() { -#if defined(__APPLE__) || defined(PLATFORM_BSD) +#if !defined(LINUX) return GetCPUFreqFromPROC(); #else // Try to open cpuinfo_max_freq. If the kernel was built with cpu scaling support disabled, this will fail. diff --git a/tier0/cpu_usage.cpp b/tier0/cpu_usage.cpp index 1fc1752b..01932df4 100644 --- a/tier0/cpu_usage.cpp +++ b/tier0/cpu_usage.cpp @@ -124,7 +124,7 @@ float GetCPUUsage() float GetCPUUsage() { -#ifdef ANDROID +#if defined(ANDROID) || defined(PLATFORM_HAIKU) return 0; #else double loadavg[3]; diff --git a/tier0/platform_posix.cpp b/tier0/platform_posix.cpp index 425f8cff..ca0e776f 100644 --- a/tier0/platform_posix.cpp +++ b/tier0/platform_posix.cpp @@ -16,7 +16,7 @@ #include #include -#if defined(OSX) || defined(PLATFORM_BSD) +#if defined(OSX) || defined(PLATFORM_FBSD) # ifdef PLATFORM_BSD # include # include @@ -446,6 +446,9 @@ PLATFORM_INTERFACE void Plat_SetAllocErrorFn( Plat_AllocErrorFn fn ) // From the Apple tech note: http://developer.apple.com/library/mac/#qa/qa1361/_index.html bool Plat_IsInDebugSession() { +#if defined(PLATFORM_BSD) && !defined(PLATFORM_FBSD) + return false; // TODO: OpenBSD and NetBSD support +#else static int s_IsInDebugSession; int junk; struct kinfo_proc info; @@ -466,6 +469,7 @@ bool Plat_IsInDebugSession() #endif return !!s_IsInDebugSession; +#endif } #elif defined( LINUX ) @@ -502,6 +506,14 @@ bool Plat_IsInDebugSession() return ( tracerpid > 0 ); } +#else +# warning "TODO: Plat_IsInDebugSession()" + +bool Plat_IsInDebugSession() +{ + return false; +} + #endif // defined( LINUX ) void Plat_DebugString( const char * psz ) @@ -559,11 +571,7 @@ PLATFORM_INTERFACE const char *Plat_GetCommandLineA() PLATFORM_INTERFACE bool GetMemoryInformation( MemoryInformation *pOutMemoryInfo ) { - #if defined( LINUX ) || defined( OSX ) || defined(PLATFORM_BSD) - return false; - #else - #error "Need to fill out GetMemoryInformation or at least return false for this platform" - #endif + return false; } @@ -571,7 +579,7 @@ PLATFORM_INTERFACE bool Is64BitOS() { #if defined OSX return true; -#elif defined(LINUX) || defined(PLATFORM_BSD) +#elif defined(POSIX) FILE *pp = popen( "uname -m", "r" ); if ( pp != NULL ) { diff --git a/tier0/threadtools.cpp b/tier0/threadtools.cpp index 06c8296f..a84c1f7d 100644 --- a/tier0/threadtools.cpp +++ b/tier0/threadtools.cpp @@ -27,13 +27,8 @@ #define GetLastError() errno typedef void *LPVOID; #if !defined(OSX) -#if defined(ANDROID) #include #include -#else - #include - #include -#endif #define sem_unlink( arg ) #define OS_TO_PTHREAD(x) (x) #else @@ -43,7 +38,7 @@ #define OS_TO_PTHREAD(x) pthread_from_mach_thread_np( x ) #endif // !OSX -#ifdef PLATFORM_BSD +#if defined(PLATFORM_BSD) || defined(PLATFORM_HAIKU) # undef OS_TO_PTRHEAD # define OS_TO_PTHREAD(x) (pthread_t)(x) #endif @@ -1632,7 +1627,7 @@ bool CThreadFullMutex::Release() // //----------------------------------------------------------------------------- -#if defined( WIN32 ) || defined( _PS3 ) || defined( _OSX ) || defined (_LINUX) || defined(PLATFORM_BSD) +#if defined( WIN32 ) || defined( _PS3 ) || defined(POSIX) #if !defined(_PS3) namespace GenericThreadLocals { diff --git a/tier0/wscript b/tier0/wscript index b02c60bf..be773b9a 100755 --- a/tier0/wscript +++ b/tier0/wscript @@ -17,6 +17,9 @@ def configure(conf): conf.define('TIER0_DLL_EXPORT',1) # conf.define('NO_HOOK_MALLOC',1) + if conf.env.DEST_OS == 'freebsd': + conf.check_cc(lib='execinfo') + def build(bld): source = [ 'assert_dialog.cpp', @@ -82,6 +85,9 @@ def build(bld): libs = ['ADVAPI32', 'WS2_32'] else: libs = ['DL', 'M', 'LOG'] + if bld.env.DEST_OS == 'freebsd': libs += ['EXECINFO'] + if bld.env.DEST_OS == 'haiku': libs += ['NETWORK'] + install_path = bld.env.LIBDIR diff --git a/tier1/KeyValues.cpp b/tier1/KeyValues.cpp index 75664e43..45823e2f 100644 --- a/tier1/KeyValues.cpp +++ b/tier1/KeyValues.cpp @@ -2239,7 +2239,7 @@ bool EvaluateConditional( const char *str ) return bNot; if ( Q_stristr( str, "$LINUX" ) ) - return ( IsLinux() || IsBSD() || IsOSX() ) ^ bNot; + return ( IsPosix() ) ^ bNot; if ( Q_stristr( str, "$POSIX" ) ) return IsPosix() ^ bNot; diff --git a/tier1/interface.cpp b/tier1/interface.cpp index 78dacc82..12e75f32 100644 --- a/tier1/interface.cpp +++ b/tier1/interface.cpp @@ -247,7 +247,7 @@ HMODULE Sys_LoadLibrary( const char *pLibraryName, Sys_Flags flags ) #elif POSIX int dlopen_mode = RTLD_NOW; -#ifndef ANDROID +#if !defined(ANDROID) && !defined(PLATFORM_HAIKU) if ( flags & SYS_NOLOAD ) dlopen_mode |= RTLD_NOLOAD; #endif @@ -271,6 +271,8 @@ static bool s_bRunningWithDebugModules = false; #ifdef ANDROID #define DEFAULT_LIB_PATH "" +#elif defined(PLATFORM_HAIKU) +#define DEFAULT_LIB_PATH "lib/" #else #define DEFAULT_LIB_PATH "bin/" #endif diff --git a/tier1/strtools.cpp b/tier1/strtools.cpp index ce1adb0c..682b3729 100644 --- a/tier1/strtools.cpp +++ b/tier1/strtools.cpp @@ -82,7 +82,7 @@ #ifdef ANDROID #include "common/iconv.h" #elif POSIX -#include +# include #endif static int FastToLower( char c ) @@ -2953,11 +2953,11 @@ extern "C" void qsort_s( void *base, size_t num, size_t width, int (*compare )(v void V_qsort_s( void *base, size_t num, size_t width, int ( __cdecl *compare )(void *, const void *, const void *), void * context ) { -#if defined(OSX) || defined(PLATFORM_BSD) - // the arguments are swapped 'round on the mac - awesome, huh? - return qsort_r( base, num, width, context, compare ); -#else +#if defined(_WIN32) || defined(LINUX) + // the arguments are swapped 'round on the win32 - awesome, huh? return qsort_s( base, num, width, compare, context ); +#else + return qsort_r( base, num, width, context, compare ); #endif } diff --git a/tier1/wscript b/tier1/wscript index 0a5f684b..9dfc09c8 100755 --- a/tier1/wscript +++ b/tier1/wscript @@ -75,8 +75,7 @@ def build(bld): '../', '../public', '../public/tier1', - '../public/tier0', - '../common' + '../public/tier0' ] defines = [] @@ -84,9 +83,10 @@ def build(bld): libs = [] if bld.env.DEST_OS == 'win32': libs += ['RPCRT4'] - elif bld.env.DEST_OS == "darwin": + elif bld.env.DEST_OS in ['darwin', 'haiku']: libs += ['ICONV'] - + if bld.env.DEST_OS == 'haiku': libs += ['GNU'] + bld.stlib( source = source, target = PROJECT_NAME, diff --git a/togl/linuxwin/cglmbuffer.cpp b/togl/linuxwin/cglmbuffer.cpp index ecba047b..3cd45d6e 100644 --- a/togl/linuxwin/cglmbuffer.cpp +++ b/togl/linuxwin/cglmbuffer.cpp @@ -1071,7 +1071,7 @@ void CGLMBuffer::Unlock( int nActualSize, const void *pActualData ) g_nTotalVBLockBytes += nActualSize; #endif -#ifndef OSX +#if !defined(OSX) && !defined(PLATFORM_HAIKU) if ( m_nPinnedMemoryOfs >= 0 ) { #if TOGL_SUPPORT_NULL_DEVICE diff --git a/togl/linuxwin/dxabstract.cpp b/togl/linuxwin/dxabstract.cpp index 45100948..e0f6e6c0 100644 --- a/togl/linuxwin/dxabstract.cpp +++ b/togl/linuxwin/dxabstract.cpp @@ -38,7 +38,7 @@ #include "glmgr_flush.inl" -#if defined(OSX) || defined(LINUX) || (defined (WIN32) && defined( DX_TO_GL_ABSTRACTION )) || defined(PLATFORM_BSD) +#if defined(POSIX) || (defined (WIN32) && defined( DX_TO_GL_ABSTRACTION )) #include "appframework/ilaunchermgr.h" extern ILauncherMgr *g_pLauncherMgr; #endif diff --git a/togl/linuxwin/glentrypoints.cpp b/togl/linuxwin/glentrypoints.cpp index 621ab394..15dddeaf 100644 --- a/togl/linuxwin/glentrypoints.cpp +++ b/togl/linuxwin/glentrypoints.cpp @@ -43,7 +43,7 @@ #include "tier1.h" #include "tier2/tier2.h" -#if (defined(_LINUX) || defined(PLATFORM_BSD)) && !defined(__ANDROID__) +#if defined(POSIX) && !defined(__ANDROID__) && !defined(PLATFORM_HAIKU) #include #endif @@ -54,7 +54,7 @@ #error #endif -#if defined(OSX) || defined(LINUX) || (defined (WIN32) && defined( DX_TO_GL_ABSTRACTION )) || defined(PLATFORM_BSD) +#if defined(POSIX) || (defined (WIN32) && defined( DX_TO_GL_ABSTRACTION )) #include "appframework/ilaunchermgr.h" ILauncherMgr *g_pLauncherMgr = NULL; #endif @@ -296,7 +296,7 @@ static bool CheckOpenGLExtension_internal(const char *ext, const int coremajor, return false; } } -#elif !defined ( OSX ) && !defined( __ANDROID__ ) +#elif !defined ( OSX ) && !defined( __ANDROID__ ) && !defined(PLATFORM_HAIKU) if (!ptr) { static CDynamicFunctionOpenGL< true, Display *( APIENTRY *)( ), Display* > glXGetCurrentDisplay("glXGetCurrentDisplay"); @@ -427,7 +427,7 @@ COpenGLEntryPoints::COpenGLEntryPoints() #undef GL_EXT #endif -#ifdef OSX +#if defined(OSX) || defined(PLATFORM_HAIKU) m_bHave_GL_NV_bindless_texture = false; m_bHave_GL_AMD_pinned_memory = false; #else diff --git a/togl/linuxwin/glmgr.cpp b/togl/linuxwin/glmgr.cpp index 745862b1..cf92a7b4 100644 --- a/togl/linuxwin/glmgr.cpp +++ b/togl/linuxwin/glmgr.cpp @@ -1771,7 +1771,7 @@ void GLMContext::PreloadTex( CGLMTex *tex, bool force ) // bind texture and sampling params CGLMTex *pPrevTex = m_samplers[15].m_pBoundTex; -#ifndef OSX // 10.6 +#if !defined(OSX) && !defined(PLATFORM_HAIKU) if ( m_bUseSamplerObjects ) { gGL->glBindSampler( 15, 0 ); @@ -2410,7 +2410,7 @@ void GLMContext::Present( CGLMTex *tex ) m_nTotalVSUniformCalls = 0, m_nTotalVSUniformBoneCalls = 0, m_nTotalVSUniformsSet = 0, m_nTotalVSUniformsBoneSet = 0, m_nTotalPSUniformCalls = 0, m_nTotalPSUniformsSet = 0; #endif -#ifndef OSX +#if !defined(OSX) && !defined(PLATFORM_HAIKU) GLMGPUTimestampManagerTick(); #endif } @@ -2609,7 +2609,7 @@ GLMContext::GLMContext( IDirect3DDevice9 *pDevice, GLMDisplayParams *params ) m_texLayoutTable = new CGLMTexLayoutTable; -#ifndef OSX +#if !defined(OSX) && !defined(PLATFORM_HAIKU) if ( m_bUseSamplerObjects ) { memset( m_samplerObjectHash, 0, sizeof( m_samplerObjectHash ) ); @@ -2850,7 +2850,7 @@ void GLMContext::Reset() GLMContext::~GLMContext () { -#ifndef OSX +#if !defined(OSX) && !defined(PLATFORM_HAIKU) GLMGPUTimestampManagerDeinit(); for ( uint t = 0; t < cNumPinnedMemoryBuffers; t++ ) diff --git a/togl/linuxwin/glmgr_flush.inl b/togl/linuxwin/glmgr_flush.inl index 75325947..b5ddc379 100644 --- a/togl/linuxwin/glmgr_flush.inl +++ b/togl/linuxwin/glmgr_flush.inl @@ -12,7 +12,7 @@ FORCEINLINE uint32 bitmix32(uint32 a) return a; } -#ifndef OSX +#if !defined(OSX) && !defined(PLATFORM_HAIKU) FORCEINLINE GLuint GLMContext::FindSamplerObject( const GLMTexSamplingParams &desiredParams ) { @@ -255,7 +255,7 @@ FORCEINLINE void GLMContext::FlushDrawStates( uint nStartIndex, uint nEndIndex, GL_BATCH_PERF( m_FlushStats.m_nNumChangedSamplers += m_nNumDirtySamplers ); -#if !defined( OSX ) // no support for sampler objects in OSX 10.6 (GL 2.1 profile) +#if !defined( OSX ) && !defined(PLATFORM_HAIKU) // no support for sampler objects in OSX 10.6 (GL 2.1 profile) if ( m_bUseSamplerObjects) { while ( m_nNumDirtySamplers ) diff --git a/togl/linuxwin/glmgrbasics.cpp b/togl/linuxwin/glmgrbasics.cpp index 7a02f7f3..f510087a 100644 --- a/togl/linuxwin/glmgrbasics.cpp +++ b/togl/linuxwin/glmgrbasics.cpp @@ -2628,11 +2628,6 @@ bool GLMDetectOGLP( void ) #include #ifndef _WIN32 #include -#ifdef LINUX -#include -#else -#include -#endif #endif // From Technical Q&A QA1361 @@ -2643,43 +2638,7 @@ bool GLMDetectOGLP( void ) bool GLMDetectGDB( void ) // aka AmIBeingDebugged() { -#ifdef OSX - bool result; - int junk; - int mib[4]; - struct kinfo_proc info; - size_t size; - - // Initialize the flags so that, - // if sysctl fails for some bizarre - // reason, we get a predictable result. - - info.kp_proc.p_flag = 0; - - // Initialize mib, which tells sysctl the info - // we want, in this case we're looking for - // information about a specific process ID. - - mib[0] = CTL_KERN; - mib[1] = KERN_PROC; - mib[2] = KERN_PROC_PID; - mib[3] = getpid(); - - // Call sysctl. - - size = sizeof(info); - junk = sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, NULL, 0); - - assert(junk == 0); - - // We're being debugged if the P_TRACED - // flag is set. - - result = ( (info.kp_proc.p_flag & P_TRACED) != 0 ); - return result; -#else return Sys_IsDebuggerPresent(); -#endif } @@ -3116,7 +3075,7 @@ void GLMSetIndent( int indent ) char sg_pPIXName[128]; -#ifndef OSX +#if !defined(OSX) && !defined(PLATFORM_HAIKU) ConVar gl_telemetry_gpu_pipeline_flushing( "gl_telemetry_gpu_pipeline_flushing", "0" ); class CGPUTimestampManager @@ -3724,7 +3683,7 @@ static uint g_nPIXEventIndex; void GLMBeginPIXEvent( const char *str ) { -#ifndef OSX +#if !defined(OSX) && !defined(PLATFORM_HAIKU) char szName[1024]; V_snprintf( szName, sizeof( szName ), "[ID:%u FR:%u] %s", g_nPIXEventIndex, g_GPUTimestampManager.GetCurFrame(), str ); const char *p = tmDynamicString( TELEMETRY_LEVEL2, szName ); //p can be null if tm is getting shut down @@ -3748,7 +3707,7 @@ void GLMBeginPIXEvent( const char *str ) void GLMEndPIXEvent( void ) { -#ifndef OSX +#if !defined(OSX) && !defined(PLATFORM_HAIKU) g_GPUTimestampManager.EndZone(); #endif diff --git a/togles/wscript b/togles/wscript index 0fedceaa..43ceb92d 100755 --- a/togles/wscript +++ b/togles/wscript @@ -39,6 +39,7 @@ def build(bld): includes = [ '.', + '../common', '../public', '../public/tier0', '../public/tier1' diff --git a/vgui2/src/system_posix.cpp b/vgui2/src/system_posix.cpp index 9473d416..f4cfb99d 100644 --- a/vgui2/src/system_posix.cpp +++ b/vgui2/src/system_posix.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include @@ -33,6 +32,8 @@ #include #elif defined(LINUX) #include +#elif defined(PLATFORM_HAIKU) +# include #endif #ifdef OSX #include @@ -292,7 +293,7 @@ void CSystem::ShellExecute(const char *command, const char *file) if ( pid == 0 ) { // Child -#if defined(LINUX) || defined(PLATFORM_BSD) +#if defined(POSIX) && !defined(OSX) // Escape steam runtime if necessary const char *szSteamRuntime = getenv( "STEAM_RUNTIME" ); if ( szSteamRuntime ) @@ -587,6 +588,10 @@ int CSystem::GetAvailableDrives(char *buf, int bufLen) //----------------------------------------------------------------------------- double CSystem::GetFreeDiskSpace(const char *path) { +#if PLATFORM_HAIKU + struct statvfs buf; + int ret = statvfs(path, &buf); +#else #if __DARWIN_ONLY_64_BIT_INO_T || PLATFORM_BSD // MoeMod: newer macOS only support 64bit, so no statfs64 is provided struct statfs buf; @@ -594,6 +599,7 @@ double CSystem::GetFreeDiskSpace(const char *path) #else struct statfs64 buf; int ret = statfs64( path, &buf ); +#endif #endif if ( ret < 0 ) return 0.0; diff --git a/vgui2/src/wscript b/vgui2/src/wscript index b4063e14..ae1edd35 100644 --- a/vgui2/src/wscript +++ b/vgui2/src/wscript @@ -53,7 +53,7 @@ def build(bld): '../../public', '../../public/tier0', '../../public/tier1', - '../../common' + '../../common', ] + bld.env.INCLUDES_SDL2 defines = [] diff --git a/vgui2/vgui_controls/wscript b/vgui2/vgui_controls/wscript index 68644dc0..e940e130 100644 --- a/vgui2/vgui_controls/wscript +++ b/vgui2/vgui_controls/wscript @@ -97,6 +97,7 @@ def build(bld): includes = [ '.', + '../../common', '../../public', '../../public/tier0', '../../public/tier1' diff --git a/vgui2/vgui_surfacelib/FontManager.cpp b/vgui2/vgui_surfacelib/FontManager.cpp index 870113aa..95b325ba 100644 --- a/vgui2/vgui_surfacelib/FontManager.cpp +++ b/vgui2/vgui_surfacelib/FontManager.cpp @@ -584,20 +584,20 @@ FallbackFont_t g_FallbackFonts[] = { NULL, "Monaco" } // every other font falls back to this }; -#elif defined(LINUX) || defined(PLATFORM_BSD) -static const char *g_szValidAsianFonts[] = { "Marlett", "WenQuanYi Zen Hei", "unifont", NULL }; - +#elif defined(_PS3) // list of how fonts fallback FallbackFont_t g_FallbackFonts[] = { - { "DejaVu Sans", NULL }, - { NULL, "DejaVu Sans" }, // every other font falls back to this + { NULL, "Tahoma" }, // every other font falls back to this }; -#elif defined(_PS3) +#elif defined(POSIX) +static const char *g_szValidAsianFonts[] = { "Marlett", "WenQuanYi Zen Hei", "unifont", NULL }; + // list of how fonts fallback FallbackFont_t g_FallbackFonts[] = { - { NULL, "Tahoma" }, // every other font falls back to this + { "DejaVu Sans", NULL }, + { NULL, "DejaVu Sans" }, // every other font falls back to this }; #else #error @@ -649,10 +649,10 @@ const char *CFontManager::GetForeignFallbackFontName() return "Tahoma"; #elif defined(OSX) return "Helvetica"; -#elif defined(LINUX) || defined(PLATFORM_BSD) - return "WenQuanYi Zen Hei"; #elif defined(_PS3) return "Tahoma"; +#elif defined(POSIX) + return "WenQuanYi Zen Hei"; #else #error #endif diff --git a/vgui2/vgui_surfacelib/wscript b/vgui2/vgui_surfacelib/wscript index c469a336..9916b28d 100644 --- a/vgui2/vgui_surfacelib/wscript +++ b/vgui2/vgui_surfacelib/wscript @@ -42,6 +42,8 @@ def build(bld): ] + bld.env.INCLUDES_FC + bld.env.INCLUDES_FT2 defines = [] + if bld.env.DEST_OS == 'haiku': + defines += ['HAVE_FC=0'] libs = [] diff --git a/vguimatsurface/FontTextureCache.cpp b/vguimatsurface/FontTextureCache.cpp index 7703be73..c0d62bfa 100644 --- a/vguimatsurface/FontTextureCache.cpp +++ b/vguimatsurface/FontTextureCache.cpp @@ -10,7 +10,7 @@ #include #elif defined( OSX ) #include -#elif defined( LINUX ) || defined(PLATFORM_BSD) +#elif defined(POSIX) //#error #elif defined( _X360 ) #else diff --git a/vguimatsurface/MatSystemSurface.cpp b/vguimatsurface/MatSystemSurface.cpp index 02f11001..800a0fb2 100644 --- a/vguimatsurface/MatSystemSurface.cpp +++ b/vguimatsurface/MatSystemSurface.cpp @@ -146,7 +146,7 @@ CMatSystemSurface g_MatSystemSurface; EXPOSE_SINGLE_INTERFACE_GLOBALVAR( CMatSystemSurface, ISurface, VGUI_SURFACE_INTERFACE_VERSION, g_MatSystemSurface ); -#if defined(LINUX) || defined(OSX) || defined(PLATFORM_BSD) +#if defined(POSIX) CUtlDict< CMatSystemSurface::font_entry, unsigned short > CMatSystemSurface::m_FontData; #endif @@ -407,7 +407,7 @@ InitReturnVal_t CMatSystemSurface::Init( void ) FontManager().SetLanguage( "english" ); } -#if defined(LINUX) || defined(OSX) || defined(PLATFORM_BSD) +#if defined(POSIX) FontManager().SetFontDataHelper( &CMatSystemSurface::FontDataHelper ); #endif @@ -1907,7 +1907,7 @@ bool CMatSystemSurface::AddCustomFontFile( const char *fontName, const char *fon } Assert( success ); return success; -#elif defined(LINUX) || defined(OSX) || defined(PLATFORM_BSD) +#elif defined(POSIX) int size; if ( CMatSystemSurface::FontDataHelper( fontName, size, fontFileName ) ) @@ -1921,7 +1921,7 @@ bool CMatSystemSurface::AddCustomFontFile( const char *fontName, const char *fon #endif } -#if defined(LINUX) || defined(OSX) || defined(PLATFORM_BSD) +#if defined(POSIX) static void RemoveSpaces( CUtlString &str ) { diff --git a/vguimatsurface/MatSystemSurface.h b/vguimatsurface/MatSystemSurface.h index bc46b1fd..f8f1bf41 100644 --- a/vguimatsurface/MatSystemSurface.h +++ b/vguimatsurface/MatSystemSurface.h @@ -556,7 +556,7 @@ private: int m_nFullscreenViewportHeight; ITexture *m_pFullscreenRenderTarget; -#if defined(LINUX) || defined(OSX) || defined(PLATFORM_BSD) +#if defined(POSIX) struct font_entry { void *data; diff --git a/video/videoservices.cpp b/video/videoservices.cpp index 58f1e8c6..e38bc78c 100644 --- a/video/videoservices.cpp +++ b/video/videoservices.cpp @@ -58,14 +58,14 @@ DEFINE_ENUM_BITWISE_OPERATORS( EPlatform_t ); const EPlatform_t thisPlatform = PLATFORM_XBOX_360; #elif defined( _PS3 ) const EPlatform_t thisPlatform = PLATFORM_PS3; -#elif defined ( _LINUX ) || defined(PLATFORM_BSD) +#elif defined(POSIX) const EPlatform_t thisPlatform = PLATFORM_LINUX; #else #error "UNABLE TO DETERMINE PLATFORM" #endif -#if defined( OSX ) || defined( LINUX ) || defined(PLATFORM_BSD) +#if defined(POSIX) ILauncherMgr *g_pLauncherMgr = NULL; #endif @@ -1382,7 +1382,7 @@ bool CVideoCommonServices::ProcessFullScreenInput( bool &bAbortEvent, bool &bPau bool bEscPressed = ( m_bScanEsc ) ? CGEventSourceKeyState( kCGEventSourceStateCombinedSessionState, kVK_Escape ) : false; bool bReturnPressed = ( m_bScanReturn ) ? CGEventSourceKeyState( kCGEventSourceStateCombinedSessionState, kVK_Return ) : false; bool bSpacePressed = ( m_bScanSpace ) ? CGEventSourceKeyState( kCGEventSourceStateCombinedSessionState, kVK_Space ) : false; -#elif defined(LINUX) || defined(PLATFORM_BSD) +#elif defined(POSIX) g_pLauncherMgr->PumpWindowsMessageLoop(); // Escape, return, or space stops or pauses the playback diff --git a/waf b/waf index b2f4c6f4..f754d112 100755 --- a/waf +++ b/waf @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # encoding: latin-1 # Thomas Nagy, 2005-2018 # diff --git a/wscript b/wscript index 84f00019..e36da8a7 100644 --- a/wscript +++ b/wscript @@ -1,4 +1,5 @@ #! /usr/bin/env python +# vim: noexpandtab # encoding: utf-8 # nillerusr @@ -221,14 +222,30 @@ def define_platform(conf): '_DLL_EXT=.dylib' ]) - elif conf.env.DEST_OS in ['freebsd', 'openbsd', 'netbsd', 'dragonflybsd']: # Tested only in freebsd + elif conf.env.DEST_OS in ['freebsd', 'openbsd', 'netbsd']: # Tested only in freebsd + if conf.env.DEST_OS == 'freebsd': + conf.env.append_unique('DEFINES', ['PLATFORM_FBSD=1']) conf.env.append_unique('DEFINES', [ 'POSIX=1', '_POSIX=1', 'PLATFORM_POSIX=1', 'GNUC', # but uses clang + 'NO_HOOK_MALLOC', 'PLATFORM_BSD=1', '_DLL_EXT=.so' ]) + elif conf.env.DEST_OS == 'haiku': + conf.check_cc(lib='iconv') + conf.check_cc(lib='gnu') + conf.check_cc(lib='network') + conf.env.append_unique('DEFINES', [ + 'POSIX=1', '_POSIX=1', 'PLATFORM_POSIX=1', + 'GNUC', + 'NO_HOOK_MALLOC', + '_GNU_SOURCE', + 'PLATFORM_HAIKU=1', + '_DLL_EXT=.so' + ]) + if conf.options.DEBUG_ENGINE: conf.env.append_unique('DEFINES', [ 'DEBUG', '_DEBUG' @@ -378,9 +395,6 @@ def configure(conf): elif conf.env.DEST_CPU in ['arm', 'aarch64']: flags += ['-fsigned-char', '-mfpu=neon-vfpv4'] - if conf.env.DEST_OS == 'freebsd': - linkflags += ['-lexecinfo'] - if conf.env.DEST_OS != 'win32': cflags += flags linkflags += flags @@ -454,7 +468,6 @@ def configure(conf): 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/')]) if conf.env.DEST_OS != 'android': if conf.env.DEST_OS != 'win32': @@ -490,7 +503,7 @@ def configure(conf): conf.check(lib='android_support', uselib_store='ANDROID_SUPPORT') conf.check(lib='opus', uselib_store='OPUS') - if conf.env.DEST_OS == "darwin": + if conf.env.DEST_OS == 'darwin': conf.check(lib='iconv', uselib_store='ICONV') conf.env.FRAMEWORK_APPKIT = "AppKit" conf.env.FRAMEWORK_IOKIT = "IOKit" @@ -557,7 +570,9 @@ def configure(conf): # indicate if we are packaging for Linux/BSD if conf.env.DEST_OS != 'android': - conf.env.LIBDIR = conf.env.PREFIX+'/bin/' + if conf.env.DEST_OS in ['haiku']: + conf.env.LIBDIR = conf.env.PREFIX+'/lib/' + else: conf.env.LIBDIR = conf.env.PREFIX+'/bin/' conf.env.TESTDIR = conf.env.PREFIX+'/tests/' conf.env.BINDIR = conf.env.PREFIX else: @@ -595,3 +610,4 @@ def build(bld): projects['game'] += ['togl'] bld.add_subproject(projects['game']) +