|
1 | 1 | #!/usr/bin/env bash
|
2 |
| -# playdate.bash |
3 |
| - |
4 | 2 | set -euo pipefail
|
5 |
| -#set -x |
6 |
| - |
7 |
| -DATETIME="$(date +%Y-%m-%d_%H%M%S).pdx" |
8 |
| - |
9 |
| -: ${1?"Usage: $0 [docker] srcdir [buildir]"} |
10 |
| -SRC_DIR="${1}" |
11 |
| -BUILD_DIR="${2-}" |
12 |
| - |
13 |
| -if [[ -d "$SRC_DIR" ]]; then |
14 |
| - SRC_DIR="$(realpath $SRC_DIR)" |
15 |
| -else |
16 |
| - echo "$SRC_DIR: directory not found." |
17 |
| - false |
18 |
| -fi |
19 |
| - |
20 |
| -if [[ -f "$SRC_DIR/pdxinfo" ]]; then |
21 |
| - PROJECT="$(grep -m1 'bundleID=' src/pdxinfo |awk -F '=' '{ print $2 }' )" |
22 |
| - VERSION="$(grep -m1 'version=' src/pdxinfo |awk -F '=' '{ print $2 }' )" |
23 |
| - BUILD="$(grep -m1 'buildNumber=' src/pdxinfo |awk -F '=' '{ print $2 }' )" |
24 |
| - FILENAME="${PROJECT}_${VERSION}-build${BUILD}_$(date +%Y-%m-%d_%H%M%S).pdx" |
25 |
| -else |
26 |
| - FILENAME="playdate_$(date +%Y-%m-%d_%H%M%S).pdx" |
27 |
| -fi |
28 |
| - |
29 |
| - |
30 |
| -if [[ -z "$BUILD_DIR" ]]; then |
31 |
| - if [[ -d "$SRC_DIR/../build" ]]; then |
32 |
| - BUILD_DIR="$(realpath $SRC_DIR/../build)" |
33 |
| - else |
34 |
| - BUILD_DIR="/tmp/playdate" |
35 |
| - mkdir -p "$BUILD_DIR" |
36 |
| - fi |
37 |
| -fi |
38 |
| - |
39 |
| -function macos_build { |
40 |
| - export PLAYDATE_SDK_PATH="${PLAYDATE_SDK_PATH:-$HOME/Developer/PlaydateSDK/}" |
41 |
| - MAINLUA="$SRC_DIR/main.lua" |
42 |
| - OUTPDX="$BUILD_DIR/$FILENAME" |
43 |
| - "$PLAYDATE_SDK_PATH/bin/pdc" $MAINLUA $OUTPDX |
44 |
| -} |
45 |
| - |
46 |
| -function docker_build { |
47 |
| - DOCKER_TAG="playdate" |
48 |
| - OUTPDX="$BUILD_DIR/$FILENAME" |
49 |
| - docker run \ |
50 |
| - --mount "type=bind,source=$BUILD_DIR,target=/app/build" \ |
51 |
| - --mount "type=bind,source=$(realpath $SRC_DIR),target=/app/src/,readonly" \ |
52 |
| - -it $DOCKER_TAG bash -c "pdc /app/src /app/build/$FILENAME" |
53 |
| - |
54 |
| -} |
55 | 3 |
|
56 |
| -#macos_build |
57 |
| -docker_build |
58 |
| -echo "$OUTPDX" |
59 |
| -open "$OUTPDX" |
| 4 | +BUNDLE="$(basename $PWD).pdx" |
| 5 | +pdc src/main.lua "$BUNDLE" |
| 6 | +open "$BUNDLE" |
0 commit comments