build.sh 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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:
  15. # 1. Use the Uranium branch with the branch same if it exists.
  16. # 2. Otherwise, use the default branch name "master"
  17. URANIUM_BRANCH="${CI_COMMIT_REF_NAME:-master}"
  18. output="$(git ls-remote --heads https://github.com/Ultimaker/Uranium.git "${URANIUM_BRANCH}")"
  19. if [ -z "${output}" ]; then
  20. echo "Could not find Uranium banch ${URANIUM_BRANCH}, fallback to use master."
  21. URANIUM_BRANCH="master"
  22. fi
  23. echo "Using Uranium branch ${URANIUM_BRANCH} ..."
  24. git clone --depth=1 -b "${URANIUM_BRANCH}" https://github.com/Ultimaker/Uranium.git "${PROJECT_DIR}"/Uranium
  25. export PYTHONPATH="${PROJECT_DIR}/Uranium:.:${PYTHONPATH}"
  26. mkdir build
  27. cd build
  28. cmake3 \
  29. -DCMAKE_BUILD_TYPE=Debug \
  30. -DCMAKE_PREFIX_PATH="${CURA_BUILD_ENV_PATH}" \
  31. -DURANIUM_DIR="${PROJECT_DIR}/Uranium" \
  32. -DBUILD_TESTS=ON \
  33. ..
  34. make
  35. ctest3 --output-on-failure -T Test