summaryrefslogtreecommitdiff
path: root/examples/build_report.pl
diff options
context:
space:
mode:
authorhathach <[email protected]>2018-03-06 19:14:01 +0700
committerhathach <[email protected]>2018-03-06 19:14:01 +0700
commit4dc917c9ba8b746a4e5ce1934af019840bd20355 (patch)
tree5c8d270f36a6c38e98a64a991de54270e5a2d3f0 /examples/build_report.pl
parentfce85875c49a7d18115c4f0c2cf91d7f8e5df9d9 (diff)
rename demo to examples
Diffstat (limited to 'examples/build_report.pl')
-rw-r--r--examples/build_report.pl64
1 files changed, 64 insertions, 0 deletions
diff --git a/examples/build_report.pl b/examples/build_report.pl
new file mode 100644
index 000000000..3aba44c63
--- /dev/null
+++ b/examples/build_report.pl
@@ -0,0 +1,64 @@
+#!/usr/bin/perl
+
+use Scalar::Util qw(looks_like_number);
+
+$" = "\n"; # change list separator
+
+$keil_size = "Program Size:.+";
+
+%report_patterns =
+( #toolchain, pattern-list
+ 'keil' => ['Build target \'(.+)\'', '(\d+ Error.+\d+ Warning)', $keil_size . 'Code=(\d+)', $keil_size . 'RO-data=(\d+)', $keil_size . 'RW-data=(\d+)', $keil_size . 'ZI-data=(\d+)'],
+ 'iar' => ['Building configuration.+ (.+)', 'Total number of (.+)', '((\s+\d+){4})\s+[0-9a-f]+'],
+ 'xpresso' => ['Build of configuration (\S+) ', '(Finished) building target', '((\s+\d+){4})\s+[0-9a-f]+']
+);
+
+@report_file_list = <build_all_*.txt>;
+#print "@report_file_list"; die;
+
+open $freport, ">build_report.txt" or die "cannot open build_reprot.txt";
+
+foreach (@report_file_list)
+{
+ /build_all_([^_]+)_/;
+ build_report($_, $1);
+}
+
+sub build_report
+{
+ my $report_file = $_[0];
+ my $toolchain = $_[1];
+
+ my @pattern = @{$report_patterns{$toolchain}};
+
+ open $report_handle, $report_file or die "cannot open $report_file";
+
+ $report_file =~ /build_all_(.+).txt/;
+
+ print $freport "--------------------------------------------------------------------\n";
+ printf $freport "%-25s", $1;
+ printf $freport "%13s", "" if $toolchain eq 'iar';
+ print $freport " text data bss dec" if $toolchain eq 'xpresso' or $toolchain eq 'iar';
+ print $freport " Code RO RW ZI" if $toolchain eq 'keil';
+ print $freport "\n--------------------------------------------------------------------";
+
+ while( my $line = <$report_handle> )
+ {
+ local $/ = "\r\n";
+ chomp $line;
+
+ foreach (@pattern)
+ {
+ if ($line =~ /$_/)
+ {
+ my $fmat = ($_ eq $pattern[0]) ? "\n%-25s" : "%s ";
+ $fmat = "%6s " if $toolchain eq 'keil' and looks_like_number($1);
+ printf $freport $fmat, $1;
+ }
+ }
+ }
+
+ close $report_handle;
+
+ print $freport "\n\n";
+} \ No newline at end of file