Files
haikuports/games-strategy/0ad/patches/0ad-0.0.23-alpha.patch
BenjaminAmos 32e9dd25b4 0AD: new recipe (#1852)
disabled for now. some unresolved issues in the PR still stand.
2019-11-15 21:58:41 +01:00

1336 lines
53 KiB
Diff

diff -urdN -E -b -w -B --strip-trailing-cr original/0ad-0.0.23-alpha/build/premake/extern_libs4.lua 0ad-0.0.23-alpha/build/premake/extern_libs4.lua
--- original/0ad-0.0.23-alpha/build/premake/extern_libs4.lua 2018-04-08 21:41:31.011534336 +0000
+++ 0ad-0.0.23-alpha/build/premake/extern_libs4.lua 2019-06-05 09:51:34.060030976 +0000
@@ -347,7 +347,7 @@
elseif os.is("macosx") then
add_default_include_paths("iconv")
defines { "LIBICONV_STATIC" }
- elseif os.getversion().description == "FreeBSD" then
+ elseif os.getversion().description == "FreeBSD" or os.is("haiku") then
defines { "HAVE_ICONV_CONST" }
defines { "ICONV_CONST=const" }
end
@@ -359,6 +359,7 @@
add_default_links({
win_names = { "libiconv" },
osx_names = { "iconv" },
+ unix_names = { "iconv" },
dbg_suffix = "",
no_delayload = 1,
})
@@ -722,14 +723,14 @@
link_settings = function()
add_default_links({
win_names = { },
- unix_names = { "X11" },
+-- unix_names = { "X11" },
})
end,
},
xcursor = {
link_settings = function()
add_default_links({
- unix_names = { "Xcursor" },
+-- unix_names = { "Xcursor" },
})
end,
},
diff -urdN -E -b -w -B --strip-trailing-cr original/0ad-0.0.23-alpha/build/premake/extern_libs5.lua 0ad-0.0.23-alpha/build/premake/extern_libs5.lua
--- original/0ad-0.0.23-alpha/build/premake/extern_libs5.lua 2018-04-29 15:44:48.011272192 +0000
+++ 0ad-0.0.23-alpha/build/premake/extern_libs5.lua 2019-06-07 17:12:40.761528320 +0000
@@ -313,6 +313,7 @@
add_default_links({
win_names = { "libiconv" },
osx_names = { "iconv" },
+ unix_names = { "iconv" },
dbg_suffix = "",
no_delayload = 1,
})
@@ -685,17 +686,21 @@
},
x11 = {
link_settings = function()
+ if not os.istarget("haiku") then
add_default_links({
win_names = { },
unix_names = { "X11" },
})
+ end
end,
},
xcursor = {
link_settings = function()
+ if not os.istarget("haiku") then
add_default_links({
unix_names = { "Xcursor" },
})
+ end
end,
},
zlib = {
diff -urdN -E -b -w -B --strip-trailing-cr original/0ad-0.0.23-alpha/build/premake/premake4.lua 0ad-0.0.23-alpha/build/premake/premake4.lua
--- original/0ad-0.0.23-alpha/build/premake/premake4.lua 2018-04-29 15:44:48.052428800 +0000
+++ 0ad-0.0.23-alpha/build/premake/premake4.lua 2019-06-05 11:28:48.069730304 +0000
@@ -382,7 +382,7 @@
-- add X11 includes paths after all the others so they don't conflict with
-- bundled libs
function project_add_x11_dirs()
- if not os.is("windows") and not os.is("macosx") then
+ if not os.is("windows") and not os.is("macosx") and not os.is("haiku") then
-- X11 includes may be installed in one of a gadzillion of five places
-- Famous last words: "You can't include too much! ;-)"
includedirs {
@@ -835,6 +835,7 @@
windows = { "lib/sysdep/os/win", "lib/sysdep/os/win/wposix", "lib/sysdep/os/win/whrt" },
macosx = { "lib/sysdep/os/osx", "lib/sysdep/os/unix" },
bsd = { "lib/sysdep/os/bsd", "lib/sysdep/os/unix", "lib/sysdep/os/unix/x" },
+ haiku = { "lib/sysdep/os/haiku", "lib/sysdep/os/unix" }
}
for i,v in pairs(sysdep_dirs[os.get()]) do
table.insert(source_dirs, v);
@@ -1022,6 +1023,13 @@
linkoptions { "-framework ApplicationServices", "-framework Cocoa", "-framework CoreFoundation" }
end
+
+ if os.is("haiku") then
+ linkoptions {
+ links { "be" }
+ "/boot/system/lib/libnetwork.so"
+ }
+ end
end
@@ -1458,6 +1465,13 @@
includedirs { source_root .. "pch/test/" }
end
+
+ if os.is("haiku") then
+ linkoptions {
+ links { "be" }
+ "/boot/system/lib/libnetwork.so"
+ }
+ end
end
-- must come first, so that VC sets it as the default project and therefore
diff -urdN -E -b -w -B --strip-trailing-cr original/0ad-0.0.23-alpha/build/premake/premake5/build/gmake.unix/Premake5.make 0ad-0.0.23-alpha/build/premake/premake5/build/gmake.unix/Premake5.make
--- original/0ad-0.0.23-alpha/build/premake/premake5/build/gmake.unix/Premake5.make 2017-10-28 16:10:49.040370176 +0000
+++ 0ad-0.0.23-alpha/build/premake/premake5/build/gmake.unix/Premake5.make 2019-01-10 17:32:02.104857600 +0000
@@ -22,9 +22,9 @@
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -O3 -Wall -Wextra
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -O3 -Wall -Wextra -fno-stack-protector
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
- LIBS += bin/Release/liblua-lib.a bin/Release/libzip-lib.a bin/Release/libzlib-lib.a bin/Release/libcurl-lib.a bin/Release/libmbedtls-lib.a -lm -ldl -lrt
+ LIBS += bin/Release/liblua-lib.a bin/Release/libzip-lib.a bin/Release/libzlib-lib.a bin/Release/libcurl-lib.a bin/Release/libmbedtls-lib.a -lm -lnetwork -lbsd
LDDEPS += bin/Release/liblua-lib.a bin/Release/libzip-lib.a bin/Release/libzlib-lib.a bin/Release/libcurl-lib.a bin/Release/libmbedtls-lib.a
- ALL_LDFLAGS += $(LDFLAGS) -s -rdynamic
+ ALL_LDFLAGS += $(LDFLAGS) -s
LINKCMD = $(CC) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
define PREBUILDCMDS
endef
@@ -49,9 +49,9 @@
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -g -Wall -Wextra
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -g -Wall -Wextra
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
- LIBS += bin/Debug/liblua-lib.a bin/Debug/libzip-lib.a bin/Debug/libzlib-lib.a bin/Debug/libcurl-lib.a bin/Debug/libmbedtls-lib.a -lm -ldl -lrt
+ LIBS += bin/Debug/liblua-lib.a bin/Debug/libzip-lib.a bin/Debug/libzlib-lib.a bin/Debug/libcurl-lib.a bin/Debug/libmbedtls-lib.a -lm -lnetwork
LDDEPS += bin/Debug/liblua-lib.a bin/Debug/libzip-lib.a bin/Debug/libzlib-lib.a bin/Debug/libcurl-lib.a bin/Debug/libmbedtls-lib.a
- ALL_LDFLAGS += $(LDFLAGS) -rdynamic
+ ALL_LDFLAGS += $(LDFLAGS)
LINKCMD = $(CC) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
define PREBUILDCMDS
endef
diff -urdN -E -b -w -B --strip-trailing-cr original/0ad-0.0.23-alpha/build/premake/premake5/contrib/curl/lib/curl_setup.h 0ad-0.0.23-alpha/build/premake/premake5/contrib/curl/lib/curl_setup.h
--- original/0ad-0.0.23-alpha/build/premake/premake5/contrib/curl/lib/curl_setup.h 2017-10-28 16:10:49.057147392 +0000
+++ 0ad-0.0.23-alpha/build/premake/premake5/contrib/curl/lib/curl_setup.h 2019-01-10 17:03:25.658243584 +0000
@@ -86,6 +86,10 @@
# include "config-linux.h"
#endif
+#ifdef __HAIKU__
+# include "config-linux.h"
+#endif
+
#ifdef __APPLE__ && __MACH__
# include "config-osx.h"
#endif
diff -urdN -E -b -w -B --strip-trailing-cr original/0ad-0.0.23-alpha/build/premake/premake5/contrib/curl/lib/if2ip.c 0ad-0.0.23-alpha/build/premake/premake5/contrib/curl/lib/if2ip.c
--- original/0ad-0.0.23-alpha/build/premake/premake5/contrib/curl/lib/if2ip.c 2017-10-28 16:10:49.063963136 +0000
+++ 0ad-0.0.23-alpha/build/premake/premake5/contrib/curl/lib/if2ip.c 2019-01-10 17:07:04.829423616 +0000
@@ -40,6 +40,9 @@
#ifdef HAVE_SYS_SOCKIO_H
# include <sys/sockio.h>
#endif
+#ifdef __HAIKU__
+# include <sys/sockio.h>
+#endif
#ifdef HAVE_IFADDRS_H
# include <ifaddrs.h>
#endif
diff -urdN -E -b -w -B --strip-trailing-cr original/0ad-0.0.23-alpha/build/premake/premake5/contrib/curl/premake5.lua 0ad-0.0.23-alpha/build/premake/premake5/contrib/curl/premake5.lua
--- original/0ad-0.0.23-alpha/build/premake/premake5/contrib/curl/premake5.lua 2017-10-28 16:10:49.031457280 +0000
+++ 0ad-0.0.23-alpha/build/premake/premake5/contrib/curl/premake5.lua 2019-01-10 16:47:35.566493184 +0000
@@ -27,7 +27,7 @@
defines { "USE_MBEDTLS" }
filter { "system:linux or bsd" }
- defines { "CURL_HIDDEN_SYMBOLS" }
+ defines { "CURL_HIDDEN_SYMBOLS", "_BSD_SOURCE" }
-- find the location of the ca bundle
local ca = nil
diff -urdN -E -b -w -B --strip-trailing-cr original/0ad-0.0.23-alpha/build/premake/premake5/premake5.lua 0ad-0.0.23-alpha/build/premake/premake5/premake5.lua
--- original/0ad-0.0.23-alpha/build/premake/premake5/premake5.lua 2017-10-28 16:10:49.048496640 +0000
+++ 0ad-0.0.23-alpha/build/premake/premake5/premake5.lua 2019-06-07 15:26:48.134217728 +0000
@@ -164,12 +164,12 @@
filter "system:windows"
links { "ole32", "ws2_32", "advapi32" }
- filter "system:linux or bsd or hurd"
+ filter "system:linux or bsd or hurd or haiku"
defines { "LUA_USE_POSIX", "LUA_USE_DLOPEN" }
- links { "m" }
- linkoptions { "-rdynamic" }
+ links { "m", "dl", "network" }
+ linkoptions { "-Wl,--export-all-symbols" }
- filter "system:linux or hurd"
+ filter { "system:linux or hurd", "system:not bsd" }
links { "dl", "rt" }
filter { "system:not windows", "system:not macosx" }
diff -urdN -E -b -w -B --strip-trailing-cr original/0ad-0.0.23-alpha/build/premake/premake5/src/host/os_getversion.c 0ad-0.0.23-alpha/build/premake/premake5/src/host/os_getversion.c
--- original/0ad-0.0.23-alpha/build/premake/premake5/src/host/os_getversion.c 2017-10-28 16:10:49.025427968 +0000
+++ 0ad-0.0.23-alpha/build/premake/premake5/src/host/os_getversion.c 2019-06-07 15:18:41.352321536 +0000
@@ -193,7 +193,7 @@
/*************************************************************/
-#elif defined(PLATFORM_BSD) || defined(PLATFORM_LINUX) || defined(PLATFORM_SOLARIS) || defined(PLATFORM_HURD)
+#elif defined(PLATFORM_BSD) || defined(PLATFORM_LINUX) || defined(PLATFORM_SOLARIS) || defined(PLATFORM_HURD) || defined(__HAIKU__)
#include <string.h>
#include <sys/utsname.h>
diff -urdN -E -b -w -B --strip-trailing-cr original/0ad-0.0.23-alpha/build/premake/premake5/src/host/premake.c 0ad-0.0.23-alpha/build/premake/premake5/src/host/premake.c
--- original/0ad-0.0.23-alpha/build/premake/premake5/src/host/premake.c 2017-10-28 16:10:49.023592960 +0000
+++ 0ad-0.0.23-alpha/build/premake/premake5/src/host/premake.c 2019-06-07 16:03:00.429654016 +0000
@@ -368,6 +370,7 @@
}
#endif
+#if !defined(__HAIKU__)
/* As a fallback, search the PATH with argv[0] */
if (!path)
{
@@ -400,6 +403,11 @@
path = lua_tostring(L, -1);
}
+#else
+ /* The fallback logic is broken and always was. This re-implements it correctly IN C. */
+ getcwd(buffer, PATH_MAX);
+ path = buffer;
+#endif
lua_pushstring(L, path);
return 1;
diff -urdN -E -b -w -B --strip-trailing-cr original/0ad-0.0.23-alpha/build/premake/premake5/src/host/premake.h 0ad-0.0.23-alpha/build/premake/premake5/src/host/premake.h
--- original/0ad-0.0.23-alpha/build/premake/premake5/src/host/premake.h 2017-10-28 16:10:49.025952256 +0000
+++ 0ad-0.0.23-alpha/build/premake/premake5/src/host/premake.h 2019-06-07 16:01:49.395051008 +0000
@@ -43,7 +43,7 @@
#define PLATFORM_STRING "windows"
#endif
-#define PLATFORM_POSIX (PLATFORM_LINUX || PLATFORM_BSD || PLATFORM_MACOSX || PLATFORM_SOLARIS)
+#define PLATFORM_POSIX (PLATFORM_LINUX || PLATFORM_BSD || PLATFORM_MACOSX || PLATFORM_SOLARIS || PLATFORM_HAIKU)
/* Pull in platform-specific headers required by built-in functions */
diff -urdN -E -b -w -B --strip-trailing-cr original/0ad-0.0.23-alpha/build/premake/premake5.lua 0ad-0.0.23-alpha/build/premake/premake5.lua
--- original/0ad-0.0.23-alpha/build/premake/premake5.lua 2018-04-22 18:14:45.011534336 +0000
+++ 0ad-0.0.23-alpha/build/premake/premake5.lua 2019-06-07 19:00:27.612368384 +0000
@@ -344,7 +344,7 @@
defines { "INSTALLED_LIBDIR=" .. _OPTIONS["libdir"] }
end
- if os.istarget("linux") or os.istarget("bsd") then
+ if os.istarget("linux") or os.istarget("bsd") or os.istarget("haiku") then
-- To use our local shared libraries, they need to be found in the
-- runtime dynamic linker path. Add their path to -rpath.
if _OPTIONS["libdir"] then
@@ -370,7 +370,7 @@
-- add X11 includes paths after all the others so they don't conflict with
-- bundled libs
function project_add_x11_dirs()
- if not os.istarget("windows") and not os.istarget("macosx") then
+ if not os.istarget("windows") and not os.istarget("macosx") and not os.istarget("haiku") then
-- X11 includes may be installed in one of a gadzillion of five places
-- Famous last words: "You can't include too much! ;-)"
sysincludedirs {
@@ -835,6 +835,7 @@
windows = { "lib/sysdep/os/win", "lib/sysdep/os/win/wposix", "lib/sysdep/os/win/whrt" },
macosx = { "lib/sysdep/os/osx", "lib/sysdep/os/unix" },
bsd = { "lib/sysdep/os/bsd", "lib/sysdep/os/unix", "lib/sysdep/os/unix/x" },
+ haiku = { "lib/sysdep/os/haiku", "lib/sysdep/os/unix" }
}
for i,v in pairs(sysdep_dirs[os.target()]) do
table.insert(source_dirs, v);
@@ -1036,6 +1037,13 @@
links { "ApplicationServices.framework", "Cocoa.framework", "CoreFoundation.framework" }
end
+
+ if os.istarget("haiku") then
+ links { "be" }
+ linkoptions {
+ "/boot/system/lib/libnetwork.so"
+ }
+ end
end
@@ -1420,6 +1428,13 @@
includedirs { source_root .. "pch/test/" }
end
+
+ if os.istarget("haiku") then
+ links { "be" }
+ linkoptions {
+ "/boot/system/lib/libnetwork.so"
+ }
+ end
end
-- must come first, so that VC sets it as the default project and therefore
diff -urdN -E -b -w -B --strip-trailing-cr original/0ad-0.0.23-alpha/build/workspaces/update-workspaces.sh 0ad-0.0.23-alpha/build/workspaces/update-workspaces.sh
--- original/0ad-0.0.23-alpha/build/workspaces/update-workspaces.sh 2017-10-30 13:52:05.021495808 +0000
+++ 0ad-0.0.23-alpha/build/workspaces/update-workspaces.sh 2019-06-07 15:03:49.098566144 +0000
@@ -1,9 +1,10 @@
#!/bin/sh
-if [ "$(id -u)" = "0" ]; then
- echo "Running as root will mess up file permissions. Aborting ..." 1>&2
- exit 1
-fi
+#if [ "$(id -u)" = "0" ]; then
+# echo "Running as root will mess up file permissions. Aborting ..."
+#1>&2
+# exit 1
+#fi
die()
{
diff -urdN -E -b -w -B --strip-trailing-cr original/0ad-0.0.23-alpha/libraries/source/fcollada/include/FCDocument/FCDocument.h 0ad-0.0.23-alpha/libraries/source/fcollada/include/FCDocument/FCDocument.h
--- original/0ad-0.0.23-alpha/libraries/source/fcollada/include/FCDocument/FCDocument.h 2018-03-03 16:33:02.051118080 +0000
+++ 0ad-0.0.23-alpha/libraries/source/fcollada/include/FCDocument/FCDocument.h 2019-06-07 17:02:13.541589504 +0000
@@ -30,7 +30,7 @@
#if defined(WIN32)
template <class T> class FCOLLADA_EXPORT FCDLibrary; /**< Trick Doxygen. */
template <class T> class FCOLLADA_EXPORT FUUniqueStringMapT; /**< Trick Doxygen. */
-#elif defined(LINUX) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
+#elif defined(LINUX) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) || defined(__HAIKU__)
template <class T> class FCDLibrary; /**< Trick Doxygen. */
template <class T> class FUUniqueStringMapT; /**< Trick Doxygen. */
#endif // LINUX
diff -urdN -E -b -w -B --strip-trailing-cr original/0ad-0.0.23-alpha/libraries/source/fcollada/include/FUtils/Platforms.h 0ad-0.0.23-alpha/libraries/source/fcollada/include/FUtils/Platforms.h
--- original/0ad-0.0.23-alpha/libraries/source/fcollada/include/FUtils/Platforms.h 2018-03-03 16:33:02.041418752 +0000
+++ 0ad-0.0.23-alpha/libraries/source/fcollada/include/FUtils/Platforms.h 2019-06-07 16:58:02.051904512 +0000
@@ -74,7 +74,7 @@
#include <wchar.h>
#include <stdint.h>
-#elif defined(LINUX) || defined(__PPU__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
+#elif defined(LINUX) || defined(__PPU__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) || defined(__HAIKU__)
#include <ctype.h>
#include <wctype.h>
#include <unistd.h>
@@ -125,7 +125,7 @@
#endif // PLATFORMS
// Important functions that some OSes have missing!
-#if defined(__APPLE__) || defined(LINUX) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
+#if defined(__APPLE__) || defined(LINUX) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) || defined(__HAIKU__)
inline char* strlower(char* str) { char* it = str; while (*it != 0) { *it = tolower(*it); ++it; } return str; }
inline wchar_t* wcslwr(wchar_t* str) { wchar_t* it = str; while (*it != 0) { *it = towlower(*it); ++it; } return str; }
inline int wcsicmp(const wchar_t* s1, const wchar_t* s2) { wchar_t c1 = *s1, c2 = *s2; while (c1 != 0 && c2 != 0) { if (c1 >= 'a' && c1 <= 'z') c1 -= 'a' + 'A'; if (c2 >= 'a' && c2 <= 'z') c2 -= 'a' + 'A'; if (c2 < c1) return -1; else if (c2 > c1) return 1; c1 = *(++s1); c2 = *(++s2); } return 0; }
diff -urdN -E -b -w -B --strip-trailing-cr original/0ad-0.0.23-alpha/libraries/source/fcollada/src/FCollada/FUtils/FUAssert.cpp 0ad-0.0.23-alpha/libraries/source/fcollada/src/FCollada/FUtils/FUAssert.cpp
--- original/0ad-0.0.23-alpha/libraries/source/fcollada/src/FCollada/FUtils/FUAssert.cpp 2017-07-10 21:53:47.007864320 +0000
+++ 0ad-0.0.23-alpha/libraries/source/fcollada/src/FCollada/FUtils/FUAssert.cpp 2019-01-09 17:21:48.744751104 +0000
@@ -12,8 +12,12 @@
#include "FUAssert.h"
#ifndef WIN32
+ #ifdef __HAIKU__
+ #include <signal.h>
+ #else
#include "sys/signal.h" // Used for throw(SIGTRAP) on UNIX-like systems
#endif
+#endif
#ifdef __APPLE__
#include <CoreServices/CoreServices.h>
diff -urdN -E -b -w -B --strip-trailing-cr original/0ad-0.0.23-alpha/libraries/source/fcollada/src/FCollada/FUtils/FUPluginManager.cpp 0ad-0.0.23-alpha/libraries/source/fcollada/src/FCollada/FUtils/FUPluginManager.cpp
--- original/0ad-0.0.23-alpha/libraries/source/fcollada/src/FCollada/FUtils/FUPluginManager.cpp 2010-04-19 21:56:45.003932160 +0000
+++ 0ad-0.0.23-alpha/libraries/source/fcollada/src/FCollada/FUtils/FUPluginManager.cpp 2019-01-09 17:27:47.778567680 +0000
@@ -27,6 +27,9 @@
#elif defined(__APPLE__) || defined(LINUX)
#include <dlfcn.h>
#include <dirent.h>
+#endif
+#if defined(__HAIKU__)
+ #include <sys/stat.h>
#endif //WIN32
//
@@ -129,6 +132,9 @@
}
#elif defined(__APPLE__) || defined(LINUX)
+ #ifdef __HAIKU__
+ struct stat s;
+ #endif
fm::string s_filter = TO_STRING(filter);
if (s_filter.length() > 0 && s_filter.front() == '*') s_filter.erase(0, 1);
if (s_filter.length() > 0 && s_filter.back() == '*') s_filter.pop_back();
@@ -139,7 +145,12 @@
dirent* directoryEntry;
while ((directoryEntry = readdir(directory)) != NULL)
{
+ #ifdef __HAIKU__
+ stat(directoryEntry->d_name, &s);
+ if (S_ISDIR(s.st_mode)) continue;
+ #else
if (directoryEntry->d_type == DT_DIR) continue; // skip sub-folders.
+ #endif
if (strstr((const char*) directoryEntry->d_name, s_filter.c_str()) != NULL)
{
// We have a match.
--- original/0ad-0.0.23-alpha/libraries/source/fcollada/src/FCollada/FUtils/FUStringBuilder.h 2012-06-04 21:33:15.005505024 +0000
+++ 0ad-0.0.23-alpha/libraries/source/fcollada/src/FCollada/FUtils/FUStringBuilder.h 2019-01-09 17:18:53.740032512 +0000
@@ -135,7 +135,7 @@
#else
inline void append(unsigned int i) { append((uint32) i); } /**< See above. */
#endif
-#elif defined(__APPLE__) || defined(__OpenBSD__)
+#elif defined(__APPLE__) || defined(__OpenBSD__) || (defined(__HAIKU__) && defined(__i386__))
inline void append(size_t i) { append((uint64)i); }
#endif // defined(WIN32)
diff -urdN -E -b -w -B --strip-trailing-cr original/0ad-0.0.23-alpha/libraries/source/nvtt/src/src/nvcore/Debug.cpp 0ad-0.0.23-alpha/libraries/source/nvtt/src/src/nvcore/Debug.cpp
--- original/0ad-0.0.23-alpha/libraries/source/nvtt/src/src/nvcore/Debug.cpp 2015-07-21 15:53:21.056623104 +0000
+++ 0ad-0.0.23-alpha/libraries/source/nvtt/src/src/nvcore/Debug.cpp 2019-01-09 19:09:51.894435328 +0000
@@ -221,6 +221,14 @@
ucontext_t * ucp = (ucontext_t *)secret;
return (void *)ucp->sc_eip;
# endif
+# elif defined(__HAIKU__)
+# if NV_CPU_X86_64
+ ucontext_t * ucp = (ucontext_t *)secret;
+ return (void *)ucp->uc_mcontext.rip;
+# elif NV_CPU_X86
+ ucontext_t * ucp = (ucontext_t *)secret;
+ return (void* )ucp->uc_mcontext.eip;
+# endif
# else
# if NV_CPU_X86_64
// #define REG_RIP REG_INDEX(rip) // seems to be 16
diff -urdN -E -b -w -B --strip-trailing-cr original/0ad-0.0.23-alpha/libraries/source/nvtt/src/src/nvcore/nvcore.h 0ad-0.0.23-alpha/libraries/source/nvtt/src/src/nvcore/nvcore.h
--- original/0ad-0.0.23-alpha/libraries/source/nvtt/src/src/nvcore/nvcore.h 2015-07-21 15:53:21.057933824 +0000
+++ 0ad-0.0.23-alpha/libraries/source/nvtt/src/src/nvcore/nvcore.h 2019-06-05 08:42:21.010485760 +0000
@@ -58,6 +58,9 @@
# define NV_OS_WIN32 1
#elif defined POSH_OS_WIN64
# define NV_OS_WIN64 1
+#elif defined POSH_OS_HAIKU
+# define NV_OS_LINUX 1
+# define NV_OS_UNIX 1
#else
# error "Unsupported OS"
#endif
diff -urdN -E -b -w -B --strip-trailing-cr original/0ad-0.0.23-alpha/libraries/source/nvtt/src/src/nvcore/poshlib/posh.h 0ad-0.0.23-alpha/libraries/source/nvtt/src/src/nvcore/poshlib/posh.h
--- original/0ad-0.0.23-alpha/libraries/source/nvtt/src/src/nvcore/poshlib/posh.h 2015-07-21 15:53:21.057671680 +0000
+++ 0ad-0.0.23-alpha/libraries/source/nvtt/src/src/nvcore/poshlib/posh.h 2019-01-09 19:11:56.499384320 +0000
@@ -303,6 +303,11 @@
# define POSH_OS_STRING "OpenBSD"
#endif
+#if defined __HAIKU__
+# define POSH_OS_HAIKU 1
+# define POSH_OS_STRING "Haiku"
+#endif
+
#if defined __CYGWIN32__
# define POSH_OS_CYGWIN32 1
# define POSH_OS_STRING "Cygwin"
diff -urdN -E -b -w -B --strip-trailing-cr original/0ad-0.0.23-alpha/libraries/source/nvtt/src/src/nvimage/ImageIO.cpp 0ad-0.0.23-alpha/libraries/source/nvtt/src/src/nvimage/ImageIO.cpp
--- original/0ad-0.0.23-alpha/libraries/source/nvtt/src/src/nvimage/ImageIO.cpp 2016-06-11 16:33:18.005767168 +0000
+++ 0ad-0.0.23-alpha/libraries/source/nvtt/src/src/nvimage/ImageIO.cpp 2019-06-05 08:46:00.321126400 +0000
@@ -28,7 +28,17 @@
#if defined(HAVE_TIFF)
# define _TIFF_DATA_TYPEDEFS_
+#if defined(__HAIKU__)
+# define int32 int32_old
+# define uint32 uint32_old
+# define TRUE TRUE_OLD
+#endif
# include <tiffio.h>
+#if defined(__HAIKU__)
+# define int32_old int32
+# define uint32_old uint32
+# define TRUE_OLD TRUE
+#endif
#endif
#if defined(HAVE_OPENEXR)
diff -urdN -E -b -w -B original/0ad-0.0.23-alpha/libraries/source/spidermonkey/build.sh 0ad-0.0.23-alpha/libraries/source/spidermonkey/build.sh
--- original/0ad-0.0.23-alpha/libraries/source/spidermonkey/build.sh 2016-10-04 15:01:34.062914560 +0000
+++ 0ad-0.0.23-alpha/libraries/source/spidermonkey/build.sh 2019-06-09 07:59:56.329515008 +0000
@@ -103,6 +103,54 @@
perl -i.bak -pe 's/(SHARED_LIBRARY_NAME\s+=).*/$1 '\''mozjs38-ps-debug'\''/' moz.build
mkdir -p build-debug
cd build-debug
+
+fixHaikuBuild()
+{
+ baseDir=$(pwd)
+
+ # HACK: HaikuPorter does not work with pip and virtual env at the moment.
+ mkdir -p _virtualenv
+ mkdir -p _virtualenv/non-packaged
+ mkdir -p _virtualenv/non-packaged/lib/
+ mkdir -p _virtualenv/non-packaged/lib/python2.7/
+ mkdir -p _virtualenv/non-packaged/lib/python2.7/site-packages/
+ cd _virtualenv/non-packaged/lib/python2.7/site-packages/
+
+ echo testing/marionette/transport > marionette_transport.pth
+ echo testing/marionette/driver > marionette_driver.pth
+ echo testing/marionette/client > marionette.pth
+ echo python/blessings > blessings.pth
+ echo python/configobj > configobj.pth
+ echo python/jsmin > jsmin.pth
+ echo python/mach > mach.pth
+ echo python/mozbuild > mozbuild.pth
+ echo build/pymake > pymake.pth
+ #optional:setup.py:python/psutil:build_ext:--inplace
+ #optional:psutil.pth:python/psutil
+ echo python/which > which.pth
+ echo other-licenses/ply/ > ply.pth
+ echo python/mock-1.0.0 > mock.pth
+ echo build > mozilla.pth
+ echo config > mozilla.pth
+ echo xpcom/typelib/xpt/tools >> mozilla.pth
+ echo dom/bindings >> mozilla.pth
+ echo dom/bindings/parser >> mozilla.pth
+ echo layout/tools/reftest >> mozilla.pth
+ echo tools/docs > moztreedocs.pth
+ #copy:build/buildconfig.py
+ #packages.txt:testing/mozbase/packages.txt
+ #objdir:build
+ echo media/webrtc/trunk/tools/gyp/pylib > gyp.pth
+ echo python/pyasn1 > pyasn1.pth
+ echo python/bitstring > bitstring.pth
+ echo python/redo > redo.pth
+ echo python/requests > requests.pth
+
+ cd $baseDir
+}
+
+fixHaikuBuild
+
CXXFLAGS="${CXXFLAGS} ${TLCXXFLAGS}" ../configure ${CONF_OPTS} --with-nspr-libs="$NSPR_LIBS" --with-nspr-cflags="$NSPR_INCLUDES" --enable-debug --disable-optimize --enable-js-diagnostics --enable-gczeal
${MAKE} ${MAKE_OPTS}
cd ..
@@ -110,6 +158,9 @@
perl -i.bak -pe 's/(SHARED_LIBRARY_NAME\s+=).*/$1 '\''mozjs38-ps-release'\''/' moz.build
mkdir -p build-release
cd build-release
+
+fixHaikuBuild
+
CXXFLAGS="${CXXFLAGS} ${TLCXXFLAGS}" ../configure ${CONF_OPTS} --with-nspr-libs="$NSPR_LIBS" --with-nspr-cflags="$NSPR_INCLUDES" --enable-optimize # --enable-gczeal --enable-debug-symbols
${MAKE} ${MAKE_OPTS}
cd ..
diff -urdN -E -b -w -B --strip-trailing-cr original/0ad-0.0.23-alpha/libraries/source/spidermonkey/FixHaikuBuild.diff 0ad-0.0.23-alpha/libraries/source/spidermonkey/FixHaikuBuild.diff
--- original/0ad-0.0.23-alpha/libraries/source/spidermonkey/FixHaikuBuild.diff 1970-01-01 00:00:00.000000000 +0000
+++ 0ad-0.0.23-alpha/libraries/source/spidermonkey/FixHaikuBuild.diff 2019-06-05 14:51:06.494665728 +0000
@@ -0,0 +1,197 @@
+diff -ur mozjs-38.0.0-old/js/src/asmjs/AsmJSSignalHandlers.cpp mozjs-38.0.0-new/js/src/asmjs/AsmJSSignalHandlers.cpp
+--- mozjs-38.0.0-old/js/src/asmjs/AsmJSSignalHandlers.cpp 2015-09-17 20:12:18.030670848 +0000
++++ mozjs-38.0.0-new/js/src/asmjs/AsmJSSignalHandlers.cpp 2017-12-16 09:53:06.911736832 +0000
+@@ -200,6 +200,28 @@
+ #elif defined(XP_MACOSX)
+ # define EIP_sig(p) ((p)->uc_mcontext->__ss.__eip)
+ # define RIP_sig(p) ((p)->uc_mcontext->__ss.__rip)
++#elif defined(__HAIKU__)
++# define EIP_sig(p) ((p)->uc_mcontext.eip)
++# if defined(__x86_64__)
++# define RIP_sig(p) ((p)->uc_mcontext.rip)
++# define RAX_sig(p) ((p)->uc_mcontext.rax)
++# define RCX_sig(p) ((p)->uc_mcontext.rcx)
++# define RDX_sig(p) ((p)->uc_mcontext.rdx)
++# define RBX_sig(p) ((p)->uc_mcontext.rbx)
++# define RSP_sig(p) ((p)->uc_mcontext.rsp)
++# define RBP_sig(p) ((p)->uc_mcontext.rbp)
++# define RSI_sig(p) ((p)->uc_mcontext.rsi)
++# define RDI_sig(p) ((p)->uc_mcontext.rdi)
++# define R8_sig(p) ((p)->uc_mcontext.r8)
++# define R9_sig(p) ((p)->uc_mcontext.r9)
++# define R10_sig(p) ((p)->uc_mcontext.r10)
++# define R11_sig(p) ((p)->uc_mcontext.r11)
++# define R12_sig(p) ((p)->uc_mcontext.r12)
++# define R13_sig(p) ((p)->uc_mcontext.r13)
++# define R14_sig(p) ((p)->uc_mcontext.r14)
++# define R15_sig(p) ((p)->uc_mcontext.r15)
++# define XMM_sig(p,i) ((p)->uc_mcontext.fpu.xmm.xmm ## i)
++# endif
+ #else
+ # error "Don't know how to read/write to the thread state via the mcontext_t."
+ #endif
+diff -ur mozjs-38.0.0-old/js/src/configure mozjs-38.0.0-new/js/src/configure
+--- mozjs-38.0.0-old/js/src/configure 2017-12-16 10:03:35.259260416 +0000
++++ mozjs-38.0.0-new/js/src/configure 2017-12-16 10:28:47.306446336 +0000
+@@ -4408,7 +4408,12 @@
+ esac
+ fi
+
++#HACK: The python modules search path is not being correctly set. This is done manually here.
++echo import site > $MOZ_BUILD_ROOT/_virtualenv/lib/python2.7/site-packages/sitecustomize.py
++echo "site.addsitedir('$MOZ_BUILD_ROOT/_virtualenv/non-packaged/lib/python2.7/site-packages/')" >> $MOZ_BUILD_ROOT/_virtualenv/lib/python2.7/site-packages/sitecustomize.py
+
++#HACK: The process.py script cannot detect the built-in variable so it should be redefined.
++export SHELL=/bin/bash
+
+ echo $ac_n "checking Python environment is Mozilla virtualenv""... $ac_c" 1>&6
+ echo "configure:4479: checking Python environment is Mozilla virtualenv" >&5
+diff -ur mozjs-38.0.0-old/js/src/gc/Memory.cpp mozjs-38.0.0-new/js/src/gc/Memory.cpp
+--- mozjs-38.0.0-old/js/src/gc/Memory.cpp 2015-09-17 20:12:18.031719424 +0000
++++ mozjs-38.0.0-new/js/src/gc/Memory.cpp 2017-12-16 09:53:06.915931136 +0000
+@@ -22,7 +22,7 @@
+ #include <sys/mman.h>
+ #include <unistd.h>
+
+-#elif defined(XP_UNIX)
++#elif defined(XP_UNIX) || defined(__HAIKU__)
+
+ #include <algorithm>
+ #include <errno.h>
+@@ -44,7 +44,7 @@
+ // The OS allocation granularity may not match the page size.
+ static size_t allocGranularity = 0;
+
+-#if defined(XP_UNIX)
++#if defined(XP_UNIX) || defined(__HAIKU__)
+ // The addresses handed out by mmap may grow up or down.
+ static mozilla::Atomic<int, mozilla::Relaxed> growthDirection(0);
+ #endif
+@@ -366,7 +366,7 @@
+ // Not implemented.
+ }
+
+-#elif defined(XP_UNIX)
++#elif defined(XP_UNIX) || defined(__HAIKU__)
+
+ void
+ InitMemorySubsystem()
+@@ -604,7 +604,11 @@
+ return false;
+
+ MOZ_ASSERT(OffsetFromAligned(p, pageSize) == 0);
++#if defined(__HAIKU__)
++ int result = posix_madvise(p, size, POSIX_MADV_DONTNEED);
++#else
+ int result = madvise(p, size, MADV_DONTNEED);
++#endif
+ return result != -1;
+ }
+
+@@ -625,7 +629,12 @@
+ int err = getrusage(RUSAGE_SELF, &usage);
+ if (err)
+ return 0;
++#if defined(__HAIKU__)
++ //HACK: the ru_majfly variable does not exist in POSIX
++ return 0;
++#else
+ return usage.ru_majflt;
++#endif
+ }
+
+ void*
+diff -ur mozjs-38.0.0-old/js/src/jsnativestack.cpp mozjs-38.0.0-new/js/src/jsnativestack.cpp
+--- mozjs-38.0.0-old/js/src/jsnativestack.cpp 2015-09-17 20:12:22.031195136 +0000
++++ mozjs-38.0.0-new/js/src/jsnativestack.cpp 2017-12-16 09:53:06.916455424 +0000
+@@ -9,9 +9,11 @@
+ #ifdef XP_WIN
+ # include "jswin.h"
+
+-#elif defined(XP_MACOSX) || defined(DARWIN) || defined(XP_UNIX)
++#elif defined(XP_MACOSX) || defined(DARWIN) || defined(XP_UNIX) || defined(__HAIKU__)
+ # include <pthread.h>
+-
++# if defined(__HAIKU__)
++ #include <OS.h>
++# endif
+ # if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
+ # include <pthread_np.h>
+ # endif
+@@ -101,6 +103,9 @@
+ # elif defined(PTHREAD_NP_H) || defined(_PTHREAD_NP_H_) || defined(NETBSD)
+ /* e.g. on FreeBSD 4.8 or newer, neundorf@kde.org */
+ pthread_attr_get_np(thread, &sattr);
++# elif defined(__HAIKU__)
++ //HACK: Haiku does not implement pthread_getattr_np as it is not POSIX
++ //get_thread_info(thread, &sattr->id);
+ # else
+ /*
+ * FIXME: this function is non-portable;
+@@ -143,6 +148,8 @@
+ // For non main-threads pthread allocates the stack itself so it tells
+ // the truth.
+ rc = pthread_attr_getstack(&sattr, &stackBase, &stackSize);
++# elif defined(__HAIKU__)
++ rc = 0;
+ # else
+ rc = pthread_attr_getstack(&sattr, &stackBase, &stackSize);
+ # endif
+diff -ur mozjs-38.0.0-old/js/src/shell/js.cpp mozjs-38.0.0-new/js/src/shell/js.cpp
+--- mozjs-38.0.0-old/js/src/shell/js.cpp 2015-09-17 20:12:22.004194304 +0000
++++ mozjs-38.0.0-new/js/src/shell/js.cpp 2017-12-16 09:53:06.917766144 +0000
+@@ -32,7 +32,7 @@
+ #include <string.h>
+ #include <sys/stat.h>
+ #include <sys/types.h>
+-#ifdef XP_UNIX
++#if defined(XP_UNIX) || defined(__HAIKU__)
+ # include <sys/mman.h>
+ # include <sys/stat.h>
+ # include <sys/wait.h>
+@@ -5892,7 +5892,7 @@
+ if (!ptr)
+ return 0;
+
+-#if defined(HAVE_MALLOC_USABLE_SIZE)
++#if defined(HAVE_MALLOC_USABLE_SIZE) && !defined(__HAIKU__)
+ return malloc_usable_size(ptr);
+ #elif defined(HAVE_MALLOC_SIZE)
+ return malloc_size(ptr);
+Only in mozjs-38.0.0-new/layout/tools/reftest/reftest: __init__.pyc
+diff -ur mozjs-38.0.0-old/mfbt/Poison.cpp mozjs-38.0.0-new/mfbt/Poison.cpp
+--- mozjs-38.0.0-old/mfbt/Poison.cpp 2015-09-17 20:12:16.000524288 +0000
++++ mozjs-38.0.0-new/mfbt/Poison.cpp 2017-12-16 09:53:06.918552576 +0000
+@@ -129,7 +129,11 @@
+ static bool
+ ProbeRegion(uintptr_t aRegion, uintptr_t aSize)
+ {
++#ifdef __HAIKU__
++ if (posix_madvise(reinterpret_cast<void*>(aRegion), aSize, POSIX_MADV_NORMAL)) {
++#else
+ if (madvise(reinterpret_cast<void*>(aRegion), aSize, MADV_NORMAL)) {
++#endif
+ return true;
+ } else {
+ return false;
+diff -ur mozjs-38.0.0-old/python/psutil/setup.py mozjs-38.0.0-new/python/psutil/setup.py
+--- mozjs-38.0.0-old/python/psutil/setup.py 2015-09-17 20:12:23.004456448 +0000
++++ mozjs-38.0.0-new/python/psutil/setup.py 2017-12-16 09:53:06.919076864 +0000
+@@ -125,6 +125,18 @@
+ libraries=['kstat', 'nsl'],),
+ posix_extension,
+ ]
++# Haiku
++elif sys.platform.startswith("haiku"):
++ extensions = []
++ """extensions = [Extension(
++ '_psutil_haiku',
++ sources=[
++ #'psutil/_psutil_bsd.c',
++ 'psutil/_psutil_common.c',
++ #'psutil/arch/bsd/process_info.c'
++ ]),
++ posix_extension,
++ ]"""
+ else:
+ sys.exit('platform %s is not supported' % sys.platform)
diff -urdN -E -b -w -B --strip-trailing-cr original/0ad-0.0.23-alpha/libraries/source/spidermonkey/patch.sh 0ad-0.0.23-alpha/libraries/source/spidermonkey/patch.sh
--- original/0ad-0.0.23-alpha/libraries/source/spidermonkey/patch.sh 2017-09-13 00:10:27.062652416 +0000
+++ 0ad-0.0.23-alpha/libraries/source/spidermonkey/patch.sh 2019-01-09 17:51:48.153092096 +0000
@@ -53,3 +53,6 @@
# Based on: https://svnweb.freebsd.org/ports/head/sysutils/py-psutil121/files/patch-_psutil_bsd.c?revision=436575&view=markup
# Related: https://bugzilla.mozilla.org/show_bug.cgi?id=1238983
patch -p0 < ../FixpsutilFreeBSD.diff
+
+# Fixes the build on Haiku by adding it as a recognised platform
+patch -p1 < ../FixHaikuBuild.diff
diff -urdN -E -b -w -B --strip-trailing-cr original/0ad-0.0.23-alpha/source/lib/allocators/page_aligned.cpp 0ad-0.0.23-alpha/source/lib/allocators/page_aligned.cpp
--- original/0ad-0.0.23-alpha/source/lib/allocators/page_aligned.cpp 2018-03-10 09:58:53.013107200 +0000
+++ 0ad-0.0.23-alpha/source/lib/allocators/page_aligned.cpp 2019-06-04 15:27:05.314310656 +0000
@@ -49,7 +49,11 @@
Status mem_Reserve(size_t size, u8** pp)
{
errno = 0;
+#if !__HAIKU__
void* ret = mmap(0, size, PROT_NONE, mmap_flags|MAP_NORESERVE, -1, 0);
+#else
+ void* ret = mmap(0, size, PROT_NONE, mmap_flags, -1, 0);
+#endif
*pp = (u8*)ret;
return StatusFromMap(ret);
}
@@ -76,7 +80,11 @@
Status mem_Decommit(u8* p, size_t size)
{
errno = 0;
+#if !__HAIKU__
void* ret = mmap(p, size, PROT_NONE, mmap_flags|MAP_NORESERVE|MAP_FIXED, -1, 0);
+#else
+ void* ret = mmap(p, size, PROT_NONE, mmap_flags|MAP_FIXED, -1, 0);
+#endif
return StatusFromMap(ret);
}
diff -urdN -E -b -w -B --strip-trailing-cr original/0ad-0.0.23-alpha/source/lib/config2.h 0ad-0.0.23-alpha/source/lib/config2.h
--- original/0ad-0.0.23-alpha/source/lib/config2.h 2017-07-10 14:26:24.022282240 +0000
+++ 0ad-0.0.23-alpha/source/lib/config2.h 2019-06-04 15:30:31.672923648 +0000
@@ -60,7 +60,7 @@
// work around a bug introduced in Linux 2.6.38
// (http://www.wildfiregames.com/forum/index.php?showtopic=14561&view=findpost&p=217710)
// OpenBSD doesn't provide aio.h so we disable its use
-# if OS_LINUX || OS_OPENBSD
+# if OS_LINUX || OS_OPENBSD || __HAIKU__
# define CONFIG2_FILE_ENABLE_AIO 0
# else
# define CONFIG2_FILE_ENABLE_AIO 1
diff -urdN -E -b -w -B --strip-trailing-cr original/0ad-0.0.23-alpha/source/lib/posix/posix_aio.h 0ad-0.0.23-alpha/source/lib/posix/posix_aio.h
--- original/0ad-0.0.23-alpha/source/lib/posix/posix_aio.h 2017-07-10 14:26:24.024117248 +0000
+++ 0ad-0.0.23-alpha/source/lib/posix/posix_aio.h 2019-06-04 14:55:11.776208384 +0000
@@ -30,7 +30,7 @@
#if OS_WIN
# include "lib/sysdep/os/win/wposix/waio.h"
-#elif OS_ANDROID || OS_OPENBSD
+#elif OS_ANDROID || OS_OPENBSD || __HAIKU__
// Android doesn't provide aio.h. We don't actually use aio on Linuxes (see
// CONFIG2_FILE_ENABLE_AIO) but we use its symbols and structs, so define
// them here
diff -urdN -E -b -w -B --strip-trailing-cr original/0ad-0.0.23-alpha/source/lib/secure_crt.h 0ad-0.0.23-alpha/source/lib/secure_crt.h
--- original/0ad-0.0.23-alpha/source/lib/secure_crt.h 2017-07-10 14:26:24.047972352 +0000
+++ 0ad-0.0.23-alpha/source/lib/secure_crt.h 2019-06-04 14:47:13.927727616 +0000
@@ -47,13 +47,13 @@
#if EMULATE_SECURE_CRT
// (conflicts with glibc definitions)
-#if !OS_UNIX || OS_MACOSX || OS_OPENBSD
+#if !OS_UNIX || OS_MACOSX || OS_OPENBSD || __HAIKU__
// return length [in characters] of a string, not including the trailing
// null character. to protect against access violations, only the
// first <max_len> characters are examined; if the null character is
// not encountered by then, <max_len> is returned.
// strnlen is available on OpenBSD
-#if !OS_OPENBSD
+#if !OS_OPENBSD && !__HAIKU__
extern size_t strnlen(const char* str, size_t max_len);
#endif
extern size_t wcsnlen(const wchar_t* str, size_t max_len);
diff -urdN -E -b -w -B --strip-trailing-cr original/0ad-0.0.23-alpha/source/lib/sysdep/os/haiku/dir_watch.cpp 0ad-0.0.23-alpha/source/lib/sysdep/os/haiku/dir_watch.cpp
--- original/0ad-0.0.23-alpha/source/lib/sysdep/os/haiku/dir_watch.cpp 1970-01-01 00:00:00.000000000 +0000
+++ 0ad-0.0.23-alpha/source/lib/sysdep/os/haiku/dir_watch.cpp 2019-06-05 11:00:18.633077760 +0000
@@ -0,0 +1,36 @@
+/* Copyright (C) 2012 Wildfire Games.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "precompiled.h"
+#include "lib/sysdep/dir_watch.h"
+
+// stub implementations
+
+Status dir_watch_Add(const OsPath& UNUSED(path), PDirWatch& UNUSED(dirWatch))
+{
+ return INFO::OK;
+}
+
+Status dir_watch_Poll(DirWatchNotifications& UNUSED(notifications))
+{
+ return INFO::OK;
+}
diff -urdN -E -b -w -B --strip-trailing-cr original/0ad-0.0.23-alpha/source/lib/sysdep/os/haiku/haiku.cpp 0ad-0.0.23-alpha/source/lib/sysdep/os/haiku/haiku.cpp
--- original/0ad-0.0.23-alpha/source/lib/sysdep/os/haiku/haiku.cpp 1970-01-01 00:00:00.000000000 +0000
+++ 0ad-0.0.23-alpha/source/lib/sysdep/os/haiku/haiku.cpp 2019-06-07 20:44:11.748683264 +0000
@@ -0,0 +1,147 @@
+/* Copyright (C) 2014 Wildfire Games.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *cd
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "precompiled.h"
+
+#include "lib/sysdep/sysdep.h"
+#include "lib/sysdep/clipboard.h"
+#include "lib/sysdep/os/unix/unix_executable_pathname.h"
+#include "lib/sysdep/gfx.h"
+#include "lib/sysdep/cursor.h"
+
+#include "ps/VideoMode.h"
+
+#include "SDL.h"
+#include "SDL_syswm.h"
+
+#include <cstdlib>
+
+#define debug_printf debug_printf_old
+#include <Clipboard.h>
+#define debug_printf_old debug_printf
+
+OsPath sys_ExecutablePathname()
+{
+ return unix_ExecutablePathname();
+}
+
+wchar_t *sys_clipboard_get()
+{
+ be_clipboard->Lock();
+ BMessage* clipBoard = be_clipboard->Data();
+ wchar_t* data = NULL;
+ if (clipBoard != NULL)
+ {
+ const char* clipData;
+ ssize_t length;
+ clipBoard->FindData("text/plain", B_MIME_TYPE, (const void**)&clipData, &length);
+ std::wstring dataString = wstring_from_utf8(clipData);
+ size_t dataStringSize = dataString.size() + 1;
+ data = new wchar_t[dataStringSize];
+ memcpy(data, dataString.c_str(), dataStringSize * sizeof(wchar_t));
+ }
+ be_clipboard->Unlock();
+
+ return data == NULL ? const_cast<wchar_t*>(L"") : data;
+}
+
+Status sys_clipboard_free(wchar_t *clip_buf)
+{
+ if (clip_buf != NULL)
+ {
+ delete clip_buf;
+ }
+ return INFO::OK;
+}
+
+Status sys_clipboard_set(const wchar_t *str)
+{
+ be_clipboard->Lock();
+ BMessage* clipBoard = be_clipboard->Data();
+ if (clipBoard != NULL)
+ {
+ be_clipboard->Clear();
+ std::string dataString = utf8_from_wstring(str);
+ const char* data = dataString.c_str();
+ clipBoard->AddData("text/plain", B_MIME_TYPE, (const void*)data, dataString.size());
+ be_clipboard->Commit();
+ }
+ be_clipboard->Unlock();
+ return INFO::OK;
+}
+
+Status sys_cursor_create()
+{
+ return INFO::OK;
+}
+
+Status sys_cursor_create_empty()
+{
+ return INFO::OK;
+}
+
+Status sys_cursor_set(sys_cursor cursor)
+{
+ return INFO::OK;
+}
+
+Status sys_cursor_free(sys_cursor cursor)
+{
+ return INFO::OK;
+}
+
+Status sys_cursor_reset()
+{
+ return INFO::OK;
+}
+
+namespace gfx
+{
+ static bool get_wminfo(SDL_SysWMinfo& wminfo)
+ {
+ SDL_VERSION(&wminfo.version);
+
+ const int ret = SDL_GetWindowWMInfo(g_VideoMode.GetWindow(), &wminfo);
+
+ if(ret == 1)
+ return true;
+
+ if(ret == -1)
+ {
+ debug_printf("SDL_GetWMInfo failed\n");
+ return false;
+ }
+ if(ret == 0)
+ {
+ debug_printf("SDL_GetWMInfo is not implemented on this platform\n");
+ return false;
+ }
+
+ debug_printf("SDL_GetWMInfo returned an unknown value: %d\n", ret);
+ return false;
+ }
+
+ Status GetVideoMode(int* xres, int* yres, int* bpp, int* freq)
+ {
+ return INFO::OK;
+ }
+}
diff -urdN -E -b -w -B --strip-trailing-cr original/0ad-0.0.23-alpha/source/lib/sysdep/os/haiku/hcpu.cpp 0ad-0.0.23-alpha/source/lib/sysdep/os/haiku/hcpu.cpp
--- original/0ad-0.0.23-alpha/source/lib/sysdep/os/haiku/hcpu.cpp 1970-01-01 00:00:00.000000000 +0000
+++ 0ad-0.0.23-alpha/source/lib/sysdep/os/haiku/hcpu.cpp 2019-06-05 11:02:53.649854976 +0000
@@ -0,0 +1,120 @@
+/* Copyright (C) 2012 Wildfire Games.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "precompiled.h"
+
+#include "lib/sysdep/os_cpu.h"
+#include "lib/alignment.h"
+#include "lib/bits.h"
+#include "lib/module_init.h"
+
+#include "valgrind.h"
+#include <unistd.h>
+#define debug_printf debug_printf_old
+#include <OS.h>
+#define debug_printf_old debug_printf
+
+size_t os_cpu_NumProcessors()
+{
+ static size_t numProcessors;
+
+ if(numProcessors == 0)
+ {
+ // Valgrind reports the number of real CPUs, but only emulates a single CPU.
+ // That causes problems when we expect all those CPUs to be distinct, so
+ // just pretend there's only one CPU
+ if (RUNNING_ON_VALGRIND)
+ numProcessors = 1;
+ else
+ {
+ long res = sysconf(_SC_NPROCESSORS_CONF);
+ ENSURE(res != -1);
+ numProcessors = (size_t)res;
+ }
+ }
+
+ return numProcessors;
+}
+
+
+uintptr_t os_cpu_ProcessorMask()
+{
+ static uintptr_t processorMask;
+
+ if(!processorMask)
+ processorMask = bit_mask<uintptr_t>(os_cpu_NumProcessors());
+
+ return processorMask;
+}
+
+
+size_t os_cpu_PageSize()
+{
+ static size_t pageSize;
+
+ if(!pageSize)
+ pageSize = (size_t)sysconf(_SC_PAGESIZE);
+
+ return pageSize;
+}
+
+
+size_t os_cpu_LargePageSize()
+{
+ // assume they're unsupported.
+ return 0;
+}
+
+
+size_t os_cpu_QueryMemorySize()
+{
+ system_info info;
+ get_system_info(&info);
+ size_t memorySize = (size_t) (info.max_pages * (B_PAGE_SIZE / 1048576.0f) + 0.5f);
+ return memorySize;
+}
+
+
+size_t os_cpu_MemoryAvailable()
+{
+ system_info info;
+ get_system_info(&info);
+ return (100 * info.used_pages / info.max_pages);
+}
+
+uintptr_t os_cpu_SetThreadAffinityMask(uintptr_t UNUSED(processorMask))
+{
+ // not yet implemented
+ return os_cpu_ProcessorMask();
+}
+
+Status os_cpu_CallByEachCPU(OsCpuCallback cb, uintptr_t cbData)
+{
+ for(size_t processor = 0; processor < os_cpu_NumProcessors(); processor++)
+ {
+ const uintptr_t processorMask = uintptr_t(1) << processor;
+ os_cpu_SetThreadAffinityMask(processorMask);
+ cb(processor, cbData);
+ }
+
+ return INFO::OK;
+}
diff -urdN -E -b -w -B --strip-trailing-cr original/0ad-0.0.23-alpha/source/lib/sysdep/os/haiku/hdbg.cpp 0ad-0.0.23-alpha/source/lib/sysdep/os/haiku/hdbg.cpp
--- original/0ad-0.0.23-alpha/source/lib/sysdep/os/haiku/hdbg.cpp 1970-01-01 00:00:00.000000000 +0000
+++ 0ad-0.0.23-alpha/source/lib/sysdep/os/haiku/hdbg.cpp 2019-06-05 10:59:07.954466304 +0000
@@ -0,0 +1,46 @@
+/* Copyright (C) 2012 Wildfire Games.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "precompiled.h"
+
+#include "lib/sysdep/sysdep.h"
+#include "lib/debug.h"
+
+void* debug_GetCaller(void* UNUSED(context), const wchar_t* UNUSED(lastFuncToSkip))
+{
+ return NULL;
+}
+
+Status debug_DumpStack(wchar_t* buf, size_t max_chars, void* UNUSED(context), const wchar_t* UNUSED(lastFuncToSkip))
+{
+ return INFO::OK;
+}
+
+Status debug_ResolveSymbol(void* ptr_of_interest, wchar_t* sym_name, wchar_t* file, int* line)
+{
+ return INFO::OK;
+}
+
+void debug_SetThreadName(char const* UNUSED(name))
+{
+ // Currently unimplemented
+}
diff -urdN -E -b -w -B --strip-trailing-cr original/0ad-0.0.23-alpha/source/lib/sysdep/os/unix/unix_executable_pathname.cpp 0ad-0.0.23-alpha/source/lib/sysdep/os/unix/unix_executable_pathname.cpp
--- original/0ad-0.0.23-alpha/source/lib/sysdep/os/unix/unix_executable_pathname.cpp 2017-07-10 14:26:24.037486592 +0000
+++ 0ad-0.0.23-alpha/source/lib/sysdep/os/unix/unix_executable_pathname.cpp 2019-06-05 11:27:05.633077760 +0000
@@ -35,7 +35,7 @@
// Find the executable's filename
Dl_info dl_info;
memset(&dl_info, 0, sizeof(dl_info));
- if (!T::dladdr((void *)sys_ExecutablePathname, &dl_info) || !dl_info.dli_fname)
+ if (!dladdr((void *)sys_ExecutablePathname, &dl_info) || !dl_info.dli_fname)
return OsPath();
const char* path = dl_info.dli_fname;
@@ -53,7 +53,7 @@
if (strchr(path, '/'))
{
char cwd[PATH_MAX];
- if (!T::getcwd(cwd, PATH_MAX))
+ if (!getcwd(cwd, PATH_MAX))
return OsPath();
char absolute[PATH_MAX];
diff -urdN -E -b -w -B --strip-trailing-cr original/0ad-0.0.23-alpha/source/lib/sysdep/os/unix/uvm.cpp 0ad-0.0.23-alpha/source/lib/sysdep/os/unix/uvm.cpp
--- original/0ad-0.0.23-alpha/source/lib/sysdep/os/unix/uvm.cpp 2017-07-10 14:26:24.038273024 +0000
+++ 0ad-0.0.23-alpha/source/lib/sysdep/os/unix/uvm.cpp 2019-06-04 16:26:42.716701696 +0000
@@ -40,7 +40,11 @@
void* ReserveAddressSpace(size_t size, size_t UNUSED(commitSize), PageType UNUSED(pageType), int UNUSED(prot))
{
errno = 0;
+#if !defined(__HAIKU__)
void* p = mmap(0, size, PROT_NONE, mmap_flags|MAP_NORESERVE, -1, 0);
+#else
+ void* p = mmap(0, size, PROT_NONE, mmap_flags, -1, 0);
+#endif
if(p == MAP_FAILED)
return 0;
return p;
@@ -77,7 +81,11 @@
bool Decommit(uintptr_t address, size_t size)
{
errno = 0;
+#if !defined(__HAIKU__)
if(mmap((void*)address, size, PROT_NONE, mmap_flags|MAP_NORESERVE|MAP_FIXED, -1, 0) == MAP_FAILED)
+#else
+ if(mmap((void*)address, size, PROT_NONE, mmap_flags|MAP_FIXED, -1, 0) == MAP_FAILED)
+#endif
return false;
return true;
}
diff -urdN -E -b -w -B --strip-trailing-cr original/0ad-0.0.23-alpha/source/lib/sysdep/os.h 0ad-0.0.23-alpha/source/lib/sysdep/os.h
--- original/0ad-0.0.23-alpha/source/lib/sysdep/os.h 2017-07-10 14:26:24.025952256 +0000
+++ 0ad-0.0.23-alpha/source/lib/sysdep/os.h 2019-06-04 15:55:52.065273856 +0000
@@ -103,7 +103,7 @@
# define OS_AMIGA 0
#endif
// Unix-based
-#if defined(unix) || defined(__unix) || defined(__unix__) || defined(_XOPEN_SOURCE) || defined(_POSIX_SOURCE)
+#if defined(unix) || defined(__unix) || defined(__unix__) || defined(_XOPEN_SOURCE) || defined(_POSIX_SOURCE) || defined(__HAIKU__)
# define OS_UNIX 1
#else
# define OS_UNIX 0
diff -urdN -E -b -w -B --strip-trailing-cr original/0ad-0.0.23-alpha/source/main.cpp 0ad-0.0.23-alpha/source/main.cpp
--- original/0ad-0.0.23-alpha/source/main.cpp 2018-05-08 10:03:46.009175040 +0000
+++ 0ad-0.0.23-alpha/source/main.cpp 2019-06-05 12:26:15.713555968 +0000
@@ -657,7 +657,8 @@
extern "C" int main(int argc, char* argv[])
{
-#if OS_UNIX
+ // Haiku only has a root user.
+#if OS_UNIX && !defined(__HAIKU__)
// Don't allow people to run the game with root permissions,
// because bad things can happen, check before we do anything
if (geteuid() == 0)
diff -urdN -E -b -w -B --strip-trailing-cr original/0ad-0.0.23-alpha/source/ps/GameSetup/GameSetup.cpp 0ad-0.0.23-alpha/source/ps/GameSetup/GameSetup.cpp
--- original/0ad-0.0.23-alpha/source/ps/GameSetup/GameSetup.cpp 2018-05-08 09:45:54.051380224 +0000
+++ 0ad-0.0.23-alpha/source/ps/GameSetup/GameSetup.cpp 2019-06-07 20:46:23.354156544 +0000
@@ -87,7 +87,7 @@
#include "tools/atlas/GameInterface/GameLoop.h"
#include "tools/atlas/GameInterface/View.h"
-#if !(OS_WIN || OS_MACOSX || OS_ANDROID) // assume all other platforms use X11 for wxWidgets
+#if !(OS_WIN || OS_MACOSX || OS_ANDROID || __HAIKU__) // assume all other platforms use X11 for wxWidgets
#define MUST_INIT_X11 1
#include <X11/Xlib.h>
#else
@@ -787,7 +787,8 @@
#if OS_UNIX
static void FixLocales()
{
-#if OS_MACOSX || OS_BSD
+#if OS_MACOSX || OS_BSD || defined(__HAIKU__)
+ // NOTE: The Haiku clipboard code relies on UTF-8 to convert strings.
// OS X requires a UTF-8 locale in LC_CTYPE so that *wprintf can handle
// wide characters. Peculiarly the string "UTF-8" seems to be acceptable
// despite not being a real locale, and it's conveniently language-agnostic,
diff -urdN -E -b -w -B original/0ad-0.0.23-alpha/source/ps/GameSetup/Paths.cpp 0ad-0.0.23-alpha/source/ps/GameSetup/Paths.cpp
--- original/0ad-0.0.23-alpha/source/ps/GameSetup/Paths.cpp 2016-11-23 13:02:58.051118080 +0000
+++ 0ad-0.0.23-alpha/source/ps/GameSetup/Paths.cpp 2019-06-08 17:35:37.093585408 +0000
@@ -141,12 +141,20 @@
const OsPath xdgConfig = XDG_Path("XDG_CONFIG_HOME", home, home/".config/" ) / subdirectoryName;
const OsPath xdgCache = XDG_Path("XDG_CACHE_HOME", home, home/".cache/" ) / subdirectoryName;
+#if !defined(__HAIKU__)
// We don't make the game vs. user data distinction on Unix
m_gameData = xdgData/"";
m_userData = m_gameData;
m_cache = xdgCache/"";
m_config = xdgConfig / "config"/"";
m_logs = xdgConfig / "logs"/"";
+#else
+ m_gameData = OsPath("/boot/system/settings/0ad/");
+ m_userData = home / "config" / "settings" / "0ad" / "";
+ m_cache = m_userData / "cache" / "";
+ m_config = m_userData / "config"/"";
+ m_logs = m_userData / "logs" / "";
+#endif
#endif
}
diff -urdN -E -b -w -B --strip-trailing-cr original/0ad-0.0.23-alpha/source/third_party/tinygettext/src/iconv.cpp 0ad-0.0.23-alpha/source/third_party/tinygettext/src/iconv.cpp
--- original/0ad-0.0.23-alpha/source/third_party/tinygettext/src/iconv.cpp 2015-12-08 18:05:11.039845888 +0000
+++ 0ad-0.0.23-alpha/source/third_party/tinygettext/src/iconv.cpp 2019-06-05 19:13:12.000000000 +0000
@@ -117,7 +117,7 @@
char* outbuf = &result[0];
// Try to convert the text.
- size_t ret = tinygettext_iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
+ size_t ret = tinygettext_iconv(cd, const_cast<char**>(&inbuf), &inbytesleft, &outbuf, &outbytesleft);
if (ret == static_cast<size_t>(-1))
{
if (errno == EILSEQ || errno == EINVAL)