build.sh 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/usr/bin/env bash
  2. # Abort at the first error.
  3. set -e
  4. SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
  5. PROJECT_DIR="$( cd "${SCRIPT_DIR}/.." && pwd )"
  6. # Make sure that environment variables are set properly
  7. source /opt/rh/devtoolset-7/enable
  8. export PATH="${CURA_BUILD_ENV_PATH}/bin:${PATH}"
  9. export PKG_CONFIG_PATH="${CURA_BUILD_ENV_PATH}/lib/pkgconfig:${PKG_CONFIG_PATH}"
  10. cd "${PROJECT_DIR}"
  11. #
  12. # Clone Uranium and set PYTHONPATH first
  13. #
  14. # Check the branch to use for Uranium.
  15. # It tries the following branch names and uses the first one that's available.
  16. # - GITHUB_HEAD_REF: the branch name of a PR. If it's not a PR, it will be empty.
  17. # - GITHUB_BASE_REF: the branch a PR is based on. If it's not a PR, it will be empty.
  18. # - GITHUB_REF: the branch name if it's a branch on the repository;
  19. # refs/pull/123/merge if it's a pull_request.
  20. # - master: the master branch. It should always exist.
  21. # For debugging.
  22. echo "GITHUB_REF: ${GITHUB_REF}"
  23. echo "GITHUB_HEAD_REF: ${GITHUB_HEAD_REF}"
  24. echo "GITHUB_BASE_REF: ${GITHUB_BASE_REF}"
  25. GIT_REF_NAME_LIST=( "${GITHUB_HEAD_REF}" "${GITHUB_BASE_REF}" "${GITHUB_REF}" "master" )
  26. for git_ref_name in "${GIT_REF_NAME_LIST[@]}"
  27. do
  28. if [ -z "${git_ref_name}" ]; then
  29. continue
  30. fi
  31. git_ref_name="$(basename "${git_ref_name}")"
  32. # Skip refs/pull/1234/merge as pull requests use it as GITHUB_REF
  33. if [[ "${git_ref_name}" == "merge" ]]; then
  34. echo "Skip [${git_ref_name}]"
  35. continue
  36. fi
  37. URANIUM_BRANCH="${git_ref_name}"
  38. output="$(git ls-remote --heads https://github.com/Ultimaker/Uranium.git "${URANIUM_BRANCH}")"
  39. if [ -n "${output}" ]; then
  40. echo "Found Uranium branch [${URANIUM_BRANCH}]."
  41. break
  42. else
  43. echo "Could not find Uranium banch [${URANIUM_BRANCH}], try next."
  44. fi
  45. done
  46. echo "Using Uranium branch ${URANIUM_BRANCH} ..."
  47. git clone --depth=1 -b "${URANIUM_BRANCH}" https://github.com/Ultimaker/Uranium.git "${PROJECT_DIR}"/Uranium
  48. export PYTHONPATH="${PROJECT_DIR}/Uranium:.:${PYTHONPATH}"
  49. mkdir build
  50. cd build
  51. cmake3 \
  52. -DCMAKE_BUILD_TYPE=Debug \
  53. -DCMAKE_PREFIX_PATH="${CURA_BUILD_ENV_PATH}" \
  54. -DURANIUM_DIR="${PROJECT_DIR}/Uranium" \
  55. -DBUILD_TESTS=ON \
  56. -DPRINT_PLUGIN_LIST=OFF \
  57. -DGENERATE_TRANSLATIONS=OFF \
  58. ..
  59. make