diff options
| author | Per Larsson <[email protected]> | 2022-01-05 10:05:22 +0100 |
|---|---|---|
| committer | Per Larsson <[email protected]> | 2022-01-05 10:05:22 +0100 |
| commit | da1ebfbac38e37eab58873a3f1bd7ed75a46c188 (patch) | |
| tree | 385ce8bc8a311c46de675c3ae3df9c48a7572618 | |
| parent | Support GC configuration from LUA. (diff) | |
| parent | Added a build of BLAKE3 for Mac (diff) | |
| download | zen-nightly.tar.xz zen-nightly.zip | |
Merge branch 'main' of https://github.com/EpicGames/zennightly
| -rw-r--r-- | thirdparty/BLAKE3/lib/Mac_x64/libblake3.a | bin | 0 -> 78200 bytes | |||
| -rwxr-xr-x | thirdparty/Oodle/lib/Mac_x64/liboo2coremac64.a | bin | 0 -> 10864632 bytes | |||
| -rw-r--r-- | xmake.lua | 2 | ||||
| -rw-r--r-- | zencore/filesystem.cpp | 42 | ||||
| -rw-r--r-- | zencore/xmake.lua | 5 |
5 files changed, 38 insertions, 11 deletions
diff --git a/thirdparty/BLAKE3/lib/Mac_x64/libblake3.a b/thirdparty/BLAKE3/lib/Mac_x64/libblake3.a Binary files differnew file mode 100644 index 000000000..c2ed0276a --- /dev/null +++ b/thirdparty/BLAKE3/lib/Mac_x64/libblake3.a diff --git a/thirdparty/Oodle/lib/Mac_x64/liboo2coremac64.a b/thirdparty/Oodle/lib/Mac_x64/liboo2coremac64.a Binary files differnew file mode 100755 index 000000000..0bcb1e6b9 --- /dev/null +++ b/thirdparty/Oodle/lib/Mac_x64/liboo2coremac64.a @@ -57,7 +57,7 @@ if is_os("windows") then -- add_ldflags("/MAP") end -if is_os("linux") then +if is_os("linux") or is_os("macosx") then add_cxxflags("-Wno-unused-value") add_cxxflags("-Wno-strict-aliasing") add_cxxflags("-Wno-implicit-fallthrough") diff --git a/zencore/filesystem.cpp b/zencore/filesystem.cpp index 9274b35de..95b92277b 100644 --- a/zencore/filesystem.cpp +++ b/zencore/filesystem.cpp @@ -18,11 +18,21 @@ # include <atlfile.h> # include <winioctl.h> # include <winnt.h> -#else +#endif + +#if ZEN_PLATFORM_LINUX # include <dirent.h> # include <fcntl.h> # include <sys/stat.h> -# include <sys/statvfs.h> +# include <unistd.h> +#endif + +#if ZEN_PLATFORM_MAC +# include <dirent.h> +# include <fcntl.h> +# include <libproc.h> +# include <sys/stat.h> +# include <sys/syslimits.h> # include <unistd.h> #endif @@ -442,7 +452,8 @@ CloneFile(std::filesystem::path FromPath, std::filesystem::path ToPath) return false; #elif ZEN_PLATFORM_MAC /* clonefile() syscall if APFS */ -# error not implemented + ZEN_UNUSED(FromPath, ToPath); + ZEN_ERROR("CloneFile() is not implemented on this platform"); return false; #endif // ZEN_PLATFORM_WINDOWS } @@ -921,18 +932,23 @@ PathFromHandle(void* NativeHandle) ZEN_UNUSED(FinalLength); return FullPath; -#elif ZEN_PLATFORM_LINUX - char Link[256]; +#elif ZEN_PLATFORM_LINUX || ZEN_PLATFORM_MAC +# if ZEN_PLATFORM_LINUX + const char* SelfFdPathFormat = "/proc/self/fd/%d"; +# else + const char* SelfFdPathFormat = "dev/fd/%d"; +# endif + + char Link[PATH_MAX]; char Path[64]; - sprintf(Path, "/proc/self/fd/%d", int(uintptr_t(NativeHandle))); + + sprintf(Path, SelfFdPathFormat, int(uintptr_t(NativeHandle))); ssize_t BytesRead = readlink(Path, Link, sizeof(Link) - 1); if (BytesRead <= 0) return std::filesystem::path(); Link[BytesRead] = '\0'; return Link; -#else -# error Unimplemented platform #endif // ZEN_PLATFORM_WINDOWS } @@ -952,8 +968,14 @@ GetRunningExecutablePath() Link[BytesRead] = '\0'; return Link; -#else -# error Unimplemented platform +#elif ZEN_PLATFORM_MAC + char Buffer[PROC_PIDPATHINFO_MAXSIZE]; + + int SelfPid = GetCurrentProcessId(); + if (proc_pidpath(SelfPid, Buffer, sizeof(Buffer)) <= 0) + return {}; + + return Buffer; #endif // ZEN_PLATFORM_WINDOWS } diff --git a/zencore/xmake.lua b/zencore/xmake.lua index 7475d7e1c..1af64f5c2 100644 --- a/zencore/xmake.lua +++ b/zencore/xmake.lua @@ -16,6 +16,11 @@ target('zencore') add_links("blake3") add_links("oo2corelinux64") add_syslinks("pthread") + elseif is_os("macosx") then + add_linkdirs("$(projectdir)/thirdparty/BLAKE3/lib/Mac_x64") + add_linkdirs("$(projectdir)/thirdparty/Oodle/lib/Mac_x64") + add_links("blake3") + add_links("oo2coremac64") end add_options("zentrace") add_packages( |