license.sh 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/bin/bash
  2. if [ "$#" -ne 0 ]
  3. then
  4. USAGE="Usage:
  5. scripts/license.sh
  6. Checks and appends MPL2 license to all files.
  7. ";
  8. echo "$USAGE"
  9. exit 1
  10. fi
  11. # By default use Alec's email address.
  12. HEADER="\
  13. This file is part of libigl, a simple c++ geometry processing library.
  14. Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
  15. This Source Code Form is subject to the terms of the Mozilla Public License
  16. v. 2.0. If a copy of the MPL was not distributed with this file, You can
  17. obtain one at http://mozilla.org/MPL/2.0/.";
  18. HEADER_TMPFILE="libigl.header.tmpfile";
  19. CPPHEADER=`echo "$HEADER" | sed -e "s/^/\/\/ /"`
  20. #echo -e "$(echo "$HEADER" | sed -e "s/^/\/\/ /")\n$(cat test.h)" > test.h
  21. FIRST_LINE_OF_HEADER=`echo -e "$HEADER" | head -1`
  22. # Files from third-party sources
  23. EXCEPT="tga|MCTables|marching_cubes"
  24. SRC_FILES=`find include/igl -name \*.h -print -o -name \*.cpp -print`
  25. SRC_FILES=`echo "$SRC_FILES" | egrep -v $EXCEPT`
  26. for s in $SRC_FILES
  27. do
  28. if ! head -1 $s | grep -F "$FIRST_LINE_OF_HEADER" >/dev/null
  29. then
  30. echo "Appending license header to $s..."
  31. echo "$CPPHEADER" |cat - $s > /tmp/out && mv /tmp/out $s
  32. fi;
  33. done