generate_version_header.sh 783 B

123456789101112131415161718192021222324252627282930
  1. #/bin/sh
  2. tmpfile=versionheader.tmp
  3. tmpfile2=versionheader.tmp2
  4. echo "*************************" > $tmpfile
  5. echo " VERSION INFO" >> $tmpfile
  6. if hg status; then
  7. echo "hg summary" >> $tmpfile
  8. hg summary >> $tmpfile
  9. echo "************************" >> $tmpfile
  10. echo "hg tip" >> $tmpfile
  11. hg tip >> $tmpfile
  12. echo "************************" >> $tmpfile
  13. elif git status; then
  14. echo "************************" >> $tmpfile
  15. echo "git log -1" >> $tmpfile
  16. git log -1 >> $tmpfile
  17. echo "************************" >> $tmpfile
  18. fi
  19. sed 's/"/\\"/g' $tmpfile | sed 's/^\(.*\)$/"\1\\n"/' > $tmpfile2
  20. echo "#pragma once" > $1
  21. echo "#include <string>" >> $1
  22. echo "static std::string get_version_info() {" >> $1
  23. echo "return std::string(" >> $1
  24. cat $tmpfile2 >> $1
  25. echo ");}" >> $1