summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2023-06-20 19:38:27 +0200
committerFabio Alessandrelli <fabio.alessandrelli@gmail.com>2023-06-21 03:54:39 +0200
commit85efdfd6ce365a0ac8502777b8c142be463cfe29 (patch)
treeb929a16bde002200f430ec4df0d44defd90f0481 /tools
parent32ae1d11958dcf04d0bd9c5c5ca98e21221a57d7 (diff)
downloadfork-godot-webrtc-native-85efdfd6ce365a0ac8502777b8c142be463cfe29.tar.gz
fork-godot-webrtc-native-85efdfd6ce365a0ac8502777b8c142be463cfe29.tar.bz2
fork-godot-webrtc-native-85efdfd6ce365a0ac8502777b8c142be463cfe29.zip
Linux ARM32/ARM64, better toolchains support.
Needs updated godot-cpp to build library with custom toolchains. Make the OpenSSL and CMake tools more customizable letting the user override the default platform flags via build options. Improve dependency handling.
Diffstat (limited to 'tools')
-rw-r--r--tools/cmake.py34
-rw-r--r--tools/openssl.py62
-rw-r--r--tools/rtc.py15
3 files changed, 73 insertions, 38 deletions
diff --git a/tools/cmake.py b/tools/cmake.py
index 4141ee0..c590860 100644
--- a/tools/cmake.py
+++ b/tools/cmake.py
@@ -5,10 +5,11 @@ import SCons.Builder
import SCons.Action
-def cmake_platform_config(env):
- config = {
- "CMAKE_BUILD_TYPE": env["CMAKEBUILDTYPE"],
- }
+def cmake_default_flags(env):
+ if env.get("cmake_default_flags", ""):
+ return SCons.Util.CLVar(env["cmake_default_flags"])
+
+ config = {}
if "CC" in env:
config["CMAKE_C_COMPILER"] = env["CC"]
@@ -33,13 +34,17 @@ def cmake_platform_config(env):
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
+ linux_flags = {
+ "x86_64": "-m64",
+ "x86_32": "-m32",
+ }.get(env["arch"], "")
+ if linux_flags:
+ config["CMAKE_C_FLAGS"] = linux_flags
+ config["CMAKE_CXX_FLAGS"] = linux_flags
elif env["platform"] == "macos":
if env["arch"] == "universal":
- config["CMAKE_OSX_ARCHITECTURES"] = "x86_64;arm64"
+ config["CMAKE_OSX_ARCHITECTURES"] = '"x86_64;arm64"'
else:
config["CMAKE_OSX_ARCHITECTURES"] = env["arch"]
if env["macos_deployment_target"] != "default":
@@ -70,7 +75,7 @@ def cmake_platform_config(env):
elif env["platform"] == "windows":
config["CMAKE_SYSTEM_NAME"] = "Windows"
- flags = ["'-D%s=%s'" % it for it in config.items()]
+ flags = ["-D%s=%s" % it for it in config.items()]
if env["CMAKEGENERATOR"]:
flags.extend(["-G", env["CMAKEGENERATOR"]])
elif env["platform"] == "windows":
@@ -96,18 +101,21 @@ def cmake_generator(target, source, env, for_signature):
]
+def options(opts):
+ opts.Add("cmake_default_flags", "Default CMake platform flags override, will be autodetected if not specified.", "")
+
+
def exists(env):
return True
def generate(env):
env["CMAKE"] = "cmake"
- env["_cmake_platform_config"] = cmake_platform_config
- env["CMAKEPLATFORMCONFIG"] = "${_cmake_platform_config(__env__)}"
- env["CMAKEBUILDTYPE"] = "Release"
+ env["_cmake_default_flags"] = cmake_default_flags
+ env["CMAKEDEFAULTFLAGS"] = "${_cmake_default_flags(__env__)}"
env["CMAKEGENERATOR"] = ""
env["CMAKECONFFLAGS"] = SCons.Util.CLVar("")
- env["CMAKECONFCOM"] = "$CMAKE -B ${TARGET.dir} $CMAKEPLATFORMCONFIG $CMAKECONFFLAGS ${SOURCE.dir}"
+ env["CMAKECONFCOM"] = "$CMAKE -B ${TARGET.dir} $CMAKEDEFAULTFLAGS $CMAKECONFFLAGS ${SOURCE.dir}"
env["CMAKEBUILDJOBS"] = "${__env__.GetOption('num_jobs')}"
env["CMAKEBUILDFLAGS"] = SCons.Util.CLVar("")
env["CMAKEBUILDCOM"] = "$CMAKE --build ${TARGET.dir} $CMAKEBUILDFLAGS -j$CMAKEBUILDJOBS"
diff --git a/tools/openssl.py b/tools/openssl.py
index 8af782a..c7d88a6 100644
--- a/tools/openssl.py
+++ b/tools/openssl.py
@@ -13,6 +13,9 @@ def ssl_platform_target(env):
targets = {
"x86_32": "linux-x86",
"x86_64": "linux-x86_64",
+ "arm64": "linux-aarch64",
+ "arm32": "linux-armv4",
+ "rv64": "linux64-riscv64",
}
elif platform == "android":
targets = {
@@ -56,7 +59,7 @@ def ssl_platform_target(env):
return target
-def ssl_default_options(env):
+def ssl_platform_options(env):
ssl_config_options = [
"no-ssl2",
"no-ssl3",
@@ -70,13 +73,12 @@ def ssl_default_options(env):
return ssl_config_options
-def ssl_platform_config(env):
- opts = ssl_default_options(env)
- target = ssl_platform_target(env)
+def ssl_platform_flags(env):
args = []
- if env["platform"] == "android" and env.get("android_api_level", ""):
- api = int(env["android_api_level"])
- args.append("-D__ANDROID_API__=%s" % api)
+ if env["platform"] == "android":
+ if env.get("android_api_level", ""):
+ api = int(env["android_api_level"])
+ args.append("-D__ANDROID_API__=%s" % api)
elif env["platform"] == "macos":
# OSXCross toolchain setup.
if sys.platform != "darwin" and "OSXCROSS_ROOT" in os.environ:
@@ -90,7 +92,26 @@ def ssl_platform_config(env):
"x86_64": "--cross-compile-prefix=x86_64-w64-mingw32-",
}
args.append(mingw_prefixes[env["arch"]])
- return opts + [target] + args
+ return args
+
+
+def ssl_configure_args(env):
+ if env.get("openssl_configure_options", ""):
+ opts = SCons.Util.CLVar(env["openssl_configure_options"])
+ else:
+ opts = ssl_platform_options(env)
+
+ if env.get("openssl_configure_target", ""):
+ target = [env["openssl_configure_target"]]
+ else:
+ target = [ssl_platform_target(env)]
+
+ if env.get("openssl_configure_flags", ""):
+ flags = SCons.Util.CLVar(env["openssl_configure_flags"])
+ else:
+ flags = ssl_platform_flags(env)
+
+ return opts + target + flags
def ssl_emitter(target, source, env):
@@ -158,7 +179,19 @@ def ssl_generator(target, source, env, for_signature):
def options(opts):
opts.Add(PathVariable("openssl_source", "Path to the openssl sources.", "thirdparty/openssl"))
opts.Add("openssl_build", "Destination path of the openssl build.", "bin/thirdparty/openssl")
- opts.Add(BoolVariable("openssl_debug", "Make a debug build of OpenSSL.", False))
+ opts.Add(
+ "openssl_configure_options",
+ "OpenSSL configure options override. Will use a reasonable default if not specified.",
+ "",
+ )
+ opts.Add(
+ "openssl_configure_target", "OpenSSL configure target override, will be autodetected if not specified.", ""
+ )
+ opts.Add(
+ "openssl_configure_flags",
+ "OpenSSL configure compiler flags override. Will be autodetected if not specified.",
+ "",
+ )
def exists(env):
@@ -175,10 +208,7 @@ def generate(env):
env["ENV"]["ANDROID_NDK_ROOT"] = env.get("ANDROID_NDK_ROOT", os.environ.get("ANDROID_NDK_ROOT", ""))
env["SSL_SOURCE"] = env.Dir(env["openssl_source"]).abspath
- env["SSL_BUILD"] = env.Dir(
- env["openssl_build"]
- + "/{}/{}/{}".format(env["platform"], env["arch"], "debug" if env["openssl_debug"] else "release")
- ).abspath
+ env["SSL_BUILD"] = env.Dir(env["openssl_build"] + "/{}/{}".format(env["platform"], env["arch"])).abspath
env["SSL_INSTALL"] = env.Dir(env["SSL_BUILD"] + "/dest").abspath
env["SSL_INCLUDE"] = env.Dir(env["SSL_INSTALL"] + "/include").abspath
lib_ext = ".lib" if env.get("is_msvc", False) else ".a"
@@ -188,11 +218,11 @@ def generate(env):
# Configure action
env["PERL"] = env.get("PERL", "perl")
- env["_ssl_platform_config"] = ssl_platform_config
- env["SSLPLATFORMCONFIG"] = "${_ssl_platform_config(__env__)}"
+ env["_ssl_configure_args"] = ssl_configure_args
+ env["SSLPLATFORMCONFIG"] = "${_ssl_configure_args(__env__)}"
env["SSLCONFFLAGS"] = SCons.Util.CLVar("")
# fmt: off
- env["SSLCONFIGCOM"] = "cd ${TARGET.dir} && $PERL -- ${SOURCE.abspath} --prefix=$SSL_INSTALL --openssldir=$SSL_INSTALL $SSLPLATFORMCONFIG $SSLCONFFLAGS"
+ env["SSLCONFIGCOM"] = 'cd ${TARGET.dir} && $PERL -- ${SOURCE.abspath} --prefix="${SSL_INSTALL}" --openssldir="${SSL_INSTALL}" $SSLPLATFORMCONFIG $SSLCONFFLAGS'
# fmt: on
# Build action
diff --git a/tools/rtc.py b/tools/rtc.py
index 61b6bcc..a487b08 100644
--- a/tools/rtc.py
+++ b/tools/rtc.py
@@ -3,6 +3,7 @@ import os
def rtc_cmake_config(env):
config = {
+ "CMAKE_BUILD_TYPE": "RelWithDebInfo" if env["debug_symbols"] else "Release",
"USE_NICE": 0,
"NO_WEBSOCKET": 1,
"NO_EXAMPLES": 1,
@@ -17,7 +18,7 @@ def rtc_cmake_config(env):
return config
-def build_library(env):
+def build_library(env, ssl):
if env["platform"] == "windows":
env.PrependUnique(LIBS=["iphlpapi", "bcrypt"])
@@ -25,11 +26,10 @@ def build_library(env):
rtc_env = env.Clone()
rtc_targets = [env.Dir(env["RTC_BUILD"])] + env["RTC_LIBS"]
- rtc_sources = [env.Dir(env["RTC_SOURCE"])]
- rtc_env.Append(CMAKECONFFLAGS=["'-D%s=%s'" % it for it in rtc_cmake_config(env).items()])
+ rtc_sources = [env.Dir(env["RTC_SOURCE"])] + ssl
+ rtc_env.Append(CMAKECONFFLAGS=["-D%s=%s" % it for it in rtc_cmake_config(env).items()])
rtc_env.Append(CMAKEBUILDFLAGS=["-t", "datachannel-static"])
- rtc = rtc_env.CMake(rtc_targets, rtc_sources, CMAKEBUILDTYPE=env["RTC_BUILD_TYPE"])
- rtc_env.Depends(rtc, rtc_env["SSL_LIBS"])
+ rtc = rtc_env.CMake(rtc_targets, rtc_sources)
return rtc
@@ -39,10 +39,7 @@ def exists(env):
def generate(env):
env["RTC_SOURCE"] = env.Dir("#thirdparty/libdatachannel").abspath
- env["RTC_BUILD_TYPE"] = "RelWithDebInfo" if env["debug_symbols"] else "Release"
- env["RTC_BUILD"] = env.Dir(
- "#bin/thirdparty/libdatachannel/{}/{}/{}".format(env["platform"], env["arch"], env["RTC_BUILD_TYPE"])
- ).abspath
+ env["RTC_BUILD"] = env.Dir("#bin/thirdparty/libdatachannel/{}/{}".format(env["platform"], env["arch"])).abspath
env["RTC_INCLUDE"] = env["RTC_SOURCE"] + "/include"
lib_ext = ".a"
lib_prefix = "lib"