]> git.donarmstrong.com Git - kiibohd-controller.git/blobdiff - Lib/CMake/sizeCalculator
Start removing select Linux-isms
[kiibohd-controller.git] / Lib / CMake / sizeCalculator
index 1bf814ead4b50f57482a314eab26c594fbec1ed2..b0ab2e61d84e76f51db1b8e0e2355a4fc08109e1 100755 (executable)
@@ -1,16 +1,25 @@
-#!/bin/bash
+#!/usr/bin/env bash
 #| Jacob Alexander 2014
 #| Arg List
 #| 1 - size binary   (e.g. avr-size)
-#| 2 - target binary (e.g. ihex)
+#| 2 - measurement type (flash or ram)
 #| 3 - binary file   (e.g. kiibohd.hex)
 #| 4 - total available (flash/ram) in bytes
-#| 5 - flash/ram
+#| 5 - flash/ram text
 
 
-# Looks for the data column, to get the flash/ram used (in bytes)
-# <size binary> --target=<target binary> <binary file> | cut -f2 | tail -n 1
-USED=$("$1" --target="$2" "$3" | cut -f2 | tail -n 1)
+case "$2" in
+"flash")
+       USED=$("$1" "$3" | tail -n-1 | awk '{ print $1+$2 }')
+       ;;
+"ram")
+       USED=$("$1" "$3" | tail -n-1 | awk '{ print $2+$3 }')
+       ;;
+*)
+       echo "INVALID Measurement type: $2"
+       exit 1
+esac
+
 
 # Calculates the total flash/ram used
 TOTAL="$4"
@@ -35,7 +44,7 @@ fi
 
 # Displays Results
 NAME="$5"
-echo -e "\t\033[1m${NAME}\033[m: ${COLOR}${PERCENTAGE}%\033[m ${USED}/${TOTAL}\tbytes"
+echo -e "\t\033[1m${NAME}\033[m: ${COLOR}${PERCENTAGE}%\033[m \t${USED}/${TOTAL}\tbytes"
 
 exit 0