Fix mac exe path and mac debugging

This commit is contained in:
Krzosa Karol
2024-01-27 22:01:14 +01:00
parent 7b8dd6fd50
commit 5a528e1ef8
2 changed files with 32 additions and 3 deletions

View File

@@ -386,13 +386,20 @@ OS_API OS_Date OS_GetDate(void) {
#include <time.h> #include <time.h>
#include <dirent.h> #include <dirent.h>
OS_API bool OS_EnableTerminalColors(void) { return true; } #if OS_MAC
OS_API bool OS_IsAbsolute(S8_String path) { OS_API S8_String OS_GetExePath(MA_Arena *arena) {
bool result = path.len >= 1 && path.str[0] == '/'; char buf[PATH_MAX];
uint32_t bufsize = PATH_MAX;
if (_NSGetExecutablePath(buf, &bufsize)) {
return S8_MakeEmpty();
}
S8_String result = S8_Copy(arena, S8_Make(buf, bufsize));
return result; return result;
} }
#else
OS_API S8_String OS_GetExePath(MA_Arena *arena) { OS_API S8_String OS_GetExePath(MA_Arena *arena) {
char buffer[PATH_MAX] = {}; char buffer[PATH_MAX] = {};
if (readlink("/proc/self/exe", buffer, PATH_MAX) == -1) { if (readlink("/proc/self/exe", buffer, PATH_MAX) == -1) {
@@ -402,6 +409,15 @@ OS_API S8_String OS_GetExePath(MA_Arena *arena) {
return result; return result;
} }
#endif
OS_API bool OS_EnableTerminalColors(void) { return true; }
OS_API bool OS_IsAbsolute(S8_String path) {
bool result = path.len >= 1 && path.str[0] == '/';
return result;
}
OS_API S8_String OS_GetExeDir(MA_Arena *arena) { OS_API S8_String OS_GetExeDir(MA_Arena *arena) {
S8_String path = OS_GetExePath(arena); S8_String path = OS_GetExePath(arena);
S8_String dir = S8_ChopLastSlash(path); S8_String dir = S8_ChopLastSlash(path);

View File

@@ -6,21 +6,34 @@
int main() { int main() {
TestSimpleInsertAndIntegrity(); TestSimpleInsertAndIntegrity();
IO_Printf("TestSimpleInsertAndIntegrity() - DONE\n");
TestStrings(); TestStrings();
IO_Printf("TestStrings() - DONE\n");
TestExclusiveArenaBackedArray(); TestExclusiveArenaBackedArray();
IO_Printf("TestExclusiveArenaBackedArray() - DONE\n");
TestRemoveForLoop(); TestRemoveForLoop();
IO_Printf("TestRemoveForLoop() - DONE\n");
TestBasic(); TestBasic();
IO_Printf("TestBasic() - DONE\n");
TestReverseLoop(); TestReverseLoop();
IO_Printf("TestReverseLoop() - DONE\n");
TestCopy(); TestCopy();
IO_Printf("TestCopy() - DONE\n");
TestBuffer(); TestBuffer();
IO_Printf("TestBuffer() - DONE\n");
TestCreateAllocate(); TestCreateAllocate();
IO_Printf("TestCreateAllocate() - DONE\n");
TestBootstrap(); TestBootstrap();
IO_Printf("TestBootstrap() - DONE\n");
TestBootstrapExclusive(); TestBootstrapExclusive();
IO_Printf("TestBootstrapExclusive() - DONE\n");
TestBootstrapArenaClear(); TestBootstrapArenaClear();
IO_Printf("TestBootstrapArenaClear() - DONE\n");
TestClexer(); TestClexer();
IO_Printf("TestClexer() - DONE\n");
// Unicode iteration over codepoints using For // Unicode iteration over codepoints using For
{ {