From dc5ec1ec848f226c20ff856de7a544ed7aa4bf20 Mon Sep 17 00:00:00 2001 From: Jeffrey Clark Date: Sun, 7 Apr 2024 12:43:43 -0500 Subject: [PATCH] fix osx framework download idempotency and fetch latest * make Frameworks order only dep * use file name variable in target rules * osx build with latest sdl2 frameworks like CI * remove macos sdl lookup workflow steps --- .github/workflows/build.yml | 54 +++---------------------------------- Makefiles/Makefile.OSX | 34 +++++++++++++---------- 2 files changed, 23 insertions(+), 65 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 291dafeb..06b335ac 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -41,7 +41,7 @@ jobs: makefile: Makefile.OSX shell: bash archive: tar - archive_files: Frameworks/ + archive_files: Frameworks/*.framework runs-on: ${{ matrix.os }} defaults: run: @@ -53,54 +53,6 @@ jobs: run: | sudo apt update sudo apt install -y libsdl2-dev libsdl2-net-dev - - if: startsWith(matrix.os, 'macos') - name: Find latest macos SDL2 release - id: find_sdl - uses: joutvhu/get-release@v1 - with: - debug: true - owner: libsdl-org - repo: SDL - latest: true - pattern: 'release-2\..*' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - if: startsWith(matrix.os, 'macos') - name: Find latest macos SDL2_net release - id: find_sdl_net - uses: joutvhu/get-release@v1 - with: - debug: true - owner: libsdl-org - repo: SDL_net - latest: true - pattern: 'release-2\..*' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Install macos build dependencies - if: startsWith(matrix.os, 'macos') - run: | - cd Frameworks - echo ::group::download sdl2 - curl -fLo SDL2.dmg https://github.com/libsdl-org/SDL/releases/download/${{ steps.find_sdl.outputs.tag_name }}/SDL2-${{ steps.find_sdl.outputs.name }}.dmg - echo ::endgroup:: - echo ::group::download sdl_net - curl -fLo SDL2_net.dmg https://github.com/libsdl-org/SDL_net/releases/download/${{ steps.find_sdl_net.outputs.tag_name }}/SDL2_net-${{ steps.find_sdl_net.outputs.name }}.dmg - echo ::endgroup:: - echo ::group::attach dmg - hdiutil attach -quiet SDL2.dmg - hdiutil attach -quiet SDL2_net.dmg - echo ::endgroup:: - echo ::group::copy frameworks - cp -r /Volumes/SDL2/SDL2.framework . - cp -r /Volumes/SDL2_net/SDL2_net.framework . - xattr -dr com.apple.quarantine SDL2.framework - xattr -dr com.apple.quarantine SDL2_net.framework - echo ::endgroup:: - echo ::group::detach dmg - hdiutil detach -quiet /Volumes/SDL2 - hdiutil detach -quiet /Volumes/SDL2_net - echo ::endgroup:: - name: Install windows build dependencies if: startsWith(matrix.os, 'windows') uses: msys2/setup-msys2@v2 @@ -112,9 +64,9 @@ jobs: mingw64/mingw-w64-x86_64-gcc mingw64/mingw-w64-x86_64-SDL2 mingw64/mingw-w64-x86_64-SDL2_net - - name: Build with Symbols + - name: Build run: | - OPT_INPUT="${{ github.event.inputs.opt }}" + OPT_INPUT="${{ inputs.opt }}" make -f Makefiles/${{ matrix.makefile }} release NET_BOARD=1 OUTFILE=../supermodel${{ matrix.outfile_ext }} OPT="${OPT_INPUT:-"-O3 -g"}" LDOPT="" - name: Validate run: ./supermodel${{ matrix.outfile_ext }} -print-games diff --git a/Makefiles/Makefile.OSX b/Makefiles/Makefile.OSX index bdc0d8b8..035d44e5 100644 --- a/Makefiles/Makefile.OSX +++ b/Makefiles/Makefile.OSX @@ -67,7 +67,7 @@ endif PLATFORM_CXXFLAGS = -F./Frameworks $(SDL_CFLAGS) -DSUPERMODEL_OSX PLATFORM_LDFLAGS = -F./Frameworks $(SDL_LIBS) -lz -lm -lstdc++ -Wl,-rpath,@executable_path/../Frameworks -Wl,-rpath,@executable_path/Frameworks -PLATFORM_DIRS = Frameworks Frameworks/SDL2_net.framework Frameworks/SDL2.framework +PLATFORM_DIRS = Frameworks/SDL2_net.framework Frameworks/SDL2.framework ############################################################################### @@ -95,31 +95,37 @@ clean: ############################################################################### Frameworks: - $(info Creating directory : Frameworks) + $(info Creating directory : $@) $(SILENT)mkdir Frameworks -Frameworks/SDL2.dmg: Frameworks - $(info Downloading Framework : Frameworks/SDL2.dmg) - $(SILENT)curl https://github.com/libsdl-org/SDL/releases/download/release-2.30.1/SDL2-2.30.1.dmg -sfL --output $@ - $(SILENT)touch $@ +Frameworks/SDL2.dmg.url: | Frameworks + $(info Finding Latest Release : $@) + $(SILENT)curl -fs https://api.github.com/repos/libsdl-org/SDL/releases/latest | awk '/"browser_download_url": "(.*\.dmg)"/{m++; if (m>1) exit; print $$2 }' | tr -d '"' > $@ -Frameworks/SDL2_net.dmg: Frameworks - $(info Downloading Framework : Frameworks/SDL2_net.dmg) - $(SILENT)curl https://github.com/libsdl-org/SDL_net/releases/download/release-2.2.0/SDL2_net-2.2.0.dmg -sfL --output $@ - $(SILENT)touch $@ +Frameworks/SDL2_net.dmg.url: | Frameworks + $(info Finding Latest Release : $@) + $(SILENT)curl -fs https://api.github.com/repos/libsdl-org/SDL_net/releases/latest | awk '/"browser_download_url": "(.*\.dmg)"/{m++; if (m>1) exit; print $$2 }' | tr -d '"' > $@ + +Frameworks/SDL2.dmg: Frameworks/SDL2.dmg.url + $(info Downloading : $(shell cat $@.url)) + $(SILENT)curl "$(shell cat $@.url)" -sfL --output $@ + +Frameworks/SDL2_net.dmg: Frameworks/SDL2_net.dmg.url + $(info Downloading : $(shell cat $@.url)) + $(SILENT)curl "$(shell cat $@.url)" -sfL --output $@ Frameworks/SDL2.framework: Frameworks/SDL2.dmg - $(info Extracting Framework : SDL2) + $(info Extracting : $@) $(SILENT)hdiutil attach -quiet Frameworks/SDL2.dmg $(SILENT)cp -r /Volumes/SDL2/SDL2.framework Frameworks - $(SILENT)xattr -dr com.apple.quarantine Frameworks/SDL2.framework + $(SILENT)xattr -dr com.apple.quarantine $@ $(SILENT)hdiutil detach -quiet /Volumes/SDL2 $(SILENT)touch $@ Frameworks/SDL2_net.framework: Frameworks/SDL2_net.dmg - $(info Extracting Framework : SDL2_net) + $(info Extracting : $@) $(SILENT)hdiutil attach -quiet Frameworks/SDL2_net.dmg $(SILENT)cp -r /Volumes/SDL2_net/SDL2_net.framework Frameworks - $(SILENT)xattr -dr com.apple.quarantine Frameworks/SDL2_net.framework + $(SILENT)xattr -dr com.apple.quarantine $@ $(SILENT)hdiutil detach -quiet /Volumes/SDL2_net $(SILENT)touch $@ \ No newline at end of file