summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: bc23cf4e2d4daeb388e9beef44dccacd19d98da0 (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
# Maintainer: Arthur "arthuro555" Pacaud <arthur.pacaud@hotmail.fr>
# Maintainer: Popolon <popolon@popolon.org>
# Contributor: Paulequilibrio
# Contributor: JKA Network <contacto@jkanetwork.com>
# Contributor: Todor Imreorov for github <blurymind@gmail.com>

pkgname=gdevelop
pkgver=5.4.208
pkgrel=1
pkgdesc="A full-featured, open source game engine, allowing to create HTML5 with powerful visual scripting."
arch=(x86_64 armv7l arm64)
url=https://gdevelop.io
license=('MIT')
groups=()
provides=("gdevelop=${pkgver}")
conflicts=('gdevelop-bin' 'gdevelop-git')
makedepends=('npm' 'git' 'jq' 'clang')
_electron='electron22'
depends=("$_electron")
source=("gdevelop::git+https://github.com/4ian/GDevelop.git#tag=v${pkgver}"
  'emsdk::git+https://github.com/emscripten-core/emsdk.git'
  'gdevelop.desktop')
sha256sums=('SKIP'
  'SKIP'
  '240f24320686eff28e9d5226440d5f195098c1f59bff030bbfa88ed07aa72244')

prepare() {
  "$srcdir/emsdk/emsdk" install 3.1.21
  "$srcdir/emsdk/emsdk" activate 3.1.21
}

build() {
  EMSDK_QUIET=1 source "$srcdir/emsdk/emsdk_env.sh"
  
  # Set basic build variables
  export NODE_ENV='production' # Enables optimisations in JS build tools
  export NODE_OPTIONS="--max-old-space-size=8192" # Allows NodeJS VM to allocate enough RAM to build the IDE
  export CC=$(which clang)
  export CXX=$(which clang++)
  # Arch's clang package contains a patch that changes clange default flags: https://wiki.archlinux.org/title/Clang#Stack_protector
  # We disable this change, since this breaks emscripten.
  export CXXFLAGS="-fno-stack-protector -w"
  export CFLAGS="-fno-stack-protector -w"
  # Arch sets default linker flags which are incompatible with wasm-ld.
  export LDFLAGS=""
  
  cd "$srcdir/gdevelop/GDevelop.js"
  npm install --no-audit --no-fund --prefer-offline --include dev
  npm run build
  
  cd "$srcdir/gdevelop/newIDE/app"
  
  npm install --no-audit --no-fund --prefer-offline --include dev
  NODE_ENV='development' npx -y update-browserslist-db@latest
  
  cd "$srcdir/gdevelop/newIDE/electron-app"
  
  local electronVer
  electronVer="$(</usr/lib/$_electron/version)"
  local package
  package="$(jq ".devDependencies.electron = \"$electronVer\"" package.json)"
  echo -E "${package}" > package.json
  
  npm install --no-audit --no-fund --prefer-offline --include dev
  npm run build -- --linux dir --"${!CARCH}" -c.electronDist="/usr/lib/electron" -c.electronVersion="$_electron"
}

package() {
  mkdir -p "${pkgdir}/usr/share/gdevelop/"
  cp -a --no-preserve=ownership "$srcdir/gdevelop/newIDE/electron-app/dist/linux-unpacked/resources/." "${pkgdir}/usr/share/gdevelop/"
  chmod -R 755 "${pkgdir}/usr/share/gdevelop/"
  
  mkdir -p "${pkgdir}/usr/bin/"
  cat >>"${pkgdir}/usr/bin/gdevelop" <<EOD
#! /usr/bin/sh
exec $_electron /usr/share/gdevelop/app.asar "\$@"
EOD
  chmod 644 "${pkgdir}/usr/bin/gdevelop"
  
  install -Dm644 "$srcdir/gdevelop.desktop" "${pkgdir}/usr/share/applications/gdevelop.desktop"
  install -Dm644 "$srcdir/gdevelop/newIDE/app/public/favicon-512.png" "$pkgdir/usr/share/pixmaps/gdevelop.png"
}