diff options
author | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2023-05-25 02:33:18 +0200 |
---|---|---|
committer | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2023-05-25 06:07:03 +0200 |
commit | 45549e020fd99195b9db3222a1733e21af2032d5 (patch) | |
tree | b428a52bd3133dcca9f8c97830a374aa28d23dcc /tools | |
parent | ee40730c205c2eff6c4078ed6229ccbe1c6c02d2 (diff) | |
download | fork-godot-webrtc-native-45549e020fd99195b9db3222a1733e21af2032d5.tar.gz fork-godot-webrtc-native-45549e020fd99195b9db3222a1733e21af2032d5.tar.bz2 fork-godot-webrtc-native-45549e020fd99195b9db3222a1733e21af2032d5.zip |
[SCons] Move platform configuration to cmake tool.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/cmake.py | 59 | ||||
-rw-r--r-- | tools/rtc.py | 45 |
2 files changed, 60 insertions, 44 deletions
diff --git a/tools/cmake.py b/tools/cmake.py index 2362312..d552da6 100644 --- a/tools/cmake.py +++ b/tools/cmake.py @@ -1,3 +1,6 @@ +import os + + def exists(env): return True @@ -5,6 +8,7 @@ def exists(env): def generate(env): env.AddMethod(cmake_configure, "CMakeConfigure") env.AddMethod(cmake_build, "CMakeBuild") + env.AddMethod(cmake_platform_flags, "CMakePlatformFlags") def cmake_configure(env, source, target, opt_args): @@ -22,5 +26,58 @@ def cmake_configure(env, source, target, opt_args): def cmake_build(env, source, target=""): jobs = env.GetOption("num_jobs") - env = env.Clone() return env.Execute("cmake --build %s %s -j%s" % (source, "-t %s" % target if target else "", jobs)) + + +def cmake_platform_flags(env, config=None): + if config is None: + config = {} + + if "CC" in env: + config["CMAKE_C_COMPILER"] = env["CC"] + if "CXX" in env: + config["CMAKE_CXX_COMPILER"] = env["CXX"] + + if env["platform"] == "android": + api = env["android_api_level"] + abi = { + "arm64": "arm64-v8a", + "arm32": "armeabi-v7a", + "x86_32": "x86", + "x86_64": "x86_64", + }[env["arch"]] + config["CMAKE_SYSTEM_NAME"] = "Android" + config["CMAKE_SYSTEM_VERSION"] = api + config["CMAKE_ANDROID_ARCH_ABI"] = abi + config["ANDROID_ABI"] = abi + config["CMAKE_TOOLCHAIN_FILE"] = "%s/build/cmake/android.toolchain.cmake" % os.environ.get( + "ANDROID_NDK_ROOT", "" + ) + config["CMAKE_ANDROID_STL_TYPE"] = "c++_static" + + elif env["platform"] == "linux": + march = "-m32" if env["arch"] == "x86_32" else "-m64" + config["CMAKE_C_FLAGS"] = march + config["CMAKE_CXX_FLAGS"] = march + + elif env["platform"] == "macos": + if env["arch"] == "universal": + raise ValueError("OSX architecture not supported: %s" % env["arch"]) + config["CMAKE_OSX_ARCHITECTURES"] = env["arch"] + if env["macos_deployment_target"] != "default": + config["CMAKE_OSX_DEPLOYMENT_TARGET"] = env["macos_deployment_target"] + + elif env["platform"] == "ios": + if env["arch"] == "universal": + raise ValueError("iOS architecture not supported: %s" % env["arch"]) + config["CMAKE_SYSTEM_NAME"] = "iOS" + config["CMAKE_OSX_ARCHITECTURES"] = env["arch"] + if env["ios_min_version"] != "default": + config["CMAKE_OSX_DEPLOYMENT_TARGET"] = env["ios_min_version"] + if env["ios_simulator"]: + config["CMAKE_OSX_SYSROOT"] = "iphonesimulator" + + elif env["platform"] == "windows": + config["CMAKE_SYSTEM_NAME"] = "Windows" + + return config diff --git a/tools/rtc.py b/tools/rtc.py index 34da8eb..680e772 100644 --- a/tools/rtc.py +++ b/tools/rtc.py @@ -7,6 +7,7 @@ def rtc_cmake_config(env): "NO_WEBSOCKET": 1, "NO_EXAMPLES": 1, "NO_TESTS": 1, + "BUILD_WITH_WARNINGS": "0", # Disables werror in libsrtp. "OPENSSL_USE_STATIC_LIBS": 1, "OPENSSL_INCLUDE_DIR": env["SSL_INCLUDE"], "OPENSSL_SSL_LIBRARY": env["SSL_LIBRARY"], @@ -14,49 +15,7 @@ def rtc_cmake_config(env): "OPENSSL_ROOT_DIR": env["SSL_BUILD"], "CMAKE_BUILD_TYPE": "%s" % ("RelWithDebInfo" if env["debug_symbols"] else "Release"), } - if "CC" in env: - config["CMAKE_C_COMPILER"] = env["CC"] - if "CXX" in env: - config["CMAKE_CXX_COMPILER"] = env["CXX"] - - if env["platform"] == "android": - api = env["android_api_level"] if int(env["android_api_level"]) > 28 else "28" - abi = { - "arm64": "arm64-v8a", - "arm32": "armeabi-v7a", - "x86_32": "x86", - "x86_64": "x86_64", - }[env["arch"]] - config["CMAKE_SYSTEM_NAME"] = "Android" - config["CMAKE_SYSTEM_VERSION"] = api - config["CMAKE_ANDROID_ARCH_ABI"] = abi - config["ANDROID_ABI"] = abi - config["CMAKE_TOOLCHAIN_FILE"] = "%s/build/cmake/android.toolchain.cmake" % os.environ.get( - "ANDROID_NDK_ROOT", "" - ) - config["CMAKE_ANDROID_STL_TYPE"] = "c++_static" - elif env["platform"] == "linux": - march = "-m32" if env["arch"] == "x86_32" else "-m64" - config["CMAKE_C_FLAGS"] = march - config["CMAKE_CXX_FLAGS"] = march - elif env["platform"] == "macos": - if env["arch"] == "universal": - raise ValueError("OSX architecture not supported: %s" % env["arch"]) - config["CMAKE_OSX_ARCHITECTURES"] = env["arch"] - if env["macos_deployment_target"] != "default": - config["CMAKE_OSX_DEPLOYMENT_TARGET"] = env["macos_deployment_target"] - elif env["platform"] == "ios": - if env["arch"] == "universal": - raise ValueError("iOS architecture not supported: %s" % env["arch"]) - config["CMAKE_SYSTEM_NAME"] = "iOS" - config["CMAKE_OSX_DEPLOYMENT_TARGET"] = "11.0" - config["CMAKE_OSX_ARCHITECTURES"] = env["arch"] - if env["ios_simulator"]: - config["CMAKE_OSX_SYSROOT"] = "iphonesimulator" - elif env["platform"] == "windows": - config["CMAKE_SYSTEM_NAME"] = "Windows" - config["BUILD_WITH_WARNINGS"] = "0" # Disables werror in libsrtp. - return config + return env.CMakePlatformFlags(config) def rtc_emitter(target, source, env): |