summaryrefslogtreecommitdiff
path: root/maint/binary_size
blob: b6cad514dd2e32894d033c780f7da80676929e30 (plain)
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
#!/usr/bin/env bash
#
# binary_size: Build arti with a given set of options, and
# dump the binary size in a json format.

set -euo pipefail

ORIGDIR=$(pwd)
TMPDIR=$(mktemp -d -t arti_binsize."XX""XX""XX")
trap 'cd "$ORIGDIR" && rm -rf "$TMPDIR"' 0

RUST_TARGET=$(rustc -vV | sed -n 's|host: ||p')

cd "$(dirname "$0")/.."

echo "{"
echo "  \"date\": \"$(date -u -Iseconds)\","
echo "  \"head\": \"$(git rev-parse HEAD)\","
echo "  \"default_target\": \"$RUST_TARGET\","
echo "  \"options\": \"$*\","

cargo build --locked --profile=release-small "$@"

cp ./target/release-small/arti "$TMPDIR"
cd "$TMPDIR"

gzip -9 -k arti
xz -9 -k arti

du -sb arti arti.gz arti.xz | sed -e 's/\(\S*\)\s\(\S*\)/  "\2": \1,/;'
echo "}"