Fork from inav at github. Modified for some special functions needs.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.2 KiB

  1. #!/bin/bash
  2. REVISION=$(git rev-parse --short HEAD)
  3. BRANCH=$(git rev-parse --abbrev-ref HEAD)
  4. REVISION=$(git rev-parse --short HEAD)
  5. LAST_COMMIT_DATE=$(git log -1 --date=short --format="%cd")
  6. TARGET_FILE=obj/cleanflight_${TARGET}
  7. TRAVIS_REPO_SLUG=${TRAVIS_REPO_SLUG:=$USER/undefined}
  8. BUILDNAME=${BUILDNAME:=travis}
  9. TRAVIS_BUILD_NUMBER=${TRAVIS_BUILD_NUMBER:=undefined}
  10. CURL_BASEOPTS=(
  11. "--retry" "10"
  12. "--retry-max-time" "120" )
  13. CURL_PUB_BASEOPTS=(
  14. "--form" "revision=${REVISION}"
  15. "--form" "branch=${BRANCH}"
  16. "--form" "travis_build_number=${TRAVIS_BUILD_NUMBER}"
  17. "--form" "last_commit_date=${LAST_COMMIT_DATE}"
  18. "--form" "github_repo=${TRAVIS_REPO_SLUG}"
  19. "--form" "build_name=${BUILDNAME}" )
  20. # A hacky way of running the unit tests at the same time as the normal builds.
  21. if [ $RUNTESTS ] ; then
  22. cd ./src/test && make test
  23. # A hacky way of building the docs at the same time as the normal builds.
  24. elif [ $PUBLISHDOCS ] ; then
  25. if [ $PUBLISH_URL ] ; then
  26. # Patch Gimli to fix underscores_inside_words
  27. curl -L "${CURL_BASEOPTS[@]}" https://github.com/walle/gimli/archive/v0.5.9.tar.gz | tar zxf -
  28. sed -i 's/).render(/, :no_intra_emphasis => true).render(/' gimli-0.5.9/ext/github_markup.rb
  29. cd gimli-0.5.9/
  30. gem build gimli.gemspec && gem install gimli
  31. cd ../
  32. ./build_docs.sh
  33. curl -k "${CURL_BASEOPTS[@]}" "${CURL_PUB_BASEOPTS[@]}" --form "manual=@docs/Manual.pdf" ${PUBLISH_URL} || true
  34. fi
  35. elif [ $PUBLISHMETA ] ; then
  36. if [ $PUBLISH_URL ] ; then
  37. RECENT_COMMITS=$(git shortlog -n25)
  38. curl -k "${CURL_BASEOPTS[@]}" "${CURL_PUB_BASEOPTS[@]}" --form "recent_commits=${RECENT_COMMITS}" ${PUBLISH_URL} || true
  39. fi
  40. elif [ $TARGET ] ; then
  41. if [ $PUBLISH_URL ] ; then
  42. make -j2
  43. if [ -f ${TARGET_FILE}.bin ] ; then
  44. TARGET_FILE=${TARGET_FILE}.bin
  45. elif [ -f ${TARGET_FILE}.hex ] ; then
  46. TARGET_FILE=${TARGET_FILE}.hex
  47. else
  48. echo "build artifact (hex or bin) for ${TARGET_FILE} not found, aborting";
  49. exit 1
  50. fi
  51. curl -k "${CURL_BASEOPTS[@]}" "${CURL_PUB_BASEOPTS[@]}" --form "file=@${TARGET_FILE}" ${PUBLISH_URL} || true
  52. exit 0;
  53. else
  54. make -j2 $MAKEFILE
  55. fi
  56. elif [ $GOAL ] ; then
  57. make V=0 $GOAL
  58. else
  59. # No target specified, build all with very low verbosity.
  60. make V=0 all
  61. fi