summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 07094cf707c6bb778d94ea150fce0872ecda477b (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
# Maintainer: Alex Hirzel <alex at hirzel period us>

pkgname=luisarender-git
pkgver=de7818a7
pkgrel=1
pkgdesc="High-Performance Rendering Framework on Stream Architectures"
arch=('x86_64')
url="https://luisa-render.com/"
license=('BSD')
depends=('gcc-libs' 'cuda' 'glfw-wayland')
makedepends=('clang' 'git' 'cmake')
source=(
	'git+https://github.com/LuisaGroup/LuisaRender.git'
	'git+https://github.com/LuisaGroup/LuisaCompute.git'
	'git+https://github.com/jarro2783/cxxopts.git'
	'git+https://github.com/assimp/assimp.git'
	'git+https://github.com/fastfloat/fast_float.git'
	'git+https://github.com/syoyo/tinyexr.git'

	# for compute
	'git+https://github.com/Cyan4973/xxHash.git'
	'git+https://github.com/gabime/spdlog.git'
	'git+https://github.com/chriskohlhoff/asio.git'
	'git+https://github.com/nothings/stb.git'
	'git+https://github.com/nlohmann/json.git'
	'git+https://github.com/glfw/glfw.git'
	'git+https://github.com/ocornut/imgui.git'
	'git+https://github.com/LuisaGroup/EASTL.git'
	'git+https://github.com/jothepro/doxygen-awesome-css.git'
	'git+https://github.com/pybind/pybind11'
	'git+https://github.com/abseil/abseil-cpp.git'
	'git+https://github.com/KhronosGroup/SPIRV-Headers'
	'git+https://github.com/KhronosGroup/SPIRV-Tools.git'
	'git+https://github.com/KhronosGroup/glslang.git'
	'git+https://github.com/google/shaderc.git'

	# submodules within compute
	'git+https://github.com/LuisaGroup/EABase.git'
	'git+https://github.com/microsoft/mimalloc.git'
)

md5sums=(
	'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP'
	'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP'
	'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP'
)

pkgver() {
	git -C "$srcdir/LuisaRender" describe --long --tags --always | sed -r 's/^v//;s/([^-]*-g)/r\1/;s/-/./g'
}

prepare() {
	cd "$srcdir/LuisaRender"

	# map submodules from sources list into the project structure
	# this list contains folder name -> path mappings, and since there is
	# nesting we need to be careful to 'cd' to the correct parent repository
	# when calling "submodule update"
	for clone_path in \
		"LuisaCompute        src/compute" \
		"xxHash              src/compute/src/ext/xxHash" \
		"spdlog              src/compute/src/ext/spdlog" \
		"asio                src/compute/src/ext/asio" \
		"stb                 src/compute/src/ext/stb/stb" \
		"json                src/compute/src/ext/json" \
		"glfw                src/compute/src/ext/glfw" \
		"imgui               src/compute/src/ext/imgui/imgui" \
		"EASTL               src/compute/src/ext/EASTL" \
		"EABase              src/compute/src/ext/EASTL/packages/EABase" \
		"mimalloc            src/compute/src/ext/EASTL/packages/mimalloc" \
		"doxygen-awesome-css src/compute/src/ext/doxygen-awesome-css" \
		"pybi                src/compute/src/ext/pybind11" \
		"abseil-cpp          src/compute/src/ext/abseil-cpp" \
		"SPIRV-Hea           src/compute/src/ext/SPIRV-Headers" \
		"SPIRV-Tools         src/compute/src/ext/SPIRV-Tools" \
		"glslang             src/compute/src/ext/glslang" \
		"shaderc             src/compute/src/ext/shaderc" \
		"cxxopts             src/ext/cxxopts" \
		"assimp              src/ext/assimp" \
		"fast_float          src/ext/fast_float" \
		"tinyexr             src/ext/tinyexr" \
	; do
		clone_path=( $clone_path );      # string to array
		clone=${clone_path[0]};          # first path from above - the cloned folder from PKGBUILD
		full_repo_path=${clone_path[1]}; # second path from above - where it's used in git tree

		# split full_repo_path into sections, e.g.
		# [src/compute/src/ext/EASTL] / [packages/mimalloc]
		# ^ repo_with_submodule         ^ submodule_path_within_repo
		repo_with_submodule=$(dirname $(dirname $full_repo_path))
		submodule_path_within_repo=$(basename $(dirname $full_repo_path))/$(basename $full_repo_path)

		git config submodule.$full_repo_path.url $srcdir/$clone
		pushd $repo_with_submodule > /dev/null
			git config submodule.$full_repo_path.url $srcdir/$clone
			git -c protocol.file.allow=always submodule update --init $submodule_path_within_repo
		popd > /dev/null
	done
}

build() {
	cmake -S "$srcdir/LuisaRender" \
		-B "$srcdir/build" \
		-DCMAKE_BUILD_TYPE=Release

	make -C "$srcdir/build" ${MAKEFLAGS:--j1}
}

package() {
	cd "$srcdir/build"

	pkgusr="$pkgdir/usr"
	pkglib="$pkgusr/lib/$pkgname"

	cd "$srcdir/LuisaRender"
	install -Dm644 LICENSE "$pkgusr/share/licenses/$pkgname/LICENSE"

	# for now, we manually pick things out of the build folder rather than using
	# the install.
	cd "$srcdir/build/bin"
	for binary_name in luisa-render-*; do
		dest="$pkgusr/bin/$binary_name"
		install -Dm755 $binary_name $dest
		patchelf --set-rpath "/usr/lib/$pkgname" "$dest"
	done
	for so in *.so*; do
		dest="$pkglib/$so"
		install -Dm755 "$so" $dest
		patchelf --set-rpath "/usr/lib/$pkgname" "$dest"
	done
}