-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·35 lines (26 loc) · 997 Bytes
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#! /bin/bash
# Run this from the directory where your game's Package.swift lives:
#
# $ cd Examples/HelloWorld
# $ ../../build.sh
# $ open HelloWorld.pdx
set -e
ROOT=$(dirname $0)
SDK="$HOME/Developer/PlaydateSDK/C_API"
BUILD_DIR=.build/arm64-apple-macosx/debug
APP_NAME=$(swift package describe | head -1 | cut -w -f 2)
# Hackishly copy the API headers into the library's source dir because I don't know to get SPM
# to refer to them from the include path:
cp -r "$SDK"/pd_api* $ROOT/swift-pd/Sources/CPlaydate/
# Compile and link the game (and the Playdate library along with it):
swift build
# Run pdc to convert/assemble any required assets:
echo "Assembling app assets with pdc $(pdc --version)"
touch Sources/Resources/pdex.bin
pdc Sources/Resources "$APP_NAME"
rm Sources/Resources/pdex.bin
rm "${APP_NAME}.pdx/pdex.bin"
# Copy the game library into place:
cp "${BUILD_DIR}/lib${APP_NAME}.dylib" "${APP_NAME}.pdx/pdex.dylib"
# ls -lh "${APP_NAME}.pdx"
echo "done: ${APP_NAME}.pdx"