2014-09-17 10:30:33 +03:00
|
|
|
#!/bin/sh
|
|
|
|
set -euv
|
|
|
|
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
|
|
|
|
header_files="$script_dir"/../src/*/*.h
|
|
|
|
cpp_files="$script_dir"/../src/*/*.cpp
|
|
|
|
|
2014-09-29 23:50:37 +03:00
|
|
|
header_files+=" "$(find "$script_dir"/../games -name '*.h')
|
|
|
|
cpp_files+=" "$(find "$script_dir"/../games -name '*.cpp')
|
2014-09-17 10:30:33 +03:00
|
|
|
|
2014-09-19 12:48:34 +03:00
|
|
|
header_files+=" "$(find "$script_dir"/../builtin -name '*.h')
|
|
|
|
cpp_files+=" "$(find "$script_dir"/../builtin -name '*.cpp')
|
2014-09-17 10:30:33 +03:00
|
|
|
|
2014-09-19 18:44:26 +03:00
|
|
|
header_files+=" "$(find "$script_dir"/../3rdparty/c55lib -name '*.h')
|
|
|
|
cpp_files+=" "$(find "$script_dir"/../3rdparty/c55lib -name '*.cpp')
|
|
|
|
|
2014-09-24 14:51:50 +03:00
|
|
|
lua_files=""$(find "$script_dir"/../extensions -name '*.lua')
|
|
|
|
lua_files+=" "$(find "$script_dir"/../client -name '*.lua')
|
2014-09-29 23:50:37 +03:00
|
|
|
lua_files+=" "$(find "$script_dir"/../games -name '*.lua')
|
2014-09-24 14:51:50 +03:00
|
|
|
|
|
|
|
cmake_files="$script_dir"/../CMakeLists.txt
|
|
|
|
|
2014-09-17 10:30:33 +03:00
|
|
|
echo "header_files: $header_files"
|
|
|
|
echo "cpp_files: $cpp_files"
|
2014-09-24 14:51:50 +03:00
|
|
|
echo "lua_files: $lua_files"
|
|
|
|
echo "cmake_files: $cmake_files"
|
2014-09-17 10:30:33 +03:00
|
|
|
|
2014-10-06 13:36:28 +03:00
|
|
|
# Fix all that uncrustify is capable of
|
|
|
|
uncrustify_base="$script_dir/../util/uncrustify.cfg"
|
|
|
|
uncrustify_add_header="$script_dir/../util/uncrustify.header.cfg"
|
|
|
|
uncrustify_add_cpp="$script_dir/../util/uncrustify.cpp.cfg"
|
|
|
|
|
|
|
|
uncrustify_header="/tmp/buildat.uncrustify.header.cfg"
|
|
|
|
uncrustify_cpp="/tmp/buildat.uncrustify.cpp.cfg"
|
|
|
|
cat "$uncrustify_base" "$uncrustify_add_header" > "$uncrustify_header"
|
|
|
|
cat "$uncrustify_base" "$uncrustify_add_cpp" > "$uncrustify_cpp"
|
|
|
|
|
|
|
|
uncrustify -c "$uncrustify_header" --no-backup $header_files
|
|
|
|
uncrustify -c "$uncrustify_cpp" --no-backup $cpp_files
|
2014-09-17 10:30:33 +03:00
|
|
|
|
2014-09-24 14:51:50 +03:00
|
|
|
# Fix or add Vim modeline magic
|
|
|
|
sed -i '/^\/\/ vim: set /d' $header_files $cpp_files
|
|
|
|
for f in $header_files $cpp_files; do
|
|
|
|
echo '// vim: set noet ts=4 sw=4:' >> $f
|
|
|
|
done
|
2014-09-24 15:13:49 +03:00
|
|
|
sed -i '/^-- vim: set /d' $lua_files
|
|
|
|
for f in $lua_files; do
|
|
|
|
echo '-- vim: set noet ts=4 sw=4:' >> $f
|
|
|
|
done
|
|
|
|
sed -i '/^# vim: set /d' $cmake_files
|
|
|
|
for f in $cmake_files; do
|
2014-09-24 14:51:50 +03:00
|
|
|
echo '# vim: set noet ts=4 sw=4:' >> $f
|
|
|
|
done
|
|
|
|
|
2014-09-24 14:28:10 +03:00
|
|
|
# Format CMake too
|
|
|
|
sed -i -e 's/\(^[ \t]*\)\([A-Za-z_]\+\)[ \t]*(/\1\L\2(/' $cmake_files
|
|
|
|
sed -i -e 's/([\t ]\+\([A-Za-z_${)]\)/(\1/g' $cmake_files
|
|
|
|
sed -i -e 's/\([A-Za-z_}(]\)[\t ]\+)/\1)/g' $cmake_files
|
|
|
|
|