# Maintainer (arch): Antonio Rojas <arojas@archlinux.org>
# Contributor: Sven-Hendrik Haase <sh@lutzhaase.com>
# Contributor: Imanol Celaya <ornitorrincos@archlinux-es.org>
# Contributor: Lukas Jirkovsky <l.jirkovsky@gmail.com>
# Contributor: Dan Vratil <progdan@progdansoft.com>
# Contributor: thotypous <matiasΘarchlinux-br·org>
# Contributor: delor <bartekpiech gmail com>
# Maintainer: bill-auger <bill-auger@programmer.net>
# Contributor: André Silva <emulatorman@hyperbola.info>
# Contributor: Theo von Arx <theova@member.fsf.org>


# parabola changes and rationale:
# - buld without qt5-webengine (help GUI is unavailable)
# - disable 'googletest' tests - requires internet access - libretools does not allow that


pkgname=qtcreator
pkgver=6.0.0
_clangver=13.0.0
[[ "${CARCH}" == 'i686' ]] && _clangver=12.0.1
pkgrel=1
pkgrel+=.parabola1
pkgdesc='Lightweight, cross-platform integrated development environment'
arch=(x86_64)
arch+=(armv7h i686)
url='https://www.qt.io'
license=(GPL3)
depends=(qt6-tools qt6-svg qt6-quick3d qt6-webengine qt6-serialport qt6-shadertools qt6-5compat
         clang=$_clangver clazy yaml-cpp) # syntax-highlighting
depends=( $( sed -E 's/(qt5-webengine|yaml-cpp)//g' <<<${depends[@]} ) )
depends_i686=(icu-compat) # this build requires v69 on i686
makedepends=(cmake llvm python)
options=(docs)
optdepends=('qt6-doc: integrated Qt documentation'
            'qt6-examples: welcome page examples'
            'qt6-translations: for other languages'
            'gdb: debugger'
            'cmake: cmake project support'
            'x11-ssh-askpass: ssh support'
            'git: git support'
            'mercurial: mercurial support'
            'bzr: bazaar support'
            'valgrind: analyze support'
            'perf: performer analyzer'
            'mlocate: locator filter')
source=(https://download.qt.io/official_releases/qtcreator/${pkgver%.*}/$pkgver/qt-creator-opensource-src-$pkgver.tar.xz)
sha256sums=('6beb7802f6ab339f0ea947530e6902245057ec161b2b6d2ed9053e1bee1be0bf')

_enable_tests=OFF # 'OFF' or 'ON' - 'ON' requires internet access


build() {
  cmake -B build -S qt-creator-opensource-src-$pkgver \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_INSTALL_LIBEXECDIR=lib \
    -DWITH_DOCS=ON \
    -DBUILD_DEVELOPER_DOCS=ON \
    -DBUILD_QBS=OFF \
    -DBUILD_TESTING=$_enable_tests \
    -DBUILD_HELPVIEWERBACKEND_QTWEBENGINE=OFF \
    -DQTC_CLANG_BUILDMODE_MATCH=ON

  cmake --build build
  cmake --build build --target docs
}

package() {
  DESTDIR="$pkgdir" cmake --install build

  # Install docs
  cp -r build/share/doc "$pkgdir"/usr/share

  install -Dm644 qt-creator-opensource-src-$pkgver/LICENSE.GPL3-EXCEPT "$pkgdir"/usr/share/licenses/qtcreator/LICENSE.GPL3-EXCEPT
}
