protobuf2.5工程及c文件格式化腳本

#! /bin/sh -e

# This script downgrades MSVC 2008 projects to MSVC 2005 projects, allowing
# people with MSVC 2005 to open them.  Otherwise, MSVC 2005 simply refuses to
# open projects created with 2008.  We run this as part of our release process.
# If you obtained the code direct from version control and you want to use
# MSVC 2005, you may have to run this manually.  (Hint:  Use Cygwin or MSYS.)

doSln() {
	for file in *.sln; do
		echo "downgrading $file..."
		sed -i -re 's/Format Version 9.00/Format Version 10.00/g;
				  s/Visual Studio 2005/Visual Studio 2008/g;' $file
	done
}

doVcproj() {
	for file in *.vcproj; do
		echo "downgrading $file..."
		sed -i -re 's/Version="8.00"/Version="9.00"/g;' $file
	done
}

fileList() {
	local basedir=$1
	for dir in $(ls $basedir)
	do
		dir=$basedir$dir
		if [ -f "$dir" ];then
			echo "$dir"
		elif [ -L "$dir" ]; then
			echo "$dir"
		else
			fileList $dir/
		fi
	done
}

doSln
doVcproj

cd ../gtest/msvc
doSln
doVcproj

cd ../../
echo "fmort c and cpp files"
fileList "./" | while read line
do
	filename=`echo $line | awk -F"." '{if(NF>2){print $(NF);}}'`
	if [[ $filename = "c" || $filename = "cc" || $filename = "cpp" || $filename = "h" || $filename = "hpp" ]]; then
		astyle --style=ansi $line
	fi
done

fileList "./" | while read line
do
	filename=`echo $line | awk -F"." '{if(NF>2){print $(NF);}}'`
	if [ "$filename" = "orig" ];then
		echo "rm -f $line"
		rm -f $line
	fi
done

# Yes, really, that's it.
相關文章
相關標籤/搜索