ivversion.sh 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. folder=$(echo $PWD) ;
  2. #echo $folder;
  3. filepath=$folder/../.git/refs/heads/master;
  4. #echo $filepath;
  5. VERSIONCODE="v1.0"
  6. if [ -f "$filepath" ]; then
  7. gitversion=$(cat $folder/../.git/refs/heads/master)
  8. # echo $gitversion
  9. VERSIONCODE=$gitversion
  10. else
  11. echo "not found file "$filepath
  12. VERSIONCODE="v1.0-develop"
  13. fi
  14. echo $VERSIONCODE
  15. VERSIONINFO=$(echo "#define IVVERSION \"$VERSIONCODE\"")
  16. echo $VERSIONINFO
  17. if [ ! -f "ivversion_def.h" ]; then
  18. echo "ivversion_def.h not exit."
  19. echo "#ifndef IVVERSION_DEF_H" >> ivversion_def.h
  20. echo "#define IVVERSION_DEF_H" >> ivversion_def.h
  21. echo $VERSIONINFO >> ivversion_def.h
  22. echo "#endif" >> ivversion_def.h
  23. else
  24. echo "file exist."
  25. OLDVERSIONINFO=$(sed -n "3p" ivversion_def.h)
  26. echo "old:"$OLDVERSIONINFO
  27. if [ ! "$OLDVERSIONINFO"x = "$VERSIONINFO"x ]; then
  28. cat /dev/null > ivversion_def.h
  29. echo "#ifndef IVVERSION_DEF_H" >> ivversion_def.h
  30. echo "#define IVVERSION_DEF_H" >> ivversion_def.h
  31. echo $VERSIONINFO >> ivversion_def.h
  32. echo "#endif" >> ivversion_def.h
  33. else
  34. echo "VERSION Not Change. so not need update ivversion_def.h"
  35. fi
  36. fi