| 1 |
import os |
| 2 |
import platform |
| 3 |
import sys |
| 4 |
from typing import TYPE_CHECKING |
| 5 |
|
| 6 |
from methods import get_compiler_version, print_error, print_info, print_warning, using_gcc |
| 7 |
from platform_methods import detect_arch, validate_arch |
| 8 |
|
| 9 |
if TYPE_CHECKING: |
| 10 |
from SCons.Script.SConscript import SConsEnvironment |
| 11 |
|
| 12 |
|
| 13 |
def get_name(): |
| 14 |
return "LinuxBSD" |
| 15 |
|
| 16 |
|
| 17 |
def can_build(): |
| 18 |
if os.name != "posix" or sys.platform == "darwin": |
| 19 |
return False |
| 20 |
|
| 21 |
pkgconf_error = os.system("pkg-config --version > /dev/null") |
| 22 |
if pkgconf_error: |
| 23 |
print_error("pkg-config not found. Aborting.") |
| 24 |
return False |
| 25 |
|
| 26 |
return True |
| 27 |
|
| 28 |
|
| 29 |
def get_opts(): |
| 30 |
from SCons.Variables import BoolVariable, EnumVariable |
| 31 |
|
| 32 |
return [ |
| 33 |
EnumVariable("linker", "Linker program", "default", ["default", "bfd", "gold", "lld", "mold"], ignorecase=2), |
| 34 |
BoolVariable("use_llvm", "Use the LLVM compiler", False), |
| 35 |
BoolVariable("use_static_cpp", "Link libgcc and libstdc++ statically for better portability", True), |
| 36 |
BoolVariable("use_coverage", "Test Godot coverage", False), |
| 37 |
BoolVariable("use_ubsan", "Use LLVM/GCC compiler undefined behavior sanitizer (UBSAN)", False), |
| 38 |
BoolVariable("use_asan", "Use LLVM/GCC compiler address sanitizer (ASAN)", False), |
| 39 |
BoolVariable("use_lsan", "Use LLVM/GCC compiler leak sanitizer (LSAN)", False), |
| 40 |
BoolVariable("use_tsan", "Use LLVM/GCC compiler thread sanitizer (TSAN)", False), |
| 41 |
BoolVariable("use_msan", "Use LLVM compiler memory sanitizer (MSAN)", False), |
| 42 |
BoolVariable("use_sowrap", "Dynamically load system libraries", True), |
| 43 |
BoolVariable("alsa", "Use ALSA", True), |
| 44 |
BoolVariable("pulseaudio", "Use PulseAudio", True), |
| 45 |
BoolVariable("dbus", "Use D-Bus to handle screensaver and portal desktop settings", True), |
| 46 |
BoolVariable("speechd", "Use Speech Dispatcher for Text-to-Speech support", True), |
| 47 |
BoolVariable("fontconfig", "Use fontconfig for system fonts support", True), |
| 48 |
BoolVariable("udev", "Use udev for gamepad connection callbacks", True), |
| 49 |
BoolVariable("x11", "Enable X11 display", True), |
| 50 |
BoolVariable("wayland", "Enable Wayland display", True), |
| 51 |
BoolVariable("libdecor", "Enable libdecor support", True), |
| 52 |
BoolVariable("touch", "Enable touch events", True), |
| 53 |
BoolVariable("execinfo", "Use libexecinfo on systems where glibc is not available", False), |
| 54 |
] |
| 55 |
|
| 56 |
|
| 57 |
def get_doc_classes(): |
| 58 |
return [ |
| 59 |
"EditorExportPlatformLinuxBSD", |
| 60 |
] |
| 61 |
|
| 62 |
|
| 63 |
def get_doc_path(): |
| 64 |
return "doc_classes" |
| 65 |
|
| 66 |
|
| 67 |
def get_flags(): |
| 68 |
return { |
| 69 |
"arch": detect_arch(), |
| 70 |
"supported": ["library", "mono"], |
| 71 |
} |
| 72 |
|
| 73 |
|
| 74 |
def configure(env: "SConsEnvironment"): |
| 75 |
|
| 76 |
supported_arches = ["x86_32", "x86_64", "arm32", "arm64", "rv64", "ppc64", "loongarch64"] |
| 77 |
validate_arch(env["arch"], get_name(), supported_arches) |
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
if env.dev_build: |
| 82 |
|
| 83 |
|
| 84 |
env.Append(LINKFLAGS=["-rdynamic"]) |
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
host_is_64_bit = sys.maxsize > 2**32 |
| 89 |
if host_is_64_bit and env["arch"] == "x86_32": |
| 90 |
env.Append(CCFLAGS=["-m32"]) |
| 91 |
env.Append(LINKFLAGS=["-m32"]) |
| 92 |
elif not host_is_64_bit and env["arch"] == "x86_64": |
| 93 |
env.Append(CCFLAGS=["-m64"]) |
| 94 |
env.Append(LINKFLAGS=["-m64"]) |
| 95 |
|
| 96 |
|
| 97 |
if env["arch"] == "rv64": |
| 98 |
|
| 99 |
env.Append(CCFLAGS=["-march=rv64gc"]) |
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
if "CXX" in env and "clang" in os.path.basename(env["CXX"]): |
| 104 |
|
| 105 |
env["use_llvm"] = True |
| 106 |
|
| 107 |
if env["use_llvm"]: |
| 108 |
if "clang++" not in os.path.basename(env["CXX"]): |
| 109 |
env["CC"] = "clang" |
| 110 |
env["CXX"] = "clang++" |
| 111 |
env.extra_suffix = ".llvm" + env.extra_suffix |
| 112 |
|
| 113 |
if env["linker"] != "default": |
| 114 |
print("Using linker program: " + env["linker"]) |
| 115 |
if env["linker"] == "mold" and using_gcc(env): |
| 116 |
cc_version = get_compiler_version(env) |
| 117 |
cc_semver = (cc_version["major"], cc_version["minor"]) |
| 118 |
if cc_semver < (12, 1): |
| 119 |
found_wrapper = False |
| 120 |
for path in ["/usr/libexec", "/usr/local/libexec", "/usr/lib", "/usr/local/lib"]: |
| 121 |
if os.path.isfile(path + "/mold/ld"): |
| 122 |
env.Append(LINKFLAGS=["-B" + path + "/mold"]) |
| 123 |
found_wrapper = True |
| 124 |
break |
| 125 |
if not found_wrapper: |
| 126 |
for path in os.environ["PATH"].split(os.pathsep): |
| 127 |
if os.path.isfile(path + "/ld.mold"): |
| 128 |
env.Append(LINKFLAGS=["-B" + path]) |
| 129 |
found_wrapper = True |
| 130 |
break |
| 131 |
if not found_wrapper: |
| 132 |
print_error( |
| 133 |
"Couldn't locate mold installation path. Make sure it's installed in /usr, /usr/local or in PATH environment variable." |
| 134 |
) |
| 135 |
sys.exit(255) |
| 136 |
else: |
| 137 |
env.Append(LINKFLAGS=["-fuse-ld=mold"]) |
| 138 |
else: |
| 139 |
env.Append(LINKFLAGS=["-fuse-ld=%s" % env["linker"]]) |
| 140 |
|
| 141 |
if env["use_coverage"]: |
| 142 |
env.Append(CCFLAGS=["-ftest-coverage", "-fprofile-arcs"]) |
| 143 |
env.Append(LINKFLAGS=["-ftest-coverage", "-fprofile-arcs"]) |
| 144 |
|
| 145 |
if env["use_ubsan"] or env["use_asan"] or env["use_lsan"] or env["use_tsan"] or env["use_msan"]: |
| 146 |
env.extra_suffix += ".san" |
| 147 |
env.Append(CPPDEFINES=["SANITIZERS_ENABLED"]) |
| 148 |
|
| 149 |
if env["use_ubsan"]: |
| 150 |
env.Append( |
| 151 |
CCFLAGS=[ |
| 152 |
"-fsanitize=undefined,shift,shift-exponent,integer-divide-by-zero,unreachable,vla-bound,null,return,signed-integer-overflow,bounds,float-divide-by-zero,float-cast-overflow,nonnull-attribute,returns-nonnull-attribute,bool,enum,vptr,pointer-overflow,builtin" |
| 153 |
] |
| 154 |
) |
| 155 |
env.Append(LINKFLAGS=["-fsanitize=undefined"]) |
| 156 |
if env["use_llvm"]: |
| 157 |
env.Append( |
| 158 |
CCFLAGS=[ |
| 159 |
"-fsanitize=nullability-return,nullability-arg,function,nullability-assign,implicit-integer-sign-change" |
| 160 |
] |
| 161 |
) |
| 162 |
else: |
| 163 |
env.Append(CCFLAGS=["-fsanitize=bounds-strict"]) |
| 164 |
|
| 165 |
if env["use_asan"]: |
| 166 |
env.Append(CCFLAGS=["-fsanitize=address,pointer-subtract,pointer-compare"]) |
| 167 |
env.Append(LINKFLAGS=["-fsanitize=address"]) |
| 168 |
|
| 169 |
if env["use_lsan"]: |
| 170 |
env.Append(CCFLAGS=["-fsanitize=leak"]) |
| 171 |
env.Append(LINKFLAGS=["-fsanitize=leak"]) |
| 172 |
|
| 173 |
if env["use_tsan"]: |
| 174 |
env.Append(CCFLAGS=["-fsanitize=thread"]) |
| 175 |
env.Append(LINKFLAGS=["-fsanitize=thread"]) |
| 176 |
|
| 177 |
if env["use_msan"] and env["use_llvm"]: |
| 178 |
env.Append(CCFLAGS=["-fsanitize=memory"]) |
| 179 |
env.Append(CCFLAGS=["-fsanitize-memory-track-origins"]) |
| 180 |
env.Append(CCFLAGS=["-fsanitize-recover=memory"]) |
| 181 |
env.Append(LINKFLAGS=["-fsanitize=memory"]) |
| 182 |
|
| 183 |
env.Append(CCFLAGS=["-ffp-contract=off"]) |
| 184 |
|
| 185 |
if env["library_type"] == "shared_library": |
| 186 |
env.Append(CCFLAGS=["-fPIC"]) |
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
if env["lto"] == "auto": |
| 191 |
env["lto"] = "thin" if env["use_llvm"] else "full" |
| 192 |
|
| 193 |
if env["lto"] != "none": |
| 194 |
if env["lto"] == "thin": |
| 195 |
if not env["use_llvm"]: |
| 196 |
print_error("ThinLTO is only compatible with LLVM, use `use_llvm=yes` or `lto=full`.") |
| 197 |
sys.exit(255) |
| 198 |
env.Append(CCFLAGS=["-flto=thin"]) |
| 199 |
env.Append(LINKFLAGS=["-flto=thin"]) |
| 200 |
elif not env["use_llvm"] and env.GetOption("num_jobs") > 1: |
| 201 |
env.Append(CCFLAGS=["-flto"]) |
| 202 |
env.Append(LINKFLAGS=["-flto=" + str(env.GetOption("num_jobs"))]) |
| 203 |
else: |
| 204 |
env.Append(CCFLAGS=["-flto"]) |
| 205 |
env.Append(LINKFLAGS=["-flto"]) |
| 206 |
|
| 207 |
if not env["use_llvm"]: |
| 208 |
env["RANLIB"] = "gcc-ranlib" |
| 209 |
env["AR"] = "gcc-ar" |
| 210 |
|
| 211 |
env.Append(CCFLAGS=["-pipe"]) |
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
if env["use_sowrap"]: |
| 216 |
env.Append(CPPDEFINES=["SOWRAP_ENABLED"]) |
| 217 |
|
| 218 |
if env["wayland"]: |
| 219 |
if os.system("wayland-scanner -v 2>/dev/null") != 0: |
| 220 |
print_warning("wayland-scanner not found. Disabling Wayland support.") |
| 221 |
env["wayland"] = False |
| 222 |
|
| 223 |
if env["touch"]: |
| 224 |
env.Append(CPPDEFINES=["TOUCH_ENABLED"]) |
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
if not env["builtin_freetype"]: |
| 229 |
env.ParseConfig("pkg-config freetype2 --cflags --libs") |
| 230 |
|
| 231 |
if not env["builtin_graphite"]: |
| 232 |
env.ParseConfig("pkg-config graphite2 --cflags --libs") |
| 233 |
|
| 234 |
if not env["builtin_icu4c"]: |
| 235 |
env.ParseConfig("pkg-config icu-i18n icu-uc --cflags --libs") |
| 236 |
|
| 237 |
if not env["builtin_harfbuzz"]: |
| 238 |
env.ParseConfig("pkg-config harfbuzz harfbuzz-icu --cflags --libs") |
| 239 |
|
| 240 |
if not env["builtin_icu4c"] or not env["builtin_harfbuzz"]: |
| 241 |
print_warning( |
| 242 |
"System-provided icu4c or harfbuzz cause known issues for GDExtension (see GH-91401 and GH-100301)." |
| 243 |
) |
| 244 |
|
| 245 |
if not env["builtin_libpng"]: |
| 246 |
env.ParseConfig("pkg-config libpng16 --cflags --libs") |
| 247 |
|
| 248 |
if not env["builtin_enet"]: |
| 249 |
env.ParseConfig("pkg-config libenet --cflags --libs") |
| 250 |
print_warning( |
| 251 |
"System-provided ENet has its functionality limited to IPv4 only and no DTLS support, unless patched for Godot." |
| 252 |
) |
| 253 |
|
| 254 |
if not env["builtin_zstd"]: |
| 255 |
env.ParseConfig("pkg-config libzstd --cflags --libs") |
| 256 |
|
| 257 |
if env["brotli"] and not env["builtin_brotli"]: |
| 258 |
env.ParseConfig("pkg-config libbrotlicommon libbrotlidec --cflags --libs") |
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
if not env["builtin_libtheora"]: |
| 264 |
env["builtin_libogg"] = False |
| 265 |
env["builtin_libvorbis"] = False |
| 266 |
if env.editor_build: |
| 267 |
env.ParseConfig("pkg-config theora theoradec theoraenc --cflags --libs") |
| 268 |
else: |
| 269 |
env.ParseConfig("pkg-config theora theoradec --cflags --libs") |
| 270 |
else: |
| 271 |
if env["arch"] in ["x86_64", "x86_32"]: |
| 272 |
env["x86_libtheora_opt_gcc"] = True |
| 273 |
|
| 274 |
if not env["builtin_libvorbis"]: |
| 275 |
env["builtin_libogg"] = False |
| 276 |
if env.editor_build: |
| 277 |
env.ParseConfig("pkg-config vorbis vorbisfile vorbisenc --cflags --libs") |
| 278 |
else: |
| 279 |
env.ParseConfig("pkg-config vorbis vorbisfile --cflags --libs") |
| 280 |
|
| 281 |
if not env["builtin_libogg"]: |
| 282 |
env.ParseConfig("pkg-config ogg --cflags --libs") |
| 283 |
|
| 284 |
if not env["builtin_libwebp"]: |
| 285 |
env.ParseConfig("pkg-config libwebp --cflags --libs") |
| 286 |
|
| 287 |
if not env["builtin_libjpeg_turbo"]: |
| 288 |
env.ParseConfig("pkg-config libturbojpeg --cflags --libs") |
| 289 |
|
| 290 |
if not env["builtin_mbedtls"]: |
| 291 |
|
| 292 |
|
| 293 |
if os.system("pkg-config --exists mbedtls") == 0: |
| 294 |
env.ParseConfig("pkg-config mbedtls mbedcrypto mbedx509 --cflags --libs") |
| 295 |
else: |
| 296 |
env.Append(LIBS=["mbedtls", "mbedcrypto", "mbedx509"]) |
| 297 |
|
| 298 |
if not env["builtin_wslay"]: |
| 299 |
env.ParseConfig("pkg-config libwslay --cflags --libs") |
| 300 |
|
| 301 |
if not env["builtin_miniupnpc"]: |
| 302 |
env.ParseConfig("pkg-config miniupnpc --cflags --libs") |
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
if not env["builtin_pcre2"]: |
| 307 |
env.ParseConfig("pkg-config libpcre2-32 --cflags --libs") |
| 308 |
|
| 309 |
if not env["builtin_recastnavigation"]: |
| 310 |
env.ParseConfig("pkg-config recastnavigation --cflags --libs") |
| 311 |
|
| 312 |
if not env["builtin_embree"] and env["arch"] in ["x86_64", "arm64"]: |
| 313 |
|
| 314 |
env.Append(LIBS=["embree4"]) |
| 315 |
|
| 316 |
if not env["builtin_openxr"]: |
| 317 |
env.ParseConfig("pkg-config openxr --cflags --libs") |
| 318 |
|
| 319 |
if env["fontconfig"]: |
| 320 |
if not env["use_sowrap"]: |
| 321 |
if os.system("pkg-config --exists fontconfig") == 0: |
| 322 |
env.ParseConfig("pkg-config fontconfig --cflags --libs") |
| 323 |
env.Append(CPPDEFINES=["FONTCONFIG_ENABLED"]) |
| 324 |
else: |
| 325 |
print_warning("fontconfig development libraries not found. Disabling the system fonts support.") |
| 326 |
env["fontconfig"] = False |
| 327 |
else: |
| 328 |
env.Append(CPPDEFINES=["FONTCONFIG_ENABLED"]) |
| 329 |
|
| 330 |
if env["alsa"]: |
| 331 |
if not env["use_sowrap"]: |
| 332 |
if os.system("pkg-config --exists alsa") == 0: |
| 333 |
env.ParseConfig("pkg-config alsa --cflags --libs") |
| 334 |
env.Append(CPPDEFINES=["ALSA_ENABLED", "ALSAMIDI_ENABLED"]) |
| 335 |
else: |
| 336 |
print_warning("ALSA development libraries not found. Disabling the ALSA audio driver.") |
| 337 |
env["alsa"] = False |
| 338 |
else: |
| 339 |
env.Append(CPPDEFINES=["ALSA_ENABLED", "ALSAMIDI_ENABLED"]) |
| 340 |
|
| 341 |
if env["pulseaudio"]: |
| 342 |
if not env["use_sowrap"]: |
| 343 |
if os.system("pkg-config --exists libpulse") == 0: |
| 344 |
env.ParseConfig("pkg-config libpulse --cflags --libs") |
| 345 |
env.Append(CPPDEFINES=["PULSEAUDIO_ENABLED"]) |
| 346 |
else: |
| 347 |
print_warning("PulseAudio development libraries not found. Disabling the PulseAudio audio driver.") |
| 348 |
env["pulseaudio"] = False |
| 349 |
else: |
| 350 |
env.Append(CPPDEFINES=["PULSEAUDIO_ENABLED", "_REENTRANT"]) |
| 351 |
|
| 352 |
if env["dbus"] and env["threads"]: |
| 353 |
if not env["use_sowrap"]: |
| 354 |
if os.system("pkg-config --exists dbus-1") == 0: |
| 355 |
env.ParseConfig("pkg-config dbus-1 --cflags --libs") |
| 356 |
env.Append(CPPDEFINES=["DBUS_ENABLED"]) |
| 357 |
else: |
| 358 |
print_warning("D-Bus development libraries not found. Disabling screensaver prevention.") |
| 359 |
env["dbus"] = False |
| 360 |
else: |
| 361 |
env.Append(CPPDEFINES=["DBUS_ENABLED"]) |
| 362 |
|
| 363 |
if env["speechd"]: |
| 364 |
if not env["use_sowrap"]: |
| 365 |
if os.system("pkg-config --exists speech-dispatcher") == 0: |
| 366 |
env.ParseConfig("pkg-config speech-dispatcher --cflags --libs") |
| 367 |
env.Append(CPPDEFINES=["SPEECHD_ENABLED"]) |
| 368 |
else: |
| 369 |
print_warning("speech-dispatcher development libraries not found. Disabling text to speech support.") |
| 370 |
env["speechd"] = False |
| 371 |
else: |
| 372 |
env.Append(CPPDEFINES=["SPEECHD_ENABLED"]) |
| 373 |
|
| 374 |
if not env["use_sowrap"]: |
| 375 |
if os.system("pkg-config --exists xkbcommon") == 0: |
| 376 |
env.ParseConfig("pkg-config xkbcommon --cflags --libs") |
| 377 |
env.Append(CPPDEFINES=["XKB_ENABLED"]) |
| 378 |
else: |
| 379 |
if env["wayland"]: |
| 380 |
print_error("libxkbcommon development libraries required by Wayland not found. Aborting.") |
| 381 |
sys.exit(255) |
| 382 |
else: |
| 383 |
print_warning( |
| 384 |
"libxkbcommon development libraries not found. Disabling dead key composition and key label support." |
| 385 |
) |
| 386 |
else: |
| 387 |
env.Append(CPPDEFINES=["XKB_ENABLED"]) |
| 388 |
|
| 389 |
if platform.system() == "Linux": |
| 390 |
if env["udev"]: |
| 391 |
if not env["use_sowrap"]: |
| 392 |
if os.system("pkg-config --exists libudev") == 0: |
| 393 |
env.ParseConfig("pkg-config libudev --cflags --libs") |
| 394 |
env.Append(CPPDEFINES=["UDEV_ENABLED"]) |
| 395 |
else: |
| 396 |
print_warning("libudev development libraries not found. Disabling controller hotplugging support.") |
| 397 |
env["udev"] = False |
| 398 |
else: |
| 399 |
env.Append(CPPDEFINES=["UDEV_ENABLED"]) |
| 400 |
else: |
| 401 |
env["udev"] = False |
| 402 |
|
| 403 |
if env["sdl"]: |
| 404 |
if env["builtin_sdl"]: |
| 405 |
env.Append(CPPDEFINES=["SDL_ENABLED"]) |
| 406 |
elif os.system("pkg-config --exists sdl3") == 0: |
| 407 |
env.ParseConfig("pkg-config sdl3 --cflags --libs") |
| 408 |
env.Append(CPPDEFINES=["SDL_ENABLED"]) |
| 409 |
else: |
| 410 |
print_warning( |
| 411 |
"SDL3 development libraries not found, and `builtin_sdl` was explicitly disabled. Disabling SDL input driver support." |
| 412 |
) |
| 413 |
env["sdl"] = False |
| 414 |
|
| 415 |
|
| 416 |
if not env["builtin_zlib"]: |
| 417 |
env.ParseConfig("pkg-config zlib --cflags --libs") |
| 418 |
|
| 419 |
env.Prepend(CPPPATH=["#platform/linuxbsd"]) |
| 420 |
if env["use_sowrap"]: |
| 421 |
env.Prepend(CPPPATH=["#thirdparty/linuxbsd_headers"]) |
| 422 |
|
| 423 |
env.Append( |
| 424 |
CPPDEFINES=[ |
| 425 |
"LINUXBSD_ENABLED", |
| 426 |
"UNIX_ENABLED", |
| 427 |
("_FILE_OFFSET_BITS", 64), |
| 428 |
] |
| 429 |
) |
| 430 |
|
| 431 |
if env["x11"]: |
| 432 |
if not env["use_sowrap"]: |
| 433 |
if os.system("pkg-config --exists x11"): |
| 434 |
print_error("X11 libraries not found. Aborting.") |
| 435 |
sys.exit(255) |
| 436 |
env.ParseConfig("pkg-config x11 --cflags --libs") |
| 437 |
if os.system("pkg-config --exists xcursor"): |
| 438 |
print_error("Xcursor library not found. Aborting.") |
| 439 |
sys.exit(255) |
| 440 |
env.ParseConfig("pkg-config xcursor --cflags --libs") |
| 441 |
if os.system("pkg-config --exists xinerama"): |
| 442 |
print_error("Xinerama library not found. Aborting.") |
| 443 |
sys.exit(255) |
| 444 |
env.ParseConfig("pkg-config xinerama --cflags --libs") |
| 445 |
if os.system("pkg-config --exists xext"): |
| 446 |
print_error("Xext library not found. Aborting.") |
| 447 |
sys.exit(255) |
| 448 |
env.ParseConfig("pkg-config xext --cflags --libs") |
| 449 |
if os.system("pkg-config --exists xrandr"): |
| 450 |
print_error("XrandR library not found. Aborting.") |
| 451 |
sys.exit(255) |
| 452 |
env.ParseConfig("pkg-config xrandr --cflags --libs") |
| 453 |
if os.system("pkg-config --exists xrender"): |
| 454 |
print_error("XRender library not found. Aborting.") |
| 455 |
sys.exit(255) |
| 456 |
env.ParseConfig("pkg-config xrender --cflags --libs") |
| 457 |
if os.system("pkg-config --exists xi"): |
| 458 |
print_error("Xi library not found. Aborting.") |
| 459 |
sys.exit(255) |
| 460 |
env.ParseConfig("pkg-config xi --cflags --libs") |
| 461 |
env.Append(CPPDEFINES=["X11_ENABLED"]) |
| 462 |
|
| 463 |
if env["wayland"]: |
| 464 |
if not env["use_sowrap"]: |
| 465 |
if os.system("pkg-config --exists libdecor-0"): |
| 466 |
print_warning("libdecor development libraries not found. Disabling client-side decorations.") |
| 467 |
env["libdecor"] = False |
| 468 |
else: |
| 469 |
env.ParseConfig("pkg-config libdecor-0 --cflags --libs") |
| 470 |
if os.system("pkg-config --exists wayland-client"): |
| 471 |
print_error("Wayland client library not found. Aborting.") |
| 472 |
sys.exit(255) |
| 473 |
env.ParseConfig("pkg-config wayland-client --cflags --libs") |
| 474 |
if os.system("pkg-config --exists wayland-cursor"): |
| 475 |
print_error("Wayland cursor library not found. Aborting.") |
| 476 |
sys.exit(255) |
| 477 |
env.ParseConfig("pkg-config wayland-cursor --cflags --libs") |
| 478 |
if os.system("pkg-config --exists wayland-egl"): |
| 479 |
print_error("Wayland EGL library not found. Aborting.") |
| 480 |
sys.exit(255) |
| 481 |
env.ParseConfig("pkg-config wayland-egl --cflags --libs") |
| 482 |
else: |
| 483 |
env.Prepend(CPPPATH=["#thirdparty/linuxbsd_headers/wayland/"]) |
| 484 |
if env["libdecor"]: |
| 485 |
env.Prepend(CPPPATH=["#thirdparty/linuxbsd_headers/libdecor-0/"]) |
| 486 |
|
| 487 |
if env["libdecor"]: |
| 488 |
env.Append(CPPDEFINES=["LIBDECOR_ENABLED"]) |
| 489 |
|
| 490 |
env.Append(CPPDEFINES=["WAYLAND_ENABLED"]) |
| 491 |
env.Append(LIBS=["rt"]) |
| 492 |
|
| 493 |
if env["accesskit"]: |
| 494 |
if env["accesskit_sdk_path"] != "": |
| 495 |
env.Prepend(CPPPATH=[env["accesskit_sdk_path"] + "/include"]) |
| 496 |
if env["arch"] == "arm64": |
| 497 |
env.Append(LIBPATH=[env["accesskit_sdk_path"] + "/lib/linux/arm64/static/"]) |
| 498 |
elif env["arch"] == "arm32": |
| 499 |
env.Append(LIBPATH=[env["accesskit_sdk_path"] + "/lib/linux/arm32/static/"]) |
| 500 |
elif env["arch"] == "rv64": |
| 501 |
env.Append(LIBPATH=[env["accesskit_sdk_path"] + "/lib/linux/riscv64gc/static/"]) |
| 502 |
elif env["arch"] == "x86_64": |
| 503 |
env.Append(LIBPATH=[env["accesskit_sdk_path"] + "/lib/linux/x86_64/static/"]) |
| 504 |
elif env["arch"] == "x86_32": |
| 505 |
env.Append(LIBPATH=[env["accesskit_sdk_path"] + "/lib/linux/x86/static/"]) |
| 506 |
env.Append(LIBS=["accesskit"]) |
| 507 |
else: |
| 508 |
env.Append(CPPDEFINES=["ACCESSKIT_DYNAMIC"]) |
| 509 |
env.Append(CPPDEFINES=["ACCESSKIT_ENABLED"]) |
| 510 |
|
| 511 |
if env["vulkan"]: |
| 512 |
env.Append(CPPDEFINES=["VULKAN_ENABLED", "RD_ENABLED"]) |
| 513 |
if not env["use_volk"]: |
| 514 |
env.ParseConfig("pkg-config vulkan --cflags --libs") |
| 515 |
if not env["builtin_glslang"]: |
| 516 |
|
| 517 |
env.Append(LIBS=["glslang", "SPIRV", "glslang-default-resource-limits"]) |
| 518 |
|
| 519 |
if env["opengl3"]: |
| 520 |
env.Append(CPPDEFINES=["GLES3_ENABLED"]) |
| 521 |
|
| 522 |
env.Append(LIBS=["pthread"]) |
| 523 |
|
| 524 |
if platform.system() == "Linux": |
| 525 |
env.Append(LIBS=["dl"]) |
| 526 |
|
| 527 |
if platform.libc_ver()[0] != "glibc": |
| 528 |
if env["execinfo"]: |
| 529 |
env.Append(LIBS=["execinfo"]) |
| 530 |
env.Append(CPPDEFINES=["CRASH_HANDLER_ENABLED"]) |
| 531 |
else: |
| 532 |
|
| 533 |
|
| 534 |
print_info("Using `execinfo=no` disables the crash handler on platforms where glibc is missing.") |
| 535 |
else: |
| 536 |
env.Append(CPPDEFINES=["CRASH_HANDLER_ENABLED"]) |
| 537 |
|
| 538 |
if platform.system() == "FreeBSD": |
| 539 |
env.Append(LINKFLAGS=["-lkvm"]) |
| 540 |
|
| 541 |
|
| 542 |
if env["use_static_cpp"]: |
| 543 |
env.Append(LINKFLAGS=["-static-libgcc", "-static-libstdc++"]) |
| 544 |
if env["use_llvm"] and platform.system() != "FreeBSD": |
| 545 |
env["LINKCOM"] = env["LINKCOM"] + " -l:libatomic.a" |
| 546 |
else: |
| 547 |
if env["use_llvm"] and platform.system() != "FreeBSD": |
| 548 |
env.Append(LIBS=["atomic"]) |