.gitlab-ci.yml 9.94 KB
Newer Older
Alberto Mardegan's avatar
Alberto Mardegan committed
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
  - binutils
8 9 10 11 12 13 14 15
    # for build_dependencies
  - dbus
  - exiv2
  - opencv
    # for test-desktop
  - lcov 
    # for appimage
  - tools
Alberto Mardegan's avatar
Alberto Mardegan committed
16

Alberto Mardegan's avatar
Alberto Mardegan committed
17 18 19 20 21
stages:
  - deps
  - build
  - test

22
.desktop_dependencies: &desktop_dependencies
Alberto Mardegan's avatar
Alberto Mardegan committed
23
  - export APT_CACHE_DIR=`pwd`/apt-cache && mkdir -pv $APT_CACHE_DIR
Alberto Mardegan's avatar
Alberto Mardegan committed
24
  - PACKAGES+=libexpat1-dev # for libdbus
25
  - PACKAGES+=" libjpeg8-dev libpng12-dev libtiff5-dev zlib1g-dev" # for OpenCV
Alberto Mardegan's avatar
Alberto Mardegan committed
26
  - PACKAGES+=" fuse libegl1-mesa" # for AppImage
27 28
  - |
      apt-get update -yq && apt-get -o dir::cache::archives="$APT_CACHE_DIR" install -y \
29
          build-essential gettext pkg-config libglu1-mesa-dev libxrender1 \
Alberto Mardegan's avatar
Alberto Mardegan committed
30
          sqlite3 gcovr \
Alberto Mardegan's avatar
Alberto Mardegan committed
31 32
          wget \
          $PACKAGES
Alberto Mardegan's avatar
Alberto Mardegan committed
33 34 35
  - 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
Alberto Mardegan's avatar
Alberto Mardegan committed
36

37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
  # Build binutils
  - BINUTILS_VERSION="2.26.1"
  - BINUTILS_ARCHIVE="binutils-${BINUTILS_VERSION}.tar.bz2"
  - mkdir -p binutils && cd binutils
  - if [ ! -d "binutils-${BINUTILS_VERSION}" ]; then
  -     if [ ! -f "$BINUTILS_ARCHIVE" ]; then
  -         wget -c -nv "https://mirror.tochlab.net/pub/gnu/binutils/$BINUTILS_ARCHIVE"
  -         tar xjf "$BINUTILS_ARCHIVE"
  -     fi
  - fi
  - cd "binutils-${BINUTILS_VERSION}"
  - if [ ! -f Makefile ]; then
  -     ./configure --prefix=/usr --localstatedir=/var --sysconfdir=/etc
  - fi
  - make -j8
  - make install
  - cd ../..


Alberto Mardegan's avatar
Alberto Mardegan committed
56 57 58 59 60
build_dependencies:
  stage: deps
  artifacts:
    paths:
      - staging
61 62
  before_script:
    - *desktop_dependencies
Alberto Mardegan's avatar
Alberto Mardegan committed
63
  script:
Alberto Mardegan's avatar
Alberto Mardegan committed
64
    - DBUS_DIR="$PWD/dbus"
65
    - OPENCV_DIR="$PWD/opencv"
Alberto Mardegan's avatar
Alberto Mardegan committed
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
    - 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 \
85
            -DBUILD_SHARED_LIBS=OFF \
Alberto Mardegan's avatar
Alberto Mardegan committed
86 87 88 89 90 91
            ..
    - 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
92 93
      # 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
94

Alberto Mardegan's avatar
Alberto Mardegan committed
95 96 97 98 99 100 101 102 103 104 105 106 107 108
      # 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

109
      # Build opencv
110
    - OPENCV_VERSION="3.4.8"
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
    - 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 \
129 130 131
            -DBUILD_opencv_calib3d=ON \
            -DBUILD_opencv_objdetect=ON \
            -DBUILD_opencv_dnn=OFF \
132 133 134 135 136 137 138 139 140 141 142
            -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 \
143
            -DBUILD_opencv_videoio=OFF \
144
            -DBUILD_opencv_videostab=OFF \
145 146
            -DCPU_DISPATCH= \
            -DCV_TRACE=OFF \
147 148 149 150 151 152 153
            -DWITH_1394=OFF \
            -DWITH_CUDA=OFF \
            -DWITH_CUFFT=OFF \
            -DWITH_FFMPEG=OFF \
            -DWITH_GIGEAPI=OFF \
            -DWITH_GSTREAMER=OFF \
            -DWITH_GTK=OFF \
154 155 156 157
            -DWITH_IMGCODEC_HDR=OFF \
            -DWITH_IMGCODEC_PXM=OFF \
            -DWITH_IMGCODEC_SUNRASTER=OFF \
            -DWITH_IPP=OFF \
158 159 160 161 162 163
            -DWITH_JASPER=OFF \
            -DWITH_LIBV4L=OFF \
            -DWITH_OPENCL=OFF \
            -DWITH_OPENCLAMDBLAS=OFF \
            -DWITH_OPENCLAMDFFT=OFF \
            -DWITH_OPENEXR=OFF \
164
            -DWITH_PROTOBUF=OFF \
165 166
            -DWITH_PVAPI=OFF \
            -DWITH_V4L=OFF \
167 168
            -DCMAKE_CXX_FLAGS="-static-libgcc -static-libstdc++" \
            -DENABLE_PRECOMPILED_HEADERS=OFF \
169
            -DBUILD_SHARED_LIBS=OFF \
170 171 172
            ..
    - make -j8
    - make install
173 174 175
    # Hack: add static libs
    - cat $STAGING/lib/pkgconfig/opencv.pc | tr '\n' '\r' | sed 's/\rLibs.private://' | tr '\r' '\n' > $STAGING/lib/pkgconfig/opencv.pc.out
    - mv $STAGING/lib/pkgconfig/opencv.pc{.out,}
176

Alberto Mardegan's avatar
Alberto Mardegan committed
177 178
build_desktop:
  stage: build
179 180
  before_script:
    - *desktop_dependencies
Alberto Mardegan's avatar
Alberto Mardegan committed
181
  script:
Alberto Mardegan's avatar
Alberto Mardegan committed
182 183
    - STAGING="$PWD/staging"
    - export PKG_CONFIG_PATH="$STAGING/lib/pkgconfig:$PKG_CONFIG_PATH"
Alberto Mardegan's avatar
Alberto Mardegan committed
184 185 186 187
    - mkdir build
    - cd build
    - PREFIX=/opt/imaginario qmake CONFIG+=debug CONFIG+=coverage CONFIG+=desktop ..
    - make -j 4
Alberto Mardegan's avatar
Alberto Mardegan committed
188 189
  dependencies:
    - build_dependencies
Alberto Mardegan's avatar
Alberto Mardegan committed
190 191 192 193 194 195
  artifacts:
    paths:
      - build/

test_desktop:
  stage: test
196 197
  before_script:
    - *desktop_dependencies
Alberto Mardegan's avatar
Alberto Mardegan committed
198
  script:
Alberto Mardegan's avatar
Alberto Mardegan committed
199 200 201 202 203 204 205
    - 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"
Alberto Mardegan's avatar
Alberto Mardegan committed
206
    - STAGING="$PWD/staging"
Alberto Mardegan's avatar
Alberto Mardegan committed
207 208
    - find build | xargs touch # Avoid rebuilding
    - cd build
Alberto Mardegan's avatar
Alberto Mardegan committed
209
    - LD_LIBRARY_PATH="$STAGING/lib:$LD_LIBRARY_PATH" make coverage-html
Alberto Mardegan's avatar
Alberto Mardegan committed
210
  dependencies:
Alberto Mardegan's avatar
Alberto Mardegan committed
211
    - build_dependencies
Alberto Mardegan's avatar
Alberto Mardegan committed
212
    - build_desktop
213 214 215
  artifacts:
    paths:
      - build/coverage-html/
Alberto Mardegan's avatar
Alberto Mardegan committed
216 217 218 219 220 221 222 223 224 225

appimage:
  stage: build
  only:
    - tags
  dependencies:
    - build_dependencies
  artifacts:
    paths:
      - appimage/
226 227
  before_script:
    - *desktop_dependencies
Alberto Mardegan's avatar
Alberto Mardegan committed
228
  script:
229
    - SRCDIR="$PWD"
Alberto Mardegan's avatar
Alberto Mardegan committed
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252
    - 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 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
253
    - objdump -T $STAGING/usr/bin/imaginario | grep GLIBCXX && exit 1
Alberto Mardegan's avatar
Alberto Mardegan committed
254 255 256 257 258 259 260 261 262 263 264 265
    - 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 \
266
            -qmldir=${SRCDIR}/src/desktop/qml \
Alberto Mardegan's avatar
Alberto Mardegan committed
267
            -extra-plugins=imageformats/libqsvg.so,iconengines,geoservices/libqtgeoservices_osm.so \
268
            -exclude-libs=libqsqlodbc,libqsqlpsql,libqtposition_geoclue2,libqtposition_positionpoll,libqtposition_serialnmea,libqtposition_geoclue \
Alberto Mardegan's avatar
Alberto Mardegan committed
269 270 271 272 273 274 275
            -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
276
    - cp /usr/local/Qt/5.12.*/gcc_64/plugins/platformthemes/libqgtk3.so usr/plugins/platformthemes/
Alberto Mardegan's avatar
Alberto Mardegan committed
277 278 279 280 281 282 283 284 285
    - 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"'

286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310
deps_click:
  image: clickable/ci-16.04-armhf
  stage: deps
  cache:
    key: "$CI_JOB_NAME"
    paths:
    - opencv-build/
  script:
    - 'if [ ! -x "opencv-build/install" ]; then'
    -     clickable run ./build_opencv.sh
    - fi
  artifacts:
    paths:
      - opencv-build/install
    expire_in: 1h

build_click:
  image: clickable/ci-16.04-armhf
  stage: build
  script:
    - clickable build
    - find . -name '*.click'
  artifacts:
    paths:
      - build/*/app/it.mardy.imaginario_*.click