Build Nazara on macos up to Nazara_network (not included
This commit is contained in:
parent
d243e7bcd2
commit
4bf49876c6
|
|
@ -158,6 +158,15 @@ function NazaraBuild:Execute()
|
|||
"../src/",
|
||||
"../thirdparty/include"
|
||||
})
|
||||
|
||||
if (os.ishost("macosx")) then
|
||||
includedirs({
|
||||
"../include",
|
||||
"../src/",
|
||||
"../thirdparty/include",
|
||||
"/usr/local/include/" --brew
|
||||
})
|
||||
end
|
||||
|
||||
files(moduleTable.Files)
|
||||
excludes(moduleTable.FilesExcluded)
|
||||
|
|
@ -171,6 +180,14 @@ function NazaraBuild:Execute()
|
|||
"../thirdparty/lib/common",
|
||||
"../lib"
|
||||
})
|
||||
|
||||
if (os.ishost("macosx")) then
|
||||
libdirs({
|
||||
"../thirdparty/lib/common",
|
||||
"../lib",
|
||||
"/usr/local/lib" --brew
|
||||
})
|
||||
end
|
||||
|
||||
-- Output to lib/conf/arch
|
||||
self:FilterLibDirectory("../lib/", targetdir)
|
||||
|
|
@ -928,7 +945,10 @@ end
|
|||
|
||||
function NazaraBuild:PostconfigGenericProject()
|
||||
-- Add options required for C++17 thread and filesystem (have to be linked last)
|
||||
filter("action:gmake*")
|
||||
filter({"action:gmake*", "system:macosx"})
|
||||
links("pthread")
|
||||
|
||||
filter({"action:gmake*", "system:not macosx"})
|
||||
links("stdc++fs")
|
||||
links("pthread")
|
||||
|
||||
|
|
|
|||
|
|
@ -21,11 +21,15 @@ MODULE.OsDefines.Windows = {
|
|||
"SDL_VIDEO_DRIVER_WINDOWS=1"
|
||||
}
|
||||
|
||||
MODULE.OsDefines.Posix = {
|
||||
"SDL_VIDEO_DRIVER_X11=1",
|
||||
"SDL_VIDEO_DRIVER_WAYLAND=1",
|
||||
}
|
||||
|
||||
MODULE.DynLib = {
|
||||
"SDL2"
|
||||
}
|
||||
|
||||
MODULE.Custom = function()
|
||||
filter("system:linux")
|
||||
defines("SDL_VIDEO_DRIVER_X11=1")
|
||||
defines("SDL_VIDEO_DRIVER_WAYLAND=1")
|
||||
|
||||
filter("system:macosx")
|
||||
defines("SDL_VIDEO_DRIVER_COCOA=1")
|
||||
end
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ namespace Nz
|
|||
}
|
||||
};
|
||||
|
||||
#ifdef NAZARA_PLATFORM_POSIX
|
||||
#ifdef NAZARA_PLATFORM_LINUX
|
||||
template<typename T>
|
||||
void SinCos(std::enable_if_t<!std::is_same<T, float>::value && !std::is_same<T, long double>::value, double> x, T* sin, T* cos)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -121,9 +121,12 @@
|
|||
|
||||
#define NAZARA_EXPORT __attribute__((visibility ("default")))
|
||||
#define NAZARA_IMPORT __attribute__((visibility ("default")))
|
||||
/*#elif defined(__APPLE__) && defined(__MACH__)
|
||||
#define NAZARA_PLATFORM_MACOSX
|
||||
#define NAZARA_PLATFORM_POSIX*/
|
||||
#elif defined(__APPLE__) && defined(__MACH__)
|
||||
#define NAZARA_PLATFORM_MACOSX
|
||||
#define NAZARA_PLATFORM_POSIX
|
||||
|
||||
#define NAZARA_EXPORT __attribute__((visibility ("default")))
|
||||
#define NAZARA_IMPORT __attribute__((visibility ("default")))
|
||||
#else
|
||||
#error This operating system is not fully supported by the Nazara Engine
|
||||
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ namespace Nz
|
|||
virtual void Value(UInt16& val) = 0;
|
||||
virtual void Value(UInt32& val) = 0;
|
||||
virtual void Value(UInt64& val) = 0;
|
||||
virtual void Value(std::size_t& val) = 0;
|
||||
inline void SizeT(std::size_t& val);
|
||||
|
||||
virtual void Variable(ShaderNodes::VariablePtr& var) = 0;
|
||||
|
|
@ -101,6 +102,7 @@ namespace Nz
|
|||
void Value(UInt16& val) override;
|
||||
void Value(UInt32& val) override;
|
||||
void Value(UInt64& val) override;
|
||||
void Value(std::size_t& val) override;
|
||||
void Variable(ShaderNodes::VariablePtr& var) override;
|
||||
|
||||
ByteStream& m_stream;
|
||||
|
|
@ -132,6 +134,7 @@ namespace Nz
|
|||
void Value(UInt16& val) override;
|
||||
void Value(UInt32& val) override;
|
||||
void Value(UInt64& val) override;
|
||||
void Value(std::size_t& val) override;
|
||||
void Variable(ShaderNodes::VariablePtr& var) override;
|
||||
|
||||
ByteStream& m_stream;
|
||||
|
|
|
|||
|
|
@ -132,7 +132,11 @@ namespace Nz
|
|||
"libopenal.so.0",
|
||||
"libopenal.so"
|
||||
};
|
||||
//#elif defined(NAZARA_PLATFORM_MACOSX)
|
||||
#elif defined(NAZARA_PLATFORM_MACOSX)
|
||||
const char* libs[] = {
|
||||
"libopenal.dylib",
|
||||
"libopenal.1.dylib",
|
||||
};
|
||||
#else
|
||||
NazaraError("Unknown OS");
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@ namespace Nz
|
|||
{
|
||||
if (!m_endOfFileUpdated)
|
||||
{
|
||||
struct stat64 fileSize;
|
||||
if (fstat64(m_fileDescriptor, &fileSize) == -1)
|
||||
struct Stat fileSize;
|
||||
if (Fstat(m_fileDescriptor, &fileSize) == -1)
|
||||
fileSize.st_size = 0;
|
||||
|
||||
m_endOfFile = (GetCursorPos() >= static_cast<UInt64>(fileSize.st_size));
|
||||
|
|
@ -50,7 +50,7 @@ namespace Nz
|
|||
|
||||
UInt64 FileImpl::GetCursorPos() const
|
||||
{
|
||||
off64_t position = lseek64(m_fileDescriptor, 0, SEEK_CUR);
|
||||
Off_t position = Lseek(m_fileDescriptor, 0, SEEK_CUR);
|
||||
return static_cast<UInt64>(position);
|
||||
}
|
||||
|
||||
|
|
@ -77,7 +77,7 @@ namespace Nz
|
|||
if (mode & OpenMode_Truncate)
|
||||
flags |= O_TRUNC;
|
||||
|
||||
int fileDescriptor = open64(filePath.generic_u8string().data(), flags, permissions);
|
||||
int fileDescriptor = Open_def(filePath.generic_u8string().data(), flags, permissions);
|
||||
if (fileDescriptor == -1)
|
||||
{
|
||||
NazaraError("Failed to open \"" + filePath.generic_u8string() + "\" : " + Error::GetLastSystemError());
|
||||
|
|
@ -166,12 +166,12 @@ namespace Nz
|
|||
|
||||
m_endOfFileUpdated = false;
|
||||
|
||||
return lseek64(m_fileDescriptor, offset, moveMethod) != -1;
|
||||
return Lseek(m_fileDescriptor, offset, moveMethod) != -1;
|
||||
}
|
||||
|
||||
bool FileImpl::SetSize(UInt64 size)
|
||||
{
|
||||
return ftruncate64(m_fileDescriptor, size) != 0;
|
||||
return Ftruncate(m_fileDescriptor, size) != 0;
|
||||
}
|
||||
|
||||
std::size_t FileImpl::Write(const void* buffer, std::size_t size)
|
||||
|
|
|
|||
|
|
@ -16,6 +16,24 @@
|
|||
#include <ctime>
|
||||
#include <filesystem>
|
||||
|
||||
#if defined(NAZARA_PLATFORM_MACOSX)
|
||||
#define Stat stat
|
||||
#define Fstat fstat
|
||||
#define Off_t off_t
|
||||
#define Lseek lseek
|
||||
#define Open_def open
|
||||
#define Ftruncate ftruncate
|
||||
#elif defined(NAZARA_PLATFORM_LINUX)
|
||||
#define Stat stat64
|
||||
#define Fstat fstat64
|
||||
#define Off_t off64_t
|
||||
#define Lseek lseek64
|
||||
#define Open_def open64
|
||||
#define Ftruncate ftruncate64
|
||||
#else
|
||||
#error This operating system is not fully supported by the Nazara Engine
|
||||
#endif
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class File;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,10 @@
|
|||
#include <Nazara/Core/Functor.hpp>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
#if defined(NAZARA_PLATFORM_MACOSX)
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
bool TaskSchedulerImpl::Initialize(unsigned int workerCount)
|
||||
|
|
@ -191,4 +195,55 @@ namespace Nz
|
|||
pthread_cond_t TaskSchedulerImpl::s_cvEmpty;
|
||||
pthread_cond_t TaskSchedulerImpl::s_cvNotEmpty;
|
||||
pthread_barrier_t TaskSchedulerImpl::s_barrier;
|
||||
|
||||
#if defined(NAZARA_PLATFORM_MACOSX)
|
||||
//Code from https://blog.albertarmea.com/post/47089939939/using-pthreadbarrier-on-mac-os-x
|
||||
int TaskSchedulerImpl::pthread_barrier_init(pthread_barrier_t *barrier, const pthread_barrierattr_t *attr, unsigned int count)
|
||||
{
|
||||
if(count == 0)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if(pthread_mutex_init(&barrier->mutex, 0) < 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if(pthread_cond_init(&barrier->cond, 0) < 0)
|
||||
{
|
||||
pthread_mutex_destroy(&barrier->mutex);
|
||||
return -1;
|
||||
}
|
||||
barrier->tripCount = count;
|
||||
barrier->count = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int TaskSchedulerImpl::pthread_barrier_destroy(pthread_barrier_t *barrier)
|
||||
{
|
||||
pthread_cond_destroy(&barrier->cond);
|
||||
pthread_mutex_destroy(&barrier->mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int TaskSchedulerImpl::pthread_barrier_wait(pthread_barrier_t *barrier)
|
||||
{
|
||||
pthread_mutex_lock(&barrier->mutex);
|
||||
++(barrier->count);
|
||||
if(barrier->count >= barrier->tripCount)
|
||||
{
|
||||
barrier->count = 0;
|
||||
pthread_cond_broadcast(&barrier->cond);
|
||||
pthread_mutex_unlock(&barrier->mutex);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
pthread_cond_wait(&barrier->cond, &(barrier->mutex));
|
||||
pthread_mutex_unlock(&barrier->mutex);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,17 @@
|
|||
#include <pthread.h>
|
||||
#include <queue>
|
||||
|
||||
#if defined(NAZARA_PLATFORM_MACOSX)
|
||||
typedef int pthread_barrierattr_t;
|
||||
typedef struct
|
||||
{
|
||||
pthread_mutex_t mutex;
|
||||
pthread_cond_t cond;
|
||||
int count;
|
||||
int tripCount;
|
||||
} pthread_barrier_t;
|
||||
#endif
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
struct Functor;
|
||||
|
|
@ -45,6 +56,12 @@ namespace Nz
|
|||
static pthread_cond_t s_cvEmpty;
|
||||
static pthread_cond_t s_cvNotEmpty;
|
||||
static pthread_barrier_t s_barrier;
|
||||
|
||||
#if defined(NAZARA_PLATFORM_MACOSX)
|
||||
static int pthread_barrier_init(pthread_barrier_t *barrier, const pthread_barrierattr_t *attr, unsigned int count);
|
||||
static int pthread_barrier_destroy(pthread_barrier_t *barrier);
|
||||
static int pthread_barrier_wait(pthread_barrier_t *barrier);
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ namespace Nz
|
|||
#elif defined(NAZARA_PLATFORM_LINUX)
|
||||
std::string_view temp(string);
|
||||
// Nothing to do
|
||||
#elif defined(NAZARA_PLATFORM_MACOS)
|
||||
#elif defined(NAZARA_PLATFORM_MACOSX)
|
||||
std::string temp(string);
|
||||
ReplaceStr(temp, "\n", "\r");
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -465,6 +465,11 @@ namespace Nz
|
|||
{
|
||||
m_stream << val;
|
||||
}
|
||||
|
||||
void ShaderAstSerializer::Value(std::size_t& val)
|
||||
{
|
||||
m_stream << val;
|
||||
}
|
||||
|
||||
void ShaderAstSerializer::Variable(ShaderNodes::VariablePtr& var)
|
||||
{
|
||||
|
|
@ -731,6 +736,11 @@ namespace Nz
|
|||
{
|
||||
m_stream >> val;
|
||||
}
|
||||
|
||||
void ShaderAstUnserializer::Value(std::size_t& val)
|
||||
{
|
||||
m_stream >> val;
|
||||
}
|
||||
|
||||
void ShaderAstUnserializer::Variable(ShaderNodes::VariablePtr& var)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -36,4 +36,10 @@ LIBRARY.Custom = function()
|
|||
|
||||
filter({"architecture:x86", "system:linux"})
|
||||
defines("_POSIX_VER")
|
||||
|
||||
filter({"architecture:x86_64", "system:macosx"})
|
||||
defines("_POSIX_VER_64")
|
||||
|
||||
filter({"architecture:x86", "system:macosx"})
|
||||
defines("_POSIX_VER")
|
||||
end
|
||||
Loading…
Reference in New Issue