Javicle - a JSON Video Composition Language
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

jvcl_common 2.0 KiB

4 年前
4 年前
4 年前
4 年前
4 年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #!/bin/bash
  2. function die () {
  3. echo 1>&2 "${1}"
  4. exit 1
  5. }
  6. function handle_help_request() {
  7. if [[ -z "${2}" ]]; then
  8. return
  9. fi
  10. if [[ ${2} == "-h" || ${2} == "--help" ]]; then
  11. while IFS='' read -r line || [[ -n "$line" ]]; do
  12. if [[ ${line} =~ ^#.* ]]; then
  13. if [[ ! ${line} =~ ^#!/bin/bash.* ]]; then
  14. echo "${line}"
  15. fi
  16. else
  17. break
  18. fi
  19. done <"${1}"
  20. if [[ -z "${JVCL_SKIP_ENV_VAR_HELP}" ]] ; then
  21. echo "# Environment Variables
  22. #
  23. # JVCL_SCRATCH_DIR : Use this as the scratch directory
  24. # Default is to create a new temp directory
  25. #
  26. # JVCL_NO_EXEC : If set to anything, print the commands that would
  27. # have run but do not execute anything
  28. #
  29. "
  30. fi
  31. exit 1
  32. fi
  33. }
  34. # Ensure Java is installed and that it is Java 11
  35. if [[ -z "$(which java)" ]] ; then
  36. die "Java 11 not installed (java command not found on PATH)"
  37. fi
  38. JAVA_OK=0
  39. for token in $(java -version 2>&1 | grep -i version) ; do
  40. case "${token}" in '"11.'*)
  41. JAVA_OK=1
  42. esac
  43. done
  44. if [[ ${JAVA_OK} -eq 0 ]] ; then
  45. die "Java 11 not installed (java -version check failed)"
  46. fi
  47. JVCL_DIR="$(cd "$(dirname "${0}")"/.. && pwd)"
  48. JVCL_JAR="$(find "${JVCL_DIR}"/target -type f -name "jvcl-*-prod.jar" | head -1)"
  49. if [[ -z "${JVCL_JAR}" ]] ; then
  50. # Ensure maven is installed
  51. if [[ -z "$(which mvn)" ]] ; then
  52. die "Maven not installed (mvn command not found on PATH), cannot build JVCL jar"
  53. fi
  54. mvn -DskipTests=true -Puberjar clean package || die "Error building JVCL jar"
  55. JVCL_JAR="$(find "${JVCL_DIR}"/target -type f -name "jvcl-*-prod.jar" | head -1)"
  56. if [[ -z "${JVCL_JAR}" ]] ; then
  57. die "No JVCL jar file found after successful build"
  58. fi
  59. fi
  60. SCRATCH_DIR=""
  61. NO_EXEC=""
  62. if [[ -z "${JVCL_SKIP_ENV_VAR_HELP}" ]] ; then
  63. if [[ -n "${JVCL_SCRATCH_DIR}" ]] ; then
  64. SCRATCH_DIR="--temp-dir ${JVCL_SCRATCH_DIR}"
  65. fi
  66. if [[ -n "${JVCL_NO_EXEC}" ]] ; then
  67. NO_EXEC="--no-exec"
  68. fi
  69. fi
  70. JVCL_OPTIONS="${SCRATCH_DIR} ${NO_EXEC}"
  71. handle_help_request "${0}" "${1}"