summaryrefslogtreecommitdiff
path: root/hurrycurry-standalone-files-git/PKGBUILD
blob: 19685a3c3aa3a4b095d623c49a08d8e4bc1e0262 (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
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
135
136
137
138
139
140
141
142
# Maintainer: metamuffin <metamuffin@disroot.org>

pkgname=hurrycurry-standalone-files-git
pkgver=r2312.64075a8c
pkgrel=1
pkgdesc="A game about cooking (standalone files (git))"
arch=('any')
url="https://codeberg.org/hurrycurry/hurrycurry"
license=('AGPL3')
makedepends=(
    'rustup'
    'deno'
    'graphviz'
    'godot'
    'esbuild'
    'typst'
    'nsis'
    'mingw-w64-gcc'
    'mingw-w64-binutils'
    'lib32-rust-libs'
)
source=("hurrycurry::git+https://codeberg.org/hurrycurry/hurrycurry.git"
        "hurrycurry-windows-installer::git+https://codeberg.org/hurrycurry/windows-installer.git"
        "hurrycurry-website::git+https://codeberg.org/hurrycurry/website.git")
sha256sums=('SKIP'
            'SKIP'
            'SKIP')

_targets=(
    "x86_64-unknown-linux-gnu"
    "aarch64-unknown-linux-gnu"
    # "armv7-unknown-linux-gnueabi"
    "i686-unknown-linux-gnu"
    "x86_64-pc-windows-gnu"
    "i686-pc-windows-gnu"
    "aarch64-linux-android"
    "armv7-linux-androideabi"
    "i686-linux-android"
    "x86_64-linux-android"
)

_target_suf() {
    if echo "$t" | grep -q android; then
        echo -n ".apk"
    elif echo "$t" | grep -q windows; then
        echo -n ".exe"
    fi
}

pkgver() {
    cd "hurrycurry"
    printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}
prepare() {
    cd "hurrycurry"
    rustup default nightly
    for t in "${_targets[@]}"; do
        rustup target add --toolchain "$(cat rust-toolchain)" "$t"
        cargo fetch --locked --target "$t"
    done
}
build() {
    # this might be useful:
    # > ln -s /usr/x86_64-w64-mingw32/lib/lib{i,I}phlpapi.a
    # > ln -s /usr/x86_64-w64-mingw32/include/{i,I}phlpapi.h
    # > ln -s /usr/i686-w64-mingw32/lib/lib{i,I}phlpapi.a
    # > ln -s /usr/i686-w64-mingw32/include/{i,I}phlpapi.h

    export GODOT_ANDROID_KEYSTORE_RELEASE_PATH="$HOME/infra/misc/hurrycurry/hurrycurry.keystore" # this wont work on your machine :)
    export GODOT_ANDROID_KEYSTORE_RELEASE_USER="hurrycurry"
    export GODOT_ANDROID_KEYSTORE_RELEASE_PASSWORD="hurrycurry"
    export CXXFLAGS=
    export LDFLAGS=
    export CFLAGS=

    mkdir -p out
    pushd "hurrycurry"

    git reset --hard

    make client
    make -C data all

    local datafiles
    datafiles=(data/recipes/*.yaml data/maps/*.yaml data/index.yaml data/book.json)
    tar --zstd -cvf ../out/data.tar.zst "${datafiles[@]}"
    zip ../out/data.zip "${datafiles[@]}"

    sed -i "s/^const DISTRIBUTION := .*/const DISTRIBUTION := \"standalone\"/" client/global.gd
    sed -i "s/^const VERSION := .*/const VERSION := \"$pkgver-$pkgrel\"/" client/global.gd

    godot --headless --export-pack wasm32-unknown-unknown ../../out/client-any.pck client/project.godot
    godot --headless --export-release wasm32-unknown-unknown ../../out/client-wasm32-unknown-unknown.html client/project.godot
    for t in "${_targets[@]}"; do
        godot --headless --export-release "$t" "../../out/client-$t$(_target_suf "$t")" client/project.godot
    done

    sed -i "s/^const DISTRIBUTION := .*/const DISTRIBUTION := \"windows-installer\"/" client/global.gd
    godot --headless --export-release "x86_64-pc-windows-gnu" "../../out/client-windows-installer-64.exe" client/project.godot
    godot --headless --export-release "i686-pc-windows-gnu" "../../out/client-windows-installer-32.exe" client/project.godot

    for t in "${_targets[@]}"; do
        if echo "$t" | grep -q android; then echo skip "$t"; continue; fi
        echo build "$t"
        cargo build --release --target "$t" --bin hurrycurry-server
        cargo build --release --target "$t" --bin hurrycurry-discover
        cargo build --release --target "$t" --bin hurrycurry-replaytool
    done

    popd
    pushd hurrycurry-windows-installer

    ln -svfT ../hurrycurry-website website
    make \
        NSIFLAGS="-DVERSION=$pkgver-$pkgrel" \
        DATA=../out/data.tar.zst \
        CLIENT_64=../out/client-windows-installer-64.exe \
        CLIENT_32=../out/client-windows-installer-32.exe \
        SERVER_64=../hurrycurry/target/x86_64-pc-windows-gnu/release/hurrycurry-server.exe \
        SERVER_32=../hurrycurry/target/i686-pc-windows-gnu/release/hurrycurry-server.exe \
        DISCOVER_64=../hurrycurry/target/x86_64-pc-windows-gnu/release/hurrycurry-discover.exe \
        DISCOVER_32=../hurrycurry/target/i686-pc-windows-gnu/release/hurrycurry-discover.exe

    popd
}
package() {
    out="$pkgdir/usr/share/hurrycurry/standalone-files/nightly"
    install -Dvm644 "out/client-any.pck" "$out/client-any.pck"
    install -Dvm644 "out/data.tar.zst" "$out/data.tar.zst"
    install -Dvm644 "out/data.zip" "$out/data.zip"
    for t in "${_targets[@]}"; do
        local suf
        suf=$(_target_suf "$t")
        install -Dvm644 "out/client-$t$suf" "$out/client-$t$suf"
        if echo "$t" | grep -q android; then continue; fi
        install -Dvm644 "hurrycurry/target/$t/release/hurrycurry-server$suf" "$out/server-$t$suf"
        install -Dvm644 "hurrycurry/target/$t/release/hurrycurry-discover$suf" "$out/discover-$t$suf"
        install -Dvm644 "hurrycurry/target/$t/release/hurrycurry-replaytool$suf" "$out/replaytool-$t$suf"
    done
    install -Dvm644 "hurrycurry-windows-installer/hurrycurry-install-x86_64.exe" "$out/windows-installer-x86_64.exe"
    install -Dvm644 "hurrycurry-windows-installer/hurrycurry-install-i686.exe" "$out/windows-installer-i686.exe"
}