build_and_deploy_tizen_plugin.sh 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. #!/bin/bash
  2. CURDIR=$PWD
  3. SCRIPT_DIR=$( cd $(dirname $0) ; pwd -P )
  4. cd $SCRIPT_DIR
  5. usage()
  6. {
  7. cat << EOF
  8. usage: $0 [OPTIONS]
  9. Build and deploy Qt Creator Ninja plugin
  10. OPTIONS:
  11. -h Show this message
  12. -q path to qmake
  13. -b Qt Creator installation (build) directory. We will deploy plugin there
  14. -s Qt creator source directory. If it is not set script will download Qt sources automatically.
  15. examples:
  16. $0 -q /home/user/Qt5.3.1/5.3/gcc_64/bin/qmake -b /home/user/Qt5.3.1/Tools/QtCreator
  17. EOF
  18. exit
  19. }
  20. QMAKE_PATH=$(type -P qmake)
  21. while getopts ":b:hs:q:" opt; do
  22. case $opt in
  23. b)
  24. export QTC_BUILD="$OPTARG"
  25. ;;
  26. h)
  27. usage
  28. ;;
  29. s)
  30. QTC_SOURCE="$OPTARG"
  31. ;;
  32. q)
  33. export QMAKE_PATH="$OPTARG"
  34. ;;
  35. ?)
  36. echo "Invalid option: -$OPTARG"
  37. usage
  38. ;;
  39. esac
  40. done
  41. set -e
  42. if [ -z "$QTC_BUILD" ]; then
  43. echo "undefined Qt Creator's build/install directory, use -b parameter"
  44. usage
  45. fi
  46. if [ -z "$QMAKE_PATH" ]; then
  47. echo "Can't find qmake in path, please set -q parameter"
  48. usage
  49. fi
  50. QT_CREATOR_VERSION_OUTPUT=$("$QTC_BUILD"/bin/qtcreator -platform minimal -version 2>&1)
  51. QT_CREATOR_VERSION=$(echo $QT_CREATOR_VERSION_OUTPUT | grep -o "Qt Creator [0-9][0-9\.]*" | grep -o "[0-9\.]*")
  52. QT_CREATOR_QT_VERSION=$(echo $QT_CREATOR_VERSION_OUTPUT | grep -o "based on Qt [0-9][0-9\.]*" | grep -o "[0-9\.]*")
  53. QT_CREATOR_QT_MAJOR_VERSION=$(echo $QT_CREATOR_QT_VERSION | cut -d . -f1)
  54. QMAKE_QT_PATH_VERSION=$(${QMAKE_PATH} -version | grep -o "Using Qt version [0-9\.]*" | grep -o "[0-9\.]*")
  55. QMAKE_QT_PATH_MAJOR_VERSION=$(echo $QMAKE_QT_PATH_VERSION | cut -d . -f1)
  56. if [ "$QT_CREATOR_QT_MAJOR_VERSION" != "$QMAKE_QT_PATH_MAJOR_VERSION" ]; then
  57. echo "qmake (${QMAKE_PATH}) Qt version ($QMAKE_QT_PATH_VERSION) is not compatible with Qt used by Qt creator($QT_CREATOR_QT_VERSION)"
  58. exit 1
  59. fi
  60. if [[ "$QT_CREATOR_VERSION" != "3"* ]]; then
  61. echo "The plugin is compatible only with QtCreator 3.* version"
  62. exit 1
  63. fi
  64. echo found Qt Creator - version $QT_CREATOR_VERSION build with Qt $QT_CREATOR_QT_VERSION in $QTC_BUILD
  65. if [ -z "$QTC_SOURCE" ]; then
  66. if [ ! -d qt-creator-sources ]; then
  67. echo "Qt creator's source directory not set no qt-creator-sources directory in $SCRIPT_DIR. Downloading creator sources for Qt Creator $QT_CREATOR_VERSION"
  68. QT_CREATOR_BRANCH=${QT_CREATOR_VERSION:0:-2}
  69. git clone http://git.gitorious.org/qt-creator/qt-creator.git -b $QT_CREATOR_BRANCH qt-creator-sources
  70. fi
  71. QTC_SOURCE="$PWD/qt-creator-sources"
  72. fi
  73. cd "$QTC_SOURCE"
  74. set +e
  75. echo fetching latest Qt Creator sources
  76. git fetch origin
  77. set -e
  78. git checkout v$QT_CREATOR_VERSION
  79. QTC_SOURCE=$PWD
  80. echo Qt Creator source set to $QTC_SOURCE
  81. export QTC_BUILD
  82. export QTC_SOURCE
  83. mkdir -p $SCRIPT_DIR/plugins
  84. cd $SCRIPT_DIR/plugins
  85. if [ ! -d tizen ]; then
  86. echo downloading plugin sources
  87. git clone http://git.gitorious.org/tizenbuildtools/qtcreator-tizen-plugin.git tizen
  88. fi
  89. cd tizen
  90. git fetch
  91. QTCREATOR_TIZEN_PLUGIN_BRANCH=${QT_CREATOR_VERSION:0:-2}
  92. set +e
  93. CONTAINS_BRANCH=$(git branch -r | grep -c "origin/$QTCREATOR_TIZEN_PLUGIN_BRANCH")
  94. set -e
  95. if [ "$CONTAINS_BRANCH" == "0" ]; then
  96. echo "There is no Tizen plugin for QtCreator: $QTCREATOR_TIZEN_PLUGIN_BRANCH"
  97. exit 1;
  98. fi
  99. git reset --hard origin/$QTCREATOR_TIZEN_PLUGIN_BRANCH
  100. ${QMAKE_PATH} -r
  101. make -j $(grep -c ^processor /proc/cpuinfo)
  102. echo "Done !!!"
  103. echo "Tizen Plugin built and deployed to Qt Creator plugins directory"
  104. cd "$CUR_DIR"