summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--SConstruct8
-rw-r--r--misc/webrtc.gdextension4
-rw-r--r--tools/cmake.py34
-rw-r--r--tools/openssl.py62
-rw-r--r--tools/rtc.py15
5 files changed, 83 insertions, 40 deletions
diff --git a/SConstruct b/SConstruct
index fffebea..58b501b 100644
--- a/SConstruct
+++ b/SConstruct
@@ -145,9 +145,13 @@ for tool in ["openssl", "cmake", "rtc"]:
ssl = env.OpenSSL()
-rtc = env.BuildLibDataChannel()
+rtc = env.BuildLibDataChannel(ssl)
-env.Depends(sources, [ssl, rtc])
+# Forces building our sources after OpenSSL and libdatachannel.
+# This is because OpenSSL headers are generated by their build system and SCons doesn't know about them.
+# Note: This might not be necessary in this specific case since our sources doesn't include OpenSSL headers directly,
+# but it's better to be safe in case of indirect inclusions by one of our other dependencies.
+env.Depends(sources, ssl + rtc)
# Make the shared library
result_name = "libwebrtc_native{}{}".format(env["suffix"], env["SHLIBSUFFIX"])
diff --git a/misc/webrtc.gdextension b/misc/webrtc.gdextension
index a717d0d..9fe979a 100644
--- a/misc/webrtc.gdextension
+++ b/misc/webrtc.gdextension
@@ -6,6 +6,8 @@ entry_symbol = "webrtc_extension_init"
linux.debug.x86_64 = "res://webrtc/lib/libwebrtc_native.linux.template_debug.x86_64.so"
linux.debug.x86_32 = "res://webrtc/lib/libwebrtc_native.linux.template_debug.x86_32.so"
+linux.debug.arm64 = "res://webrtc/lib/libwebrtc_native.linux.template_debug.arm64.so"
+linux.debug.arm32 = "res://webrtc/lib/libwebrtc_native.linux.template_debug.arm32.so"
macos.debug = "res://webrtc/lib/libwebrtc_native.macos.template_debug.universal.dylib"
windows.debug.x86_64 = "res://webrtc/lib/libwebrtc_native.windows.template_debug.x86_64.dll"
windows.debug.x86_32 = "res://webrtc/lib/libwebrtc_native.windows.template_debug.x86_32.dll"
@@ -16,6 +18,8 @@ ios.debug.x86_64 = "res://webrtc/lib/libwebrtc_native.ios.template_debug.x86_64.
linux.release.x86_64 = "res://webrtc/lib/libwebrtc_native.linux.template_release.x86_64.so"
linux.release.x86_32 = "res://webrtc/lib/libwebrtc_native.linux.template_release.x86_32.so"
+linux.release.arm64 = "res://webrtc/lib/libwebrtc_native.linux.template_release.arm64.so"
+linux.release.arm32 = "res://webrtc/lib/libwebrtc_native.linux.template_release.arm32.so"
macos.release = "res://webrtc/lib/libwebrtc_native.macos.template_release.universal.dylib"
windows.release.x86_64 = "res://webrtc/lib/libwebrtc_native.windows.template_release.x86_64.dll"
windows.release.x86_32 = "res://webrtc/lib/libwebrtc_native.windows.template_release.x86_32.dll"
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"