-
Notifications
You must be signed in to change notification settings - Fork 0
/
export
executable file
·160 lines (141 loc) · 5.5 KB
/
export
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/usr/bin/env bash
REALNAME="Antsy Alien Attack Pico"
LOWERNAME="${REALNAME,,}"
FILENAME="${LOWERNAME// /-}"
VER="1.$(date +%y.%j%H)"
P8="main.p8"
OPTS="-windowed -0 -home ./config -root_path ."
function pico_export() {
local TARGET="${1}"
local EXPORT_PATH="exports/${TARGET}"
mkdir -p "${EXPORT_PATH}"
# Custom PICO-8 HTML template with WebGL CRT
if [ ! -e ./config/plates/crtplate.html ]; then
wget -qc "https://raw.githubusercontent.com/carlc27843/pico8-crt-plate/main/crtplate.html" -O "./config/plates/crtplate.html"
sed -i "s/PICO-8 Cartridge/${REALNAME}/" ./config/plates/crtplate.html
fi
# Add any target specific export options
local EXPORT_OPTS=""
if [[ ${TARGET} == *wasm* ]]; then
EXPORT_OPTS+=" -w"
fi
if [[ ${TARGET} == *crt* ]]; then
EXPORT_OPTS+=" -p ./config/plates/crtplate"
fi
# Show EXIT in the main menu by default
echo "native_build=false" > build_config.p8
# Export the target
case "${TARGET}" in
bin)
echo "native_build=true" > build_config.p8
pico8 "${OPTS}" -export "${EXPORT_PATH}/${FILENAME}.bin" "${P8}"
mv "${EXPORT_PATH}/${FILENAME}.bin"/*.zip exports/
mkdir -p "${EXPORT_PATH}/${FILENAME}.bin/macos"
mv "${EXPORT_PATH}/${FILENAME}.bin/${FILENAME}.app" "${EXPORT_PATH}/${FILENAME}.bin/macos/"
;;
cart)
pico8 "${OPTS}" -export "${EXPORT_PATH}/${FILENAME}.p8.png" "${P8}"
cp "${EXPORT_PATH}/${FILENAME}.p8.png" exports/
;;
html*|wasm*)
pico8 "${OPTS}" -export "${EXPORT_OPTS} ${EXPORT_PATH}/${FILENAME}.html" "${P8}";;
esac
# Make .zip of the HTML/WASM export for Itch.io.
if [[ ${TARGET} == *html* ]] || [[ ${TARGET} == *wasm* ]]; then
mv "${EXPORT_PATH}/${FILENAME}.html" "exports/${TARGET}/index.html"
pushd "${EXPORT_PATH}"
zip -9 "../${FILENAME}_${TARGET}.zip" *
popd
fi
}
function pico_appimage() {
# https://www.booleanworld.com/creating-linux-apps-run-anywhere-appimage/
if [ -x appimagetool-x86_64.AppImage ]; then
local TARGET="AppImage"
mkdir -p "exports/${TARGET}"
local EXPORT_PATH="exports/${TARGET}"
cp "exports/bin/${FILENAME}.bin/linux/antsy-alien-attack-pico" "${EXPORT_PATH}/"
cp "exports/bin/${FILENAME}.bin/linux/data.pod" "${EXPORT_PATH}/"
cp "exports/bin/${FILENAME}.bin/linux/${FILENAME}.png" "${EXPORT_PATH}/"
cp packaging/antsy-alien-attack-pico.desktop "${EXPORT_PATH}/"
cat << 'EOF' > "${EXPORT_PATH}/AppRun"
#!/bin/sh
cd "$(dirname "$0")"
exec ./antsy-alien-attack-pico
EOF
chmod 755 "${EXPORT_PATH}/AppRun"
./appimagetool-x86_64.AppImage "${EXPORT_PATH}" "exports/${FILENAME}_${VER}.AppImage"
chmod +x "exports/${FILENAME}_${VER}.AppImage"
else
wget -c "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage" -O ./appimagetool-x86_64.AppImage
chmod 755 ./appimagetool-x86_64.AppImage
fi
}
function pico_flatpak() {
# https://www.steinzone.de/wordpress/how-to-build-a-flatpak-of-a-sdl2-game-commander-genius/
return
}
function pico_snap() {
if [ -x /snap/bin/snapcraft ]; then
local TARGET="snap"
mkdir -p "exports/${TARGET}/snap"
cp -a packaging/snap/* "exports/${TARGET}/snap/"
local EXPORT_PATH="exports/${TARGET}"
mkdir -p "${EXPORT_PATH}/game"
cp "exports/bin/${FILENAME}.bin/linux/"* "${EXPORT_PATH}/game/"
cp packaging/antsy-alien-attack-pico.desktop "${EXPORT_PATH}/game/"
sed -i s'|Icon=antsy-alien-attack-pico|Icon=/antsy-alien-attack-pico\.png|' "${EXPORT_PATH}/game/antsy-alien-attack-pico.desktop"
sed -i "s/version: '0'/version: '${VER}'/" "${EXPORT_PATH}/snap/snapcraft.yaml"
pushd "${EXPORT_PATH}"
snapcraft
popd
mv "${EXPORT_PATH}/"*.snap exports/
fi
}
function pico_deb() {
if [ -x /usr/bin/dpkg-buildpackage ]; then
local TARGET="deb"
mkdir -p "exports/${TARGET}/debian"
cp -a packaging/debian/* "exports/${TARGET}/debian/"
local EXPORT_PATH="exports/${TARGET}"
mkdir -p "${EXPORT_PATH}/opt/antsy-alien-attack-pico"
mkdir -p "${EXPORT_PATH}/usr/share/icons/hicolor/128x128/apps"
mkdir -p "${EXPORT_PATH}/usr/share/applications"
cp "exports/bin/${FILENAME}.bin/linux/antsy-alien-attack-pico" "${EXPORT_PATH}/opt/antsy-alien-attack-pico/"
cp "exports/bin/${FILENAME}.bin/linux/data.pod" "${EXPORT_PATH}/opt/antsy-alien-attack-pico/"
cp "exports/bin/${FILENAME}.bin/linux/${FILENAME}.png" "${EXPORT_PATH}/usr/share/icons/hicolor/128x128/apps/antsy-alien-attack-pico.png"
cp packaging/antsy-alien-attack-pico.desktop "${EXPORT_PATH}/usr/share/applications/"
pushd "${EXPORT_PATH}"
dch --newversion="${VER}" --distribution unstable "Release ${REALNAME} ${VER}"
dpkg-buildpackage --build=binary --no-check-builddeps --compression=gzip
popd
fi
}
function pico_dmg() {
# https://stackoverflow.com/a/7553878
if [ -x /usr/local/bin/dmg ]; then
genisoimage -V "${REALNAME}" -D -R -apple -no-pad -o "exports/${FILENAME}_uncompressed.dmg" "exports/bin/${FILENAME}.bin/macos/"
dmg "exports/${FILENAME}_uncompressed.dmg" "exports/${FILENAME}.dmg"
else
genisoimage -V "${REALNAME}" -D -R -apple -no-pad -o "exports/${FILENAME}.dmg" "exports/bin/${FILENAME}.bin/macos/"
fi
}
if ! grep -q __label__ "${P8}"; then
echo "ERROR! Your pico-8 project doesn't have a label."
echo " Run your game and press F2 to create one"
exit 1
fi
rm -rf exports
mkdir -p exports
echo "${VER}" > exports/version.txt
pico_export bin
pico_export cart
pico_export html
pico_export html_crt
pico_export wasm
pico_export wasm_crt
pico_appimage
pico_deb
pico_dmg
#pico_snap
pico_snap