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 89cf629
Show file tree
Hide file tree
Showing 12 changed files with 185 additions and 47 deletions.
46 changes: 41 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,39 @@ 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: 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 }}
ls -la
./cage-test-core
7 changes: 4 additions & 3 deletions cmake/cage_build_configuration.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ macro(cage_build_configuration)
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)

# rpath
set(CMAKE_MACOSX_RPATH TRUE)
set(CMAKE_SKIP_RPATH FALSE)
set(CMAKE_SKIP_BUILD_RPATH TRUE)
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_SKIP_INSTALL_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_BUILD_RPATH "")
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_BUILD_RPATH "\$ORIGIN")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
set(CMAKE_INSTALL_RPATH "\$ORIGIN")

Expand Down
2 changes: 1 addition & 1 deletion externals/jpeg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ message(STATUS "----------------------------------------------------------------

include_directories("${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/jpeg")

if(CMAKE_SIZEOF_VOID_P EQUAL 8)
if(CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT APPLE)
if(WIN32)
set(CMAKE_ASM_NASM_COMPILER "${CMAKE_CURRENT_SOURCE_DIR}/yasm/win64/bin/yasm.exe" CACHE INTERNAL "" FORCE)
set(CMAKE_ASM_NASM_FLAGS "${CMAKE_ASM_NASM_FLAGS} -DWIN64 -D__x86_64__ -D\"EXTN(name)=name\"") # target_compile_definitions does not work with nasm
Expand Down
5 changes: 4 additions & 1 deletion sources/include/cage-core/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,10 @@ namespace cage
GCHL_GENERATE(bool, 5);
#undef GCHL_GENERATE

// allow to use l-value-reference operator overloads with r-value-reference Stringizer
// stupid macos
CAGE_FORCE_INLINE StringizerBase<N> &operator+(std::size_t other) requires(!std::is_same_v<uint64, std::size_t>) { return *this + uint64(other); }

// 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
103 changes: 80 additions & 23 deletions sources/include/cage-core/math.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ namespace cage
GCHL_GENERATE(float);
GCHL_GENERATE(double);
#undef GCHL_GENERATE

// stupid macos
template<int = 0>
requires(!std::is_same_v<uint64, std::size_t>)
CAGE_FORCE_INLINE constexpr Real(std::size_t other) noexcept : value((value_type)other)
{}

explicit constexpr Real(Rads other) noexcept;
explicit constexpr Real(Degs other) noexcept;

Expand Down Expand Up @@ -635,71 +642,71 @@ namespace cage
CAGE_CORE_API Transform operator+(Vec3 l, Transform r) noexcept;

#define GCHL_GENERATE(OPERATOR) \
CAGE_FORCE_INLINE constexpr Real &operator OPERATOR##=(Real &l, Real r) noexcept \
CAGE_FORCE_INLINE constexpr Real &operator OPERATOR##=(Real & l, Real r) noexcept \
{ \
return l = l OPERATOR r; \
} \
CAGE_FORCE_INLINE constexpr Rads &operator OPERATOR##=(Rads &l, Rads r) noexcept \
CAGE_FORCE_INLINE constexpr Rads &operator OPERATOR##=(Rads & l, Rads r) noexcept \
{ \
return l = l OPERATOR r; \
} \
CAGE_FORCE_INLINE constexpr Rads &operator OPERATOR##=(Rads &l, Real r) noexcept \
CAGE_FORCE_INLINE constexpr Rads &operator OPERATOR##=(Rads & l, Real r) noexcept \
{ \
return l = l OPERATOR r; \
} \
CAGE_FORCE_INLINE constexpr Degs &operator OPERATOR##=(Degs &l, Degs r) noexcept \
CAGE_FORCE_INLINE constexpr Degs &operator OPERATOR##=(Degs & l, Degs r) noexcept \
{ \
return l = l OPERATOR r; \
} \
CAGE_FORCE_INLINE constexpr Degs &operator OPERATOR##=(Degs &l, Real r) noexcept \
CAGE_FORCE_INLINE constexpr Degs &operator OPERATOR##=(Degs & l, Real r) noexcept \
{ \
return l = l OPERATOR r; \
} \
CAGE_FORCE_INLINE constexpr Vec2 &operator OPERATOR##=(Vec2 &l, Vec2 r) noexcept \
CAGE_FORCE_INLINE constexpr Vec2 &operator OPERATOR##=(Vec2 & l, Vec2 r) noexcept \
{ \
return l = l OPERATOR r; \
} \
CAGE_FORCE_INLINE constexpr Vec2 &operator OPERATOR##=(Vec2 &l, Real r) noexcept \
CAGE_FORCE_INLINE constexpr Vec2 &operator OPERATOR##=(Vec2 & l, Real r) noexcept \
{ \
return l = l OPERATOR r; \
} \
CAGE_FORCE_INLINE constexpr Vec3 &operator OPERATOR##=(Vec3 &l, Vec3 r) noexcept \
CAGE_FORCE_INLINE constexpr Vec3 &operator OPERATOR##=(Vec3 & l, Vec3 r) noexcept \
{ \
return l = l OPERATOR r; \
} \
CAGE_FORCE_INLINE constexpr Vec3 &operator OPERATOR##=(Vec3 &l, Real r) noexcept \
CAGE_FORCE_INLINE constexpr Vec3 &operator OPERATOR##=(Vec3 & l, Real r) noexcept \
{ \
return l = l OPERATOR r; \
} \
CAGE_FORCE_INLINE constexpr Vec4 &operator OPERATOR##=(Vec4 &l, Vec4 r) noexcept \
CAGE_FORCE_INLINE constexpr Vec4 &operator OPERATOR##=(Vec4 & l, Vec4 r) noexcept \
{ \
return l = l OPERATOR r; \
} \
CAGE_FORCE_INLINE constexpr Vec4 &operator OPERATOR##=(Vec4 &l, Real r) noexcept \
CAGE_FORCE_INLINE constexpr Vec4 &operator OPERATOR##=(Vec4 & l, Real r) noexcept \
{ \
return l = l OPERATOR r; \
} \
CAGE_FORCE_INLINE constexpr Vec2i &operator OPERATOR##=(Vec2i &l, Vec2i r) noexcept \
CAGE_FORCE_INLINE constexpr Vec2i &operator OPERATOR##=(Vec2i & l, Vec2i r) noexcept \
{ \
return l = l OPERATOR r; \
} \
CAGE_FORCE_INLINE constexpr Vec2i &operator OPERATOR##=(Vec2i &l, sint32 r) noexcept \
CAGE_FORCE_INLINE constexpr Vec2i &operator OPERATOR##=(Vec2i & l, sint32 r) noexcept \
{ \
return l = l OPERATOR r; \
} \
CAGE_FORCE_INLINE constexpr Vec3i &operator OPERATOR##=(Vec3i &l, Vec3i r) noexcept \
CAGE_FORCE_INLINE constexpr Vec3i &operator OPERATOR##=(Vec3i & l, Vec3i r) noexcept \
{ \
return l = l OPERATOR r; \
} \
CAGE_FORCE_INLINE constexpr Vec3i &operator OPERATOR##=(Vec3i &l, sint32 r) noexcept \
CAGE_FORCE_INLINE constexpr Vec3i &operator OPERATOR##=(Vec3i & l, sint32 r) noexcept \
{ \
return l = l OPERATOR r; \
} \
CAGE_FORCE_INLINE constexpr Vec4i &operator OPERATOR##=(Vec4i &l, Vec4i r) noexcept \
CAGE_FORCE_INLINE constexpr Vec4i &operator OPERATOR##=(Vec4i & l, Vec4i r) noexcept \
{ \
return l = l OPERATOR r; \
} \
CAGE_FORCE_INLINE constexpr Vec4i &operator OPERATOR##=(Vec4i &l, sint32 r) noexcept \
CAGE_FORCE_INLINE constexpr Vec4i &operator OPERATOR##=(Vec4i & l, sint32 r) noexcept \
{ \
return l = l OPERATOR r; \
}
Expand All @@ -710,11 +717,11 @@ namespace cage
GCHL_GENERATE(%);
#undef GCHL_GENERATE
#define GCHL_GENERATE(OPERATOR) \
CAGE_FORCE_INLINE constexpr Quat &operator OPERATOR##=(Quat &l, Quat r) noexcept \
CAGE_FORCE_INLINE constexpr Quat &operator OPERATOR##=(Quat & l, Quat r) noexcept \
{ \
return l = l OPERATOR r; \
} \
CAGE_FORCE_INLINE constexpr Quat &operator OPERATOR##=(Quat &l, Real r) noexcept \
CAGE_FORCE_INLINE constexpr Quat &operator OPERATOR##=(Quat & l, Real r) noexcept \
{ \
return l = l OPERATOR r; \
}
Expand All @@ -724,19 +731,19 @@ namespace cage
GCHL_GENERATE(/);
#undef GCHL_GENERATE
#define GCHL_GENERATE(OPERATOR) \
CAGE_FORCE_INLINE Mat3 &operator OPERATOR##=(Mat3 &l, Mat3 r) noexcept \
CAGE_FORCE_INLINE Mat3 &operator OPERATOR##=(Mat3 & l, Mat3 r) noexcept \
{ \
return l = l OPERATOR r; \
} \
CAGE_FORCE_INLINE Mat4 &operator OPERATOR##=(Mat4 &l, Mat4 r) noexcept \
CAGE_FORCE_INLINE Mat4 &operator OPERATOR##=(Mat4 & l, Mat4 r) noexcept \
{ \
return l = l OPERATOR r; \
} \
CAGE_FORCE_INLINE constexpr Mat3 &operator OPERATOR##=(Mat3 &l, Real r) noexcept \
CAGE_FORCE_INLINE constexpr Mat3 &operator OPERATOR##=(Mat3 & l, Real r) noexcept \
{ \
return l = l OPERATOR r; \
} \
CAGE_FORCE_INLINE constexpr Mat4 &operator OPERATOR##=(Mat4 &l, Real r) noexcept \
CAGE_FORCE_INLINE constexpr Mat4 &operator OPERATOR##=(Mat4 & l, Real r) noexcept \
{ \
return l = l OPERATOR r; \
}
Expand Down Expand Up @@ -1312,6 +1319,56 @@ namespace cage
return str + "(" + other[0] + "," + other[1] + "," + other[2] + "," + other[3] + ")";
}
}

// stupid macos
template<int = 0>
requires(!std::is_same_v<uint64, std::size_t>)
CAGE_FORCE_INLINE constexpr uint64 sqr(std::size_t x) noexcept
{
return x * x;
}
template<int = 0>
requires(!std::is_same_v<uint64, std::size_t>)
CAGE_FORCE_INLINE constexpr double sqrt(std::size_t x)
{
return sqrt((uint64)x);
}
template<int = 0>
requires(!std::is_same_v<uint64, std::size_t>)
CAGE_FORCE_INLINE constexpr uint64 abs(std::size_t x) noexcept
{
return x;
}
template<int = 0>
requires(!std::is_same_v<uint64, std::size_t>)
CAGE_FORCE_INLINE constexpr uint64 min(std::size_t a, std::size_t b) noexcept
{
return min((uint64)a, (uint64)b);
}
template<int = 0>
requires(!std::is_same_v<uint64, std::size_t>)
CAGE_FORCE_INLINE constexpr uint64 max(std::size_t a, std::size_t b) noexcept
{
return max((uint64)a, (uint64)b);
}
template<int = 0>
requires(!std::is_same_v<uint64, std::size_t>)
CAGE_FORCE_INLINE constexpr uint64 clamp(std::size_t v, std::size_t a, std::size_t b)
{
return clamp((uint64)v, (uint64)a, (uint64)b);
}
template<int = 0>
requires(!std::is_same_v<uint64, std::size_t>)
CAGE_FORCE_INLINE constexpr uint64 interpolate(std::size_t a, std::size_t b, Real f) noexcept
{
return interpolate((uint64)a, (uint64)b, f);
}
template<int = 0>
requires(!std::is_same_v<uint64, std::size_t>)
CAGE_FORCE_INLINE constexpr uint64 randomRange(std::size_t a, std::size_t b)
{
return randomRange((uint64)a, (uint64)b);
}
}

#endif // guard_math_h_c0d63c8d_8398_4b39_81b4_99671252b150_
2 changes: 1 addition & 1 deletion sources/libcore/audio/vorbis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ namespace cage
CAGE_ASSERT(size == 1 || nmemb == 1);
VorbisDecoder *impl = (VorbisDecoder *)datasource;
size_t r = size * nmemb;
r = min(r, impl->file->size() - impl->file->tell());
r = min(r, size_t(impl->file->size() - impl->file->tell()));
if (r > 0)
impl->file->read({ (char *)ptr, (char *)ptr + r });
return r;
Expand Down
2 changes: 1 addition & 1 deletion sources/libcore/filesystem/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ namespace cage
return false;

char buffer[String::MaxLength + 1]; // plus 1 to allow detecting that the line is too long
PointerRange<char> pr = { buffer, buffer + min(origLeft, sizeof(buffer)) };
PointerRange<char> pr = { buffer, buffer + min(origLeft, (uintPtr)sizeof(buffer)) };
read(pr);
try
{
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
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
Loading

0 comments on commit 89cf629

Please sign in to comment.