summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2023-05-25 07:29:57 +0200
committerGitHub <noreply@github.com>2023-05-25 07:29:57 +0200
commitdf643250f5e35d5ecbbd6dafab940a4e7e4d2f25 (patch)
treeb428a52bd3133dcca9f8c97830a374aa28d23dcc
parentee40730c205c2eff6c4078ed6229ccbe1c6c02d2 (diff)
parent45549e020fd99195b9db3222a1733e21af2032d5 (diff)
downloadfork-godot-webrtc-native-df643250f5e35d5ecbbd6dafab940a4e7e4d2f25.tar.gz
fork-godot-webrtc-native-df643250f5e35d5ecbbd6dafab940a4e7e4d2f25.tar.bz2
fork-godot-webrtc-native-df643250f5e35d5ecbbd6dafab940a4e7e4d2f25.zip
Merge pull request #98 from Faless/build/cmake_platform
[SCons] Move platform configuration to cmake tool.
-rw-r--r--SConstruct9
-rw-r--r--tools/cmake.py59
-rw-r--r--tools/rtc.py45
3 files changed, 68 insertions, 45 deletions
diff --git a/SConstruct b/SConstruct
index 553b2fb..1d540c8 100644
--- a/SConstruct
+++ b/SConstruct
@@ -21,6 +21,14 @@ opts = Variables(["customs.py"], ARGUMENTS)
opts.Add(EnumVariable("godot_version", "The Godot target version", "4", ["3", "4"]))
opts.Update(env)
+# Minimum target platform versions.
+if "ios_min_version" not in ARGUMENTS:
+ ARGUMENTS["ios_min_version"] = "11.0"
+if "macos_deployment_target" not in ARGUMENTS:
+ ARGUMENTS["macos_deployment_target"] = "11.0"
+if "android_api_level" not in ARGUMENTS:
+ ARGUMENTS["android_api_level"] = "28"
+
if env["godot_version"] == "3":
if "platform" in ARGUMENTS and ARGUMENTS["platform"] == "macos":
ARGUMENTS["platform"] = "osx" # compatibility with old osx name
@@ -81,7 +89,6 @@ if env["godot_version"] == "3":
elif env["bits"] == "32":
env["CC"] = "i686-w64-mingw32-gcc"
else:
- ARGUMENTS["ios_min_version"] = "11.0"
env = SConscript("godot-cpp/SConstruct").Clone()
# Should probably go to upstream godot-cpp.
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):