summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Wilgus <me.theuser@yahoo.com>2019-07-18 09:41:38 -0500
committerWilliam Wilgus <me.theuser@yahoo.com>2019-07-18 10:53:34 -0500
commitd5908f520e8b21091766076584c9f582dbcdae1c (patch)
tree58a071e1c014b6157dfb54d45a81a40a25b7ab63
parentc9aeb4284e6456b8ca846f2bdfcd8f68d6ecd7b8 (diff)
downloadrockbox-d5908f520e8b21091766076584c9f582dbcdae1c.tar.gz
rockbox-d5908f520e8b21091766076584c9f582dbcdae1c.zip
Fix Red lua move constants out of binary image
didn't consider sims might have reserved enums Change-Id: Ic404972f0836bc81ba149f4ecdd3ec61bd8bd4b3
-rwxr-xr-xapps/plugins/lua/rbdefines_helper.pl17
1 files changed, 13 insertions, 4 deletions
diff --git a/apps/plugins/lua/rbdefines_helper.pl b/apps/plugins/lua/rbdefines_helper.pl
index 671936962e..f15cc71d36 100755
--- a/apps/plugins/lua/rbdefines_helper.pl
+++ b/apps/plugins/lua/rbdefines_helper.pl
@@ -47,7 +47,10 @@ my @all_defines;
47my $def_regex = qr/#define\s+([^\s\r\n]+)\s+([^\r\n]+)/; 47my $def_regex = qr/#define\s+([^\s\r\n]+)\s+([^\r\n]+)/;
48my $quot_regex = qr/.*([\"\']).*/; 48my $quot_regex = qr/.*([\"\']).*/;
49my $num_regex = qr/.*([\+\-\*\\|&\d]).*/; 49my $num_regex = qr/.*([\+\-\*\\|&\d]).*/;
50 50my $configh_regex = qr/^\s*#define\s*__CONFIG_H__\s*$/;
51my $config_h = "?";
52my $exclude_regex = qr/^#define\s*_?POSIX.*/;
53my $exclude_enum_regex = qr/^#define\s*(_SC_|_PC_|_CS_).*/;
51print <<EOF 54print <<EOF
52#include <stdio.h> 55#include <stdio.h>
53#include <stdbool.h> 56#include <stdbool.h>
@@ -62,7 +65,10 @@ EOF
62 65
63while(my $line = <STDIN>) 66while(my $line = <STDIN>)
64{ 67{
65 68 if($config_h eq "?" && $line =~ $configh_regex) { $config_h = $line; }
69 next if($config_h eq "?"); #don't capture till we get to the config file
70 next if($line =~ $exclude_regex);
71
66 if($line =~ $def_regex) #does it begin with #define? 72 if($line =~ $def_regex) #does it begin with #define?
67 { 73 {
68 push(@all_defines, $line); #save all defines for possible ambiguous macros 74 push(@all_defines, $line); #save all defines for possible ambiguous macros
@@ -85,12 +91,14 @@ while(my $line = <STDIN>)
85 } 91 }
86 elsif($line =~ /^(?!.*;)enum.*{/) #enum { 92 elsif($line =~ /^(?!.*;)enum.*{/) #enum {
87 { 93 {
94 next if($line =~ /enum\s*__.*/); #don't add reserved
88 print $line; 95 print $line;
89 next if($line =~ /.*};.*/); 96 next if($line =~ /.*};.*/);
90 do_enum($line) 97 do_enum($line)
91 } 98 }
92 elsif($line =~ /^(?!.*[;\(\)])enum.*/) #enum 99 elsif($line =~ /^(?!.*[;\(\)])enum.*/) #enum
93 { 100 {
101 next if($line =~ /enum\s*__.*/); #don't add reserved
94 #need to be careful might be a function returning enum 102 #need to be careful might be a function returning enum
95 my $lastline = $line; 103 my $lastline = $line;
96 next if($line =~ /.*};.*/); 104 next if($line =~ /.*};.*/);
@@ -105,7 +113,8 @@ while(my $line = <STDIN>)
105 } 113 }
106 114
107} 115}
108 116#warn "total defines: ".scalar @all_defines;
117#warn "captured defines: ".scalar @captured_defines;
109#Sort the functions 118#Sort the functions
110my @sorted_defines = sort { @$a{'name'} cmp @$b{'name'} } @captured_defines; 119my @sorted_defines = sort { @$a{'name'} cmp @$b{'name'} } @captured_defines;
111 120
@@ -176,7 +185,7 @@ sub do_enum {
176 185
177 while($line = <STDIN>) 186 while($line = <STDIN>)
178 { 187 {
179 188 next if($line =~ $exclude_enum_regex);
180 if($line =~ /.*};.*/) 189 if($line =~ /.*};.*/)
181 { 190 {
182 print $line; 191 print $line;