/ maint / binary_size
binary_size
 1  #!/usr/bin/env bash
 2  #
 3  # binary_size: Build arti with a given set of options, and
 4  # dump the binary size in a json format.
 5  
 6  set -euo pipefail
 7  
 8  ORIGDIR=$(pwd)
 9  TMPDIR=$(mktemp -d -t arti_binsize."XX""XX""XX")
10  trap 'cd "$ORIGDIR" && rm -rf "$TMPDIR"' 0
11  
12  RUST_TARGET=$(rustc -vV | sed -n 's|host: ||p')
13  
14  cd "$(dirname "$0")/.."
15  
16  echo "{"
17  echo "  \"date\": \"$(date -u -Iseconds)\","
18  echo "  \"head\": \"$(git rev-parse HEAD)\","
19  echo "  \"default_target\": \"$RUST_TARGET\","
20  echo "  \"options\": \"$*\","
21  
22  cargo build --locked --release "$@"
23  
24  cp ./target/release/arti "$TMPDIR"
25  cd "$TMPDIR"
26  
27  strip --strip-debug arti
28  gzip -9 -k arti
29  xz -9 -k arti
30  
31  du -sb arti arti.gz arti.xz | sed -e 's/\(\S*\)\s\(\S*\)/  "\2": \1,/;'
32  echo "}"
33