Skip to content

Commit

Permalink
Merge pull request #30 from WhenGryphonsFly/workflow
Browse files Browse the repository at this point in the history
Fix verbose flag issue
  • Loading branch information
WhenGryphonsFly authored Aug 22, 2023
2 parents 9142981 + 169fce8 commit 527a96e
Showing 1 changed file with 28 additions and 28 deletions.
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

0 comments on commit 527a96e

Please sign in to comment.