build.sh 789 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/bin/bash
  2. if [ $# -ne 1 ] ;then
  3. echo "Usage:$0 all|clean" && exit
  4. fi
  5. root_path=$(pwd)
  6. uname=$(uname -s)
  7. if [ "$uname" == "Darwin" ] ;then
  8. platform="macosx"
  9. else
  10. platform="linux"
  11. fi
  12. function build() {
  13. cd $root_path/$1
  14. real_path=$(pwd)
  15. echo "开始编译:$1"
  16. if [ "$1" == "lua-snapshot" ] ;then
  17. make $2
  18. elif [ "$1" == "jmutil" ] ;then
  19. make $2
  20. elif [ "$1" == "luafilesystem" ] ;then
  21. make $2
  22. else
  23. make all
  24. fi
  25. }
  26. function install() {
  27. echo "cd $root_path/$1 && make install"
  28. cd $root_path/$1 && make install
  29. }
  30. function clean() {
  31. echo "cd $root_path/$1 && make clean"
  32. cd $root_path/$1 && make clean
  33. }
  34. dir=$(ls -l ./ |awk '/^d/ {print $NF}')
  35. for i in $dir
  36. do
  37. if [ "$1" == "all" ] ;then
  38. build $i $platform
  39. install $i
  40. echo ""
  41. else
  42. clean $i
  43. echo ""
  44. fi
  45. done