Make genearation of libconstants.c more robust
Changes to the clang build flags passed into gen_constants.sh
can cause compile errors for the generated libconstants.c. Make
this process more robust by:
1. Typecasting values to unsigned long to address compiler failures
when other integer types are added to libconstants.c.
2. Making the grep statement filter out constants defined
without a value but with trailing whitespace e.g.
"#define ANDROID_API_H ".
Change-Id: I91d65db70b9e267882a8f381a836bbd7caded22e
diff --git a/gen_constants.sh b/gen_constants.sh
index 7b39156..9f217ee 100755
--- a/gen_constants.sh
+++ b/gen_constants.sh
@@ -40,7 +40,7 @@
# { "AT_FDWCD", AT_FDCWD },
# endif
SED_MULTILINE='s@#define ([[:upper:]][[:upper:]0-9_]*).*@#ifdef \1\
- { "\1", \1 },\
+ { "\1", (unsigned long) \1 },\
#endif // \1@'
# Passes the previous list of #includes to the C preprocessor and prints out
@@ -54,7 +54,7 @@
const struct constant_entry constant_table[] = {
$(echo "$INCLUDES" | \
${CC} -dD - -E | \
- grep '^#define [[:upper:]][[:upper:]0-9_]* ' | \
+ grep -E '^#define [[:upper:]][[:upper:]0-9_]*(\s)+[[:alnum:]]' | \
grep -Ev '(SIGRTMAX|SIGRTMIN|SIG_|NULL)' | \
sort -u | \
sed -Ee "${SED_MULTILINE}")