singleuse: make git grep faster, add Apple nm support

- avoid regexp in grep to make it run faster.
- add support for parsing Apple `nm` output:
  - skip leading underscore from function names.
  - pick object name from output.

Closes #15070
This commit is contained in:
Viktor Szakats 2024-09-26 21:16:21 +02:00
parent f0f9e2c61f
commit fcc89619d9
No known key found for this signature in database
GPG Key ID: B5ABD165E2AEF201

View File

@ -152,7 +152,7 @@ my %api = (
sub doublecheck {
my ($f, $used) = @_;
open(F, "git grep -le '$f\\W' -- lib ${unittests}packages|");
open(F, "git grep -Fwle '$f' -- lib ${unittests}packages|");
my @also;
while(<F>) {
my $e = $_;
@ -180,13 +180,17 @@ while (<N>) {
if($l =~ /^([0-9a-z_-]+)\.o:/) {
$file = $1;
}
if($l =~ /^([0-9a-f]+) T (.*)/) {
# libcurl.a(unity_0_c.c.o):
elsif($l =~ /\(([0-9a-z_.-]+)\.o\):/) { # Apple nm
$file = $1;
}
if($l =~ /^([0-9a-f]+) T _?(.*)/) {
my ($name)=($2);
#print "Define $name in $file\n";
$file =~ s/^libcurl_la-//;
$exist{$name} = $file;
}
elsif($l =~ /^ U (.*)/) {
elsif($l =~ /^ U _?(.*)/) {
my ($name)=($1);
#print "Uses $name in $file\n";
$uses{$name} .= "$file, ";