03_build_plugin.sh 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/bin/bash
  2. ##############################################################################
  3. # Linux libobs plugin build function
  4. ##############################################################################
  5. #
  6. # This script file can be included in build scripts for Linux or run directly
  7. #
  8. ##############################################################################
  9. # Halt on errors
  10. set -eE
  11. build_obs_plugin() {
  12. status "Build plugin ${PRODUCT_NAME}"
  13. trap "caught_error 'builds_obs_plugin'" ERR
  14. ensure_dir "${CHECKOUT_DIR}"
  15. step "Configuring OBS plugin build system"
  16. check_ccache
  17. cmake -S . -B ${BUILD_DIR} -G Ninja ${CMAKE_CCACHE_OPTIONS} ${QUIET:+-Wno-deprecated -Wno-dev --log-level=ERROR}
  18. step "Building OBS plugin"
  19. cmake --build ${BUILD_DIR}
  20. }
  21. build-plugin-standalone() {
  22. CHECKOUT_DIR="$(git rev-parse --show-toplevel)"
  23. if [ -f "${CHECKOUT_DIR}/CI/include/build_environment.sh" ]; then
  24. source "${CHECKOUT_DIR}/CI/include/build_environment.sh"
  25. fi
  26. PRODUCT_NAME="${PRODUCT_NAME:-obs-plugin}"
  27. source "${CHECKOUT_DIR}/CI/include/build_support.sh"
  28. source "${CHECKOUT_DIR}/CI/include/build_support_linux.sh"
  29. build_obs_plugin
  30. }
  31. print_usage() {
  32. echo -e "Usage: ${0}\n" \
  33. "-h, --help : Print this help\n" \
  34. "-q, --quiet : Suppress most build process output\n" \
  35. "-v, --verbose : Enable more verbose build process output\n" \
  36. "--build-dir : Specify alternative build directory (default: build)\n"
  37. }
  38. build-plugin-main() {
  39. if [ -z "${_RUN_OBS_BUILD_SCRIPT}" ]; then
  40. while true; do
  41. case "${1}" in
  42. -h | --help ) print_usage; exit 0 ;;
  43. -q | --quiet ) export QUIET=TRUE; shift ;;
  44. -v | --verbose ) export VERBOSE=TRUE; shift ;;
  45. --build-dir ) BUILD_DIR="${2}"; shift 2 ;;
  46. -- ) shift; break ;;
  47. * ) break ;;
  48. esac
  49. done
  50. build-plugin-standalone
  51. fi
  52. }
  53. build-plugin-main $*