summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: aea495deb770006245a0a2558c05b1aba7e13dd9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# Maintainer: taotieren <admin@taotieren.com>

pkgname=mcuviewer-git
pkgver=1.1.0.r0.g3650ed7
pkgrel=2
pkgdesc="Real-time embedded variable & trace viewer"
arch=($CARCH)
url="https://github.com/klonyyy/MCUViewer"
license=('GPL-3.0-only')
provides=(${pkgname%-git})
conflicts=(${pkgname%-git})
depends=(
    sh
    gcc-libs
    glfw
    glib2
    glibc
    gtk3
    libglvnd
    libusb
    #     jlink-software-and-documentation
    #     stlink
)
makedepends=(
    cmake
    git
    ninja
    spdlog
    pkgconf
    python
)
optdepends=(
    'jlink-software-and-documentation: Segger JLink software & documentation pack for Linux'
    'stlink: Open source STM32 MCU programming toolset'
)
backup=()
options=()
source=("${pkgname}::git+${url}.git")
sha256sums=('SKIP')

pkgver() {
    cd "${srcdir}/${pkgname}"
    (
        set -o pipefail
        git describe --long --tag --abbrev=7 2>/dev/null | sed 's/^v//g;s/\([^-]*-g\)/r\1/;s/-/./g' ||
            printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short=7 HEAD)"
    )
}

prepare() {
    git -C "${srcdir}/${pkgname}" clean -dfx
}

build() {
    export CFLAGS+=" ${CPPFLAGS}"
    export CXXFLAGS+=" ${CPPFLAGS}"
    export LDFLAGS+=" ${LDFLAGS}"

    cd "${srcdir}/${pkgname}/"

    sed -e 's|/usr/local/MCUViewer|/usr/share/MCUViewer|g' \
        -e 's|/usr/local/lib|/usr/lib|g' \
        -i \
        CMakeLists.txt \
        launch/install/Unix/MCUViewer.desktop \
        launch/install/Unix/MCUViewer.conf

    sed -e 's|plugdev|uucp|g' \
        -i \
        launch/install/Unix/udevrules/49-stlinkv1.rules \
        launch/install/Unix/udevrules/49-stlinkv2-1.rules \
        launch/install/Unix/udevrules/49-stlinkv2.rules \
        launch/install/Unix/udevrules/49-stlinkv3.rules

    cmake -S . \
        -DCMAKE_BUILD_TYPE=None \
        -DCMAKE_INSTALL_PREFIX=/usr \
        -DCMAKE_INSTALL_LIBDIR=lib \
        -DCMAKE_INSTALL_LIBEXECDIR=lib \
        -Wno-dev \
        -Bbuild \
        -GNinja

    ninja -C build
}

package() {
    DESTDIR="${pkgdir}" ninja -C "${srcdir}"/$pkgname/build install
    install -Dm644 "${srcdir}"/$pkgname/LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}/"
    cp -r "${srcdir}"/$pkgname/example "${pkgdir}"/usr/share/MCUViewer/

    install -Dm755 /dev/stdin "${pkgdir}"/usr/bin/mcuviewer <<EOF
#!/usr/bin/env bash

cd /usr/share/MCUViewer/
./MCUViewer "\$@"
EOF
    #     rm -rf "${pkgdir}"/usr/lib/libjlinkarm.so*
    #     ln -sf /opt/SEGGER/JLink/libjlinkarm.so.8 "${pkgdir}"/usr/lib/libjlinkarm.so
}