Created
February 2, 2017 11:30
-
-
Save barbieri/86d8a3a8dda47a8563310810a1f7e3f5 to your computer and use it in GitHub Desktop.
Scan C/H source files for #if/#ifdef/#elif symbols, ignore some based on EFL conventions and the rest try to provide the cmake function to check for them
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
find $1 -type 'f' \( -name '*.c' -o -name '*.h' -o -name '*.x' \) | | |
xargs grep --no-filename '^ *# *\(if\|elif\)' | | |
sed 's/^ *# *\(if\|ifdef\|ifndef\|elif\)//g' | | |
sed 's/\(defined\|[()!&|><=]\|^DBG\|^CRI\|^WRN\|^INF\|^ERR\|^NDEBUG\|^EAPI\|__cplusplus\|__APPLE__\|__MACH__\|_MSC_VER\|_WIN32\|__GNUC__\|\(INT\|UINT\)\(8\|16\|32\|64\)_\(MAX\|MIN\)\|HAVE_\(EXOTIC\|ESCAPE\|EVIL\)\)//g' | | |
tr ' ' '\n' | sort -u | while read s; do | |
if [ -z "$s" ]; then | |
continue | |
elif [ ${s#HAVE_} != $s ]; then | |
r=${s#HAVE_} | |
if [ ${r%_H} != $r ]; then | |
h=${r%_H} | |
h=${h,,} | |
h=${h/_/\/} | |
echo "$s - HEADER_CHECK($h.h)" | |
else | |
r=${r,,} | |
OIFS="$IFS" | |
IFS=$'\n' | |
found=0 | |
for f in `apropos -e -s 2,3 $r 2>/dev/null | sed 's/^\([^ ]\+\) (\([^ ]\+\)).*$/man \2 \1/g'`; do | |
IFS="$OIFS" | |
if [ `echo $f | cut -d' ' -f 3` == $r ]; then | |
export MANWIDTH=4096 | |
incs=`$f | grep '#include' | sed 's/^.*#include \+<\([^>]\+\)>.*$/\1/g' | tr '\n' ' '` | |
if [ -n "$incs" ]; then | |
incs=" INCLUDE_FILES $incs" | |
fi | |
libs=`$f | grep -e ' -l' | sed 's/^.*\( -l[A-Za-z0-9_, ]\+\).*$/\1/g' | sed 's/\( -l\|,\)//g' | tr '\n' ' '` | |
if [ -n "$libs" ]; then | |
libs=" LIBRARIES $libs" | |
fi | |
echo "$s - FUNC_CHECK($r$incs$libs) # see $f" | |
found=1 | |
fi | |
done | |
IFS="$OIFS" | |
if [ $found = 0 ]; then | |
echo "$s" | |
fi | |
fi | |
else | |
echo "$s" | |
fi | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment