build_plugins.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/bin/bash
  2. set -e
  3. if [ -z $1 ] ; then
  4. echo "$0 <destination directory>"
  5. exit 1
  6. fi
  7. DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
  8. OCV="$( cd "${DIR}/../../../.." >/dev/null 2>&1 && pwd )"
  9. mkdir -p "${1}" # Docker creates non-existed mounts with 'root' owner, lets ensure that dir exists under the current user to avoid "Permission denied" problem
  10. DST="$( cd "$1" >/dev/null 2>&1 && pwd )"
  11. CFG=${2:-Release}
  12. do_build()
  13. {
  14. TAG=$1
  15. D=$2
  16. F=$3
  17. shift 3
  18. docker build \
  19. --build-arg http_proxy \
  20. --build-arg https_proxy \
  21. $@ \
  22. -t $TAG \
  23. -f "${D}/${F}" \
  24. "${D}"
  25. }
  26. do_run()
  27. {
  28. TAG=$1
  29. shift 1
  30. docker run \
  31. -it \
  32. --rm \
  33. -v "${OCV}":/opencv:ro \
  34. -v "${DST}":/dst \
  35. -e CFG=$CFG \
  36. --user $(id -u):$(id -g) \
  37. $TAG \
  38. "$@"
  39. }
  40. build_gtk2_ubuntu()
  41. {
  42. VER=$1
  43. shift 1
  44. TAG=opencv_highgui_ubuntu_gtk2_builder:${VER}
  45. do_build $TAG "${DIR}/plugin_gtk" Dockerfile-ubuntu-gtk2 --build-arg VER=${VER}
  46. do_run $TAG /opencv/modules/highgui/misc/plugins/plugin_gtk/build.sh /dst gtk2_ubuntu${VER} ${CFG} "$@"
  47. }
  48. build_gtk3_ubuntu()
  49. {
  50. VER=$1
  51. shift 1
  52. TAG=opencv_highgui_ubuntu_gtk3_builder:${VER}
  53. do_build $TAG "${DIR}/plugin_gtk" Dockerfile-ubuntu-gtk3 --build-arg VER=${VER}
  54. do_run $TAG /opencv/modules/highgui/misc/plugins/plugin_gtk/build.sh /dst gtk3_ubuntu${VER} ${CFG} "$@"
  55. }
  56. echo "OpenCV: ${OCV}"
  57. echo "Destination: ${DST}"
  58. build_gtk2_ubuntu 16.04
  59. build_gtk2_ubuntu 16.04 -DOPENCV_PLUGIN_NAME=opencv_highgui_gtk2-opengl_ubuntu16.04 -DWITH_OPENGL=ON -DWITH_GTK_2_X=ON
  60. build_gtk2_ubuntu 18.04
  61. build_gtk3_ubuntu 18.04
  62. build_gtk3_ubuntu 20.04