MT#55283 support CFLAGS in str hash helper

Fixes #1919

Change-Id: Ibac4475c96063b69868546e54e27f9f61b7b909b
pull/1923/head
Richard Fuchs 1 month ago
parent 95f75d690b
commit 26072ed6a1

@ -56,7 +56,7 @@ endif
t38.c: spandsp_logging.h
%.strhash.c: %.c ../utils/const_str_hash
../utils/const_str_hash "$<" < "$<" > "$@"
../utils/const_str_hash "$<" $(CFLAGS) < "$<" > "$@"
$(BUILD_TEST_ALTS): $(wildcard ../lib/$(subst .h,-*,$(BUILD_TEST_ALTS)))
../utils/build_test_wrapper "$@" 2> /dev/null

@ -7,12 +7,34 @@ use IPC::Cmd qw[can_run];
can_run('gperf') or die 'No gperf binary found, make sure to have gperf installed!';
my (%defines_0, %defines_1, %defines_2, %defines_4);
{
my @argv;
for my $arg (@ARGV) {
if ($arg !~ /^-/) {
push(@argv, $arg);
next;
}
if ($arg =~ /^-D(.*?)=(.*)$/) {
$defines_0{$1} = $2;
next;
}
if ($arg =~ /^-D(.*?)$/) {
$defines_0{$1} = '1';
next;
}
}
@ARGV = @argv; ## no critic (RequireLocalizedPunctuationVars)
}
print("/******** GENERATED FILE ********/\n");
my $rewritten_input = '';
my @sections;
my @slots;
my (%defines_0, %defines_1, %defines_2, %defines_4);
my $ifdefs = 0;
# collect keywords and rewrite input file with in lookup keys
@ -31,7 +53,7 @@ while (my $line = <STDIN>) {
my $num = scalar(@sections);
my $new_section;
if ($line =~ /CSH_SECTION|CSH_LOOKUP|CSH_NUM_LOOKUPS/
&& $line =~ /^#define\s+(\w+)(?:\s+(.*?)|\(\s*(\w+)\s*\)\s+(.*?)|\(\s*(\w+)\s*,\s*(\w+)\s*\)\s+(.*?)|\(\s*(\w+)\s*,\s*(\w+)\s*,\s*(\w+)\s*,\s*(\w+)\s*\)\s+(.*?))$/) {
&& $line =~ /^\s*#define\s+(\w+)(?:\s+(.*?)|\(\s*(\w+)\s*\)\s+(.*?)|\(\s*(\w+)\s*,\s*(\w+)\s*\)\s+(.*?)|\(\s*(\w+)\s*,\s*(\w+)\s*,\s*(\w+)\s*,\s*(\w+)\s*\)\s+(.*?))$/) {
if ($2) {
$defines_0{$1} = $2;
}
@ -47,6 +69,31 @@ while (my $line = <STDIN>) {
$rewritten_input .= "\n";
next;
}
if ($line =~ /^\s*#endif/) {
if ($ifdefs) {
$ifdefs--;
}
$rewritten_input .= $line;
next;
}
if ($line =~ /^\s*#if(n?)def\s+(\S+)/) {
if ((!$1 && !$defines_0{$2}) || ($1 && $defines_0{$2}) || $ifdefs) {
$ifdefs++;
}
$rewritten_input .= $line;
next;
}
if ($line =~ /^\s*#if\s+/) {
if ($ifdefs) {
$ifdefs++;
}
$rewritten_input .= $line;
next;
}
if ($ifdefs) {
$rewritten_input .= $line;
next;
}
for my $def (keys(%defines_0)) {
my $sub = $defines_0{$def};
$line =~ s/(\W|^)\Q$def\E(\W|$)/$1$sub$2/g;

Loading…
Cancel
Save