From 2f6928f01688728ef1a390de5caa6990dc60bf31 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Thu, 14 Oct 2021 09:52:33 -0400 Subject: [PATCH] Make calcrom data info optional --- .github/calcrom/calcrom.pl | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/.github/calcrom/calcrom.pl b/.github/calcrom/calcrom.pl index 4858babb95..2aaf25c436 100755 --- a/.github/calcrom/calcrom.pl +++ b/.github/calcrom/calcrom.pl @@ -1,12 +1,18 @@ #!/usr/bin/perl use IPC::Cmd qw[ run ]; +use Getopt::Long; -(@ARGV == 1) - or die "ERROR: no map file specified.\n"; +my $usage = "Usage: calcrom.pl file.map [--data]\n"; + +(@ARGV >= 1) + or die $usage; open(my $file, $ARGV[0]) or die "ERROR: could not open file '$ARGV[0]'.\n"; +my $showData; +GetOptions("data" => \$showData) or die $usage; + my $src = 0; my $asm = 0; my $srcdata = 0; @@ -149,17 +155,13 @@ else print "$undocumented symbols undocumented ($undocPct%)\n"; } -print "\n"; -my $dataTotal = $srcdata + $data; -my $srcDataPct = sprintf("%.4f", 100 * $srcdata / $dataTotal); -my $dataPct = sprintf("%.4f", 100 * $data / $dataTotal); +if ($showData) +{ + print "\n"; + my $dataTotal = $srcdata + $data; + my $srcDataPct = sprintf("%.4f", 100 * $srcdata / $dataTotal); + my $dataPct = sprintf("%.4f", 100 * $data / $dataTotal); -if ($data == 0) -{ - print "Data porting to C is 100% complete\n" -} -else -{ print "$dataTotal total bytes of data\n"; print "$srcdata bytes of data in src ($srcDataPct%)\n"; print "$data bytes of data in data ($dataPct%)\n";