From 21e524a798bf3c3728f63657ff2e7a79f6de9ee6 Mon Sep 17 00:00:00 2001 From: Andreia Gaita Date: Mon, 5 Feb 2024 20:55:06 +0100 Subject: [PATCH] C#: Let platforms signal if they support it or not Instead of hardcoding platform names that support C#, let platforms set a flag indicating if they support it. All public platforms except web already support it, and it's a pain to maintain a patch for this list just to add additional names of proprietary console platforms. This makes adding new platforms or variants or existing platforms much easier, as the platform can signal what it supports/doesn't support directly, and we can avoid harcoding platform names. --- modules/mono/config.py | 10 +++------- platform/android/detect.py | 1 + platform/ios/detect.py | 1 + platform/linuxbsd/detect.py | 1 + platform/macos/detect.py | 1 + platform/windows/detect.py | 1 + 6 files changed, 8 insertions(+), 7 deletions(-) diff --git a/modules/mono/config.py b/modules/mono/config.py index 859d77b262c..3d087c9e27b 100644 --- a/modules/mono/config.py +++ b/modules/mono/config.py @@ -1,8 +1,3 @@ -# Prior to .NET Core, we supported these: ["windows", "macos", "linuxbsd", "android", "web", "ios"] -# Eventually support for each them should be added back. -supported_platforms = ["windows", "macos", "linuxbsd", "android", "ios"] - - def can_build(env, platform): if env["arch"].startswith("rv"): return False @@ -14,9 +9,10 @@ def can_build(env, platform): def configure(env): - platform = env["platform"] + # Check if the platform has marked mono as supported. + supported = env.get("supported", []) - if platform not in supported_platforms: + if not "mono" in supported: raise RuntimeError("This module does not currently support building for this platform") env.add_module_version_string("mono") diff --git a/platform/android/detect.py b/platform/android/detect.py index a417ef454b0..3da8ee0b62c 100644 --- a/platform/android/detect.py +++ b/platform/android/detect.py @@ -68,6 +68,7 @@ def get_flags(): return [ ("arch", "arm64"), # Default for convenience. ("target", "template_debug"), + ("supported", ["mono"]), ] diff --git a/platform/ios/detect.py b/platform/ios/detect.py index 26d81c8ed6a..1f2e9359462 100644 --- a/platform/ios/detect.py +++ b/platform/ios/detect.py @@ -49,6 +49,7 @@ def get_flags(): ("arch", "arm64"), # Default for convenience. ("target", "template_debug"), ("use_volk", False), + ("supported", ["mono"]), ] diff --git a/platform/linuxbsd/detect.py b/platform/linuxbsd/detect.py index 59cc6e7962b..6737c0c4e00 100644 --- a/platform/linuxbsd/detect.py +++ b/platform/linuxbsd/detect.py @@ -65,6 +65,7 @@ def get_doc_path(): def get_flags(): return [ ("arch", detect_arch()), + ("supported", ["mono"]), ] diff --git a/platform/macos/detect.py b/platform/macos/detect.py index b41d2141fbf..fe2a0adc60c 100644 --- a/platform/macos/detect.py +++ b/platform/macos/detect.py @@ -50,6 +50,7 @@ def get_flags(): return [ ("arch", detect_arch()), ("use_volk", False), + ("supported", ["mono"]), ] diff --git a/platform/windows/detect.py b/platform/windows/detect.py index 801b32140a6..12b14ee99ea 100644 --- a/platform/windows/detect.py +++ b/platform/windows/detect.py @@ -215,6 +215,7 @@ def get_flags(): return [ ("arch", arch), + ("supported", ["mono"]), ]