Repository navigation
Expand file tree
/
Copy pathbundle-tools.sh
More file actions
executable file
·95 lines (83 loc) · 3.76 KB
/
Copy pathbundle-tools.sh
File metadata and controls
executable file
·95 lines (83 loc) · 3.76 KB
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
#!/bin/sh
# Put the desktop tools into a rockbox.zip produced by `make zip`.
#
# database_pb.exe and artcache_pb.exe ship in .rockbox/tools/. They bring the
# player's database and art cache up to date from the computer, with the
# player's own tagcache.c and art_cache.c, so the files they write are the
# ones the firmware beside them reads.
#
# soundscan.exe ships as .rockbox/tools/soundscan.exe together with the codecs
# it loads, which are the player's own decoders built for the host: the tool
# has to measure with the same code the player does or the numbers it writes
# would not mean what the player reads. Without that directory beside it the
# tool loads no decoder at all and reports every track as unreadable.
#
# Each tool is made from the same tree every time, so it writes the paths and
# record layout the firmware beside it reads. A failed make stops the script:
# shipping the previous binary would ship one out of step with the firmware.
#
# They are Windows binaries and need a Windows simulator build to link against,
# which not every machine has. A missing simulator is reported and the tools
# skipped rather than fatal: the firmware in the zip is complete without it.
# release.sh checks for it, so a published zip still cannot go out without one.
#
# Usage: run from inside a build dir, or pass the build dir as an argument.
set -e
ROOT="$(cd "$(dirname "$0")" && pwd)"
BUILDDIR="$(cd "${1:-.}" && pwd)"
ZIP="$BUILDDIR/rockbox.zip"
if [ ! -f "$ZIP" ]; then
echo "bundle-tools.sh: no rockbox.zip in $BUILDDIR -- run 'make zip' first" >&2
exit 1
fi
TOOL="$ROOT/tools/soundscan/soundscan.exe"
# The Windows simulator supplies the autoconf.h the tool compiles against and
# the codecs it loads, which are the player's own built for the host.
CODECS="$ROOT/build-sim-ipodvideo-win32"
if [ ! -f "$CODECS/autoconf.h" ]; then
echo "bundle-tools.sh: NOT shipping the desktop tools -- no Windows simulator" >&2
echo "bundle-tools.sh: build one first: ./build-sim.sh 5g win" >&2
exit 0
fi
# make decides whether the binary is current; under set -e its failure, with
# its own output, ends the script before anything is added to the zip.
echo "bundle-tools.sh: making soundscan.exe"
make -C "$ROOT/tools/soundscan" win
echo "bundle-tools.sh: making database_pb.exe"
make -C "$ROOT/tools/database_pb" win
echo "bundle-tools.sh: making artcache_pb.exe"
make -C "$ROOT/tools/artcache_pb" win
STAGE="$(mktemp -d)"
trap 'rm -rf "$STAGE"' EXIT
mkdir -p "$STAGE/.rockbox/tools/codecs"
cp "$TOOL" "$STAGE/.rockbox/tools/soundscan.exe"
cp "$ROOT/tools/database_pb/database_pb.exe" "$STAGE/.rockbox/tools/"
cp "$ROOT/tools/artcache_pb/artcache_pb.exe" "$STAGE/.rockbox/tools/"
n=0
for c in "$CODECS"/lib/rbcodec/codecs/*.codec; do
[ -f "$c" ] || continue
cp "$c" "$STAGE/.rockbox/tools/codecs/"
n=$((n + 1))
done
# Stripped in the staging directory and never in the tree: these carry debug
# symbols the player has no use for, and they are most of the size -- a codec
# goes from 155K to 20K, the whole directory from twelve megabytes to under
# two. What stays behind in tools/ keeps its symbols for debugging.
STRIP=""
for s in x86_64-w64-mingw32-strip strip; do
command -v "$s" >/dev/null 2>&1 && { STRIP="$s"; break; }
done
if [ -n "$STRIP" ]; then
"$STRIP" "$STAGE/.rockbox/tools/soundscan.exe" 2>/dev/null || true
"$STRIP" "$STAGE/.rockbox/tools/database_pb.exe" 2>/dev/null || true
"$STRIP" "$STAGE/.rockbox/tools/artcache_pb.exe" 2>/dev/null || true
for c in "$STAGE"/.rockbox/tools/codecs/*.codec; do
"$STRIP" "$c" 2>/dev/null || true
done
fi
if [ "$n" -eq 0 ]; then
echo "bundle-tools.sh: NOT shipping the desktop tools -- no host codecs" >&2
exit 0
fi
(cd "$STAGE" && zip -qr "$ZIP" .rockbox)
echo "bundled the desktop tools ($n codecs) into $ZIP"