-
Notifications
You must be signed in to change notification settings - Fork 213
Expand file tree
/
Copy pathopenrvcore-conanfile.py
More file actions
260 lines (214 loc) · 10 KB
/
openrvcore-conanfile.py
File metadata and controls
260 lines (214 loc) · 10 KB
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
256
257
258
259
260
import os
import sys
from conan import ConanFile
from conan.tools.cmake import CMake, CMakeDeps, cmake_layout, CMakeToolchain
from conan.tools.gnu import PkgConfigDeps
from conan.tools.microsoft import VCVars
from conan.tools.env import VirtualBuildEnv
from conan.errors import ConanException
# The comment below is relevant for WINDOWS only because of the usage of MSYS2.
# The Python path should be pre-appended to the PATH environment variables in the
# buildenv section of the profile used to build the recipe.
# It will ensure that the Python path is the first path in the environment variable.
# This is a special case because of the way that MSYS2 merges the PATH environment variables.
# (MSYS2 PATH = MSYS2 PATH + CMD PATH)
#
# Here's an example of a buildenv section (also, see example under conan/profiles):
#
# [buildenv]
# PATH=+(path)/c/Program Files/Python310
#
class OpenRVBase:
setuptools_use_distutils = ""
def layout(self):
cmake_layout(self)
def build_requirements(self):
if self.settings.os == "Windows":
self.win_bash = True
if not self.conf.get("tools.microsoft.bash:path", check_type=str):
pkgs = [
"mingw-w64-x86_64-autotools",
"mingw-w64-x86_64-cmake",
"mingw-w64-x86_64-cmake-cmcldeps",
"mingw-w64-x86_64-glew",
"mingw-w64-x86_64-libarchive",
"mingw-w64-x86_64-make",
"mingw-w64-x86_64-meson",
"mingw-w64-x86_64-python-pip",
"mingw-w64-x86_64-python-psutil",
"mingw-w64-x86_64-toolchain",
"autoconf",
"automake",
"bison",
"flex",
"git",
"libtool",
"nasm",
"p7zip",
"patch",
]
pkgsStr = " ".join(pkgs)
self.tool_requires("msys2/cci.latest", options={"additional_packages": pkgsStr})
else:
self.tool_requires("ninja/1.11.1")
self.tool_requires("cmake/3.31.8")
def requirements(self):
self.requires("zlib/1.3.1", force=True, options={"shared": True})
self.requires("libatomic_ops/7.10.0", options={"shared": False})
# Version conflict: ffmpeg/4.4.3->libwebp/1.3.2, ->libwebp/1.2.1
# Webp >=1.3.0 depends on sharpyuv and it causes issues with OIIO.
self.requires("libwebp/1.2.1", force=True, options={"shared": False})
self.requires("dav1d/1.5.3", force=True, options={"shared": True})
self.requires(
"libjpeg-turbo/2.1.4",
force=True,
options={
"shared": True,
},
)
# Override openssl version for ffmpeg, but do not use it for OpenRV right now.
self.requires("openssl/3.6.2", force=True, options={"shared": True, "no_zlib": True})
# Override boost version for other dependencies.
self.requires(
"boost/1.85.0",
force=True,
options={"shared": True, "extra_b2_flags": "-d+0 -s NO_LZMA=1"},
)
# PCRE2 for Windows (boost regex used on other platforms)
if self.settings.os == "Windows":
self.requires(
"pcre2/10.44",
force=True,
options={
"shared": True,
"with_zlib": False,
"with_bzip2": False,
"support_jit": False,
"build_pcre2_16": False,
"build_pcre2_32": False,
},
)
# Override imath version for other dependencies.
self.requires("imath/3.1.12", force=True, options={"shared": True})
self.requires("libdeflate/1.25", force=True, options={"shared": True})
self.requires("openexr/3.3.6", force=True, options={"shared": True})
self.requires("libpng/1.6.55", force=True, options={"shared": True})
# libtiff is force-built from source in CMake (private headers needed).
# Excluded from Conan: libtiff 4.6.0 doesn't build against libjpeg-turbo (12-bit API).
# openjph/openexr pull it in transitively; disabled via openjph:with_tiff=False.
self.requires("openjpeg/2.5.4", force=True, options={"shared": True})
self.requires(
"libraw/0.21.1",
force=True,
options={"shared": True, "with_jpeg": "libjpeg-turbo", "with_jasper": False},
)
self.requires("openjph/0.26.3", force=True, options={"shared": True})
def generate(self):
buildenv = VirtualBuildEnv(self)
buildenv.generate()
if self.settings.os == "Windows":
ms = VCVars(self)
ms.generate()
deps = CMakeDeps(self)
# OIIO 3.x links openjph via $<TARGET_NAME_IF_EXISTS:openjph> which
# requires a non-namespaced target. CMakeDeps defaults to openjph::openjph.
deps.set_property("openjph", "cmake_target_name", "openjph")
deps.generate()
# Generate pkg-config .pc files so that ExternalProject builds (FFmpeg)
# can discover Conan-provided shared libraries like dav1d via pkg-config.
pc = PkgConfigDeps(self)
pc.generate()
# Setup CMakeToolchain generator.
if not self.settings.os == "Windows":
tc = CMakeToolchain(self, generator="Ninja")
else:
tc = CMakeToolchain(self)
# Qt location: use QT_HOME env var, fall back to conventional paths.
qt_version = os.getenv("QT_VERSION", "6.5.3")
qt_home = os.getenv("QT_HOME")
if not qt_home:
# Build platform-specific default path
if self.settings.os == "Windows":
qt_home = f"c:/Qt/{qt_version}/msvc2019_64"
else:
home = os.getenv("HOME", "")
qt_dir = os.path.join(home, "Qt6.5.3", qt_version)
if self.settings.os == "Linux":
qt_home = os.path.join(qt_dir, "gcc_64")
elif self.settings.os == "Macos":
# Recent Qt versions use "macos", older ones use "clang_64"
macos_path = os.path.join(qt_dir, "macos")
clang_path = os.path.join(qt_dir, "clang_64")
qt_home = macos_path if os.path.isdir(macos_path) else clang_path
self.output.warning(
f"QT_HOME not set, using default: {qt_home}. "
"Set the QT_HOME environment variable to point to your Qt installation."
)
if not os.path.isdir(qt_home):
raise ConanException(
f"Qt directory not found: {qt_home}. "
"Set the QT_HOME environment variable to a valid Qt installation path."
)
if self.settings.os == "Windows":
win_perl_location = os.getenv("WIN_PERL", "c:/Strawberry/perl/bin")
if not os.path.isdir(win_perl_location):
self.output.warning(
f"Perl directory not found: {win_perl_location}. "
"Set the WIN_PERL environment variable to your Perl installation."
)
self.setuptools_use_distutils = "stdlib"
# VFX Platform: controlled by the vfx_platform option in the main conanfile.py.
tc.cache_variables["RV_VFX_PLATFORM"] = str(self.options.vfx_platform)
# Set up CMake's cached variables.
tc.cache_variables["RV_DEPS_QT_LOCATION"] = qt_home
if self.settings.os == "Windows":
tc.cache_variables["RV_DEPS_WIN_PERL_ROOT"] = win_perl_location
tc.cache_variables["CMAKE_BUILD_PARALLEL_LEVEL"] = str(os.cpu_count())
# Make sure that CMAKE_BUILD_TYPE is specified in the cmake command that Conan use.
# It seems needed on Windows for MS Visual Studio (multi-config generator).
tc.cache_variables["CMAKE_BUILD_TYPE"] = str(self.settings.build_type)
tc.cache_variables["CMAKE_FIND_PACKAGE_TARGETS_GLOBAL"] = "ON"
# Enable find-first resolution: use Conan-provided packages via find_package
# before falling back to building from source.
tc.cache_variables["RV_DEPS_PREFER_INSTALLED"] = "ON"
# Allow MINIMUM version matching for all converted dependencies so that
# Conan-supplied versions (which may be newer than the pinned RV_DEPS_*
# versions) are accepted by RV_FIND_DEPENDENCY.
for dep in [
"BOOST",
"DAV1D",
"LIBDEFLATE",
"OPENEXR",
"IMATH",
"ZLIB",
"OPENSSL",
"PNG",
"TIFF",
"JPEGTURBO",
"RAW",
"OPENJPEG",
"OPENJPH",
]:
tc.cache_variables[f"RV_DEPS_{dep}_VERSION_MATCH"] = "MINIMUM"
# Set CMAKE_PREFIX_PATH to point to the generators folder
# This allows ExternalProject_Add builds to find generated *Config.cmake files
generators_folder = os.path.join(self.build_folder, "generators")
tc.cache_variables["RV_CONAN_CMAKE_PREFIX_PATH"] = generators_folder
# Generate the CMake's toolchain and preset files.
tc.generate()
def build(self):
# NOTE: `pip install --user` fails inside virtualenvs:
# "User site-packages are not visible in this virtualenv."
in_venv = bool(os.getenv("VIRTUAL_ENV")) or (hasattr(sys, "base_prefix") and sys.prefix != sys.base_prefix)
user_flag = [] if in_venv else ["--user"]
command = " ".join(["python3", "-m", "pip", "install", *user_flag, "--upgrade", "-r", "requirements.txt"])
if self.settings.os == "Windows":
command = f"SETUPTOOLS_USE_DISTUTILS={self.setuptools_use_distutils} {command}"
self.run(command, cwd=self.source_folder)
cmake = CMake(self)
cmake.configure()
cmake.build(target="main_executable")
class PyReq(ConanFile):
name = "openrvcore"
version = "1.0.0"
package_type = "python-require"