下面是编程之家 jb51.cc 通过网络收集整理的代码片段。
编程之家小编现在分享给大家,也给大家做个参考。
#!/bin/sh #expans all the macro in source file INCLUDE="" #get all the header files directory function get_include() { for file_t in `ls -l $1|grep -E "^d|\.([ch]|cpp)$"|awk '{print $8}'` do if [ -d $1"/"$file_t ] #the file is a dir then if [ "$file_t" == "include" ] then INCLUDE=$INCLUDE" -I./"$1"/"$file_t else get_include $1"/"$file_t fi fi done export CFLAGS=$INCLUDE } function macro_expansion() { oldpath=$1 newpath=$2 if [ ! -d $newpath ] then mkdir $newpath fi if [ $? -gt 0 ] then exit fi if [ $3 -eq 0 ] then get_include $oldpath echo $CFLAGS fi for file_t in `ls -l $1|grep -E "^d|\.([ch]|cpp)$"|awk '{print $8}'` do oldfile=$oldpath"/"$file_t newfile=$newpath"/"$file_t if [ -d $oldfile ] #the file is a dir then ./expan_macro $oldfile $newfile 1 else #echo $CFLAGS gcc -E $CFLAGS $oldfile -o $newfile fi done } #Show help when script started without arguments function showHelp() { echo "Usage: $0 source_dir dst_dir flag(be 0 all the time)" echo "example:$0 src dst 0" } if [ ! $# -eq 3 ] then showHelp exit fi macro_expansion $1 $2 $3
以上是编程之家(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。
如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。