Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 11 additions & 45 deletions .github/workflows/Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,51 +7,17 @@ on:

jobs:
Build:
runs-on: macos-15
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- macos-latest
- ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run gtar as root
run: sudo chown root /opt/homebrew/bin/gtar && sudo chmod u+s /opt/homebrew/bin/gtar
- name: Get latest Swift version
id: swift-version
run: |
DOWNLOAD=$(curl "https://raw.githubusercontent.com/apple/swift-org-website/main/_data/builds/development/xcode.yml" | yq '.[0].download')
DIR=$(curl "https://raw.githubusercontent.com/apple/swift-org-website/main/_data/builds/development/xcode.yml" | yq '.[0].dir')
echo "name=$DIR" >> $GITHUB_OUTPUT
echo "url=https://download.swift.org/development/xcode/$DIR/$DOWNLOAD" >> $GITHUB_OUTPUT
- name: Cache Swift
id: cache-swift
uses: actions/cache@v4
with:
path: /Library/Developer/Toolchains/${{ steps.swift-version.outputs.name }}.xctoolchain
key: ${{ steps.swift-version.outputs.name }}
- if: ${{ steps.cache-swift.outputs.cache-hit != 'true' }}
name: Install latest Swift version
run: |
curl -L -sS --show-error --fail ${{ steps.swift-version.outputs.url }} -o swift.pkg
sudo installer -pkg swift.pkg -target /
- name: Get latest Playdate SDK version
id: playdate-version
run: |
URL=$(curl -Ls -o /dev/null -w %{url_effective} --head "https://download.panic.com/playdate_sdk/PlaydateSDK-latest.zip")
echo "name=$(echo $URL | awk -F '/' '{print $(NF)}' | awk -F '.' '{OFS="."; print $1,$2,$3}')" >> $GITHUB_OUTPUT
echo "url=$URL" >> $GITHUB_OUTPUT
- name: Cache Playdate
id: cache-playdate
uses: actions/cache@v4
with:
path: |
~/Developer/PlaydateSDK
/usr/local/playdate
key: ${{ steps.playdate-version.outputs.name }}
- if: ${{ steps.cache-playdate.outputs.cache-hit != 'true' }}
name: Install Playdate SDK
run: |
curl -L -sS --show-error --fail ${{ steps.playdate-version.outputs.url }} -o PlaydateSDK-latest.zip
unzip PlaydateSDK-latest.zip
sudo installer -pkg "PlaydateSDK.pkg" -target /
- name: Select Xcode
run: |
sudo xcode-select -s '/Applications/Xcode_16.2.app'
- name: 'Install Swift Toolchain'
uses: finnvoor/swiftly-action@main
- name: 'Install Playdate SDK'
uses: finnvoor/playdatesdk-action@main
- name: Build
run: set -o pipefail && $(xcrun -f swift -toolchain "swift latest") build -c release | xcbeautify --renderer github-actions
run: swift build -c release
File renamed without changes.
46 changes: 46 additions & 0 deletions .github/workflows/Examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Examples
on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
FlappySwift:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- macos-latest
- ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: 'Install Swift Toolchain'
uses: finnvoor/swiftly-action@main
- name: 'Install Playdate SDK'
uses: finnvoor/playdatesdk-action@main
- name: 'Install arm-none-eabi-gcc'
if: ${{ runner.os == 'Linux' }}
run: sudo apt-get install -y --no-install-recommends gcc-arm-none-eabi libnewlib-arm-none-eabi
- name: Build
working-directory: Examples/FlappySwift
run: swift package pdc
Pong:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- macos-latest
- ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: 'Install Swift Toolchain'
uses: finnvoor/swiftly-action@main
- name: 'Install Playdate SDK'
uses: finnvoor/playdatesdk-action@main
- name: 'Install arm-none-eabi-gcc'
if: ${{ runner.os == 'Linux' }}
run: sudo apt-get install -y --no-install-recommends gcc-arm-none-eabi libnewlib-arm-none-eabi
- name: Build
working-directory: Examples/Pong
run: swift package pdc
1 change: 1 addition & 0 deletions .swift-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
main-snapshot-2025-05-25
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM --platform=linux/amd64 swiftlang/swift:nightly-main-jammy

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
wget \
gcc-arm-none-eabi \
libnewlib-arm-none-eabi \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

RUN mkdir -p /opt
WORKDIR /opt
RUN wget https://download.panic.com/playdate_sdk/Linux/PlaydateSDK-latest.tar.gz \
&& tar -zxvf PlaydateSDK-latest.tar.gz \
&& rm PlaydateSDK-latest.tar.gz \
&& mv PlaydateSDK-* PlaydateSDK \
&& chmod -R 755 /opt

ENV PLAYDATE_SDK_PATH=/opt/PlaydateSDK \
ARM_NONE_EABI_GCC_PATH=/usr/lib/gcc/arm-none-eabi/10.3.1 \
ARM_NONE_EABI_SYSROOT_PATH=/usr/lib/arm-none-eabi

RUN mkdir /.swiftpm /.cache && chmod 777 /.swiftpm /.cache

RUN mkdir -p /mnt
VOLUME /mnt
WORKDIR /mnt
22 changes: 19 additions & 3 deletions Examples/FlappySwift/.swiftpm/build-and-run.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
#! /bin/sh
set -e
(killall 'Playdate Simulator' || true) 2>/dev/null

cleanup() {
osascript -e 'quit app "Playdate Simulator"' 2>/dev/null
}

trap cleanup EXIT

SWIFT=$(xcrun -f swift -toolchain "swift latest")

cd ..
swift package pdc
~/Developer/PlaydateSDK/bin/Playdate\ Simulator.app/Contents/MacOS/Playdate\ Simulator .build/plugins/PDCPlugin/outputs/$PRODUCT_NAME.pdx
"$SWIFT" package pdc

# Create a symbolic link to the compiled pdx in the Playdate Simulator Games dir
# This allows browsing the pdx as a sideloaded game, helpful for checking icons
if [ -L ~/Developer/PlaydateSDK/Disk/Games/$PRODUCT_NAME.pdx ]; then
rm -rf ~/Developer/PlaydateSDK/Disk/Games/$PRODUCT_NAME.pdx
fi
ln -s "$(pwd)/.build/plugins/PDCPlugin/outputs/$PRODUCT_NAME.pdx" ~/Developer/PlaydateSDK/Disk/Games/$PRODUCT_NAME.pdx

~/Developer/PlaydateSDK/bin/Playdate\ Simulator.app/Contents/MacOS/Playdate\ Simulator ~/Developer/PlaydateSDK/Disk/Games/$PRODUCT_NAME.pdx
26 changes: 10 additions & 16 deletions Examples/FlappySwift/Package.swift
Original file line number Diff line number Diff line change
@@ -1,42 +1,36 @@
// swift-tools-version: 5.10
// swift-tools-version: 6.1

import Foundation
import PackageDescription

let gccIncludePrefix =
"/usr/local/playdate/gcc-arm-none-eabi-9-2019-q4-major/lib/gcc/arm-none-eabi/9.2.1"

let playdateSDKPath: String = if let path = Context.environment["PLAYDATE_SDK_PATH"] {
path
} else {
"\(Context.environment["HOME"]!)/Developer/PlaydateSDK/"
}
/// Hack to force Xcode builds to not produce a dylib, since linking fails
/// without a toolset.json specified. Ideally this can be removed if/when
/// Xcode gains toolset.json support.
let xcode = (Context.environment["XPC_SERVICE_NAME"]?.count ?? 0) > 2

let package = Package(
name: "FlappySwift",
platforms: [.macOS(.v14)],
products: [.library(name: "FlappySwift", targets: ["FlappySwift"])],
products: [.library(name: "FlappySwift", type: xcode ? nil : .dynamic, targets: ["FlappySwift"])],
dependencies: [
.package(path: "../.."),
],
targets: [
.target(
name: "FlappySwift",
dependencies: [.product(name: "PlaydateKit", package: "PlaydateKit")],
exclude: ["Resources"],
swiftSettings: [
.enableExperimentalFeature("Embedded"),
.unsafeFlags([
"-whole-module-optimization",
"-Xfrontend", "-disable-objc-interop",
"-Xfrontend", "-disable-stack-protector",
"-Xfrontend", "-function-sections",
"-Xfrontend", "-gline-tables-only",
"-Xcc", "-DTARGET_EXTENSION",
"-Xcc", "-I", "-Xcc", "\(gccIncludePrefix)/include",
"-Xcc", "-I", "-Xcc", "\(gccIncludePrefix)/include-fixed",
"-Xcc", "-I", "-Xcc", "\(gccIncludePrefix)/../../../../arm-none-eabi/include",
"-I", "\(playdateSDKPath)/C_API"
"-Xcc", "-DTARGET_EXTENSION"
]),
]
],
)
]
)
4 changes: 2 additions & 2 deletions Examples/FlappySwift/Sources/FlappySwift/entry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import PlaydateKit
/// Boilerplate entry code
nonisolated(unsafe) var game: Game!
@_cdecl("eventHandler") func eventHandler(
pointer: UnsafeMutableRawPointer!,
pointer: UnsafeMutablePointer<PlaydateAPI>!,
event: System.Event,
_: CUnsignedInt
arg _: CUnsignedInt
) -> CInt {
switch event {
case .initialize:
Expand Down

This file was deleted.

22 changes: 19 additions & 3 deletions Examples/Pong/.swiftpm/build-and-run.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
#! /bin/sh
set -e
(killall 'Playdate Simulator' || true) 2>/dev/null

cleanup() {
osascript -e 'quit app "Playdate Simulator"' 2>/dev/null
}

trap cleanup EXIT

SWIFT=$(xcrun -f swift -toolchain "swift latest")

cd ..
swift package pdc
~/Developer/PlaydateSDK/bin/Playdate\ Simulator.app/Contents/MacOS/Playdate\ Simulator .build/plugins/PDCPlugin/outputs/$PRODUCT_NAME.pdx
"$SWIFT" package pdc

# Create a symbolic link to the compiled pdx in the Playdate Simulator Games dir
# This allows browsing the pdx as a sideloaded game, helpful for checking icons
if [ -L ~/Developer/PlaydateSDK/Disk/Games/$PRODUCT_NAME.pdx ]; then
rm -rf ~/Developer/PlaydateSDK/Disk/Games/$PRODUCT_NAME.pdx
fi
ln -s "$(pwd)/.build/plugins/PDCPlugin/outputs/$PRODUCT_NAME.pdx" ~/Developer/PlaydateSDK/Disk/Games/$PRODUCT_NAME.pdx

~/Developer/PlaydateSDK/bin/Playdate\ Simulator.app/Contents/MacOS/Playdate\ Simulator ~/Developer/PlaydateSDK/Disk/Games/$PRODUCT_NAME.pdx
1 change: 1 addition & 0 deletions Examples/Pong/.swiftpm/cache
26 changes: 10 additions & 16 deletions Examples/Pong/Package.swift
Original file line number Diff line number Diff line change
@@ -1,42 +1,36 @@
// swift-tools-version: 5.10
// swift-tools-version: 6.1

import Foundation
import PackageDescription

let gccIncludePrefix =
"/usr/local/playdate/gcc-arm-none-eabi-9-2019-q4-major/lib/gcc/arm-none-eabi/9.2.1"

let playdateSDKPath: String = if let path = Context.environment["PLAYDATE_SDK_PATH"] {
path
} else {
"\(Context.environment["HOME"]!)/Developer/PlaydateSDK/"
}
/// Hack to force Xcode builds to not produce a dylib, since linking fails
/// without a toolset.json specified. Ideally this can be removed if/when
/// Xcode gains toolset.json support.
let xcode = (Context.environment["XPC_SERVICE_NAME"]?.count ?? 0) > 2

let package = Package(
name: "Pong",
platforms: [.macOS(.v14)],
products: [.library(name: "Pong", targets: ["Pong"])],
products: [.library(name: "Pong", type: xcode ? nil : .dynamic, targets: ["Pong"])],
dependencies: [
.package(path: "../.."),
],
targets: [
.target(
name: "Pong",
dependencies: [.product(name: "PlaydateKit", package: "PlaydateKit")],
exclude: ["Resources"],
swiftSettings: [
.enableExperimentalFeature("Embedded"),
.unsafeFlags([
"-whole-module-optimization",
"-Xfrontend", "-disable-objc-interop",
"-Xfrontend", "-disable-stack-protector",
"-Xfrontend", "-function-sections",
"-Xfrontend", "-gline-tables-only",
"-Xcc", "-DTARGET_EXTENSION",
"-Xcc", "-I", "-Xcc", "\(gccIncludePrefix)/include",
"-Xcc", "-I", "-Xcc", "\(gccIncludePrefix)/include-fixed",
"-Xcc", "-I", "-Xcc", "\(gccIncludePrefix)/../../../../arm-none-eabi/include",
"-I", "\(playdateSDKPath)/C_API"
"-Xcc", "-DTARGET_EXTENSION"
]),
]
],
)
]
)
4 changes: 2 additions & 2 deletions Examples/Pong/Sources/Pong/entry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import PlaydateKit
/// Boilerplate entry code
nonisolated(unsafe) var game: Game!
@_cdecl("eventHandler") func eventHandler(
pointer: UnsafeMutableRawPointer!,
pointer: UnsafeMutablePointer<PlaydateAPI>!,
event: System.Event,
_: CUnsignedInt
arg _: CUnsignedInt
) -> CInt {
switch event {
case .initialize:
Expand Down
Loading