2023-01-25 17:35:53 +00:00
|
|
|
#!/usr/bin/env bash
|
2021-11-08 20:01:15 +00:00
|
|
|
#
|
2022-02-17 17:56:33 +00:00
|
|
|
# binary_size: Build arti with a given set of options, and
|
2021-11-08 20:01:15 +00:00
|
|
|
# dump the binary size in a json format.
|
|
|
|
|
2022-05-25 12:10:55 +01:00
|
|
|
set -euo pipefail
|
2021-11-08 20:01:15 +00:00
|
|
|
|
|
|
|
ORIGDIR=$(pwd)
|
2023-03-21 12:32:15 +00:00
|
|
|
TMPDIR=$(mktemp -d -t arti_binsize."XX""XX""XX")
|
2021-11-08 20:01:15 +00:00
|
|
|
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 --release "$@"
|
|
|
|
|
|
|
|
cp ./target/release/arti "$TMPDIR"
|
|
|
|
cd "$TMPDIR"
|
|
|
|
|
|
|
|
strip --strip-debug arti
|
|
|
|
gzip -9 -k arti
|
|
|
|
xz -9 -k arti
|
|
|
|
|
|
|
|
du -sb arti arti.gz arti.xz | sed -e 's/\(\S*\)\s\(\S*\)/ "\2": \1,/;'
|
|
|
|
echo "}"
|
|
|
|
|