-
Notifications
You must be signed in to change notification settings - Fork 2
/
install_single_cartridge.sh
executable file
·66 lines (55 loc) · 2.4 KB
/
install_single_cartridge.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
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
#!/bin/bash
# Install a specific cartridge for the game to the default
# PICO-8 carts location
# This is required if you need to play with multiple carts,
# as other carts will only be loaded in PICO-8 carts location
# ! This does not install data and is not useful on its own,
# make sure to use install_single_cartridge_with_data.sh or
# to manually copy data cartridges after this.
# Usage: install_single_cartridge.sh cartridge_suffix config [--itest]
# cartridge_suffix see data/cartridges.txt for the list of cartridge names
# config build config (e.g. 'debug' or 'release'. Default: 'debug')
# -i, --itest pass this option to build an itest instead of a normal game cartridge
# Currently only supported on Linux
# Configuration: paths
data_path="$(dirname "$0")/data"
# check that source and output paths have been provided
if ! [[ $# -ge 1 && $# -le 4 ]] ; then
echo "install_single_cartridge.sh takes 1 to 3 params + option value, provided $#:
\$1: cartridge_suffix (see data/cartridges.txt for the list of cartridge names)
\$2: config ('debug', 'release', etc. Default: 'debug')
-i, --itest: Pass this option to build an itest instead of a normal game cartridge."
exit 1
fi
# Configuration: cartridge
cartridge_stem="picosonic"
version=`cat "$data_path/version.txt"`
cartridge_suffix="$1"; shift
config="$1"; shift
# ! This is a short version for the usual while-case syntax, but in counterpart
# ! it doesn't support reordering (--itest must be after config)
if [[ $1 == '-i' || $1 == '--itest' ]]; then
itest=true
shift
fi
if [[ "$itest" == true ]]; then
# itest cartridges enforce special config 'itest' and ignore passed config
config='itest'
cartridge_extra_suffix='itest_all_'
else
cartridge_extra_suffix=''
fi
output_path="build/v${version}_${config}"
cartridge_filepath="${output_path}/${cartridge_stem}_${cartridge_extra_suffix}${cartridge_suffix}.p8${suffix}"
# Linux only
carts_dirpath="$HOME/.lexaloffle/pico-8/carts"
install_dirpath="${carts_dirpath}/${cartridge_stem}/v${version}_${config}"
if [[ ! -f "${cartridge_filepath}" ]]; then
echo "File ${cartridge_filepath} could not be found, cannot install. Make sure you built it first."
exit 1
fi
mkdir -p "${install_dirpath}"
echo "Installing ${cartridge_filepath} in ${install_dirpath} ..."
# trailing slash just to make sure we copy to a directory
cp "${cartridge_filepath}" "${install_dirpath}/"
echo "Done."