clean_mac.sh 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. # Jenkins defines environment variables for parameters and passes "false" to variables
  11. # that are not set. Here we clear them if they are false so we can also just define them
  12. # from command line
  13. if [[ "${CLEAN_ASSETS}" == "false" ]]; then
  14. CLEAN_ASSETS=
  15. fi
  16. if [[ "${CLEAN_OUTPUT_DIRECTORY}" == "false" ]]; then
  17. CLEAN_OUTPUT_DIRECTORY=
  18. fi
  19. if [[ -n "$CLEAN_ASSETS" ]]; then
  20. echo "[ci_build] CLEAN_ASSETS option set"
  21. for project in $(echo $CMAKE_LY_PROJECTS | sed "s/;/ /g")
  22. do
  23. if [[ -d "$project/Cache" ]]; then
  24. echo "[ci_build] Deleting \"$project/Cache\""
  25. rm -rf $project/Cache
  26. fi
  27. done
  28. fi
  29. # If the node label changes, we issue a clean output since node changes can change SDK/CMake/toolchains/etc
  30. LAST_CONFIGURE_NODE_LABEL_FILE=ci_last_node_label.txt
  31. if [[ -n "$NODE_LABEL" ]]; then
  32. if [[ -d $OUTPUT_DIRECTORY ]]; then
  33. pushd $OUTPUT_DIRECTORY
  34. if [[ -e ${LAST_CONFIGURE_NODE_LABEL_FILE} ]]; then
  35. LAST_NODE_LABEL=$(<${LAST_CONFIGURE_NODE_LABEL_FILE})
  36. else
  37. LAST_NODE_LABEL=
  38. fi
  39. # Detect if the node label has changed
  40. if [[ "${LAST_NODE_LABEL}" != "${NODE_LABEL}" ]]; then
  41. echo [ci_build] Last run was done with node label \"${LAST_NODE_LABEL}\", new node label is \"${NODE_LABEL}\", forcing CLEAN_OUTPUT_DIRECTORY
  42. CLEAN_OUTPUT_DIRECTORY=1
  43. fi
  44. popd
  45. fi
  46. fi
  47. if [[ -n "$CLEAN_OUTPUT_DIRECTORY" ]]; then
  48. echo "[ci_build] CLEAN_OUTPUT_DIRECTORY option set"
  49. if [[ -d $OUTPUT_DIRECTORY ]]; then
  50. echo "[ci_build] Deleting \"${OUTPUT_DIRECTORY}\""
  51. rm -rf ${OUTPUT_DIRECTORY}
  52. fi
  53. fi
  54. mkdir -p ${OUTPUT_DIRECTORY}
  55. # Save the node label
  56. pushd $OUTPUT_DIRECTORY
  57. echo "${NODE_LABEL}" > ${LAST_CONFIGURE_NODE_LABEL_FILE}
  58. popd