2 Star 0 Fork 0

mirrors_Qihoo360 / qbusbridge

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
format_code.sh 837 Bytes
一键复制 编辑 原始数据 按行查看 历史
Yunze Xu 提交于 2020-08-27 11:33 . Format code before build
#!/bin/bash
# Using clang-format and gofmt to format c/c++/golang source code.
formatByClangFormat() {
for file in $(find $1 -regextype "posix-egrep" -regex ".*[A-Za-z_]\.(h|c|cc)")
do
COMMAND="clang-format -i $file"
eval $COMMAND
done
echo "clang-format for directory: $1"
}
if command -v clang-format >/dev/null; then
DIRS=( ./cxx/src ./cxx/examples )
for DIR in "${DIRS[@]}"
do
formatByClangFormat $DIR
done
else
echo "[ERROR] clang-format is required to format c/c++ code"
fi
formatByGoFmt() {
for file in $(find $1 -name "*.go")
do
COMMAND="gofmt -w $file"
echo $COMMAND
eval $COMMAND
done
}
if command -v gofmt >/dev/null; then
formatByGoFmt ./golang/examples
else
echo "[WARN] gofmt is required to format golang code"
fi
1
https://gitee.com/mirrors_Qihoo360/qbusbridge.git
git@gitee.com:mirrors_Qihoo360/qbusbridge.git
mirrors_Qihoo360
qbusbridge
qbusbridge
master

搜索帮助