summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 95900e583bd957f58f036bc93b0d4df6deb81ec4 (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
# Maintainer: MuntasirSZN <muntasir.joypurhat@gmail.com>
# Maintainer: cordx56 <cordx56@cordx.cx>

pkgname=rustowl-git
pkgver=r1.0
pkgrel=1
pkgdesc='Visualize Ownership and Lifetimes in Rust'
url='https://github.com/cordx56/rustowl'
license=('MPL-2.0')
makedepends=('git' 'cargo')
arch=('any')
source=("git+https://github.com/cordx56/rustowl.git")
sha256sums=('SKIP')
conflicts=('rustowl-bin')

pkgver() {
	cd "$srcdir/rustowl"
	printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

prepare() {
    export RUSTC_BOOTSTRAP=1
    export RUSTUP_TOOLCHAIN=1.86.0
    rustup component add rust-src rustc-dev llvm-tools
    cargo fetch --locked --target "$(rustc -vV | sed -n 's/host: //p')"
}

build() {
    export CARGO_TARGET_DIR=target
    export RUSTC_BOOTSTRAP=1
    export RUSTUP_TOOLCHAIN=1.86.0
    export RUSTOWL_RUNTIME_DIRS=/opt/rustowl
    cargo build --frozen --release --all-features
}

check() {
    export RUSTC_BOOTSTRAP=1
    export RUSTUP_TOOLCHAIN=1.86.0
    cargo test --frozen --all-features
}

package() {
    find target -type d | grep -E 'rustowl-build-time-out$' | xargs -I % cp -r % ./
    cp -r "$(rustc --print=sysroot)" runtime
    cd runtime
    ls | xargs -I % find % -type f | grep -E '\.(rlib|so|dylib)$' | \
    while read file; do
        mkdir -p ../lib/$(dirname "$file")
        mv "$file" ../lib/$(dirname "$file")/
    done
    cd ..
    rm -rf runtime
    mv lib/lib runtime && rm -rf lib && mv runtime lib
    install -d -m 755 "$pkgdir/opt/rustowl"
    cp -a lib/ "$pkgdir/opt/rustowl/"
    install -Dm0755 -t "$pkgdir/usr/bin/" "target/release/rustowl"
    install -Dm0755 -t "$pkgdir/usr/bin/" "target/release/rustowlc"
    install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/rustowl/LICENSE"
    install -Dm644 rustowl-build-time-out/man/rustowl.1 "$pkgdir/usr/share/man/man1/rustowl.1"
    install -Dm644 "rustowl-build-time-out/completions/rustowl.bash" "${pkgdir}/usr/share/bash-completion/completions/rustowl"
    install -Dm644 "rustowl-build-time-out/completions/_rustowl" "${pkgdir}/usr/share/zsh/site-functions/_rustowl"
    install -Dm644 "rustowl-build-time-out/completions/rustowl.fish" "${pkgdir}/usr/share/fish/vendor_completions.d/rustowl.fish"
    install -Dm644 "rustowl-build-time-out/completions/rustowl.elv" "${pkgdir}/usr/share/elvish/completions/rustowl.elv"
    install -Dm644 "rustowl-build-time-out/completions/_rustowl.ps1" "${pkgdir}/usr/share/powershell/Modules/Rustowl/_rustowl.ps1"
}