mconnect - KDE Connect protocol implementation in Vala/C
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

189 lines
4.6 KiB

  1. #!/bin/bash -xe
  2. #
  3. # This program is free software; you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License version 2 as
  5. # published by the Free Software Foundation.
  6. #
  7. # This program is distributed in the hope that it will be useful,
  8. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. # GNU General Public License for more details.
  11. #
  12. # You should have received a copy of the GNU General Public License along
  13. # with this program; if not, write to the Free Software Foundation, Inc.,
  14. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  15. #
  16. # AUTHORS
  17. # Maciek Borzecki <maciek.borzecki (at] gmail.com>
  18. # Travis build script. The script reexecs itself inside the container (setting
  19. # IN_CONTAINER=1). The proceeds to install build dependencies and runs through
  20. # the whole build process. Source tree is bind-mounted at /mnt and the container
  21. # has its workdir set to /mnt
  22. #
  23. # NOTE: it is assumed that the script is run while at the top of source tree
  24. # (i.e. $PWD is your checked out tree, this crucial for properly mounting the
  25. # source code into the container).
  26. deps_fedora() {
  27. dnf install --best -y --refresh \
  28. meson \
  29. pkgconfig \
  30. gcc \
  31. vala \
  32. gobject-introspection-devel \
  33. json-glib-devel \
  34. libgee-devel \
  35. gnutls-devel \
  36. libnotify-devel \
  37. at-spi2-core-devel \
  38. gtk3-devel \
  39. glib-networking \
  40. tree \
  41. uncrustify
  42. }
  43. deps_opensuse() {
  44. zypper install -y \
  45. make \
  46. meson \
  47. pkgconfig \
  48. gcc \
  49. vala \
  50. gobject-introspection-devel \
  51. json-glib-devel \
  52. libgee-devel \
  53. gnutls-devel \
  54. libnotify-devel \
  55. at-spi2-core-devel \
  56. gtk3-devel \
  57. glib-networking \
  58. tree \
  59. uncrustify
  60. }
  61. deps_archlinux() {
  62. pacman -Syu --noconfirm \
  63. base-devel \
  64. meson \
  65. pkg-config \
  66. gcc \
  67. vala \
  68. glib2 \
  69. gobject-introspection \
  70. json-glib \
  71. libgee \
  72. libnotify \
  73. at-spi2-core \
  74. gtk3 \
  75. gnutls \
  76. glib-networking \
  77. tree \
  78. uncrustify
  79. }
  80. deps_ubuntu_xenial() {
  81. apt-get update && \
  82. apt-get install -y \
  83. meson/xenial-backports \
  84. pkg-config \
  85. valac \
  86. libgirepository1.0-dev \
  87. libjson-glib-dev \
  88. libgee-0.8-dev \
  89. libgnutls28-dev \
  90. libnotify-dev \
  91. libgtk-3-dev \
  92. glib-networking \
  93. tree \
  94. uncrustify
  95. }
  96. install_deps() {
  97. case "$1" in
  98. fedora)
  99. deps_fedora
  100. ;;
  101. opensuse)
  102. deps_opensuse
  103. ;;
  104. archlinux)
  105. deps_archlinux
  106. ;;
  107. ubuntu-xenial)
  108. deps_ubuntu_xenial
  109. ;;
  110. *)
  111. echo "unsupported distro $1"
  112. exit 1
  113. esac
  114. }
  115. build() {
  116. set -ex
  117. ./extra/fmt check || {
  118. echo "WARNING: code formatting check failed"
  119. [ -z "${SUPPRESS_FMT}" ] && false
  120. }
  121. mkdir -p build && \
  122. cd build && \
  123. meson .. && \
  124. ninja && \
  125. ninja test \
  126. || false
  127. DESTDIR=$PWD/install-dir ninja install
  128. (cd install-dir; LC_ALL=C tree -pan . > ../current-tree)
  129. diff -up ../extra/install-tree current-tree
  130. }
  131. build_in_container() {
  132. install_deps $1
  133. # distro specific quirks
  134. case "$1" in
  135. ubuntu-xenial|opensuse)
  136. echo "$1 is using an outdated version of uncrustify, suppress formatting errors"
  137. export SUPPRESS_FMT=1
  138. ;;
  139. esac
  140. build
  141. }
  142. spin_container() {
  143. case "$1" in
  144. fedora)
  145. DOCKER_IMG=fedora
  146. ;;
  147. archlinux)
  148. DOCKER_IMG=base/archlinux
  149. ;;
  150. opensuse)
  151. DOCKER_IMG=opensuse:tumbleweed
  152. ;;
  153. ubuntu-xenial)
  154. DOCKER_IMG=ubuntu:xenial
  155. ;;
  156. *)
  157. echo "unsupported distro $1"
  158. exit 1
  159. esac
  160. # run a container, mount sources at /mnt, st
  161. docker run --rm \
  162. -v $PWD:/mnt \
  163. -w /mnt \
  164. -e IN_CONTAINER=1 \
  165. $DOCKER_IMG \
  166. /mnt/extra/travis-build "$@"
  167. }
  168. if [ -z "$NO_BUILD" ]; then
  169. if [ "$IN_CONTAINER" = "1" ]; then
  170. build_in_container "$@"
  171. else
  172. spin_container "$@"
  173. fi
  174. fi