prepare_plugins.sh 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #!/bin/bash
  2. #
  3. # Copyright 2021 EMQ Technologies Co., Ltd.
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. #
  17. set -e
  18. go build -o test/plugins/pub/zmq_pub test/plugins/pub/zmq_pub.go
  19. chmod +x test/plugins/pub/zmq_pub
  20. go build -o test/plugins/service/http_server test/plugins/service/server.go
  21. chmod +x test/plugins/service/http_server
  22. cd test
  23. rm -rf zmq.* Zmq.so
  24. FILE=../plugins/sources/Zmq.so
  25. if [ -f "$FILE" ]; then
  26. echo "$FILE exists, not requried to build plugin."
  27. else
  28. echo "$FILE does not exist, will build the plugin."
  29. go build -trimpath -modfile ../extensions.mod --buildmode=plugin -o ../plugins/sources/Zmq.so ../extensions/sources/zmq/zmq.go
  30. fi
  31. mv ../plugins/sources/Zmq.so .
  32. cp plugins/zmq.yaml .
  33. zip zmq.zip Zmq.so zmq.yaml
  34. rm -rf zmq.yaml Zmq.so
  35. rm -rf image.* Image.so
  36. FILE=../plugins/functions/Image.so
  37. if [ -f "$FILE" ]; then
  38. echo "$FILE exists, not requried to build plugin."
  39. else
  40. echo "$FILE does not exist, will build the plugin."
  41. go build -trimpath -modfile ../extensions.mod --buildmode=plugin -o ../plugins/functions/Image.so ../extensions/functions/image/*.go
  42. fi
  43. mv ../plugins/functions/Image.so .
  44. zip image.zip Image.so
  45. rm -rf Image.so
  46. rm -rf plugins/service/web/plugins/
  47. mkdir -p plugins/service/web/plugins/
  48. mv zmq.zip plugins/service/web/plugins/
  49. mv image.zip plugins/service/web/plugins/
  50. # prepare portable plugins
  51. cd ..
  52. mkdir test/temp
  53. mkdir test/temp/mirror
  54. cd sdk/go/example/mirror
  55. go build -o ../../../../test/temp/mirror/mirror .
  56. cd ../../../..
  57. cp sdk/go/example/mirror/mirror.json test/temp/mirror
  58. cp -r sdk/go/example/mirror/sources test/temp/mirror/
  59. cd test/temp/mirror
  60. zip -r ../../plugins/service/web/plugins/mirror.zip *
  61. cd ../../..
  62. cp -r sdk/python/example/pysam test/temp/pysam
  63. cp -r sdk/python/ekuiper test/temp/pysam/
  64. cd test/temp/pysam
  65. zip -r ../../plugins/service/web/plugins/pysam.zip *
  66. cd ../..
  67. rm -r temp
  68. cd plugins/service/
  69. export BUILD_ID=dontKillMe
  70. echo "starting mock http server..."
  71. nohup ./http_server > http_server.out 2>&1 &