From cea20b6f313304a1ad17f899c5515516cb8b7609 Mon Sep 17 00:00:00 2001 From: Catherine Reprobate Date: Sat, 16 Nov 2024 12:52:49 -0800 Subject: [PATCH 1/9] osx build --- CMakeLists.txt | 2 ++ include/PR/os_libc.h | 8 ++++++++ port/src/libultra.c | 3 +++ src/include/platform.h | 4 ++++ 4 files changed, 17 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5cdfb6ccd..528460e65 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -215,6 +215,8 @@ if(NOT GL_LIBRARY) set(GL_LIBRARY opengl32) elseif(NINTENDO_SWITCH) set(GL_LIBRARY EGL glapi drm_nouveau) + elseif(APPLE) + set(GL_LIBRARY "-framework OpenGL") else() set(GL_LIBRARY GL) endif() diff --git a/include/PR/os_libc.h b/include/PR/os_libc.h index 6ec0f4db8..79497b143 100644 --- a/include/PR/os_libc.h +++ b/include/PR/os_libc.h @@ -31,10 +31,14 @@ #define _OS_LIBC_H_ #include "os_pfs.h" +#include "platform.h" #ifndef PLATFORM_N64 #include #endif +#ifdef PLATFORM_OSX +#include +#endif #ifdef _LANGUAGE_C_PLUS_PLUS extern "C" { @@ -84,9 +88,13 @@ extern "C" { /* byte string operations */ +#ifndef PLATFORM_OSX extern void bcopy(const void *, void *, size_t); +#endif extern int bcmp(const void *, const void *, size_t); +#ifndef PLATFORM_OSX extern void bzero(void *, size_t); +#endif /* Printf */ diff --git a/port/src/libultra.c b/port/src/libultra.c index 465a1e62c..c2e22cdb8 100644 --- a/port/src/libultra.c +++ b/port/src/libultra.c @@ -6,6 +6,7 @@ #include #include #include +#include "platform.h" #include "system.h" #include "input.h" #include "video.h" @@ -466,6 +467,7 @@ OSIntMask osSetIntMask(OSIntMask mask) /* libc compatibility wrappers */ +#ifndef PLATFORM_OSX #ifndef HAVE_BZERO void bzero(void *ptr, size_t size) { @@ -479,6 +481,7 @@ void bcopy(const void *src, void *dst, size_t n) memcpy(dst, src, n); } #endif +#endif #ifndef HAVE_BCMP s32 bcmp(const void *s1, const void *s2, size_t n) diff --git a/src/include/platform.h b/src/include/platform.h index 176fd83db..dfa62eb0f 100644 --- a/src/include/platform.h +++ b/src/include/platform.h @@ -10,6 +10,10 @@ #elif defined(__linux__) #define PLATFORM_POSIX 1 #define PLATFORM_LINUX 1 +// add osx +#elif defined(__APPLE__) + #define PLATFORM_POSIX 1 + #define PLATFORM_OSX 1 #else // assume POSIX-compatible #define PLATFORM_POSIX 1 From efda5a5f441342c3ef17e3de1787d889e42f4e5d Mon Sep 17 00:00:00 2001 From: fgsfds Date: Tue, 19 Nov 2024 17:37:19 +0100 Subject: [PATCH 2/9] port: also try GL4.1 core; a little bit of cleanup --- include/PR/os_libc.h | 2 -- port/fast3d/gfx_sdl2.cpp | 3 ++- port/src/libultra.c | 8 ++------ src/include/platform.h | 1 - 4 files changed, 4 insertions(+), 10 deletions(-) diff --git a/include/PR/os_libc.h b/include/PR/os_libc.h index 79497b143..42df41125 100644 --- a/include/PR/os_libc.h +++ b/include/PR/os_libc.h @@ -90,9 +90,7 @@ extern "C" { #ifndef PLATFORM_OSX extern void bcopy(const void *, void *, size_t); -#endif extern int bcmp(const void *, const void *, size_t); -#ifndef PLATFORM_OSX extern void bzero(void *, size_t); #endif diff --git a/port/fast3d/gfx_sdl2.cpp b/port/fast3d/gfx_sdl2.cpp index 181038d26..3b66eed33 100644 --- a/port/fast3d/gfx_sdl2.cpp +++ b/port/fast3d/gfx_sdl2.cpp @@ -130,7 +130,8 @@ static void gfx_sdl_init(const struct GfxWindowInitSettings *set) { { 0, 0, 0 }, // for command line override { 3, 0, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY }, { 3, 2, SDL_GL_CONTEXT_PROFILE_CORE }, - { 2, 1, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY }, + { 4, 1, SDL_GL_CONTEXT_PROFILE_CORE }, + { 2, 1, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY }, // will still require GLSL130 }; u32 glcore = false; diff --git a/port/src/libultra.c b/port/src/libultra.c index c2e22cdb8..c978d81a0 100644 --- a/port/src/libultra.c +++ b/port/src/libultra.c @@ -468,24 +468,20 @@ OSIntMask osSetIntMask(OSIntMask mask) /* libc compatibility wrappers */ #ifndef PLATFORM_OSX -#ifndef HAVE_BZERO + void bzero(void *ptr, size_t size) { memset(ptr, 0, size); } -#endif -#ifndef HAVE_BCOPY void bcopy(const void *src, void *dst, size_t n) { memcpy(dst, src, n); } -#endif -#endif -#ifndef HAVE_BCMP s32 bcmp(const void *s1, const void *s2, size_t n) { return memcmp(s1, s2, n); } + #endif diff --git a/src/include/platform.h b/src/include/platform.h index dfa62eb0f..79a1864e8 100644 --- a/src/include/platform.h +++ b/src/include/platform.h @@ -10,7 +10,6 @@ #elif defined(__linux__) #define PLATFORM_POSIX 1 #define PLATFORM_LINUX 1 -// add osx #elif defined(__APPLE__) #define PLATFORM_POSIX 1 #define PLATFORM_OSX 1 From b220d73f2c6557c1b676ad0c2c2e31615642c7da Mon Sep 17 00:00:00 2001 From: fgsfds Date: Tue, 19 Nov 2024 17:50:01 +0100 Subject: [PATCH 3/9] ci: add osx autobuilds --- .github/workflows/c-cpp.yml | 64 +++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 61dc8e3bb..1c22b34f8 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -151,6 +151,70 @@ jobs: path: bin/ retention-days: 0 + build-x86_64-osx: + runs-on: macos-14 + if: github.ref == 'refs/heads/port' + steps: + - name: Install dependencies + run: brew install cmake gcc python3 zlib git + - name: Build pd.x86_64 + run: | + cmake -G"Unix Makefiles" -Bbuild -DCMAKE_OSX_ARCHITECTURES=x86_64 . + cmake --build build --target pd -j4 --clean-first + - name: Build pd.pal.x86_64 + run: | + cmake -G"Unix Makefiles" -Bbuild_pal -DCMAKE_OSX_ARCHITECTURES=x86_64 -DROMID=pal-final . + cmake --build build_pal --target pd -j4 --clean-first + - name: Build pd.jpn.x86_64 + run: | + cmake -G"Unix Makefiles" -Bbuild_jpn -DCMAKE_OSX_ARCHITECTURES=x86_64 -DROMID=jpn-final . + cmake --build build_jpn --target pd -j4 --clean-first + - name: Prepare artifact for packaging + run: | + mkdir -p bin/data + cp build/pd.x86_64 bin/ + cp build_pal/pd.pal.x86_64 bin/ + cp build_jpn/pd.jpn.x86_64 bin/ + touch bin/data/put_your_rom_here.txt + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: pd-x86_64-osx + path: bin/ + retention-days: 0 + + build-arm64-osx: + runs-on: macos-14 + if: github.ref == 'refs/heads/port' + steps: + - name: Install dependencies + run: brew install cmake gcc python3 zlib git + - name: Build pd.arm64 + run: | + cmake -G"Unix Makefiles" -Bbuild -DCMAKE_OSX_ARCHITECTURES=arm64 . + cmake --build build --target pd -j4 --clean-first + - name: Build pd.pal.arm64 + run: | + cmake -G"Unix Makefiles" -Bbuild_pal -DCMAKE_OSX_ARCHITECTURES=arm64 -DROMID=pal-final . + cmake --build build_pal --target pd -j4 --clean-first + - name: Build pd.jpn.arm64 + run: | + cmake -G"Unix Makefiles" -Bbuild_jpn -DCMAKE_OSX_ARCHITECTURES=arm64 -DROMID=jpn-final . + cmake --build build_jpn --target pd -j4 --clean-first + - name: Prepare artifact for packaging + run: | + mkdir -p bin/data + cp build/pd.arm64 bin/ + cp build_pal/pd.pal.arm64 bin/ + cp build_jpn/pd.jpn.arm64 bin/ + touch bin/data/put_your_rom_here.txt + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: pd-arm64-osx + path: bin/ + retention-days: 0 + build-arm64-nswitch: runs-on: ubuntu-latest if: github.ref == 'refs/heads/port' From 103fb0e0e9a934a11453795a9e94ef0e5b46c3fa Mon Sep 17 00:00:00 2001 From: fgsfds Date: Tue, 19 Nov 2024 17:56:48 +0100 Subject: [PATCH 4/9] ci: what the fuck? --- .github/workflows/c-cpp.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 1c22b34f8..520a85dc5 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -159,6 +159,7 @@ jobs: run: brew install cmake gcc python3 zlib git - name: Build pd.x86_64 run: | + ls -la cmake -G"Unix Makefiles" -Bbuild -DCMAKE_OSX_ARCHITECTURES=x86_64 . cmake --build build --target pd -j4 --clean-first - name: Build pd.pal.x86_64 @@ -191,6 +192,7 @@ jobs: run: brew install cmake gcc python3 zlib git - name: Build pd.arm64 run: | + ls -la cmake -G"Unix Makefiles" -Bbuild -DCMAKE_OSX_ARCHITECTURES=arm64 . cmake --build build --target pd -j4 --clean-first - name: Build pd.pal.arm64 From 7d8e755fc733a72e369d2d245cea2fa1bfb5b5fe Mon Sep 17 00:00:00 2001 From: fgsfds Date: Tue, 19 Nov 2024 17:58:21 +0100 Subject: [PATCH 5/9] ci: forgor to checkout source --- .github/workflows/c-cpp.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 520a85dc5..a206ae34a 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -157,9 +157,10 @@ jobs: steps: - name: Install dependencies run: brew install cmake gcc python3 zlib git + - name: Checkout repository + uses: actions/checkout@v4 - name: Build pd.x86_64 run: | - ls -la cmake -G"Unix Makefiles" -Bbuild -DCMAKE_OSX_ARCHITECTURES=x86_64 . cmake --build build --target pd -j4 --clean-first - name: Build pd.pal.x86_64 @@ -190,9 +191,10 @@ jobs: steps: - name: Install dependencies run: brew install cmake gcc python3 zlib git + - name: Checkout repository + uses: actions/checkout@v4 - name: Build pd.arm64 run: | - ls -la cmake -G"Unix Makefiles" -Bbuild -DCMAKE_OSX_ARCHITECTURES=arm64 . cmake --build build --target pd -j4 --clean-first - name: Build pd.pal.arm64 From 31dbb5e7c6f8cd4f96c89884597efe84a2c06118 Mon Sep 17 00:00:00 2001 From: fgsfds Date: Tue, 19 Nov 2024 18:02:03 +0100 Subject: [PATCH 6/9] ci: osx: actually install SDL2 --- .github/workflows/c-cpp.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index a206ae34a..0c21ef396 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -156,7 +156,11 @@ jobs: if: github.ref == 'refs/heads/port' steps: - name: Install dependencies - run: brew install cmake gcc python3 zlib git + run: | + brew install cmake gcc python3 zlib git + wget http://libsdl.org/release/SDL2-2.30.9.dmg -O SDL2.dmg + hdiutil mount SDL2.dmg + sudo cp -vr /Volumes/SDL2/SDL2.framework /Library/Frameworks - name: Checkout repository uses: actions/checkout@v4 - name: Build pd.x86_64 @@ -177,6 +181,7 @@ jobs: cp build/pd.x86_64 bin/ cp build_pal/pd.pal.x86_64 bin/ cp build_jpn/pd.jpn.x86_64 bin/ + cp -vr /Library/Frameworks/SDL2.framework bin/ touch bin/data/put_your_rom_here.txt - name: Upload artifact uses: actions/upload-artifact@v4 @@ -190,7 +195,11 @@ jobs: if: github.ref == 'refs/heads/port' steps: - name: Install dependencies - run: brew install cmake gcc python3 zlib git + run: | + brew install cmake gcc python3 zlib git + wget http://libsdl.org/release/SDL2-2.30.9.dmg -O SDL2.dmg + hdiutil mount SDL2.dmg + sudo cp -vr /Volumes/SDL2/SDL2.framework /Library/Frameworks - name: Checkout repository uses: actions/checkout@v4 - name: Build pd.arm64 @@ -211,6 +220,7 @@ jobs: cp build/pd.arm64 bin/ cp build_pal/pd.pal.arm64 bin/ cp build_jpn/pd.jpn.arm64 bin/ + cp -vr /Library/Frameworks/SDL2.framework bin/ touch bin/data/put_your_rom_here.txt - name: Upload artifact uses: actions/upload-artifact@v4 From 9f43c906dbdc1627244ad478c3d5e23dd5c41c33 Mon Sep 17 00:00:00 2001 From: fgsfds Date: Tue, 19 Nov 2024 18:08:41 +0100 Subject: [PATCH 7/9] ci: osx: don't install packages already in runner; enable releases and port-net --- .github/workflows/c-cpp.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 0c21ef396..d22cb0d11 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -153,11 +153,10 @@ jobs: build-x86_64-osx: runs-on: macos-14 - if: github.ref == 'refs/heads/port' steps: - name: Install dependencies run: | - brew install cmake gcc python3 zlib git + brew install zlib wget http://libsdl.org/release/SDL2-2.30.9.dmg -O SDL2.dmg hdiutil mount SDL2.dmg sudo cp -vr /Volumes/SDL2/SDL2.framework /Library/Frameworks @@ -192,11 +191,10 @@ jobs: build-arm64-osx: runs-on: macos-14 - if: github.ref == 'refs/heads/port' steps: - name: Install dependencies run: | - brew install cmake gcc python3 zlib git + brew install zlib wget http://libsdl.org/release/SDL2-2.30.9.dmg -O SDL2.dmg hdiutil mount SDL2.dmg sudo cp -vr /Volumes/SDL2/SDL2.framework /Library/Frameworks @@ -304,7 +302,7 @@ jobs: publish-latest-build: runs-on: ubuntu-latest if: github.ref == 'refs/heads/port' - needs: [build-i686-windows, build-i686-linux, build-x86_64-windows, build-x86_64-linux, build-arm64-nswitch, build-flatpak-bundle] + needs: [build-i686-windows, build-i686-linux, build-x86_64-windows, build-x86_64-linux, build-arm64-nswitch, build-x86_64-osx, build-arm64-osx, build-flatpak-bundle] permissions: contents: write steps: From c7895d937f5a72584aade3165d886e0dcb377acd Mon Sep 17 00:00:00 2001 From: fgsfds Date: Tue, 19 Nov 2024 18:15:05 +0100 Subject: [PATCH 8/9] tools: fix the python warning about the \h --- tools/assetmgr/mklang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/assetmgr/mklang b/tools/assetmgr/mklang index a4dfbc8cc..b6a2dfb6e 100755 --- a/tools/assetmgr/mklang +++ b/tools/assetmgr/mklang @@ -89,7 +89,7 @@ The input string is UTF-8, and it needs to be re-encoded to a custom encoding. A lookup array is used for this. However, some UTF-8 characters appear multiple types with a different encoding. -For duplicates, we store the character in JSON as something like \habcd where +For duplicates, we store the character in JSON as something like \\habcd where abcd is the target value in hex. """ def encode_jp(string): From 140f6f24e89fd5dbba70632e386757ecb64535c3 Mon Sep 17 00:00:00 2001 From: fgsfds Date: Tue, 19 Nov 2024 18:17:16 +0100 Subject: [PATCH 9/9] ci: actually update osx builds to releases --- .github/workflows/c-cpp.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index d22cb0d11..0b7e6de0b 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -318,6 +318,8 @@ jobs: pushd ci-artifacts tar czf ../ci-release/pd-i686-linux.tar.gz pd-i686-linux tar czf ../ci-release/pd-x86_64-linux.tar.gz pd-x86_64-linux + tar cJf ../ci-release/pd-x86_64-osx.tar.xz pd-x86_64-osx + tar cJf ../ci-release/pd-arm64-osx.tar.xz pd-arm64-osx zip -r ../ci-release/pd-i686-windows.zip pd-i686-windows zip -r ../ci-release/pd-x86_64-windows.zip pd-x86_64-windows zip -r ../ci-release/pd-arm64-nswitch.zip pd-arm64-nswitch