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

+1-1
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

+1-1
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

+2-2
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

+1
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

+9
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

+10-8
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

+9-7
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

+11-4
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

+2-4
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

+3-1
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(

gameui/BasePanel.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2223,7 +2223,7 @@ void CBasePanel::RunMenuCommand(const char *command)
22232223

22242224
RegCloseKey(hKey);
22252225
}
2226-
#elif defined( OSX ) || defined( LINUX ) || defined(PLATFORM_BSD)
2226+
#elif defined( POSIX )
22272227
FILE *fp = fopen( "/tmp/hl2_relaunch", "w+" );
22282228
if ( fp )
22292229
{

gameui/VGuiSystemModuleLoader.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ bool CVGuiSystemModuleLoader::LoadPlatformModules(CreateInterfaceFn *factorylist
161161
{
162162
dllPath = it->GetString("dll_osx");
163163
}
164-
else if ( IsLinux() || IsBSD() )
164+
else if ( IsPosix() )
165165
{
166166
dllPath = it->GetString("dll_linux");
167167
}

launcher/launcher.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -950,7 +950,7 @@ bool GrabSourceMutex()
950950

951951
#ifdef ANDROID
952952
return true;
953-
#elif defined (LINUX) || defined(PLATFORM_BSD)
953+
#elif defined (POSIX) && !defined(OSX)
954954
/*
955955
* Linux
956956
*/
@@ -1198,7 +1198,7 @@ DLL_EXPORT int LauncherMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR
11981198
DLL_EXPORT int LauncherMain( int argc, char **argv )
11991199
#endif
12001200
{
1201-
#if (defined(LINUX) || defined(PLATFORM_BSD)) && !defined ANDROID
1201+
#if (defined(POSIX)) && !defined ANDROID
12021202
// Temporary fix to stop us from crashing in printf/sscanf functions that don't expect
12031203
// localization to mess with your "." and "," float seperators. Mac OSX also sets LANG
12041204
// 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 )
12251225
Msg("SDL version: %d.%d.%d rev: %s\n", (int)ver.major, (int)ver.minor, (int)ver.patch, SDL_GetRevision());
12261226
#endif
12271227

1228-
#if (defined LINUX || defined PLATFORM_BSD) && defined USE_SDL && defined TOGLES && !defined ANDROID
1228+
#if defined POSIX && defined USE_SDL && defined TOGLES && !defined ANDROID
12291229
SDL_SetHint(SDL_HINT_VIDEO_X11_FORCE_EGL, "1");
12301230
#endif
12311231

@@ -1553,7 +1553,7 @@ DLL_EXPORT int LauncherMain( int argc, char **argv )
15531553
RegCloseKey(hKey);
15541554
}
15551555

1556-
#elif defined( OSX ) || defined( LINUX ) || defined(PLATFORM_BSD)
1556+
#elif defined( POSIX )
15571557
struct stat st;
15581558
if ( stat( RELAUNCH_FILE, &st ) == 0 )
15591559
{

launcher_main/main.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ static void WaitForDebuggerConnect( int argc, char *argv[], int time )
216216

217217
int main( int argc, char *argv[] )
218218
{
219+
#ifndef PLATFORM_HAIKU
219220
char ld_path[4196];
220221
char *path = "bin/";
221222
char *ld_env;
@@ -234,6 +235,7 @@ int main( int argc, char *argv[] )
234235
setenv("NO_EXECVE_AGAIN", "1", 1);
235236
execve(argv[0], argv, environ);
236237
}
238+
#endif
237239

238240
void *launcher = dlopen( "bin/liblauncher" DLL_EXT_STRING, RTLD_NOW );
239241
if ( !launcher )

materialsystem/stdshaders/wscript

+1
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ def build(bld):
141141

142142
includes = [
143143
'.',
144+
'../../common',
144145
'../../public',
145146
'../../public/tier0',
146147
'../../public/tier1',

mathlib/3dnow.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
// memdbgon must be the last include file in a .cpp file!!!
1717
#include "tier0/memdbgon.h"
1818

19-
#if !defined(COMPILER_MSVC64) && !defined(LINUX) && !defined(COMPILER_CLANG)
19+
#if !defined(COMPILER_MSVC64) && !defined(POSIX) && !defined(COMPILER_CLANG)
2020
// Implement for 64-bit Windows if needed.
2121
// Clang hits "fatal error: error in backend:" and other errors when trying
2222
// to compile the inline assembly below. 3DNow support is highly unlikely to

mathlib/mathlib_base.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3343,7 +3343,7 @@ void MathLib_Init( float gamma, float texGamma, float brightness, int overbright
33433343

33443344
// SSE Generally performs better than 3DNow when present, so this is placed
33453345
// first to allow SSE to override these settings.
3346-
#if !defined( OSX ) && !defined( PLATFORM_WINDOWS_PC64 ) && !defined(LINUX) && !defined(PLATFORM_BSD)
3346+
#if !defined( OSX ) && !defined( PLATFORM_WINDOWS_PC64 ) && !defined(POSIX)
33473347
if ( bAllow3DNow && pi.m_b3DNow )
33483348
{
33493349
s_b3DNowEnabled = true;

public/XUnzip.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -4243,7 +4243,7 @@ ZRESULT TUnzip::Unzip(int index,void *dst,unsigned int len,DWORD flags)
42434243
{
42444244
#ifdef _WIN32
42454245
SetFileTime(h,&ze.ctime,&ze.atime,&ze.mtime);
4246-
#elif defined( ANDROID )
4246+
#elif defined( ANDROID ) || defined(PLATFORM_HAIKU)
42474247
struct timespec ts[2];
42484248
ts[0].tv_sec = ze.atime;
42494249
ts[0].tv_nsec = 0;

public/appframework/AppFramework.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ void AppShutdown( CAppSystemGroup *pAppSystemGroup );
6161
extern int ValveCocoaMain( int argc, char **argv, CAppSystemGroup *pAppSystemGroup ); \
6262
return ValveCocoaMain( argc, argv, &_globalVarName ); \
6363
}
64-
#elif defined( LINUX ) || defined(PLATFORM_BSD)
64+
#elif defined(POSIX)
6565
#define DEFINE_WINDOWED_APPLICATION_OBJECT_GLOBALVAR( _globalVarName ) \
6666
int main( int argc, char **argv ) \
6767
{ \

public/appframework/ilaunchermgr.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class ILauncherMgr : public IAppSystem
5252

5353
// Get the next N events. The function returns the number of events that were filled into your array.
5454
virtual int GetEvents( CCocoaEvent *pEvents, int nMaxEventsToReturn, bool debugEvents = false ) = 0;
55-
#if defined(LINUX) || defined(PLATFORM_BSD)
55+
#if defined(POSIX) && !defined(OSX)
5656
virtual int PeekAndRemoveKeyboardEvents( bool *pbEsc, bool *pbReturn, bool *pbSpace, bool debugEvents = false ) = 0;
5757
#endif
5858

public/filesystem_init.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,11 @@ bool FileSystem_GetExecutableDir( char *exedir, int exeDirLen )
344344

345345
Q_FixSlashes( exedir );
346346

347+
#ifdef PLATFORM_HAIKU
348+
const char* libDir = "lib";
349+
#else
347350
const char* libDir = "bin";
351+
#endif
348352

349353
// Return the bin directory as the executable dir if it's not in there
350354
// because that's really where we're running from...
File renamed without changes.

public/steam/steamtypes.h

+3
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ typedef __int32 intp;
5656
typedef unsigned __int32 uintp;
5757
#endif
5858

59+
#elif defined(PLATFORM_HAIKU)
60+
// Already defined
61+
5962
#else // _WIN32
6063

6164
typedef short int16;

0 commit comments

Comments
 (0)