Skip to content

Commit

Permalink
fix osx framework download idempotency and fetch latest
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
h0tw1r3 committed Apr 11, 2024
1 parent a3a67fc commit dc5ec1e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 65 deletions.
54 changes: 3 additions & 51 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand Down
34 changes: 20 additions & 14 deletions Makefiles/Makefile.OSX
Original file line number Diff line number Diff line change
Expand Up @@ -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


###############################################################################
Expand Down Expand Up @@ -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 $@

0 comments on commit dc5ec1e

Please sign in to comment.