Skip to content

Commit 2305298

Browse files
committed
Haiku: Add support
1 parent 746aa8b commit 2305298

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+213
-164
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Source code is based on TF2 2018 leak. Don't use it for commercial purposes.
1515
This project is using waf buildsystem. If you have waf-related questions look https://waf.io/book
1616

1717
# Features:
18-
- Android, OSX, FreeBSD, Windows support
18+
- Android, OSX, Windows, FreeBSD, Haiku support
1919
- Arm support( except windows )
2020
- 64bit support
2121
- Modern toolchains support

appframework/posixapp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ bool CSteamApplication::Create( )
118118
m_pFileSystem = (IFileSystem*)AddSystem( fileSystemModule, FILESYSTEM_INTERFACE_VERSION );
119119
if ( !m_pFileSystem )
120120
{
121-
Error( "Unable to load %s", pFileSystemDLL );
121+
Error( "Unable to load %s\n", pFileSystemDLL );
122122
return false;
123123
}
124124

appframework/sdlmgr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ class CSDLMgr : public ILauncherMgr
270270

271271
// Get the next N events. The function returns the number of events that were filled into your array.
272272
virtual int GetEvents( CCocoaEvent *pEvents, int nMaxEventsToReturn, bool debugEvents = false );
273-
#if defined(LINUX) || defined(PLATFORM_BSD)
273+
#if defined(POSIX) && !defined(OSX)
274274
virtual int PeekAndRemoveKeyboardEvents( bool *pbEsc, bool *pbReturn, bool *pbSpace, bool debugEvent = false );
275275
#endif
276276

@@ -1004,7 +1004,7 @@ int CSDLMgr::GetEvents( CCocoaEvent *pEvents, int nMaxEventsToReturn, bool debug
10041004
return nToWrite;
10051005
}
10061006

1007-
#if defined(LINUX) || defined(PLATFORM_BSD)
1007+
#if defined(POSIX) && !defined(OSX)
10081008

10091009
int CSDLMgr::PeekAndRemoveKeyboardEvents( bool *pbEsc, bool *pbReturn, bool *pbSpace, bool debugEvent )
10101010
{

appframework/wscript

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def build(bld):
4242

4343
includes = [
4444
'.',
45+
'../common',
4546
'../public',
4647
'../public/tier0',
4748
'../public/tier1'

common/freetype/config/ftconfig.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@
33

44
#ifdef ANDROID
55
#include <sys/cdefs.h>
6+
#elif defined(PLATFORM_HAIKU)
7+
#include <BeBuild.h>
8+
# if B_HAIKU_64_BIT
9+
# define __WORDSIZE 64
10+
# elif B_HAIKU_32_BIT
11+
# define __WORDSIZE 32
12+
# else
13+
# error "Unknown Haiku bit size"
14+
# endif
615
#elif defined(OSX) || defined(PLATFORM_BSD)
716
#include <stdint.h>
817
#else

engine/bugreporter.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
# include <sys/types.h>
2626
# include <fcntl.h>
2727
# define HW_MEMSIZE HW_PHYSMEM
28-
#elif defined(LINUX)
28+
#elif defined(LINUX) || defined(PLATFORM_HAIKU)
2929
#include <sys/types.h>
3030
#include <sys/stat.h>
3131
#include <fcntl.h>
@@ -110,7 +110,7 @@
110110
#define BUG_REPOSITORY_URL "\\\\fileserver\\bugs"
111111
#elif defined(OSX)
112112
#define BUG_REPOSITORY_URL "/Volumes/bugs"
113-
#elif defined(LINUX) || defined(PLATFORM_BSD)
113+
#elif defined(POSIX)
114114
#define BUG_REPOSITORY_URL "\\\\fileserver\\bugs"
115115
#else
116116
//#error
@@ -345,12 +345,14 @@ void DisplaySystemVersion( char *osversion, int maxlen )
345345

346346
fclose( fpKernelVer );
347347
}
348+
#elif PLATFORM_HAIKU
349+
osversion = (char *)"Haiku OS";
348350
#elif PLATFORM_BSD
349-
#ifdef __FreeBSD__
350-
osversion = (char *)"FreeBSD";
351-
#else
352-
osversion = (char *)"*BSD";
353-
#endif
351+
# ifdef PLATFORM_FBSD
352+
osversion = (char *)"FreeBSD";
353+
# else
354+
osversion = (char *)"*BSD";
355+
# endif
354356
#endif
355357
}
356358

@@ -2257,7 +2259,7 @@ void NonFileSystem_CreatePath (const char *path)
22572259
}
22582260
}
22592261

2260-
#if defined(LINUX) || defined(PLATFORM_BSD)
2262+
#if defined(POSIX) && !defined(OSX)
22612263
#define COPYFILE_ALL 0
22622264
#define BSIZE 65535
22632265
int copyfile( const char *local, const char *remote, void *ignored, int ignoredFlags )

engine/sv_main.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2714,14 +2714,16 @@ bool CGameServer::SpawnServer( const char *szMapName, const char *szMapFile, con
27142714
event->SetString( "os", "LINUX" );
27152715
#elif defined ( OSX )
27162716
event->SetString( "os", "OSX" );
2717+
#elif defined(PLATFORM_HAIKU)
2718+
event->SetString( "os", "Haiku" );
27172719
#elif defined(PLATFORM_BSD)
2718-
event->SetString("os",
2719-
# ifdef __FreeBSD__
2720-
"FreeBSD"
2721-
# else
2722-
"BSD"
2723-
# endif
2724-
);
2720+
event->SetString("os",
2721+
# ifdef PLATFORM_FBSD
2722+
"FreeBSD"
2723+
# else
2724+
"BSD"
2725+
# endif
2726+
);
27252727
#else
27262728
#error
27272729
#endif

engine/sys_dll.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include <sys/types.h>
1717
#include <sys/sysctl.h>
1818
#define HW_MEMSIZE HW_PHYSMEM
19+
#elif defined(PLATFORM_HAIKU)
20+
# include <OS.h>
1921
#endif
2022
#if defined(LINUX)
2123
#include <unistd.h>
@@ -464,7 +466,7 @@ void Sys_Error_Internal( bool bMinidump, const char *error, va_list argsList )
464466
// Doing this doesn't quite work the way we want because there is no "crashing" thread
465467
// 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
466468
//SteamAPI_WriteMiniDump( 0, NULL, build_number() );
467-
printf("\n ##### Sys_Error: %s", text );
469+
printf("\n ##### Sys_Error: %s\n", text );
468470
fflush(stdout );
469471

470472
raise(SIGTRAP);
@@ -677,6 +679,11 @@ void Sys_InitMemory( void )
677679
{
678680
memsize = ONE_HUNDRED_TWENTY_EIGHT_MB;
679681
}
682+
#elif defined(PLATFORM_HAIKU)
683+
system_info info;
684+
get_system_info(&info);
685+
686+
memsize = (uint64_t)(info.max_pages * B_PAGE_SIZE);
680687
#elif defined(LINUX)
681688
const int fd = open("/proc/meminfo", O_RDONLY);
682689
if (fd < 0)
@@ -1586,14 +1593,14 @@ CON_COMMAND( star_memory, "Dump memory stats" )
15861593
struct mstats memstats = mstats( );
15871594
Msg( "Available %.2f MB, Used: %.2f MB, #mallocs = %lu\n",
15881595
memstats.bytes_free / ( 1024.0 * 1024.0), memstats.bytes_used / ( 1024.0 * 1024.0 ), memstats.chunks_used );
1589-
#elif PLATFORM_BSD
1590-
# warning TODO: Implement memory stats (peace of sheet of course)
1591-
#else // Win32
1596+
#elif _WIN32
15921597
MEMORYSTATUS stat;
15931598
GlobalMemoryStatus( &stat );
15941599
Msg( "Available: %.2f MB, Used: %.2f MB, Free: %.2f MB\n",
15951600
stat.dwTotalPhys/( 1024.0f*1024.0f ) - 32.0f,
15961601
( stat.dwTotalPhys - stat.dwAvailPhys )/( 1024.0f*1024.0f ) - 32.0f,
15971602
stat.dwAvailPhys/( 1024.0f*1024.0f ) );
1603+
#else
1604+
# warning TODO: Implement memory stats (peace of sheet of course)
15981605
#endif
15991606
}

engine/sys_mainwind.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@
2525
#elif defined(_X360)
2626
// nothing to include for 360
2727
#elif defined(OSX)
28-
#elif defined(LINUX) || defined(PLATFORM_BSD)
29-
#include "tier0/dynfunction.h"
30-
#elif defined(_WIN32)
28+
#elif defined(POSIX) || defined(_WIN32)
3129
#include "tier0/dynfunction.h"
3230
#else
3331
#error
@@ -833,7 +831,7 @@ LRESULT CGame::WindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
833831
// return 0 if handled message, 1 if not
834832
return lRet;
835833
}
836-
#elif defined(OSX) || defined(LINUX) || defined(_WIN32) || defined(PLATFORM_BSD)
834+
#elif defined(POSIX) || defined(_WIN32)
837835

838836
#else
839837
#error

engine/wscript

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,9 @@ def build(bld):
365365
libs += ['USER32', 'WINMM', 'WININET', 'DSOUND', 'DXGUID', 'GDI32', 'bzip2']
366366
elif bld.env.DEST_OS == 'darwin' and not bld.env.DEDICATED:
367367
libs += ['APPKIT', 'COREAUDIO', 'AUDIOTOOLBOX', 'SYSTEMCONFIGURATION']
368-
368+
elif bld.env.DEST_OS == 'haiku':
369+
libs += ['NETWORK']
370+
369371
install_path = bld.env.LIBDIR
370372

371373
bld.shlib(

0 commit comments

Comments
 (0)