Skip to content

Commit

Permalink
Haiku: Add support
Browse files Browse the repository at this point in the history
  • Loading branch information
er2off committed Feb 9, 2023
1 parent 746aa8b commit 2305298
Show file tree
Hide file tree
Showing 59 changed files with 213 additions and 164 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion appframework/posixapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions appframework/sdlmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ class CSDLMgr : public ILauncherMgr

// 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

Expand Down Expand Up @@ -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 )
{
Expand Down
1 change: 1 addition & 0 deletions appframework/wscript
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def build(bld):

includes = [
'.',
'../common',
'../public',
'../public/tier0',
'../public/tier1'
Expand Down
9 changes: 9 additions & 0 deletions common/freetype/config/ftconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@

#ifdef ANDROID
#include <sys/cdefs.h>
#elif defined(PLATFORM_HAIKU)
#include <BeBuild.h>
# 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 <stdint.h>
#else
Expand Down
18 changes: 10 additions & 8 deletions engine/bugreporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# include <sys/types.h>
# include <fcntl.h>
# define HW_MEMSIZE HW_PHYSMEM
#elif defined(LINUX)
#elif defined(LINUX) || defined(PLATFORM_HAIKU)
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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 )
Expand Down
16 changes: 9 additions & 7 deletions engine/sv_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 11 additions & 4 deletions engine/sys_dll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include <sys/types.h>
#include <sys/sysctl.h>
#define HW_MEMSIZE HW_PHYSMEM
#elif defined(PLATFORM_HAIKU)
# include <OS.h>
#endif
#if defined(LINUX)
#include <unistd.h>
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
6 changes: 2 additions & 4 deletions engine/sys_mainwind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion engine/wscript
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion gameui/BasePanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand Down
2 changes: 1 addition & 1 deletion gameui/VGuiSystemModuleLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
2 changes: 1 addition & 1 deletion ivp
8 changes: 4 additions & 4 deletions launcher/launcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ bool GrabSourceMutex()

#ifdef ANDROID
return true;
#elif defined (LINUX) || defined(PLATFORM_BSD)
#elif defined (POSIX) && !defined(OSX)
/*
* Linux
*/
Expand Down Expand Up @@ -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).
Expand All @@ -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

Expand Down Expand Up @@ -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 )
{
Expand Down
2 changes: 2 additions & 0 deletions launcher_main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 )
Expand Down
1 change: 1 addition & 0 deletions materialsystem/stdshaders/wscript
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ def build(bld):

includes = [
'.',
'../../common',
'../../public',
'../../public/tier0',
'../../public/tier1',
Expand Down
2 changes: 1 addition & 1 deletion mathlib/3dnow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion mathlib/mathlib_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion public/XUnzip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion public/appframework/AppFramework.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) \
{ \
Expand Down
2 changes: 1 addition & 1 deletion public/appframework/ilaunchermgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class ILauncherMgr : public IAppSystem

// 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

Expand Down
4 changes: 4 additions & 0 deletions public/filesystem_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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...
Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions public/steam/steamtypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ typedef __int32 intp;
typedef unsigned __int32 uintp;
#endif

#elif defined(PLATFORM_HAIKU)
// Already defined

#else // _WIN32

typedef short int16;
Expand Down
Loading

0 comments on commit 2305298

Please sign in to comment.