generator.sh 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/env bash
  2. #
  3. # To generate IDE help files of Swoole.
  4. #
  5. # How to use this script:
  6. # ./bin/generator.sh # To generate stubs with latest code from the master branch of Swoole.
  7. # ./bin/generator.sh 4.4.7 # To generate stubs for a specific version of Swoole.
  8. #
  9. # You can also specify a 2nd parameter, indicating which Swoole libary version to be integrated in. By default it will
  10. # have latest Swoole libary included (from the master branch). e.g.,
  11. # ./bin/generator.sh 4.4.13 master
  12. # ./bin/generator.sh 4.4.13 a236ce004518e166b483d8d72cf5cc9ac2282164
  13. #
  14. set -e
  15. pushd "`dirname "$0"`" > /dev/null
  16. ROOT_PATH="`pwd -P`/.."
  17. popd > /dev/null # Switch back to current directory.
  18. cd "${ROOT_PATH}" # Switch to root directory of project "ide-helper".
  19. if [ -z "${1}" ] ; then
  20. echo INFO: Generating stubs with latest code from the master branch of Swoole.
  21. image_tag=latest
  22. else
  23. if [[ "${1}" =~ ^[1-9][0-9]*\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-[A-Za-z0-9_]+)?$ ]] ; then
  24. echo INFO: Generating stubs for Swoole ${1}.
  25. image_tag=${1}-php7.3
  26. else
  27. echo "Error: '${1}' is not a valid Swoole version."
  28. exit 1
  29. fi
  30. fi
  31. rm -rf ./output
  32. docker run --rm \
  33. -v "`pwd`":/var/www \
  34. -e SWOOLE_EXT_ASYNC=enabled \
  35. -e SWOOLE_EXT_ORM=enabled \
  36. -e SWOOLE_EXT_POSTGRESQL=enabled \
  37. -e SWOOLE_EXT_SERIALIZE=enabled \
  38. -e SWOOLE_EXT_ZOOKEEPER=enabled \
  39. -e SWOOLE_LIB_VERSION=${2} \
  40. -t phpswoole/swoole:${image_tag} \
  41. bash -c "composer install && SWOOLE_SRC_DIR=/usr/src/swoole ./bin/generator.php"
  42. git add ./output