strace/generate_xlat_in.sh
Dmitry V. Levin 0ed617bd66 Generate xlat/*.in files
Automatically convert xlat structures from *.c files to xlat/*.in files
using "./generate_xlat_in.sh *.c" command.
2014-05-30 21:40:03 +00:00

29 lines
834 B
Bash
Executable File

#!/bin/sh
convert() {
sed -n '/^\(static \)\?const struct xlat '"$n"'\[\] = {$/,/^};$/{
s/^[[:space:]]*XLAT(\([^)]\+\)).*/\1/p
s/^[[:space:]]*{[[:space:]]*(\?\(1<<[^),[:space:]]\+\).*/\1/p
s/.*not NULL-terminated.*/#unterminated/p
s/^\([[:space:]]*{.*\)/\1/p
s/^\t*\( *[/*].*\)/\1/p}' "$f" >> xlat/"$n".in
sed -i '/^\(static \)\?const struct xlat '"$n"'\[\] = {$/,/^};$/c #include "xlat/'"$n"'.h"' "$f"
}
for f; do
for n in $(sed -n 's/^\(static \)\?const struct xlat \([a-z0-9_]\+\)\[\] = {$/\2/p' "$f"); do
case "$n" in
cacheflush_flags|struct_user_offsets) # skip
;;
ioprio_class|ioprio_who|mtd_mode_options|personality_options|syslog_action_type|ubi_volume_props|ubi_volume_types)
echo '#unconditional' > xlat/"$n".in
convert
;;
*)
> xlat/"$n".in
convert
;;
esac
done
done