blob: 64e6aa3a6a0b9c782f777e276432832bf8e4e398 (
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
|
# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
PYTHON_COMPAT=( python3_{13..14} )
inherit cmake cuda flag-o-matic python-any-r1 toolchain-funcs virtualx xdg
MY_PV="$(ver_rs "1-3" '_')"
DESCRIPTION="An Open-Source subdivision surface library"
HOMEPAGE="https://graphics.pixar.com/opensubdiv/docs/intro.html"
SRC_URI="https://github.com/PixarAnimationStudios/OpenSubdiv/archive/v${MY_PV}.tar.gz -> ${P}.tar.gz"
S="${WORKDIR}/OpenSubdiv-${MY_PV}"
# Modfied Apache-2.0 license, where section 6 has been replaced.
# See for example CMakeLists.txt for details.
LICENSE="Apache-2.0"
# MATCHES SONAME
SLOT="0/${PV}"
KEYWORDS="amd64 ~arm ~arm64 ~x86"
IUSE="X cuda doc examples glfw opencl +opengl openmp ptex python tbb test tutorials"
RESTRICT="!test? ( test )"
# TODO needed for stringify due to unwrapped KERNEL_FILES in opensubdiv/{far,osd}/CMakeLists.txt
REQUIRED_USE="
|| ( opencl opengl )
ptex? ( glfw )
"
BDEPEND="
doc? (
app-text/doxygen
dev-python/docutils
)
python? ( ${PYTHON_DEPS} )
"
# opengl requires GLX, libglvnd[X]
RDEPEND="
examples? (
opengl? (
glfw? (
>=media-libs/glfw-3.4[X?]
)
)
)
opengl? ( media-libs/libglvnd[X] )
opencl? ( virtual/opencl )
openmp? ( || (
sys-devel/gcc:*[openmp]
llvm-runtimes/openmp
) )
ptex? ( media-libs/ptex )
tbb? ( dev-cpp/tbb:= )
test? ( >=media-libs/glfw-3.4[X] )
"
# CUDA_RUNTIME is statically linked
DEPEND="
${RDEPEND}
test? (
glfw? (
>=media-libs/glfw-3.4[X?]
)
)
cuda? ( dev-util/nvidia-cuda-toolkit:= )
"
PATCHES=(
"${FILESDIR}/${PN}-3.6.0-use-gnuinstalldirs.patch"
"${FILESDIR}/${PN}-3.6.0-cudaflags.patch"
"${FILESDIR}/${P}-cuda-13.patch"
)
pkg_pretend() {
[[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp
}
pkg_setup() {
[[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp
if use cuda; then
# When building binary packages we build all major targets unless specified otherwise
if [[ -z "${CUDAARCHS+x}" ]]; then
case ${MERGE_TYPE} in
source) CUDAARCHS="native" ;;
# buildonly) CUDAARCHS="all" ;;
buildonly) CUDAARCHS="all-major" ;;
esac
fi
# check if user provided --gpu-architecture/-arch flag instead of CUDAARCHS
for f in ${NVCCFLAGS}; do
if [[ ${f} == -arch* || ${f} == --gpu-architecture* ]]; then
CUDAARCHS="NVCC"
break
fi
done
if [[ "${CUDAARCHS}" == "NVCC" ]]; then
unset CUDAARCHS
else
export CUDAARCHS
fi
fi
}
src_prepare() {
cmake_src_prepare
sed \
-e "/install(/s/^/#DONOTINSTALL /g" \
-i \
regression/*/CMakeLists.txt \
tools/stringify/CMakeLists.txt \
|| die
sed \
-e "/install( TARGETS osd_static_[cg]pu/s/^/#DONOTINSTALL /g" \
-i \
opensubdiv/CMakeLists.txt \
|| die
if use cuda; then
# do this little headstand to filter out lto from NVCCFLAGS
local CFLAGS_orig="${CFLAGS}" CXXFLAGS_orig="${CXXFLAGS}"
filter-lto
cuda_src_prepare
CFLAGS="${CFLAGS_orig}"
CXXFLAGS="${CXXFLAGS_orig}"
fi
}
src_configure() {
local mycmakeargs=(
-DCMAKE_INSTALL_BINDIR="share/${PN}/bin"
# DirectX
-DNO_DX="yes"
# MacOS
-DNO_MACOS_FRAMEWORK="yes"
-DNO_METAL="yes"
-DNO_DOC="$(usex !doc)"
-DNO_EXAMPLES="$(usex !examples)"
-DNO_TUTORIALS="$(usex !tutorials)"
-DNO_REGRESSION="$(usex !test)"
-DNO_TESTS="$(usex !test)"
-DNO_PTEX="$(usex !ptex)"
# GUI
-DNO_OPENGL="$(usex !opengl)"
# Backends
-DNO_CUDA="$(usex !cuda)"
-DNO_OMP="$(usex !openmp)"
-DNO_TBB="$(usex !tbb)"
-DNO_OPENCL="$(usex !opencl)"
)
if use cuda; then
# The old cmake CUDA module doesn't use environment variable to initialize flags
mycmakeargs+=(
-DCUDA_PROPAGATE_HOST_FLAGS="no"
-DCUDA_NVCC_FLAGS="-forward-unknown-opts ${NVCCFLAGS}"
)
fi
if use opencl; then
mycmakeargs+=(
# not packaged https://github.com/martijnberger/clew
-DNO_CLEW="yes"
)
fi
if use opengl; then
mycmakeargs+=(
-DNO_GLTESTS="$(usex !test)"
# GLEW support is unmaintained in favour of their own GL handler code.
# Turning this on will lead to crashes when using their GPU backend.
-DNO_GLEW="yes"
-DNO_GLFW="$(usex !glfw)"
)
if use glfw; then
mycmakeargs+=(
-DGLFW_LOCATION="${ESYSROOT}/usr/$(get_libdir)"
-DNO_GLFW_X11="$(usex !X)"
)
fi
fi
if use ptex; then
mycmakeargs+=(
-DPTEX_LOCATION="${ESYSROOT}/usr/$(get_libdir)"
)
fi
if ! use python; then
mycmakeargs+=(
-DCMAKE_DISABLE_FIND_PACKAGE_Python="yes"
)
fi
cmake_src_configure
}
src_test() {
xdg_environment_reset
CMAKE_SKIP_TESTS=(
# Fails due to CL & CUDA kernels, works outside
"glImaging"
)
if ! test -w /dev/dri/card0; then
CMAKE_SKIP_TESTS+=(
"osd_regression"
)
fi
# "far_tutorial_1_2 breaks with gcc and > -O1"
tc-is-gcc && is-flagq '-O@(2|3|fast)' && CMAKE_SKIP_TESTS+=( "far_tutorial_1_2" )
if use cuda; then
cuda_add_sandbox -w
addpredict /dev/char/
addwrite /dev/dri/card0
addwrite /dev/dri/renderD128
addwrite /dev/udmabuf
fi
virtx cmake_src_test
if use examples && use opengl && use glfw; then
local KERNELS=( CPU )
use openmp && KERNELS+=( OPENMP )
use tbb && KERNELS+=( TBB )
# use cuda && KERNELS+=( CUDA )
# use opencl && KERNELS+=( CL )
use opengl && use X && KERNELS+=( XFB )
use opengl && KERNELS+=( GLSL )
#Bug https://bugs.gentoo.org/924516
virtx "${BUILD_DIR}/bin/glImaging" -w test -l 3 -s 256 256 -a -k "$(IFS=","; echo "${KERNELS[*]}")"
fi
}
|