Skip to content

Commit

Permalink
macos-14
Browse files Browse the repository at this point in the history
  • Loading branch information
malytomas committed Apr 2, 2024
1 parent c9dbeff commit d1e34d2
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 12 deletions.
54 changes: 49 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
cmake --version
git --version
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive

Expand Down Expand Up @@ -106,7 +106,7 @@ jobs:
${{ matrix.compiler.cc }} --version
${{ matrix.compiler.cxx }} --version
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive

Expand Down Expand Up @@ -191,7 +191,7 @@ jobs:
clang++ --version
git --version
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive

Expand Down Expand Up @@ -228,7 +228,7 @@ jobs:
sudo apt-get update
sudo apt-get install -y xorg-dev nasm libssl-dev clang-15
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive

Expand Down Expand Up @@ -275,7 +275,7 @@ jobs:
sudo apt-get update
sudo apt-get install -y xorg-dev nasm valgrind libssl-dev g++-13
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive

Expand All @@ -295,3 +295,47 @@ jobs:
cd build/result/relwithdebinfo
valgrind ${{ matrix.options.flags }} --tool=${{ matrix.options.tool }} ./cage-test-core
Macos:
name: macos-${{ matrix.os-version }}-${{ matrix.build-config }}
runs-on: macos-${{ matrix.os-version }}
strategy:
fail-fast: false
matrix:
os-version: [14]
build-config: [debug, release]

steps:
- name: Install packages
run: |
brew install nasm
- name: Versions
run: |
cmake --version
git --version
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Configure
run: |
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=${{ matrix.build-config }} ..
- name: Build
run: |
cd build
cmake --build . -- -j3
- name: Tests
run: |
cd build/result/${{ matrix.build-config }}
./cage-test-core
- name: Assets
run: |
cd build/result/${{ matrix.build-config }}
./cage-asset-database
2 changes: 2 additions & 0 deletions sources/include/cage-core/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,8 @@ namespace cage
GCHL_GENERATE(bool, 5);
#undef GCHL_GENERATE

CAGE_FORCE_INLINE StringizerBase<N> &operator+(std::size_t other) requires(!std::is_same_v<uint64, std::size_t>) { return *this + uint64(other); } // stupid macos

// allow to use l-value-reference operator overloads with r-value-reference Stringizer
template<class T>
CAGE_FORCE_INLINE constexpr StringizerBase<N> &operator+(const T &other) &&
Expand Down
3 changes: 2 additions & 1 deletion sources/libcore/filesystem/realFiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#endif
#ifdef CAGE_SYSTEM_MAC
#include <mach-o/dyld.h>
#include <cstring>
#endif

#include "files.h"
Expand Down Expand Up @@ -668,7 +669,7 @@ namespace cage
uint32 len = sizeof(buffer);
if (_NSGetExecutablePath(buffer, &len) != 0)
CAGE_THROW_ERROR(Exception, "_NSGetExecutablePath");
len = detail::strlen(buffer);
len = std::strlen(buffer);
return pathSimplify(String({ buffer, buffer + len }));
#else
#error This operating system is not supported
Expand Down
2 changes: 1 addition & 1 deletion sources/libcore/mesh/meshAlgorithms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ namespace cage
Vec3 p;
for (uint32 j : it)
p += ps[j];
p /= it.size();
p /= float(it.size());
for (uint32 j : it)
impl->positions[j] = p;
}
Expand Down
12 changes: 9 additions & 3 deletions sources/libcore/network/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,18 @@ namespace cage
Sock::Sock(int family, int type, int protocol) : family(family), type(type), protocol(protocol)
{
networkInitialize();
// SOCK_CLOEXEC -> close the socket on exec
#ifdef CAGE_SYSTEM_WINDOWS
descriptor = socket(family, type, protocol);
#else
#elif defined(CAGE_SYSTEM_LINUX)
// SOCK_CLOEXEC -> close the socket on exec
descriptor = socket(family, type | SOCK_CLOEXEC, protocol);
#endif // CAGE_SYSTEM_WINDOWS
#elif defined(CAGE_SYSTEM_MAC)
descriptor = socket(family, type, protocol);
// FD_CLOEXEC -> close the socket on exec
fcntl(descriptor, F_SETFD, FD_CLOEXEC);
#else
#error This operating system is not supported
#endif
if (descriptor == INVALID_SOCKET)
CAGE_THROW_ERROR(SystemError, "socket creation failed (socket)", WSAGetLastError());
}
Expand Down
10 changes: 8 additions & 2 deletions sources/libcore/network/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@
#include "../incWin.h"
#include <winsock2.h>
#include <ws2tcpip.h>

typedef char raw_type;
#define POLLRDHUP 0
#undef POLLPRI // WSAPoll rejects POLLPRI with an error
#define POLLPRI 0
#undef near
#undef far

#else

Expand All @@ -26,6 +25,7 @@ typedef char raw_type;
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>

typedef void raw_type;
typedef int SOCKET;
#define WSAGetLastError() errno
Expand All @@ -38,6 +38,12 @@ typedef int SOCKET;

#endif

#ifdef CAGE_SYSTEM_MAC
#ifndef POLLRDHUP
#define POLLRDHUP 0x2000
#endif
#endif

#include <cage-core/debug.h>
#include <cage-core/memoryBuffer.h>
#include <cage-core/networkUtils.h>
Expand Down

0 comments on commit d1e34d2

Please sign in to comment.