From 223a95a74fe4a67b97520a4d8ab6383114aa8abd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Mon, 7 Nov 2016 18:38:01 +0100 Subject: [build] add binary size logging to Linux Release builds --- scripts/log_binary_size.sh | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 scripts/log_binary_size.sh (limited to 'scripts/log_binary_size.sh') diff --git a/scripts/log_binary_size.sh b/scripts/log_binary_size.sh new file mode 100755 index 0000000000..45840174e9 --- /dev/null +++ b/scripts/log_binary_size.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +set -e +set -o pipefail + +function filesize { + if [ `uname -s` = 'Darwin' ]; then + stat -f%z $1 + else + stat --printf=%s $1 + fi +} + +# Uploads build metrics to CloudWatch +FILE=$1 +DIMENSIONS=$2 + +if [ -z "${DIMENSIONS}" ]; then + echo "* No dimensions specified for '${FILE}'" + exit 1 +fi + +if [ -f "${FILE}" ]; then + SIZE=`filesize ${FILE}` + echo "* Reporting `LC_NUMERIC=en_US printf "%'10.f\n" ${SIZE}` bytes for '${DIMENSIONS}' (${FILE})" + if [ ${CLOUDWATCH} ]; then + aws --region us-east-1 cloudwatch put-metric-data \ + --namespace "Mapbox/GL" \ + --metric-name "BinarySize" \ + --unit "Bytes" \ + --value ${SIZE} \ + --dimensions "${DIMENSIONS}" + fi +else + echo "* File '${FILE}' does not exist" + exit 1 +fi -- cgit v1.2.1