Skip to content
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

Initial commit for macOS support #220

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
8 changes: 7 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
fail-fast: false
matrix:
name: [windows-latest, ubuntu-22.04]
name: [windows-latest, ubuntu-22.04, macos-latest]
include:
- name: windows-latest
os: windows-latest
Expand All @@ -34,6 +34,12 @@ jobs:
physx: linux
physxkey: linux
anyfx: anyfxcompiler-linux
- name: macos-latest
os: macos-latest
config: darwin-ninja-debug
physx: linux
physxkey: linux
anyfx: anyfxcompiler-macos

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
Expand Down
2 changes: 1 addition & 1 deletion code/addons/scripting/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fips_dir(python)
)
nebula_end_module()

if(NOT FIPS_LINUX)
if(NOT FIPS_LINUX AND NOT FIPS_MACOS)
get_filename_component(PY_DBG_PATH ${Python_LIBRARY_DEBUG} DIRECTORY)
get_filename_component(PY_OPT_PATH ${Python_LIBRARY_RELEASE} DIRECTORY)
target_link_options(scripting PUBLIC "/WHOLEARCHIVE:scripting")
Expand Down
52 changes: 37 additions & 15 deletions code/foundation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
# Foundation
#-------------------------------------------------------------------------------

if(FIPS_LINUX)
if(FIPS_LINUX OR FIPS_OSX)
FIND_PACKAGE(CURL)
endif()

if(FIPS_OSX)
find_library(COCOA_LIBRARY Cocoa)
endif()

if (EXISTS "${NROOT}/syswork/export.zip")
create_resource("${NROOT}/syswork/" "${NROOT}/syswork/export.zip" system_resources)
set_target_properties(system_resources PROPERTIES FOLDER Resources)
Expand All @@ -15,8 +19,14 @@ endif()
nebula_begin_module(foundation)

target_precompile_headers(foundation PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/foundation/stdneb.h ${CMAKE_CURRENT_SOURCE_DIR}/core/ptr.h ${CMAKE_CURRENT_SOURCE_DIR}/core/rtti.h ${CMAKE_CURRENT_SOURCE_DIR}/core/refcounted.h)
if(FIPS_LINUX)
fips_libs(uuid cjson stdc++fs)
if(FIPS_LINUX OR FIPS_OSX)
fips_libs(cjson)
if (FIPS_LINUX)
fips_libs(uuid stdc++fs)
endif()
if (FIPS_OSX)
fips_libs(${COCOA_LIBRARY})
endif()
endif()
target_include_directories(foundation PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
fips_deps(nebula-libs zlib tinyxml)
Expand Down Expand Up @@ -512,12 +522,12 @@ nebula_begin_module(foundation)
jobs2.cc
jobs2.h
)
fips_dir(fibers)
fips_files(
fiber.h
fibers.cc
fibers.h
)
#fips_dir(fibers)
#fips_files(
# fiber.h
# fibers.cc
# fibers.h
#)
fips_dir(framesync)
fips_files(
framesynctimer.cc
Expand Down Expand Up @@ -598,10 +608,10 @@ nebula_begin_module(foundation)
win32/win32systeminfo.cc
win32/win32systeminfo.h
)
fips_dir(fibers GROUP "fibers/win32")
fips_files(
win32/win32fiber.cc
)
#fips_dir(fibers GROUP "fibers/win32")
# fips_files(
# win32/win32fiber.cc
# )
fips_dir(.)
endif()
if (FIPS_POSIX)
Expand All @@ -610,7 +620,7 @@ nebula_begin_module(foundation)
core/posix/posixsingleton.h
core/posix/posixsysfunc.cc
core/posix/posixsysfunc.h
fibers/posix/posixfiber.cc
#fibers/posix/posixfiber.cc
memory/posix/posixmemory.h
memory/posix/posixheap.cc
memory/posix/posixheap.h
Expand Down Expand Up @@ -668,12 +678,24 @@ nebula_begin_module(foundation)
elseif(FIPS_LINUX)
fips_dir(threading/linux GROUP "threading/linux")
fips_files(
linuxevent.h
posixevent.h
linuxthread.cc
linuxthread.h
)
fips_dir(threading/gcc GROUP "threading/gcc")
fips_files(gccinterlocked.cc)
elseif(FIPS_MACOS)
fips_dir(threading/posix GROUP "threading/posix")
fips_files(
posixbarrier.h
posixcriticalsection.h
posixevent.h

posixthread.cc
posixthread.h
)
fips_dir(threading/gcc GROUP "threading/gcc")
fips_files(gccinterlocked.cc)
else()
fips_dir(threading/posix GROUP "threading/posix")
fips_files(
Expand Down
4 changes: 0 additions & 4 deletions code/foundation/core/posix/posixsysfunc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,11 @@ SysFunc::Setup()
if (!SetupCalled)
{
SetupCalled = true;
#if !__MAYA__
//Threading::Thread::SetMyThreadName("MainThread");
#endif
Memory::SetupHeaps();
Memory::Heap::Setup();
Blob::Setup();
#if !__MAYA__
Net::Socket::InitNetwork();
#endif

globalStringAtomTable = new Util::GlobalStringAtomTable;
#if NEBULA_ENABLE_THREADLOCAL_STRINGATOM_TABLES
Expand Down
6 changes: 5 additions & 1 deletion code/foundation/core/posix/precompiled.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#define CORE_POSIX_PRECOMPILED_H
//------------------------------------------------------------------------------
/**
@file core/win32/precompiled.h
@file core/posix/precompiled.h

Contains precompiled headers on the Posix platform.

Expand All @@ -28,8 +28,12 @@
#include <limits.h>

// sse intrinsics
#ifdef __linux__
#include <emmintrin.h>
#include <immintrin.h>
#elif __APPLE__
#include <sse2neon.h>
#endif

//------------------------------------------------------------------------------
#endif
4 changes: 1 addition & 3 deletions code/foundation/core/singleton.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
*/
#if __WIN32__
#include "core/win32/win32singleton.h"
#elif __OSX__
#include "core/osx/osxsingleton.h"
#elif __linux__
#elif __linux__ || __APPLE__
#include "core/posix/posixsingleton.h"
#else
#error "IMPLEMENT ME!"
Expand Down
16 changes: 6 additions & 10 deletions code/foundation/core/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ typedef unsigned int uint;
typedef unsigned short ushort;
typedef unsigned char uchar;
typedef unsigned char ubyte;
typedef signed char byte;

typedef uint64_t uint64;
typedef int64_t int64;
Expand Down Expand Up @@ -142,7 +143,7 @@ OnlyBits(const FLAGS flags, const BITS bits)
#define BITS_TO_BYTES(x) (((x)+7)>>3)
#define BYTES_TO_BITS(x) ((x)<<3)

#if (__OSX__ || __linux__)
#if (__APPLE__ || __linux__)
inline ushort _byteswap_ushort(ushort x) { return ((x>>8) | (x<<8)); }
inline ulong _byteswap_ulong(ulong x) { return ((x&0xff000000)>>24) | ((x&0x00ff0000)>>8) | ((x&0x00000ff00)<<8) | ((x&0x000000ff)<<24); }
inline unsigned long long _byteswap_uint64(unsigned long long x) { return ((((unsigned long long)_byteswap_ulong((ulong)(x & 0xffffffff))) << 32) | ((unsigned long long)_byteswap_ulong((ulong)(x >> 32)))); }
Expand All @@ -154,24 +155,19 @@ typedef unsigned char byte;
#if __WIN32__
#define n_stricmp stricmp
#define n_snprintf StringCchPrintf
#elif (__OSX__ || __APPLE__ || __linux__ )
#elif __APPLE__ || __linux__
#define n_stricmp strcasecmp
#define n_snprintf sprintf
#else
#error "Unsupported platform!"
#endif

#if __MAYA__
#define ThreadLocal
#elif __WIN32__
#if __WIN32__
#define ThreadLocal __declspec(thread)
#elif __linux__
#define ThreadLocal __thread
#if (__OSX__ || __APPLE__)
// thread locals are not allowed on osx, so we define thread local as nothing to prevent problems
#undef ThreadLocal
#define ThreadLocal
#endif
#elif __APPLE__
#define ThreadLocal thread_local
#else
#error "Unsupported platform!"
#endif
Expand Down
2 changes: 1 addition & 1 deletion code/foundation/foundation/stdneb.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "util/compilerhelper.h"
#if __WIN32__
#include "core/win32/precompiled.h"
#elif __linux__
#elif __linux__ || __APPLE__
#include "core/posix/precompiled.h"
#else
#error "precompiled.h not implemented on this platform"
Expand Down
2 changes: 1 addition & 1 deletion code/foundation/io/archfs/archive.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace IO
{
#if __WIN32__ || __linux__
#if __WIN32__ || __linux__ || __APPLE__
__ImplementClass(IO::Archive, 'ARCV', IO::ZipArchive);
#else
#error "IO::Archive not implemented on this platform!"
Expand Down
2 changes: 1 addition & 1 deletion code/foundation/io/archfs/archive.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
(C) 2009 Radon Labs GmbH
(C) 2013-2020 Individual contributors, see AUTHORS file
*/
#if __WIN32__ || __linux__
#if __WIN32__ || __linux__ || __APPLE__
#include "io/zipfs/ziparchive.h"
namespace IO
{
Expand Down
2 changes: 1 addition & 1 deletion code/foundation/io/archfs/archivefilesystem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace IO
{
#if __WIN32__ || __linux__
#if __WIN32__ || __linux__ || __APPLE__
__ImplementClass(IO::ArchiveFileSystem, 'ARFS', IO::ZipFileSystem);
__ImplementInterfaceSingleton(IO::ArchiveFileSystem);
#else
Expand Down
2 changes: 1 addition & 1 deletion code/foundation/io/archfs/archivefilesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
(C) 2009 Radon Labs GmbH
(C) 2013-2020 Individual contributors, see AUTHORS file
*/
#if __WIN32__ || __linux__
#if __WIN32__ || __linux__ || __APPLE__
#include "io/zipfs/zipfilesystem.h"
namespace IO
{
Expand Down
8 changes: 2 additions & 6 deletions code/foundation/io/console.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
#include "threading/thread.h"
#if __WIN32__
#include "io/win32/win32consolehandler.h"
#elif __OSX__
#include "io/osx/osxconsolehandler.h"
#elif __linux__
#elif __linux__ || __APPLE__
#include "io/posix/posixconsolehandler.h"
#endif

Expand Down Expand Up @@ -59,9 +57,7 @@ Console::Open()
// create default console handlers
#if __WIN32__
Ptr<ConsoleHandler> consoleHandler = Win32::Win32ConsoleHandler::Create();
#elif __OSX__
Ptr<ConsoleHandler> consoleHandler = OSX::OSXConsoleHandler::Create();
#elif __linux__
#elif __linux__ || __APPLE__
Ptr<ConsoleHandler> consoleHandler = Posix::PosixConsoleHandler::Create();
#endif
this->AttachHandler(consoleHandler);
Expand Down
8 changes: 1 addition & 7 deletions code/foundation/io/filetime.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,7 @@ namespace IO
{
typedef Win32::Win32FileTime FileTime;
}
#elif __OSX__
#include "io/osx/osxfiletime.h"
namespace IO
{
typedef OSX::OSXFileTime FileTime;
}
#elif __linux__
#elif __linux__ || __APPLE__
#include "io/posix/posixfiletime.h"
namespace IO
{
Expand Down
2 changes: 1 addition & 1 deletion code/foundation/io/filewatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <functional>
#if __WIN32__
#include "io/win32/win32filewatcher.h"
#elif __linux__
#elif __linux__ || __APPLE__
#include "io/posix/linuxfilewatcher.h"
#else
#error "not implemented"
Expand Down
2 changes: 1 addition & 1 deletion code/foundation/io/gamecontentserver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace IO
{
#if (__WIN32__ || __OSX__ || __linux__)
#if (__WIN32__ || __APPLE__ || __linux__)
__ImplementClass(IO::GameContentServer, 'IGCS', Base::GameContentServerBase);
#else
#error "IO::GameContentServer not implemented on this platform!"
Expand Down
2 changes: 1 addition & 1 deletion code/foundation/io/gamecontentserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
(C) 2013-2020 Individual contributors, see AUTHORS file
*/
#include "core/config.h"
#if (__WIN32__ || __OSX__ || __linux__)
#if (__WIN32__ || __APPLE__ || __linux__)
#include "io/base/gamecontentserverbase.h"
namespace IO
{
Expand Down
6 changes: 3 additions & 3 deletions code/foundation/math/point.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ point::storeu(scalar* ptr) const
__forceinline void
point::store3(scalar* ptr) const
{
__m128 v = _mm_permute_ps(this->vec, _MM_SHUFFLE(2, 2, 2, 2));
__m128 v = _mm_shuffle_ps(this->vec, this->vec, _MM_SHUFFLE(2, 2, 2, 2));
_mm_storel_epi64(reinterpret_cast<__m128i*>(ptr), _mm_castps_si128(this->vec));
_mm_store_ss(&ptr[2], v);
}
Expand All @@ -243,8 +243,8 @@ point::store3(scalar* ptr) const
__forceinline void
point::storeu3(scalar* ptr) const
{
__m128 t1 = _mm_permute_ps(this->vec, _MM_SHUFFLE(1, 1, 1, 1));
__m128 t2 = _mm_permute_ps(this->vec, _MM_SHUFFLE(2, 2, 2, 2));
__m128 t1 = _mm_shuffle_ps(this->vec, this->vec, _MM_SHUFFLE(1, 1, 1, 1));
__m128 t2 = _mm_shuffle_ps(this->vec, this->vec, _MM_SHUFFLE(2, 2, 2, 2));
_mm_store_ss(&ptr[0], this->vec);
_mm_store_ss(&ptr[1], t1);
_mm_store_ss(&ptr[2], t2);
Expand Down
9 changes: 8 additions & 1 deletion code/foundation/math/sse.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@
(C) 2018 Individual contributors, see AUTHORS file
*/
//------------------------------------------------------------------------------

#ifdef __WIN32__ || __linux__
#include <xmmintrin.h>
#include <emmintrin.h>
#include <smmintrin.h>
#include <immintrin.h>
#elif __APPLE__
#include <sse2neon.h>
#endif

namespace Math
{
Expand Down
Loading
Loading