2020-11-30 22:14:19 +08:00
|
|
|
LICENSE=$1
|
|
|
|
FOLDER=$2
|
|
|
|
|
|
|
|
if [ -z ${FOLDER} ] || [ -z ${LICENSE} ]; then
|
|
|
|
echo "usage $0 <path/to/license> <path/to/code_folder>"
|
2020-11-24 21:28:38 +08:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2020-11-30 22:14:19 +08:00
|
|
|
cat ${LICENSE} > /dev/null || exit -1
|
|
|
|
|
2020-11-24 21:28:38 +08:00
|
|
|
FILES=`find ${FOLDER} \
|
|
|
|
| grep -E "(*\.cpp$|*\.h$|*\.cu$)" \
|
|
|
|
| grep -v thirdparty \
|
|
|
|
| grep -v cmake_build \
|
|
|
|
| grep -v cmake-build \
|
|
|
|
| grep -v output \
|
|
|
|
| grep -v "\.pb\."`
|
2020-11-30 22:14:19 +08:00
|
|
|
# echo formating ${FILES} ...
|
|
|
|
skip_count=0
|
2020-11-24 21:28:38 +08:00
|
|
|
for f in ${FILES}; do
|
2020-11-30 22:14:19 +08:00
|
|
|
if (grep "Apache License" $f > /dev/null);then
|
|
|
|
# echo "No need to copy the License Header to $f"
|
|
|
|
skip_count=$((skip_count+1))
|
2020-11-24 21:28:38 +08:00
|
|
|
else
|
2020-11-30 22:14:19 +08:00
|
|
|
cat ${LICENSE} $f > $f.new
|
2020-11-24 21:28:38 +08:00
|
|
|
mv $f.new $f
|
|
|
|
echo "License Header copied to $f"
|
|
|
|
fi
|
|
|
|
done
|
2020-11-30 22:14:19 +08:00
|
|
|
echo "license adder: $skip_count file(s) skiped"
|