.gitlab-ci.yml 8.13 KB
Newer Older
1
image: mardy/qt:trusty-qt512
Alberto Mardegan's avatar
Alberto Mardegan committed
2 3 4 5 6

cache:
  key: apt-cache
  paths:
  - apt-cache/
7 8 9 10 11 12 13 14
    # for build_dependencies
  - dbus
  - exiv2
  - opencv
    # for test-desktop
  - lcov 
    # for appimage
  - tools
Alberto Mardegan's avatar
Alberto Mardegan committed
15

16 17 18 19 20
stages:
  - deps
  - build
  - test

Alberto Mardegan's avatar
Alberto Mardegan committed
21 22
before_script:
  - export APT_CACHE_DIR=`pwd`/apt-cache && mkdir -pv $APT_CACHE_DIR
23
  - PACKAGES+=libexpat1-dev # for libdbus
24
  - PACKAGES+=" libjpeg8-dev libpng12-dev libtiff5-dev zlib1g-dev" # for OpenCV
Alberto Mardegan's avatar
Alberto Mardegan committed
25
  - PACKAGES+=" fuse libegl1-mesa" # for AppImage
26 27
  - |
      apt-get update -yq && apt-get -o dir::cache::archives="$APT_CACHE_DIR" install -y \
28
          build-essential gettext pkg-config libglu1-mesa-dev libxrender1 \
Alberto Mardegan's avatar
Alberto Mardegan committed
29
          sqlite3 gcovr \
30 31
          wget \
          $PACKAGES
Alberto Mardegan's avatar
Alberto Mardegan committed
32 33 34
  - ln -f /usr/bin/g++-7 /usr/bin/g++
  - ln -f /usr/bin/gcc-7 /usr/bin/gcc
  - ln -f /usr/bin/gcov-7 /usr/bin/gcov
35 36 37 38 39 40 41

build_dependencies:
  stage: deps
  artifacts:
    paths:
      - staging
  script:
42
    - DBUS_DIR="$PWD/dbus"
43
    - OPENCV_DIR="$PWD/opencv"
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
    - STAGING="$PWD/staging"

      # Build Exiv2
    - EXIV2_VERSION="0.27"
    - EXIV2_ARCHIVE="${EXIV2_VERSION}.tar.gz"
    - mkdir -p exiv2 && cd exiv2
    - if [ ! -d "exiv2-${EXIV2_VERSION}" ]; then
    -     if [ ! -f "$EXIV2_ARCHIVE" ]; then
    -         wget -c -nv "https://github.com/Exiv2/exiv2/archive/$EXIV2_ARCHIVE"
    -         tar xzf "$EXIV2_ARCHIVE"
    -     fi
    - fi
    - cd "exiv2-${EXIV2_VERSION}"
    - mkdir -p build ; cd build
    - |
        cmake \
            -DCMAKE_INSTALL_PREFIX=$STAGING \
            -DEXIV2_BUILD_SAMPLES=OFF \
            -DEXIV2_BUILD_EXIV2_COMMAND=OFF \
63
            -DBUILD_SHARED_LIBS=OFF \
64 65 66 67 68 69
            ..
    - make install
      # Workaround for https://github.com/Exiv2/exiv2/issues/636
    - echo '#include "exiv2lib_export.h"' > tmp_header
    - cat $STAGING/include/exiv2/convert.hpp >> tmp_header
    - mv tmp_header $STAGING/include/exiv2/convert.hpp
70 71
      # Fix the pkg-config file
    - sed -ie "s,^\(Libs:.*\),\1 -lxmp -lexpat -lz -ldl," $STAGING/lib/pkgconfig/exiv2.pc
Alberto Mardegan's avatar
Alberto Mardegan committed
72

73 74 75 76 77 78 79 80 81 82 83 84 85 86
      # Build libdbus
    - DBUS_VERSION="1.12.12"
    - mkdir -p "$DBUS_DIR" && cd "$DBUS_DIR"
    - if [ ! -d "dbus-${DBUS_VERSION}" ]; then
    -     if [ ! -f "dbus-${DBUS_VERSION}" ]; then
    -         wget -c -nv "https://dbus.freedesktop.org/releases/dbus/dbus-${DBUS_VERSION}.tar.gz"
    -         tar xzf "dbus-${DBUS_VERSION}.tar.gz"
    -     fi
    - fi
    - cd "dbus-${DBUS_VERSION}"
    - LDFLAGS="-static-libgcc" ./configure --disable-Werror --disable-stats --prefix=/usr --localstatedir=/var --sysconfdir=/etc
    - make -j8
    - make DESTDIR="$STAGING" install

87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
      # Build opencv
    - OPENCV_VERSION="2.4.13.6"
    - mkdir -p "$OPENCV_DIR" && cd "$OPENCV_DIR"
    - if [ ! -d "opencv-${OPENCV_VERSION}" ]; then
    -     if [ ! -f "opencv-${OPENCV_VERSION}" ]; then
    -         wget -c -nv "https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.tar.gz"
    -         tar xzf "${OPENCV_VERSION}.tar.gz"
    -     fi
    - fi
    - cd "opencv-${OPENCV_VERSION}"
    - mkdir -p build ; cd build
    - |
        cmake \
            -DCMAKE_INSTALL_PREFIX=$STAGING \
            -DBUILD_DOCS=OFF \
            -DBUILD_JPEG=OFF \
            -DBUILD_PNG=OFF \
            -DBUILD_PERF_TESTS=OFF \
            -DBUILD_TESTS=OFF \
            -DBUILD_opencv_apps=OFF \
            -DBUILD_opencv_calib3d=OFF \
            -DBUILD_opencv_flann=OFF \
            -DBUILD_opencv_gpu=OFF \
            -DBUILD_opencv_legacy=OFF \
            -DBUILD_opencv_ml=OFF \
            -DBUILD_opencv_nonfree=OFF \
            -DBUILD_opencv_ocl=OFF \
            -DBUILD_opencv_photo=OFF \
            -DBUILD_opencv_stitching=OFF \
            -DBUILD_opencv_superres=OFF \
            -DBUILD_opencv_ts=OFF \
            -DBUILD_opencv_video=OFF \
            -DBUILD_opencv_videostab=OFF \
            -DWITH_1394=OFF \
            -DWITH_CUDA=OFF \
            -DWITH_CUFFT=OFF \
            -DWITH_FFMPEG=OFF \
            -DWITH_GIGEAPI=OFF \
            -DWITH_GSTREAMER=OFF \
            -DWITH_GTK=OFF \
            -DWITH_JASPER=OFF \
            -DWITH_LIBV4L=OFF \
            -DWITH_OPENCL=OFF \
            -DWITH_OPENCLAMDBLAS=OFF \
            -DWITH_OPENCLAMDFFT=OFF \
            -DWITH_OPENEXR=OFF \
            -DWITH_PVAPI=OFF \
            -DWITH_V4L=OFF \
135
            -DBUILD_SHARED_LIBS=OFF \
136 137 138 139
            ..
    - make -j8
    - make install

Alberto Mardegan's avatar
Alberto Mardegan committed
140 141 142
build_desktop:
  stage: build
  script:
143 144
    - STAGING="$PWD/staging"
    - export PKG_CONFIG_PATH="$STAGING/lib/pkgconfig:$PKG_CONFIG_PATH"
Alberto Mardegan's avatar
Alberto Mardegan committed
145 146 147 148
    - mkdir build
    - cd build
    - PREFIX=/opt/imaginario qmake CONFIG+=debug CONFIG+=coverage CONFIG+=desktop ..
    - make -j 4
149 150
  dependencies:
    - build_dependencies
Alberto Mardegan's avatar
Alberto Mardegan committed
151 152 153 154 155 156 157
  artifacts:
    paths:
      - build/

test_desktop:
  stage: test
  script:
Alberto Mardegan's avatar
Alberto Mardegan committed
158 159 160 161 162 163 164
    - LCOV_DIR="$PWD/lcov"
    - 'if [ ! -x "$LCOV_DIR/bin/geninfo" ]; then'
    -     wget -c -nv "https://github.com/linux-test-project/lcov/releases/download/v1.13/lcov-1.13.tar.gz"
    -     tar xzf lcov-1.13.tar.gz
    -     cd lcov-1.13 && make PREFIX="$LCOV_DIR" install && cd -
    - fi
    - export PATH="$LCOV_DIR/bin:$PATH"
165
    - STAGING="$PWD/staging"
Alberto Mardegan's avatar
Alberto Mardegan committed
166 167
    - find build | xargs touch # Avoid rebuilding
    - cd build
168
    - LD_LIBRARY_PATH="$STAGING/lib:$LD_LIBRARY_PATH" make coverage-html
Alberto Mardegan's avatar
Alberto Mardegan committed
169
  dependencies:
170
    - build_dependencies
Alberto Mardegan's avatar
Alberto Mardegan committed
171
    - build_desktop
Alberto Mardegan's avatar
Alberto Mardegan committed
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248

appimage:
  stage: build
  only:
    - tags
  dependencies:
    - build_dependencies
  artifacts:
    paths:
      - appimage/
  script:
    - STAGING="$PWD/staging"
    - APPDIR="$PWD/appdir"
    - OUTPUT="$PWD/appimage"
    - export PKG_CONFIG_PATH="$STAGING/lib/pkgconfig:$PKG_CONFIG_PATH"
    - LINUXDEPLOYQT_NAME="linuxdeployqt-continuous-x86_64.AppImage"
    - LINUXDEPLOYQT="$PWD/tools/$LINUXDEPLOYQT_NAME"
    - 'if [ ! -x "$LINUXDEPLOYQT" ]; then'
    -     mkdir -p tools && cd tools
    -     wget -c -nv "https://github.com/probonopd/linuxdeployqt/releases/download/continuous/$LINUXDEPLOYQT_NAME"
    -     chmod a+x "$LINUXDEPLOYQT"
    -     cd ..
    - fi
      # Remove those Qt plugins that we know we won't use; this is so that
      # linuxdeployqt won't dig for their dependencies and add them into the
      # AppImage
    - |
        cd /usr/local/Qt/5.12.0/gcc_64/plugins/
        for i in position/* \
                 sqldrivers/libqsqlmysql.so \
                 sqldrivers/libqsqlpsql.so
        do
            rm "/usr/local/Qt/5.12.0/gcc_64/plugins/$i"
        done
        cd -
      # Remove other stuff that we don't want to be copied
    - cd $STAGING
    - rm -rf usr/bin/* usr/share/xml usr/share/doc usr/share/dbus-1
    - cd -
      # Build Imaginario
    - mkdir $APPDIR
    - mkdir abuild
    - cd abuild
    - qmake CONFIG+=release CONFIG+=desktop CONFIG+=nomake_tests PREFIX=/usr QMAKE_LFLAGS+="-static-libgcc -static-libstdc++" ..
    - make -j8
    - make INSTALL_ROOT=$STAGING install
    - cd ..
      # Copy those things we need into the appdir
    - cd staging
    - cp -a --parents usr/bin/ usr/share/ $APPDIR
    - mkdir -p $APPDIR/usr/lib
    - cp usr/lib/libdbus-1.so.3 $APPDIR/usr/lib # not to use the system one
    - cd ..
      # Run linuxdeployqt
    - cd appdir
    - |
        LD_LIBRARY_PATH="$STAGING/lib:$LD_LIBRARY_PATH" "$LINUXDEPLOYQT" \
            $PWD/usr/share/applications/imaginario.desktop \
            -qmldir=$APPDIR/usr/share/imaginario/qml \
            -extra-plugins=imageformats/libqsvg.so,iconengines,geoservices/libqtgeoservices_osm.so \
            -bundle-non-qt-libs \
            -no-copy-copyright-files
      # Manually copy the gtk platform theme: we don't want to add it to the
      # linuxdeployqt command, as that would also bring in the gtk3 libraries.
      # In this way, instead, the qgtk3 plugin will silently fail to load if
      # gtk3 is not installed.
    - mkdir -p usr/plugins/platformthemes
    - cp /usr/local/Qt/5.12.0/gcc_64/plugins/platformthemes/libqgtk3.so usr/plugins/platformthemes/
    - cd ..
    - find appdir
    - cd abuild
    - '"$LINUXDEPLOYQT" --appimage-extract'
    - 'PATH=./squashfs-root/usr/bin:$PATH ./squashfs-root/usr/bin/appimagetool $APPDIR'
      # Finally, copy the AppImage into the artifacts directory
    - mkdir $OUTPUT
    - 'mv "Imaginario-x86_64.AppImage" "$OUTPUT/Imaginario_${CI_COMMIT_TAG:-$CI_COMMIT_SHA}.AppImage"'