summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: fa0ec544f430d4ee97efaf88ad84366c88a00e21 (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
# Maintainer: Dylan Ferris <dylan@psilly.com>
# Maintainer: Michael Lojkovic <mikelojkovic@gmail.com>
# Maintainer: Shatur95 <genaloner@gmail.com>

# The source is about 200 MiB, with an extra ~11 GiB of dependencies downloaded in Setup.sh, and may take several hours to compile.
# If you want to turn on additional patches there are switches below.
pkgname=unreal-engine
pkgver=4.26.2
pkgrel=6
pkgdesc='A 3D game engine by Epic Games which can be used non-commercially for free.'
arch=(x86_64)
url=https://www.unrealengine.com/
makedepends=(git openssh)
depends=(icu sdl2 python lld xdg-user-dirs dos2unix)
optdepends=('qt5-base: qmake build system for projects'
            'cmake: build system for projects'
            'qtcreator: IDE for projects'
            'codelite: IDE for projects'
            'kdevelop: IDE for projects'
            'clion: IDE for projects')
license=(custom:UnrealEngine)
source=(com.unrealengine.UE4Editor.desktop
        ccache_executor.patch
        stop_mono_clone.patch
        clang_path_fix.patch)
sha256sums=('15e9f9d8dc8bd8513f6a5eca990e2aab21fd38724ad57d213b06a6610a951d58'
            '33982486f7fafac35a33dfa37c85cfba8543aa78b5fe13c395d9cccf691ef4b3'
            'aa9eb83c9f58c539d3cd43e919a4ebd6714c0aa2d32eb9b320049cf04dd01587'
            '960c5a100e0c3732f3c73fb645d3989d39acf4576d74615bbef38ebeee008b90')
options=(!strip staticlibs) # Package is 3 Gib smaller with "strip" but it takes a long time and generates many warnings

_ccache_support=false # Patches for ccache. More optimizations might be needed.
_system_mono=false # Uses System mono for unreal. Must set UE_USE_SYSTEM_MONO in your environment for it to work after install.
_install_dir="opt/$pkgname" # Default engine installation directory. Can be useful if you do not have a lot of space in /opt directory.

if [[ $_ccache_support == true ]]
then
  depends+=(ccache)
fi

if [[ $_system_mono == true ]]
then
  depends+=(mono mono-msbuild)
fi

prepare() {
  # Check access to the repository
  if ! git ls-remote git@github.com:EpicGames/UnrealEngine &>/dev/null
  then
    error 'You must register at unrealengine.com and link your github account to access this private repo. See the wiki for more info: https://wiki.archlinux.org/index.php/Unreal_Engine_4'
    exit 1
  fi

  # Download Unreal Engine source or update if the folder exists
  if [[ ! -d $pkgname ]]
  then
    git clone --depth=1 --branch=$pkgver-release git@github.com:EpicGames/UnrealEngine $pkgname
    cd $pkgname
  else
    cd $pkgname
    rm -f .git/index.lock
    git fetch --depth=1 origin tag $pkgver-release
    git reset --hard $pkgver-release
  fi

  # Apply custom patches
  patch -p1 -i "$srcdir/clang_path_fix.patch" # Replace Windows specific search with the correct path (used for -mode=GenerateClangDatabase in UBT)
  if [[ $_system_mono == true ]]
  then
    export UE_USE_SYSTEM_MONO=1
    patch -p1 -i "$srcdir/stop_mono_clone.patch"
  fi
  if [[ $_ccache_support == true ]]
  then
    patch -p1 -i "$srcdir/ccache_executor.patch"
  fi

  # Qt Creator source code access
  if [[ ! -d Engine/Plugins/Developer/QtCreatorSourceCodeAccess ]]
  then
    git -C Engine/Plugins/Developer clone --depth=1 git@github.com:fire/QtCreatorSourceCodeAccess
  fi

  ./Setup.sh
}

build() {
  cd $pkgname
  Engine/Build/BatchFiles/RunUAT.sh BuildGraph -target="Make Installed Build Linux" -script=Engine/Build/InstalledEngineBuild.xml -set:WithDDC=false -set:HostPlatformOnly=true
}

package() {
  # Desktop entry
  if [[ "$_install_dir" != "opt/$pkgname" ]] # Set new path if dir changed
  then
    sed -i "5c\Path=/$_install_dir/Engine/Binaries/Linux/" com.unrealengine.UE4Editor.desktop
    sed -i "6c\Exec=/$_install_dir/Engine/Binaries/Linux/UE4Editor %F" com.unrealengine.UE4Editor.desktop
  fi
  install -Dm775 com.unrealengine.UE4Editor.desktop "$pkgdir/usr/share/applications/com.unrealengine.UE4Editor.desktop"
  
  cd $pkgname
  
  # Icon for Desktop entry
  install -Dm770 Engine/Source/Programs/UnrealVS/Resources/Preview.png "$pkgdir/usr/share/pixmaps/ue4editor.png"

  # License
  install -Dm770 LICENSE.md "$pkgdir/usr/share/licenses/UnrealEngine/LICENSE.md"
  
  # Engine
  install -dm770 "$pkgdir/$_install_dir/Engine"
  mv LocalBuilds/Engine/Linux/* "$pkgdir/$_install_dir"
}