Skip to content

Commit 6e9bcc0

Browse files
committed
SCons: Better validation for platform-specific opt-in drivers
This replaces cryptic compilation errors with a clear error message and early build termination.
1 parent 5ca419e commit 6e9bcc0

File tree

6 files changed

+20
-8
lines changed

6 files changed

+20
-8
lines changed

SConstruct

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,11 @@ opts.Add(BoolVariable("deprecated", "Enable compatibility code for deprecated an
218218
opts.Add(EnumVariable("precision", "Set the floating-point precision level", "single", ("single", "double")))
219219
opts.Add(BoolVariable("minizip", "Enable ZIP archive support using minizip", True))
220220
opts.Add(BoolVariable("brotli", "Enable Brotli for decompresson and WOFF2 fonts support", True))
221-
opts.Add(BoolVariable("xaudio2", "Enable the XAudio2 audio driver", False))
221+
opts.Add(BoolVariable("xaudio2", "Enable the XAudio2 audio driver on supported platforms", False))
222222
opts.Add(BoolVariable("vulkan", "Enable the vulkan rendering driver", True))
223223
opts.Add(BoolVariable("opengl3", "Enable the OpenGL/GLES3 rendering driver", True))
224-
opts.Add(BoolVariable("d3d12", "Enable the Direct3D 12 rendering driver", False))
225-
opts.Add(BoolVariable("metal", "Enable the Metal rendering driver (Apple arm64 only)", False))
224+
opts.Add(BoolVariable("d3d12", "Enable the Direct3D 12 rendering driver on supported platforms", False))
225+
opts.Add(BoolVariable("metal", "Enable the Metal rendering driver on supported platforms (Apple arm64 only)", False))
226226
opts.Add(BoolVariable("openxr", "Enable the OpenXR driver", True))
227227
opts.Add(BoolVariable("use_volk", "Use the volk library to load the Vulkan loader dynamically", True))
228228
opts.Add(BoolVariable("disable_exceptions", "Force disabling exception handling code", True))

drivers/SCsub

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Import("env")
44

55
env.drivers_sources = []
6+
supported = env.get("supported", [])
67

78
# OS drivers
89
SConscript("unix/SCsub")
@@ -17,6 +18,9 @@ if env["platform"] == "windows":
1718
if not env.msvc:
1819
SConscript("backtrace/SCsub")
1920
if env["xaudio2"]:
21+
if "xaudio2" not in supported:
22+
print("Target platform '{}' does not support the XAudio2 audio driver. Aborting.".format(env["platform"]))
23+
Exit(255)
2024
SConscript("xaudio2/SCsub")
2125

2226
# Midi drivers
@@ -28,12 +32,18 @@ SConscript("winmidi/SCsub")
2832
if env["vulkan"]:
2933
SConscript("vulkan/SCsub")
3034
if env["d3d12"]:
35+
if "d3d12" not in supported:
36+
print("Target platform '{}' does not support the D3D12 rendering driver. Aborting.".format(env["platform"]))
37+
Exit(255)
3138
SConscript("d3d12/SCsub")
3239
if env["opengl3"]:
3340
SConscript("gl_context/SCsub")
3441
SConscript("gles3/SCsub")
3542
SConscript("egl/SCsub")
3643
if env["metal"]:
44+
if "metal" not in supported:
45+
print("Target platform '{}' does not support the Metal rendering driver. Aborting.".format(env["platform"]))
46+
Exit(255)
3747
SConscript("metal/SCsub")
3848

3949
# Core dependencies

modules/mono/config.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ def can_build(env, platform):
1111
def configure(env):
1212
# Check if the platform has marked mono as supported.
1313
supported = env.get("supported", [])
14-
1514
if "mono" not in supported:
16-
raise RuntimeError("This module does not currently support building for this platform")
15+
import sys
16+
17+
print("The 'mono' module does not currently support building for this platform. Aborting.")
18+
sys.exit(255)
1719

1820
env.add_module_version_string("mono")
1921

platform/ios/detect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def get_flags():
5252
"target": "template_debug",
5353
"use_volk": False,
5454
"metal": True,
55-
"supported": ["mono"],
55+
"supported": ["metal", "mono"],
5656
"builtin_pcre2_with_jit": False,
5757
}
5858

platform/macos/detect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def get_flags():
5757
"arch": detect_arch(),
5858
"use_volk": False,
5959
"metal": True,
60-
"supported": ["mono"],
60+
"supported": ["metal", "mono"],
6161
}
6262

6363

platform/windows/detect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ def get_flags():
247247

248248
return {
249249
"arch": arch,
250-
"supported": ["mono"],
250+
"supported": ["d3d12", "mono", "xaudio2"],
251251
}
252252

253253

0 commit comments

Comments
 (0)