Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix verbose flag issue #30

Merged
merged 1 commit into from
Aug 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 28 additions & 28 deletions .github/calcrom/calcrom.pl
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,6 @@

my $incbin_cmd = "find \"\$(dirname $elffname)\" \\( -name '*.s' -o -name '*.inc' \\) -exec cat {} ';' | grep -oE '^\\s*\\.incbin\\s*\"[^\"]+\"\s*,\\s*(0x)?[0-9a-fA-F]+\\s*,\\s*(0x)?[0-9a-fA-F]+' -";

my $nonmatching_cmd = "git grep -E '#if[n]?def NONMATCHING' ':/' ':(exclude).'";

my $todo_cmd = "git grep 'TODO' ':/' ':(exclude).'";

# It sucks that we have to run this three times, but I can't figure out how to get
# stdin working for subcommands in perl while still having a timeout. It's decently
# fast anyway.
Expand Down Expand Up @@ -162,22 +158,6 @@
))
or die "ERROR: Error while calculating incbin totals: $?";

my $nonmatching_as_string;
(run (
command => "$nonmatching_cmd | $count_cmd",
buffer => \$nonmatching_as_string,
timeout => 60
))
or die "ERROR: Error while calculating NONMATCHING totals: $?";

my $todo_as_string;
(run (
command => "$todo_cmd | $count_cmd",
buffer => \$todo_as_string,
timeout => 60
))
or die "ERROR: Error while calculating TODO totals: $?";

# Performing addition on a string converts it to a number. Any string that fails
# to convert to a number becomes 0. So if our converted number is 0, but our string
# is nonzero, then the conversion was an error.
Expand All @@ -204,14 +184,6 @@
(($incbin_bytes != 0) and ($incbin_bytes_as_string ne "0"))
or die "ERROR: Cannot convert string to num: '$incbin_bytes_as_string'";

my $nonmatching_count = $nonmatching_as_string + 0;
(($nonmatching_count != 0) and ($nonmatching_as_string ne "0"))
or die "ERROR: Cannot convert string to num: '$nonmatching_as_string'";

my $todo_count = $todo_as_string + 0;
(($todo_count != 0) and ($todo_as_string ne "0"))
or die "ERROR: Cannot convert string to num: '$todo_as_string'";



my $total = $src + $lib + $asm;
Expand Down Expand Up @@ -293,6 +265,34 @@

if ($verbose != 0)
{
my $nonmatching_cmd = "git grep -E '#if[n]?def NONMATCHING' ':/' ':(exclude)*.pl'";

my $todo_cmd = "git grep 'TODO' ':/' ':(exclude)*.pl'";

my $nonmatching_as_string;
(run (
command => "$nonmatching_cmd | $count_cmd",
buffer => \$nonmatching_as_string,
timeout => 60
))
or die "ERROR: Error while calculating NONMATCHING totals: $?";

my $todo_as_string;
(run (
command => "$todo_cmd | $count_cmd",
buffer => \$todo_as_string,
timeout => 60
))
or die "ERROR: Error while calculating TODO totals: $?";

my $nonmatching_count = $nonmatching_as_string + 0;
(($nonmatching_count != 0) and ($nonmatching_as_string ne "0"))
or die "ERROR: Cannot convert string to num: '$nonmatching_as_string'";

my $todo_count = $todo_as_string + 0;
(($todo_count != 0) and ($todo_as_string ne "0"))
or die "ERROR: Cannot convert string to num: '$todo_as_string'";

print "\n";
printf "%8d functions are NONMATCHING\n", $nonmatching_count;
printf "%8d comments are labeled TODO\n", $todo_count;
Expand Down