Skip to content

Haiku: Add support #193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion appframework/posixapp.cpp
Original file line number Diff line number Diff line change
@@ -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;
}

4 changes: 2 additions & 2 deletions appframework/sdlmgr.cpp
Original file line number Diff line number Diff line change
@@ -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

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

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

#ifdef ANDROID
#include <sys/cdefs.h>
#elif defined(OSX) || defined(PLATFORM_BSD)
#include <stdint.h>
#else
#include <bits/wordsize.h>
#endif
2 changes: 1 addition & 1 deletion common/vgui_surfacelib/FontManager.h
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
#endif

#include <vgui/VGUI.h>
#include "vgui_surfacelib/FontAmalgam.h"
#include "common/vgui_surfacelib/FontAmalgam.h"
#include "materialsystem/imaterialsystem.h"
#include "filesystem.h"
#include "vguifont.h"
18 changes: 10 additions & 8 deletions engine/bugreporter.cpp
Original file line number Diff line number Diff line change
@@ -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>
@@ -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 )
16 changes: 9 additions & 7 deletions engine/sv_main.cpp
Original file line number Diff line number Diff line change
@@ -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
15 changes: 11 additions & 4 deletions engine/sys_dll.cpp
Original file line number Diff line number Diff line change
@@ -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>
@@ -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
}
6 changes: 2 additions & 4 deletions engine/sys_mainwind.cpp
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion engine/wscript
Original file line number Diff line number Diff line change
@@ -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(
2 changes: 1 addition & 1 deletion gameui/BasePanel.cpp
Original file line number Diff line number Diff line change
@@ -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 )
{
2 changes: 1 addition & 1 deletion gameui/VGuiSystemModuleLoader.cpp
Original file line number Diff line number Diff line change
@@ -161,7 +161,7 @@ bool CVGuiSystemModuleLoader::LoadPlatformModules(CreateInterfaceFn *factorylist
{
dllPath = it->GetString("dll_osx");
}
else if ( IsLinux() || IsBSD() )
else if ( IsPosix() )
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is better to just use ifdefs?

{
dllPath = it->GetString("dll_linux");
}
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
@@ -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 )
{
2 changes: 2 additions & 0 deletions launcher_main/main.cpp
Original file line number Diff line number Diff line change
@@ -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 )
1 change: 1 addition & 0 deletions materialsystem/stdshaders/wscript
Original file line number Diff line number Diff line change
@@ -141,6 +141,7 @@ def build(bld):

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

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

#elif defined(PLATFORM_HAIKU)
// Already defined

#else // _WIN32

typedef short int16;
Loading