Skip to content

Commit c553786

Browse files
committed
fix ci tests for macos
1 parent 2c24b37 commit c553786

File tree

9 files changed

+113
-82
lines changed

9 files changed

+113
-82
lines changed

.github/workflows/tests.yml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,9 @@ jobs:
241241
- name: Versions
242242
run: |
243243
cmake --version
244+
git --version
244245
clang --version
245246
clang++ --version
246-
git --version
247247
248248
- uses: actions/checkout@v4
249249
with:
@@ -268,29 +268,25 @@ jobs:
268268
269269
270270
MacOS:
271-
name: macos-${{ matrix.build-config }}
272-
runs-on: macos-latest
273-
env:
274-
LDFLAGS: "-L/opt/homebrew/opt/llvm/lib"
275-
CPPFLAGS: "-I/opt/homebrew/opt/llvm/include"
276-
CC: /opt/homebrew/opt/llvm/bin/clang
277-
CXX: /opt/homebrew/opt/llvm/bin/clang++
271+
name: macos-${{ matrix.os-version }}-${{ matrix.build-config }}
272+
runs-on: macos-${{ matrix.os-version }}
278273
strategy:
279274
fail-fast: false
280275
matrix:
276+
os-version: [14, 15]
281277
build-config: [debug, release]
282278

283279
steps:
284280
- name: Install packages
285281
run: |
286-
brew install nasm llvm
282+
brew install nasm
287283
288284
- name: Versions
289285
run: |
290286
cmake --version
291287
git --version
292-
${CC} --version
293-
${CXX} --version
288+
clang --version
289+
clang++ --version
294290
295291
- uses: actions/checkout@v4
296292
with:
@@ -311,3 +307,11 @@ jobs:
311307
run: |
312308
cd build/result/${{ matrix.build-config }}
313309
./cage-test-core
310+
311+
- name: List dependencies
312+
run: |
313+
cd build/result/${{ matrix.build-config }}
314+
echo "cage-core:"
315+
otool -L libcage-core.dylib
316+
echo "cage-engine:"
317+
otool -L libcage-engine.dylib

cmake/cage_build_configuration.cmake

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,22 @@ macro(cage_build_configuration)
8585
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -flto")
8686
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto")
8787

88-
# prevent requiring executable stack (Linux only)
89-
if(NOT APPLE)
90-
add_link_options(-Wl,-z,noexecstack)
91-
endif()
92-
9388
# disable some warnings
9489
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-attributes")
9590
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-attributes -Wno-abi")
9691
endif()
9792

93+
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
94+
# prevent requiring executable stack
95+
add_link_options(-Wl,-z,noexecstack)
96+
endif()
97+
98+
if(APPLE)
99+
# disable more warnings
100+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations")
101+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
102+
endif()
103+
98104
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
99105
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-assume") # __builtin_assume has side effects that are discarded
100106
endif()

externals/avir/dummy.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
void avir_dummy_unused_symbol_to_force_cpp_compilation()
22
{
3-
// do nothing
4-
}
3+
// do nothing
4+
}

externals/dualmc/dummy.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
void dualmc_dummy_unused_symbol_to_force_cpp_compilation()
22
{
3-
// do nothing
4-
}
3+
// do nothing
4+
}

externals/fastnoise/dummy.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
void fastnoise_dummy_unused_symbol_to_force_cpp_compilation()
22
{
3-
// do nothing
4-
}
3+
// do nothing
4+
}

sources/libcore/filesystem/realFiles.cpp

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,27 @@
66
#define ftell64 _ftelli64
77
#define fseek invalidFunctionFseek
88
#define ftell invalidFunctionFtell
9-
#else
9+
#endif
10+
11+
#ifdef CAGE_SYSTEM_LINUX
12+
#define _FILE_OFFSET_BITS 64
13+
#include <dirent.h>
14+
#include <sys/stat.h>
15+
#include <unistd.h>
16+
#define fseek64 fseeko64
17+
#define ftell64 ftello64
18+
#endif
19+
20+
#ifdef CAGE_SYSTEM_MAC
1021
#define _FILE_OFFSET_BITS 64
1122
#include <dirent.h>
1223
#include <sys/stat.h>
1324
#include <unistd.h>
14-
#ifdef CAGE_SYSTEM_MAC
15-
#define fseek64 fseeko
16-
#define ftell64 ftello
17-
#define pread64 pread
18-
#define pwrite64 pwrite
19-
#include <mach-o/dyld.h>
20-
#else
21-
#define fseek64 fseeko64
22-
#define ftell64 ftello64
23-
#endif
25+
#include <mach-o/dyld.h>
26+
#define fseek64 fseeko
27+
#define ftell64 ftello
28+
#define pread64 pread
29+
#define pwrite64 pwrite
2430
#endif
2531

2632
#include "files.h"

sources/libcore/string.cpp

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,14 @@ namespace cage
185185

186186
#ifdef CAGE_SYSTEM_MAC
187187
// macOS doesn't support from_chars for floating point yet
188+
188189
void fromString(const char *s, uint32 n, float &value)
189190
{
190191
if (n == 0)
191192
CAGE_THROW_ERROR(Exception, "empty string cannot be converted to float");
192193

193194
// Check for leading or trailing whitespace
194-
if (n > 0 && (std::isspace(s[0]) || std::isspace(s[n-1])))
195+
if (n > 0 && (std::isspace(s[0]) || std::isspace(s[n - 1])))
195196
{
196197
CAGE_LOG_THROW(Stringizer() + "input string: " + s);
197198
CAGE_THROW_ERROR(Exception, "string with leading or trailing whitespace cannot be converted to float");
@@ -218,7 +219,7 @@ namespace cage
218219
CAGE_THROW_ERROR(Exception, "empty string cannot be converted to double");
219220

220221
// Check for leading or trailing whitespace
221-
if (n > 0 && (std::isspace(s[0]) || std::isspace(s[n-1])))
222+
if (n > 0 && (std::isspace(s[0]) || std::isspace(s[n - 1])))
222223
{
223224
CAGE_LOG_THROW(Stringizer() + "input string: " + s);
224225
CAGE_THROW_ERROR(Exception, "string with leading or trailing whitespace cannot be converted to double");
@@ -249,8 +250,10 @@ namespace cage
249250
CAGE_THROW_ERROR(Exception, "failed conversion of float to string");
250251
// Remove trailing zeros
251252
char *p = s + result - 1;
252-
while (p > s && *p == '0') p--;
253-
if (*p == '.') p--;
253+
while (p > s && *p == '0')
254+
p--;
255+
if (*p == '.')
256+
p--;
254257
*(++p) = '\0';
255258
return numeric_cast<uint32>(p - s);
256259
}
@@ -265,27 +268,32 @@ namespace cage
265268
CAGE_THROW_ERROR(Exception, "failed conversion of double to string");
266269
// Remove trailing zeros
267270
char *p = s + result - 1;
268-
while (p > s && *p == '0') p--;
269-
if (*p == '.') p--;
271+
while (p > s && *p == '0')
272+
p--;
273+
if (*p == '.')
274+
p--;
270275
*(++p) = '\0';
271276
return numeric_cast<uint32>(p - s);
272277
}
278+
273279
#else // CAGE_SYSTEM_MAC
274-
#define GCHL_GENERATE(TYPE) \
275-
uint32 toString(char *s, uint32 n, TYPE value) \
276-
{ \
277-
const auto [p, ec] = std::to_chars(s, s + n, value, std::chars_format::fixed); \
278-
if (ec != std::errc()) \
279-
CAGE_THROW_ERROR(Exception, "failed conversion of " CAGE_STRINGIZE(TYPE) " to string"); \
280-
*p = 0; \
281-
return numeric_cast<uint32>(p - s); \
282-
} \
283-
GCHL_FROMSTRING(TYPE)
280+
281+
#define GCHL_GENERATE(TYPE) \
282+
uint32 toString(char *s, uint32 n, TYPE value) \
283+
{ \
284+
const auto [p, ec] = std::to_chars(s, s + n, value, std::chars_format::fixed); \
285+
if (ec != std::errc()) \
286+
CAGE_THROW_ERROR(Exception, "failed conversion of " CAGE_STRINGIZE(TYPE) " to string"); \
287+
*p = 0; \
288+
return numeric_cast<uint32>(p - s); \
289+
} \
290+
GCHL_FROMSTRING(TYPE)
284291

285292
GCHL_GENERATE(float);
286293
GCHL_GENERATE(double);
294+
#undef GCHL_GENERATE
295+
287296
#endif // CAGE_SYSTEM_MAC
288-
#undef GCHL_GENERATE
289297

290298
uint32 toString(char *s, uint32 n, bool value)
291299
{

sources/libcore/systemInformation.cpp

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,25 @@
55
#include <powerbase.h> // CallNtPowerInformation
66
#pragma comment(lib, "PowrProf.lib") // CallNtPowerInformation
77
#pragma comment(lib, "Advapi32.lib") // RegGetValue
8-
#else
8+
#endif
9+
10+
#ifdef CAGE_SYSTEM_LINUX
11+
#include <algorithm>
12+
#include <cstdlib> // getenv
13+
#include <sstream>
14+
#include <string>
15+
#endif
16+
17+
#ifdef CAGE_SYSTEM_MAC
918
#include <algorithm>
1019
#include <cstdlib> // getenv
1120
#include <sstream>
1221
#include <string>
13-
#ifdef CAGE_SYSTEM_MAC
14-
#include <mach/mach.h>
15-
#include <mach/vm_statistics.h>
16-
#include <mach/mach_host.h>
17-
#include <sys/sysctl.h>
18-
#include <unistd.h> // gethostname
19-
#endif
22+
#include <mach/mach.h>
23+
#include <mach/vm_statistics.h>
24+
#include <mach/mach_host.h>
25+
#include <sys/sysctl.h>
26+
#include <unistd.h> // gethostname
2027
#endif
2128

2229
#include <cage-core/concurrent.h> // currentProcessId
@@ -100,17 +107,17 @@ namespace cage
100107
return Stringizer() + readString("ProductName") + " " + readString("DisplayVersion") + " (" + readString("CurrentVersion") + ", " + readUint("CurrentMajorVersionNumber") + "." + readUint("CurrentMinorVersionNumber") + ", " + readString("CurrentBuildNumber") + ", " + readString("EditionID") + ", " + readString("InstallationType") + ")";
101108
#elif defined(CAGE_SYSTEM_MAC)
102109
// Get macOS version using sysctlbyname
103-
char versionStr[256] = {0};
110+
char versionStr[256] = { 0 };
104111
size_t size = sizeof(versionStr);
105112
sysctlbyname("kern.osproductversion", versionStr, &size, nullptr, 0);
106113

107114
// Get build version
108-
char buildStr[256] = {0};
115+
char buildStr[256] = { 0 };
109116
size = sizeof(buildStr);
110117
sysctlbyname("kern.osversion", buildStr, &size, nullptr, 0);
111118

112119
// Get kernel version
113-
char kernelStr[256] = {0};
120+
char kernelStr[256] = { 0 };
114121
size = sizeof(kernelStr);
115122
sysctlbyname("kern.version", kernelStr, &size, nullptr, 0);
116123

0 commit comments

Comments
 (0)