build_mac.sh 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/usr/bin/env bash
  2. #
  3. # Copyright (c) Contributors to the Open 3D Engine Project.
  4. # For complete copyright and license terms please see the LICENSE at the root of this distribution.
  5. #
  6. # SPDX-License-Identifier: Apache-2.0 OR MIT
  7. #
  8. #
  9. set -o errexit # exit on the first failure encountered
  10. BASEDIR=$(dirname "$0")
  11. source $BASEDIR/env_mac.sh
  12. mkdir -p ${OUTPUT_DIRECTORY}
  13. SOURCE_DIRECTORY=${PWD}
  14. pushd $OUTPUT_DIRECTORY
  15. LAST_CONFIGURE_CMD_FILE=ci_last_configure_cmd.txt
  16. CONFIGURE_CMD="cmake '${SOURCE_DIRECTORY}' ${CMAKE_OPTIONS} ${EXTRA_CMAKE_OPTIONS}"
  17. if [[ -n "$CMAKE_LY_PROJECTS" ]]; then
  18. CONFIGURE_CMD="${CONFIGURE_CMD} -DLY_PROJECTS='${CMAKE_LY_PROJECTS}'"
  19. fi
  20. if [[ ! -e "CMakeCache.txt" ]]; then
  21. echo [ci_build] First run, generating
  22. RUN_CONFIGURE=1
  23. elif [[ ! -e ${LAST_CONFIGURE_CMD_FILE} ]]; then
  24. echo [ci_build] Last run command not found, generating
  25. RUN_CONFIGURE=1
  26. else
  27. # Detect if the input has changed
  28. LAST_CMD=$(<${LAST_CONFIGURE_CMD_FILE})
  29. if [[ "${LAST_CMD}" != "${CONFIGURE_CMD}" ]]; then
  30. echo [ci_build] Last run command different, generating
  31. RUN_CONFIGURE=1
  32. fi
  33. fi
  34. # temporarily enabling cmake regeneration for this platform
  35. # We have observed cases where continous integration has not regenerated but a regeneration was required, leaving the build in a bad state
  36. RUN_CONFIGURE=1
  37. if [[ ! -z "$RUN_CONFIGURE" ]]; then
  38. # have to use eval since $CMAKE_OPTIONS (${EXTRA_CMAKE_OPTIONS}) contains quotes that need to be processed
  39. eval echo [ci_build] ${CONFIGURE_CMD}
  40. eval ${CONFIGURE_CMD}
  41. # Save the run only if success
  42. echo "${CONFIGURE_CMD}" > ${LAST_CONFIGURE_CMD_FILE}
  43. fi
  44. echo [ci_build] cmake --build . --target ${CMAKE_TARGET} --config ${CONFIGURATION} -j $(/usr/sbin/sysctl -n hw.ncpu) -- ${CMAKE_NATIVE_BUILD_ARGS}
  45. cmake --build . --target ${CMAKE_TARGET} --config ${CONFIGURATION} -j $(/usr/sbin/sysctl -n hw.ncpu) -- ${CMAKE_NATIVE_BUILD_ARGS}
  46. popd