mirror of
https://github.com/godotengine/webrtc-native.git
synced 2026-01-03 14:09:58 +03:00
Compare commits
35 Commits
1.0.0-alph
...
1.0.0-beta
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
84e9d6dd37 | ||
|
|
a49a2b03e1 | ||
|
|
656d3a9964 | ||
|
|
2bc2a5d162 | ||
|
|
7176344056 | ||
|
|
7d260b1b32 | ||
|
|
0c10a7f3e3 | ||
|
|
40962dbe19 | ||
|
|
bdd9d50745 | ||
|
|
5348407de9 | ||
|
|
5002991511 | ||
|
|
0fc992e0d5 | ||
|
|
fbadff454c | ||
|
|
61a6d25c47 | ||
|
|
dfaad6f5ba | ||
|
|
35bdd5efa7 | ||
|
|
90aaa0b82e | ||
|
|
16f311844b | ||
|
|
dfb34df36e | ||
|
|
9715e73ae4 | ||
|
|
2e9a25bb39 | ||
|
|
6067addd96 | ||
|
|
a3fbd33464 | ||
|
|
d697901f81 | ||
|
|
3eb7d0aa3b | ||
|
|
ecec40f59e | ||
|
|
37a289addf | ||
|
|
1436024f59 | ||
|
|
690b31e7dd | ||
|
|
9b0a5d8b46 | ||
|
|
1769730ef0 | ||
|
|
04898f2714 | ||
|
|
d7fc6cde3b | ||
|
|
1009e8bb1c | ||
|
|
5fd359f674 |
87
.github/workflows/build_release.yml
vendored
87
.github/workflows/build_release.yml
vendored
@@ -1,13 +1,17 @@
|
||||
name: 🔧 Build -> Package 📦
|
||||
on: [push, pull_request]
|
||||
|
||||
env:
|
||||
# Only used for the cache key. Increment version to force clean build.
|
||||
GODOT_BASE_BRANCH: master
|
||||
|
||||
jobs:
|
||||
static-checks:
|
||||
name: 📊 Static Checks (clang-format, black format, file format)
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
@@ -42,24 +46,27 @@ jobs:
|
||||
gdnative_flags: 'android_arch=x86_64'
|
||||
sconsflags: ''
|
||||
os: 'ubuntu-20.04'
|
||||
cache-name: android-x86_64
|
||||
- platform: android
|
||||
arch: 'arm64'
|
||||
gdnative_flags: 'android_arch=arm64v8'
|
||||
sconsflags: ''
|
||||
os: 'ubuntu-20.04'
|
||||
cache-name: android-arm64
|
||||
|
||||
# iOS
|
||||
- platform: ios
|
||||
arch: 'x86_64'
|
||||
gdnative_flags: 'ios_arch=x86_64'
|
||||
sconsflags: 'ios_simulator=true'
|
||||
os: 'macos-latest'
|
||||
os: 'macos-11'
|
||||
cache-name: ios-x86_64-simulator
|
||||
- platform: ios
|
||||
arch: 'arm64'
|
||||
gdnative_flags: 'ios_arch=arm64'
|
||||
sconsflags: ''
|
||||
os: 'macos-11'
|
||||
|
||||
cache-name: ios-arm64
|
||||
|
||||
# Linux
|
||||
- platform: linux
|
||||
@@ -67,11 +74,13 @@ jobs:
|
||||
gdnative_flags: 'bits=32'
|
||||
sconsflags: ''
|
||||
os: 'ubuntu-20.04'
|
||||
cache-name: linux-x86_32
|
||||
- platform: linux
|
||||
arch: 'x86_64'
|
||||
gdnative_flags: 'bits=64'
|
||||
sconsflags: ''
|
||||
os: 'ubuntu-20.04'
|
||||
cache-name: linux-x86_64
|
||||
|
||||
# macOS
|
||||
- platform: macos
|
||||
@@ -79,11 +88,13 @@ jobs:
|
||||
gdnative_flags: 'macos_arch=x86_64 bits=64'
|
||||
sconsflags: ''
|
||||
os: 'macos-11'
|
||||
cache-name: macos-x86_64
|
||||
- platform: macos
|
||||
gdnative_flags: 'macos_arch=arm64 bits=64'
|
||||
arch: 'arm64'
|
||||
sconsflags: ''
|
||||
os: 'macos-11'
|
||||
cache-name: macos-arm64
|
||||
|
||||
# Windows
|
||||
- platform: windows
|
||||
@@ -92,14 +103,17 @@ jobs:
|
||||
sconsflags: 'use_mingw=yes'
|
||||
os: 'ubuntu-20.04'
|
||||
msvc_arch: amd64_x86
|
||||
cache-name: win-x86_32
|
||||
- platform: windows
|
||||
arch: 'x86_64'
|
||||
gdnative_flags: 'bits=64'
|
||||
sconsflags: 'use_mingw=yes'
|
||||
os: 'ubuntu-20.04'
|
||||
msvc_arch: amd64
|
||||
cache-name: win-x86_64
|
||||
|
||||
env:
|
||||
SCONS_CACHE: ${{ github.workspace }}/.scons-cache/
|
||||
SCONSFLAGS: ${{ matrix.sconsflags }} platform=${{ matrix.platform }} arch=${{ matrix.arch }} --jobs=2
|
||||
|
||||
defaults:
|
||||
@@ -107,10 +121,16 @@ jobs:
|
||||
shell: bash
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Setup Godot build cache
|
||||
uses: ./godot-cpp/.github/actions/godot-cache
|
||||
with:
|
||||
cache-name: ${{ matrix.cache-name }}
|
||||
continue-on-error: true
|
||||
|
||||
- name: Install Windows build dependencies
|
||||
if: ${{ matrix.platform == 'windows' }}
|
||||
run: |
|
||||
@@ -129,7 +149,7 @@ jobs:
|
||||
sudo apt-get install build-essential gcc-multilib g++-multilib
|
||||
|
||||
- name: Set up Python 3.x
|
||||
uses: actions/setup-python@v2
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.x'
|
||||
architecture: 'x64'
|
||||
@@ -142,33 +162,31 @@ jobs:
|
||||
scons --version
|
||||
cmake --version
|
||||
|
||||
- name: Compile Extension - debug - ${{ matrix.platform }} - ${{ matrix.arch }}
|
||||
- name: Compile Extension - template_debug - ${{ matrix.platform }} - ${{ matrix.arch }}
|
||||
run: |
|
||||
scons target=debug generate_bindings=yes
|
||||
scons target=template_debug
|
||||
|
||||
- name: Compile GDNative - debug - ${{ matrix.platform }} - ${{ matrix.arch }}
|
||||
- name: Compile Extension - template_release - ${{ matrix.platform }} - ${{ matrix.arch }}
|
||||
run: |
|
||||
scons target=debug generate_bindings=yes ${{ matrix.gdnative_flags }} godot_version=3
|
||||
|
||||
- name: Compile Extension - release - ${{ matrix.platform }} - ${{ matrix.arch }}
|
||||
run: |
|
||||
scons target=release
|
||||
scons target=template_release
|
||||
|
||||
- name: Compile GDNative - release ${{ matrix.platform }} - ${{ matrix.arch }}
|
||||
run: |
|
||||
scons target=release ${{ matrix.gdnative_flags }} godot_version=3
|
||||
scons target=release generate_bindings=yes ${{ matrix.gdnative_flags }} godot_version=3
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ github.job }}-${{ matrix.platform }}-${{ matrix.arch }}
|
||||
path: bin/*
|
||||
path: |
|
||||
bin/
|
||||
!bin/thirdparty/
|
||||
|
||||
package:
|
||||
name: 📦 Package
|
||||
needs: build
|
||||
runs-on: "ubuntu-latest"
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
@@ -179,37 +197,24 @@ jobs:
|
||||
- name: Bundle licenses.
|
||||
run: |
|
||||
cp LICENSE artifacts/LICENSE.webrtc-native
|
||||
cp deps/libdatachannel/LICENSE artifacts/LICENSE.libdatachannel
|
||||
cp deps/openssl/LICENSE.txt artifacts/LICENSE.openssl
|
||||
cp deps/libdatachannel/deps/libjuice/LICENSE artifacts/LICENSE.libjuice
|
||||
cp deps/libdatachannel/deps/usrsctp/LICENSE.md artifacts/LICENSE.usrsctp
|
||||
cp deps/libdatachannel/deps/libsrtp/LICENSE artifacts/LICENSE.libsrtp
|
||||
cp deps/libdatachannel/deps/json/LICENSE.MIT artifacts/LICENSE.json
|
||||
cp deps/libdatachannel/deps/plog/LICENSE artifacts/LICENSE.plog
|
||||
cp thirdparty/libdatachannel/LICENSE artifacts/LICENSE.libdatachannel
|
||||
cp thirdparty/openssl/LICENSE.txt artifacts/LICENSE.openssl
|
||||
cp thirdparty/libdatachannel/deps/libjuice/LICENSE artifacts/LICENSE.libjuice
|
||||
cp thirdparty/libdatachannel/deps/usrsctp/LICENSE.md artifacts/LICENSE.usrsctp
|
||||
cp thirdparty/libdatachannel/deps/libsrtp/LICENSE artifacts/LICENSE.libsrtp
|
||||
cp thirdparty/libdatachannel/deps/json/LICENSE.MIT artifacts/LICENSE.json
|
||||
cp thirdparty/libdatachannel/deps/plog/LICENSE artifacts/LICENSE.plog
|
||||
|
||||
- name: Package artifacts for release
|
||||
env:
|
||||
DESTINATION: "release"
|
||||
run: |
|
||||
mkdir release
|
||||
cd release
|
||||
|
||||
ls -R
|
||||
VERSION="extension" TYPE="webrtc" ./misc/scripts/package_release.sh
|
||||
VERSION="gdnative" TYPE="webrtc" ./misc/scripts/package_release.sh
|
||||
|
||||
for version in extension gdnative
|
||||
do
|
||||
for name in webrtc webrtc_debug
|
||||
do
|
||||
destdir="${version}/${name}"
|
||||
mkdir -p ${destdir}/lib
|
||||
find ../artifacts -wholename "*/${destdir}/lib/*" | xargs cp -t ${destdir}/lib/
|
||||
find ../artifacts -wholename "*/${destdir}/${name}.tres" -or -wholename "*/${destdir}/${name}.gdextension" | head -n 1 | xargs cp -t ${destdir}/
|
||||
find ../artifacts -wholename "*/LICENSE*" | xargs cp -t ${destdir}/
|
||||
cd ${version}
|
||||
zip -r ../godot-${version}-${name}.zip ${name}
|
||||
cd ..
|
||||
done
|
||||
done
|
||||
|
||||
ls -R
|
||||
ls -R release
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -5,3 +5,5 @@ bin/*
|
||||
.sconsign.dblite
|
||||
*.obj
|
||||
*.swp
|
||||
__pycache__/*
|
||||
*.pyc
|
||||
|
||||
4
.gitmodules
vendored
4
.gitmodules
vendored
@@ -5,8 +5,8 @@
|
||||
path = godot-cpp
|
||||
url = https://github.com/godotengine/godot-cpp.git
|
||||
[submodule "libdatachannel"]
|
||||
path = deps/libdatachannel
|
||||
path = thirdparty/libdatachannel
|
||||
url = https://github.com/paullouisageneau/libdatachannel.git
|
||||
[submodule "openssl"]
|
||||
path = deps/openssl
|
||||
path = thirdparty/openssl
|
||||
url = https://github.com/openssl/openssl.git
|
||||
|
||||
@@ -45,6 +45,4 @@ You simply need to copy that folder to the root folder of your project. Note tha
|
||||
|
||||
### License
|
||||
|
||||
The `webrtc-native` plugin is licensed under the MIT license (see [LICENSE](https://github.com/godotengine/webrtc-native/blob/master/LICENSE)), while `libdatachannel` and one of its dependencies (`libjuice`) are licensed under LGPLv2.1 or later, see [libdatachannel LICENSE](https://github.com/paullouisageneau/libdatachannel/blob/master/LICENSE) and [libjuice LICENSE](https://github.com/paullouisageneau/libjuice/blob/master/LICENSE).
|
||||
|
||||
Make sure you understand and comply with the LGPLv2.1 license when redistributing this plugin.
|
||||
The `webrtc-native` plugin is licensed under the MIT license (see [LICENSE](https://github.com/godotengine/webrtc-native/blob/master/LICENSE)), while `libdatachannel` and its dependencies are licensed under other permissive open source licences. Please see [`thirdparty/README.md`](thirdparty/README.md) for more informations.
|
||||
|
||||
70
SConstruct
70
SConstruct
@@ -2,8 +2,6 @@
|
||||
|
||||
import os, sys, platform, json, subprocess
|
||||
|
||||
import builders
|
||||
|
||||
|
||||
def add_sources(sources, dirpath, extension):
|
||||
for f in os.listdir(dirpath):
|
||||
@@ -52,7 +50,7 @@ if env["godot_version"] == "3":
|
||||
if env["platform"] in ["windows", "linux"]:
|
||||
env["arch"] = "x86_32" if env["bits"] == "32" else "x86_64"
|
||||
env["arch_suffix"] = env["arch"]
|
||||
elif env["platform"] == "osx":
|
||||
elif env["platform"] == "macos":
|
||||
env["arch"] = env["macos_arch"]
|
||||
env["arch_suffix"] = env["arch"]
|
||||
elif env["platform"] == "ios":
|
||||
@@ -66,10 +64,23 @@ if env["godot_version"] == "3":
|
||||
"x86_64": "x86_64",
|
||||
}[env["android_arch"]]
|
||||
env["arch_suffix"] = env["arch"]
|
||||
|
||||
target_compat = "template_" + env["target"]
|
||||
env["suffix"] = ".{}.{}.{}".format(env["platform"], target_compat, env["arch_suffix"])
|
||||
env["debug_symbols"] = False
|
||||
else:
|
||||
ARGUMENTS["ios_min_version"] = "11.0"
|
||||
env = SConscript("godot-cpp/SConstruct").Clone()
|
||||
|
||||
# Should probably go to upstream godot-cpp.
|
||||
# We let SCons build its default ENV as it includes OS-specific things which we don't
|
||||
# want to have to pull in manually.
|
||||
# Then we prepend PATH to make it take precedence, while preserving SCons' own entries.
|
||||
env.PrependENVPath("PATH", os.getenv("PATH"))
|
||||
env.PrependENVPath("PKG_CONFIG_PATH", os.getenv("PKG_CONFIG_PATH"))
|
||||
if "TERM" in os.environ: # Used for colored output.
|
||||
env["ENV"]["TERM"] = os.environ["TERM"]
|
||||
|
||||
# Patch mingw SHLIBSUFFIX.
|
||||
if env["platform"] == "windows" and env["use_mingw"]:
|
||||
env["SHLIBSUFFIX"] = ".dll"
|
||||
@@ -77,31 +88,22 @@ if env["platform"] == "windows" and env["use_mingw"]:
|
||||
opts.Update(env)
|
||||
|
||||
target = env["target"]
|
||||
result_path = os.path.join("bin", "gdnative" if env["godot_version"] == "3" else "extension", "webrtc" if env["target"] == "release" else "webrtc_debug")
|
||||
if env["godot_version"] == "3":
|
||||
result_path = os.path.join("bin", "gdnative", "webrtc" if env["target"] == "release" else "webrtc_debug")
|
||||
else:
|
||||
result_path = os.path.join("bin", "extension", "webrtc")
|
||||
|
||||
# Dependencies
|
||||
deps_source_dir = "deps"
|
||||
env.Append(BUILDERS={
|
||||
"BuildOpenSSL": env.Builder(action=builders.ssl_action, emitter=builders.ssl_emitter),
|
||||
"BuildLibDataChannel": env.Builder(action=builders.rtc_action, emitter=builders.rtc_emitter),
|
||||
})
|
||||
for tool in ["cmake", "common", "ssl", "rtc"]:
|
||||
env.Tool(tool, toolpath=["tools"])
|
||||
|
||||
# SSL
|
||||
ssl = env.BuildOpenSSL(env.Dir(builders.get_ssl_build_dir(env)), env.Dir(builders.get_ssl_source_dir(env)))
|
||||
|
||||
env.Prepend(CPPPATH=[builders.get_ssl_include_dir(env)])
|
||||
env.Prepend(LIBPATH=[builders.get_ssl_build_dir(env)])
|
||||
env.Append(LIBS=[ssl])
|
||||
|
||||
# RTC
|
||||
rtc = env.BuildLibDataChannel(env.Dir(builders.get_rtc_build_dir(env)), [env.Dir(builders.get_rtc_source_dir(env))] + ssl)
|
||||
|
||||
env.Append(LIBPATH=[builders.get_rtc_build_dir(env)])
|
||||
env.Append(CPPPATH=[builders.get_rtc_include_dir(env)])
|
||||
env.Prepend(LIBS=[rtc])
|
||||
ssl = env.BuildOpenSSL()
|
||||
env.NoCache(ssl) # Needs refactoring to properly cache generated headers.
|
||||
rtc = env.BuildLibDataChannel()
|
||||
|
||||
# Our includes and sources
|
||||
env.Append(CPPPATH=["src/"])
|
||||
env.Append(CPPDEFINES=["RTC_STATIC"])
|
||||
sources = []
|
||||
sources.append(
|
||||
[
|
||||
@@ -119,22 +121,18 @@ else:
|
||||
env.Depends(sources, [ssl, rtc])
|
||||
|
||||
# Make the shared library
|
||||
result_name = "webrtc_native.{}.{}.{}{}".format(env["platform"], env["target"], env["arch_suffix"], env["SHLIBSUFFIX"])
|
||||
env.Depends(sources, ssl)
|
||||
|
||||
if env["platform"] == "windows" and env["use_mingw"]:
|
||||
env.Append(LIBS=["iphlpapi", "ws2_32", "bcrypt"])
|
||||
|
||||
result_name = "webrtc_native{}{}".format(env["suffix"], env["SHLIBSUFFIX"])
|
||||
library = env.SharedLibrary(target=os.path.join(result_path, "lib", result_name), source=sources)
|
||||
Default(library)
|
||||
|
||||
# GDNativeLibrary
|
||||
gdnlib = "webrtc"
|
||||
if target != "release":
|
||||
gdnlib += "_debug"
|
||||
ext = ".tres" if env["godot_version"] == "3" else ".gdextension"
|
||||
extfile = env.Substfile(os.path.join(result_path, gdnlib + ext), "misc/webrtc" + ext, SUBST_DICT={
|
||||
"{GDNATIVE_PATH}": gdnlib,
|
||||
"{TARGET}": env["target"],
|
||||
})
|
||||
if env["godot_version"] == "3":
|
||||
gdnlib = "webrtc" if target != "debug" else "webrtc_debug"
|
||||
ext = ".tres"
|
||||
extfile = env.Substfile(os.path.join(result_path, gdnlib + ext), "misc/webrtc" + ext, SUBST_DICT={
|
||||
"{GDNATIVE_PATH}": gdnlib,
|
||||
"{TARGET}": "template_" + env["target"],
|
||||
})
|
||||
else:
|
||||
extfile = env.InstallAs(os.path.join(result_path, "webrtc.gdextension"), "misc/webrtc.gdextension")
|
||||
Default(extfile)
|
||||
|
||||
240
builders.py
240
builders.py
@@ -1,240 +0,0 @@
|
||||
import os
|
||||
from SCons.Script import Environment
|
||||
|
||||
|
||||
def get_android_api(env):
|
||||
return env["android_api_level"] if int(env["android_api_level"]) > 28 else "28"
|
||||
|
||||
|
||||
def get_deps_dir(env):
|
||||
return env.Dir("#deps").abspath
|
||||
|
||||
|
||||
def get_deps_build_dir(env):
|
||||
return get_deps_dir(env) + "/build/{}.{}.{}.dir".format(env["platform"], env["target"], env["arch_suffix"])
|
||||
|
||||
|
||||
def get_rtc_source_dir(env):
|
||||
return get_deps_dir(env) + "/libdatachannel"
|
||||
|
||||
|
||||
def get_rtc_build_dir(env):
|
||||
return get_deps_build_dir(env) + "/libdatachannel"
|
||||
|
||||
|
||||
def get_rtc_include_dir(env):
|
||||
return get_rtc_source_dir(env) + "/include"
|
||||
|
||||
|
||||
def get_ssl_source_dir(env):
|
||||
return get_deps_dir(env) + "/openssl"
|
||||
|
||||
|
||||
def get_ssl_build_dir(env):
|
||||
return get_deps_build_dir(env) + "/openssl"
|
||||
|
||||
|
||||
def get_ssl_install_dir(env):
|
||||
return get_ssl_build_dir(env) + "/dest"
|
||||
|
||||
|
||||
def get_ssl_include_dir(env):
|
||||
return get_ssl_install_dir(env) + "/include"
|
||||
|
||||
|
||||
def ssl_emitter(target, source, env):
|
||||
build_dir = get_ssl_build_dir(env)
|
||||
libs = ["libssl.a", "libcrypto.a"]
|
||||
install_dir = get_ssl_install_dir(env)
|
||||
ssl_include = os.path.join(source[0].abspath, "include")
|
||||
return [env.File(build_dir + "/" + l) for l in libs], source
|
||||
|
||||
|
||||
def ssl_action(target, source, env):
|
||||
build_dir = get_ssl_build_dir(env)
|
||||
source_dir = source[0].abspath
|
||||
|
||||
ssl_env = Environment()
|
||||
install_dir = get_ssl_install_dir(env)
|
||||
args = [
|
||||
"no-ssl3",
|
||||
"no-weak-ssl-ciphers",
|
||||
"no-legacy",
|
||||
"--prefix=%s" % install_dir,
|
||||
"--openssldir=%s" % install_dir,
|
||||
]
|
||||
if env["target"] == "debug":
|
||||
args.append("-d")
|
||||
|
||||
if env["platform"] != "windows":
|
||||
args.append("no-shared") # Windows "app" doesn't like static-only builds.
|
||||
if env["platform"] == "linux":
|
||||
if env["arch"] == "x86_32":
|
||||
args.extend(["linux-x86"])
|
||||
else:
|
||||
args.extend(["linux-x86_64"])
|
||||
|
||||
elif env["platform"] == "android":
|
||||
args.extend([
|
||||
{
|
||||
"arm64": "android-arm64",
|
||||
"arm32": "android-arm",
|
||||
"x86_32": "android-x86",
|
||||
"x86_64": "android-x86_64",
|
||||
}[env["arch"]],
|
||||
"-D__ANDROID_API__=%s" % get_android_api(env),
|
||||
])
|
||||
# Setup toolchain path.
|
||||
ssl_env.PrependENVPath("PATH", os.path.dirname(env["CC"]))
|
||||
ssl_env["ENV"]["ANDROID_NDK_ROOT"] = os.environ.get("ANDROID_NDK_ROOT", "")
|
||||
|
||||
elif env["platform"] == "macos":
|
||||
if env["arch"] == "x86_64":
|
||||
args.extend(["darwin64-x86_64"])
|
||||
elif env["arch"] == "arm64":
|
||||
args.extend(["darwin64-arm64"])
|
||||
else:
|
||||
raise ValueError("macOS architecture not supported: %s" % env["arch"])
|
||||
|
||||
elif env["platform"] == "ios":
|
||||
if env["ios_simulator"]:
|
||||
args.extend(["iossimulator-xcrun"])
|
||||
elif env["arch"] == "arm32":
|
||||
args.extend(["ios-xcrun"])
|
||||
elif env["arch"] == "arm64":
|
||||
args.extend(["ios64-xcrun"])
|
||||
else:
|
||||
raise ValueError("iOS architecture not supported: %s" % env["arch"])
|
||||
|
||||
elif env["platform"] == "windows":
|
||||
if env["arch"] == "x86_32":
|
||||
if env["use_mingw"]:
|
||||
args.extend([
|
||||
"mingw",
|
||||
"--cross-compile-prefix=i686-w64-mingw32-",
|
||||
])
|
||||
else:
|
||||
args.extend(["VC-WIN32"])
|
||||
else:
|
||||
if env["use_mingw"]:
|
||||
args.extend([
|
||||
"mingw64",
|
||||
"--cross-compile-prefix=x86_64-w64-mingw32-",
|
||||
])
|
||||
else:
|
||||
args.extend(["VC-WIN64A"])
|
||||
|
||||
jobs = env.GetOption("num_jobs")
|
||||
ssl_env.Execute([
|
||||
"mkdir -p " + build_dir, # TODO python?
|
||||
("cd %s && %s/Configure " % (build_dir, source_dir)) + " ".join(args),
|
||||
"make -C %s -j%s" % (build_dir, jobs),
|
||||
"make -C %s install_sw install_ssldirs -j%s" % (build_dir, jobs),
|
||||
]
|
||||
)
|
||||
return None
|
||||
|
||||
|
||||
def rtc_emitter(target, source, env):
|
||||
build_dir = get_rtc_build_dir(env)
|
||||
libs = ["libdatachannel-static.a", "libjuice-static.a", "libsrtp2.a", "libusrsctp.a"]
|
||||
lib_paths = [
|
||||
build_dir,
|
||||
os.path.join(build_dir, "deps/libjuice"),
|
||||
os.path.join(build_dir, "deps/libsrtp"),
|
||||
os.path.join(build_dir, "deps/usrsctp/usrsctplib"),
|
||||
]
|
||||
return [env.File(lib_paths[i] + "/" + libs[i]) for i in range(len(libs))], source
|
||||
|
||||
|
||||
def rtc_action(target, source, env):
|
||||
build_dir = get_rtc_build_dir(env)
|
||||
source_dir = source[0].abspath
|
||||
args = [
|
||||
"-B",
|
||||
build_dir,
|
||||
"-DUSE_NICE=0",
|
||||
"-DNO_WEBSOCKET=1",
|
||||
#"-DNO_MEDIA=1", # Windows builds fail without it.
|
||||
"-DNO_EXAMPLES=1",
|
||||
"-DNO_WEBSOCKET=1",
|
||||
"-DNO_TESTS=1",
|
||||
"-DOPENSSL_USE_STATIC_LIBS=1",
|
||||
"-DOPENSSL_INCLUDE_DIR=%s" % get_ssl_include_dir(env),
|
||||
"-DOPENSSL_SSL_LIBRARY=%s/libssl.a" % get_ssl_build_dir(env),
|
||||
"-DOPENSSL_CRYPTO_LIBRARY=%s/libcrypto.a" % get_ssl_build_dir(env),
|
||||
"-DCMAKE_BUILD_TYPE=%s" % ("Release" if env["target"] == "release" else "Debug"),
|
||||
]
|
||||
if env["platform"] == "android":
|
||||
abi = {
|
||||
"arm64": "arm64-v8a",
|
||||
"arm32": "armeabi-v7a",
|
||||
"x86_32": "x86",
|
||||
"x86_64": "x86_64",
|
||||
}[env["arch"]]
|
||||
args.extend([
|
||||
"-DCMAKE_SYSTEM_NAME=Android",
|
||||
"-DCMAKE_SYSTEM_VERSION=%s" % get_android_api(env),
|
||||
"-DCMAKE_ANDROID_ARCH_ABI=%s" % abi,
|
||||
"-DANDROID_ABI=%s" % abi,
|
||||
"-DCMAKE_TOOLCHAIN_FILE=%s/build/cmake/android.toolchain.cmake" % os.environ.get("ANDROID_NDK_ROOT", ""),
|
||||
"-DCMAKE_ANDROID_STL_TYPE=c++_static",
|
||||
])
|
||||
elif env["platform"] == "linux":
|
||||
if env["arch"] == "x86_32":
|
||||
args.extend([
|
||||
"-DCMAKE_C_FLAGS=-m32",
|
||||
"-DCMAKE_CXX_FLAGS=-m32"
|
||||
])
|
||||
else:
|
||||
args.extend([
|
||||
"-DCMAKE_C_FLAGS=-m64",
|
||||
"-DCMAKE_CXX_FLAGS=-m64"
|
||||
])
|
||||
elif env["platform"] == "macos":
|
||||
if env["macos_deployment_target"] != "default":
|
||||
args.extend(["-DCMAKE_OSX_DEPLOYMENT_TARGET=%s" % env["macos_deployment_target"]])
|
||||
if env["arch"] == "x86_64":
|
||||
args.extend(["-DCMAKE_OSX_ARCHITECTURES=x86_64"])
|
||||
elif env["arch"] == "arm64":
|
||||
args.extend(["-DCMAKE_OSX_ARCHITECTURES=arm64"])
|
||||
else:
|
||||
raise ValueError("OSX architecture not supported: %s" % env["arch"])
|
||||
elif env["platform"] == "ios":
|
||||
if env["arch"] == "universal":
|
||||
raise ValueError("iOS architecture not supported: %s" % env["arch"])
|
||||
args.extend([
|
||||
"-DCMAKE_SYSTEM_NAME=iOS",
|
||||
"-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0",
|
||||
"-DCMAKE_OSX_ARCHITECTURES=%s" % env["arch"],
|
||||
])
|
||||
if env["ios_simulator"]:
|
||||
args.extend(["-DCMAKE_OSX_SYSROOT=iphonesimulator"])
|
||||
elif env["platform"] == "windows":
|
||||
args.extend(["-DOPENSSL_ROOT_DIR=%s" % get_ssl_build_dir(env)])
|
||||
if env["arch"] == "x86_32":
|
||||
if env["use_mingw"]:
|
||||
args.extend([
|
||||
"-G 'Unix Makefiles'",
|
||||
"-DCMAKE_C_COMPILER=i686-w64-mingw32-gcc",
|
||||
"-DCMAKE_CXX_COMPILER=i686-w64-mingw32-g++",
|
||||
"-DCMAKE_SYSTEM_NAME=Windows",
|
||||
])
|
||||
else:
|
||||
if env["use_mingw"]:
|
||||
args.extend([
|
||||
"-G 'Unix Makefiles'",
|
||||
"-DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc",
|
||||
"-DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++",
|
||||
"-DCMAKE_SYSTEM_NAME=Windows"
|
||||
])
|
||||
|
||||
args.append(source_dir)
|
||||
jobs = env.GetOption("num_jobs")
|
||||
rtc_env = Environment()
|
||||
rtc_env.Execute([
|
||||
"cmake " + " ".join(args),
|
||||
"cmake --build %s -t datachannel-static -j%s" % (build_dir, jobs),
|
||||
]
|
||||
)
|
||||
return None
|
||||
1
deps/libdatachannel
vendored
1
deps/libdatachannel
vendored
Submodule deps/libdatachannel deleted from 93847128f1
1
deps/openssl
vendored
1
deps/openssl
vendored
Submodule deps/openssl deleted from ad4910fad2
Submodule godot-cpp updated: 0d7da02dc4...151ea35c5f
Submodule godot-cpp-3.x updated: ac572d5f84...7c09b5484d
32
misc/scripts/package_release.sh
Executable file
32
misc/scripts/package_release.sh
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
ARTIFACTS=${ARTIFACTS:-"artifacts"}
|
||||
DESTINATION=${DESTIONATION:-"release"}
|
||||
VERSION=${VERSION:-"extension"}
|
||||
TYPE=${TYPE:-"webrtc"}
|
||||
|
||||
mkdir -p ${DESTINATION}
|
||||
ls -R ${DESTINATION}
|
||||
|
||||
DESTDIR="${DESTINATION}/${VERSION}/${TYPE}"
|
||||
|
||||
mkdir -p ${DESTDIR}/lib
|
||||
|
||||
find "${ARTIFACTS}" -wholename "*/${VERSION}/${TYPE}/lib/*" | xargs cp -t "${DESTDIR}/lib/"
|
||||
find "${ARTIFACTS}" -wholename "*/LICENSE*" | xargs cp -t "${DESTDIR}/"
|
||||
|
||||
if [ $VERSION = "extension" ]; then
|
||||
find "${ARTIFACTS}" -wholename "*/${VERSION}/${TYPE}/${TYPE}.gdextension" | head -n 1 | xargs cp -t "${DESTDIR}/"
|
||||
else
|
||||
find "${ARTIFACTS}" -wholename "*/${VERSION}/${TYPE}/${TYPE}.tres" | head -n 1 | xargs cp -t "${DESTDIR}/"
|
||||
fi
|
||||
|
||||
CURDIR=$(pwd)
|
||||
cd "${DESTINATION}/${VERSION}"
|
||||
zip -r ../godot-${VERSION}-${TYPE}.zip ${TYPE}
|
||||
cd "$CURDIR"
|
||||
|
||||
ls -R ${DESTINATION}
|
||||
@@ -4,13 +4,24 @@ entry_symbol = "webrtc_extension_init"
|
||||
|
||||
[libraries]
|
||||
|
||||
linux.x86_64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.linux.{TARGET}.x86_64.so"
|
||||
linux.x86_32 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.linux.{TARGET}.x86_32.so"
|
||||
osx.x86_64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.osx.{TARGET}.x86_64.dylib"
|
||||
osx.arm64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.osx.{TARGET}.arm64.dylib"
|
||||
windows.x86_64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.windows.{TARGET}.x86_64.dll"
|
||||
windows.x86_32 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.windows.{TARGET}.x86_32.dll"
|
||||
android.arm64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.android.{TARGET}.arm64.so"
|
||||
android.x86_64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.android.{TARGET}.x86_64.so"
|
||||
ios.arm64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.ios.{TARGET}.arm64.dylib"
|
||||
ios.x86_64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.ios.{TARGET}.x86_64.simulator.dylib"
|
||||
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"
|
||||
macos.debug.x86_64 = "res://webrtc/lib/libwebrtc_native.macos.template_debug.x86_64.dylib"
|
||||
macos.debug.arm64 = "res://webrtc/lib/libwebrtc_native.macos.template_debug.arm64.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"
|
||||
android.debug.arm64 = "res://webrtc/lib/libwebrtc_native.android.template_debug.arm64.so"
|
||||
android.debug.x86_64 = "res://webrtc/lib/libwebrtc_native.android.template_debug.x86_64.so"
|
||||
ios.debug.arm64 = "res://webrtc/lib/libwebrtc_native.ios.template_debug.arm64.dylib"
|
||||
ios.debug.x86_64 = "res://webrtc/lib/libwebrtc_native.ios.template_debug.x86_64.simulator.dylib"
|
||||
|
||||
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"
|
||||
macos.release.x86_64 = "res://webrtc/lib/libwebrtc_native.macos.template_release.x86_64.dylib"
|
||||
macos.release.arm64 = "res://webrtc/lib/libwebrtc_native.macos.template_release.arm64.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"
|
||||
android.release.arm64 = "res://webrtc/lib/libwebrtc_native.android.template_release.arm64.so"
|
||||
android.release.x86_64 = "res://webrtc/lib/libwebrtc_native.android.template_release.x86_64.so"
|
||||
ios.release.arm64 = "res://webrtc/lib/libwebrtc_native.ios.template_release.arm64.dylib"
|
||||
ios.release.x86_64 = "res://webrtc/lib/libwebrtc_native.ios.template_release.x86_64.simulator.dylib"
|
||||
|
||||
@@ -40,6 +40,8 @@
|
||||
#define GDCLASS(arg1, arg2) GODOT_CLASS(arg1, arg2)
|
||||
#endif
|
||||
#else
|
||||
#include <godot_cpp/core/binder_common.hpp>
|
||||
|
||||
#include <godot_cpp/classes/global_constants_binds.hpp>
|
||||
#include <godot_cpp/classes/web_rtc_data_channel_extension.hpp>
|
||||
#endif
|
||||
|
||||
@@ -130,6 +130,42 @@ WebRTCPeerConnection::ConnectionState WebRTCLibPeerConnection::_get_connection_s
|
||||
}
|
||||
}
|
||||
|
||||
WebRTCLibPeerConnection::GatheringState WebRTCLibPeerConnection::_get_gathering_state() const {
|
||||
ERR_FAIL_COND_V(peer_connection == nullptr, GATHERING_STATE_NEW);
|
||||
|
||||
rtc::PeerConnection::GatheringState state = peer_connection->gatheringState();
|
||||
switch (state) {
|
||||
case rtc::PeerConnection::GatheringState::New:
|
||||
return GATHERING_STATE_NEW;
|
||||
case rtc::PeerConnection::GatheringState::InProgress:
|
||||
return GATHERING_STATE_GATHERING;
|
||||
case rtc::PeerConnection::GatheringState::Complete:
|
||||
return GATHERING_STATE_COMPLETE;
|
||||
default:
|
||||
return GATHERING_STATE_NEW;
|
||||
}
|
||||
}
|
||||
|
||||
WebRTCLibPeerConnection::SignalingState WebRTCLibPeerConnection::_get_signaling_state() const {
|
||||
ERR_FAIL_COND_V(peer_connection == nullptr, SIGNALING_STATE_CLOSED);
|
||||
|
||||
rtc::PeerConnection::SignalingState state = peer_connection->signalingState();
|
||||
switch (state) {
|
||||
case rtc::PeerConnection::SignalingState::Stable:
|
||||
return SIGNALING_STATE_STABLE;
|
||||
case rtc::PeerConnection::SignalingState::HaveLocalOffer:
|
||||
return SIGNALING_STATE_HAVE_LOCAL_OFFER;
|
||||
case rtc::PeerConnection::SignalingState::HaveRemoteOffer:
|
||||
return SIGNALING_STATE_HAVE_REMOTE_OFFER;
|
||||
case rtc::PeerConnection::SignalingState::HaveLocalPranswer:
|
||||
return SIGNALING_STATE_HAVE_LOCAL_PRANSWER;
|
||||
case rtc::PeerConnection::SignalingState::HaveRemotePranswer:
|
||||
return SIGNALING_STATE_HAVE_REMOTE_PRANSWER;
|
||||
default:
|
||||
return SIGNALING_STATE_CLOSED;
|
||||
}
|
||||
}
|
||||
|
||||
Error WebRTCLibPeerConnection::_initialize(const Dictionary &p_config) {
|
||||
rtc::Configuration config = {};
|
||||
if (p_config.has("iceServers") && p_config["iceServers"].get_type() == Variant::ARRAY) {
|
||||
|
||||
@@ -40,6 +40,8 @@
|
||||
#define GDCLASS(arg1, arg2) GODOT_CLASS(arg1, arg2)
|
||||
#endif
|
||||
#else
|
||||
#include <godot_cpp/core/binder_common.hpp>
|
||||
|
||||
#include <godot_cpp/classes/global_constants_binds.hpp>
|
||||
#include <godot_cpp/classes/web_rtc_peer_connection_extension.hpp>
|
||||
#endif
|
||||
@@ -73,6 +75,8 @@ public:
|
||||
void _init();
|
||||
|
||||
ConnectionState _get_connection_state() const override;
|
||||
GatheringState _get_gathering_state() const override;
|
||||
SignalingState _get_signaling_state() const override;
|
||||
|
||||
godot::Error _initialize(const godot::Dictionary &p_config) override;
|
||||
godot::Object *_create_data_channel(const godot::String &p_channel, const godot::Dictionary &p_channel_config) override;
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include <godot/gdnative_interface.h>
|
||||
#include <gdextension_interface.h>
|
||||
|
||||
#include <godot_cpp/core/class_db.hpp>
|
||||
#include <godot_cpp/core/defs.hpp>
|
||||
@@ -66,7 +66,7 @@ void unregister_webrtc_extension_types(ModuleInitializationLevel p_level) {
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
GDNativeBool GDN_EXPORT webrtc_extension_init(const GDNativeInterface *p_interface, const GDNativeExtensionClassLibraryPtr p_library, GDNativeInitialization *r_initialization) {
|
||||
GDExtensionBool GDE_EXPORT webrtc_extension_init(const GDExtensionInterface *p_interface, const GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) {
|
||||
GDExtensionBinding::InitObject init_obj(p_interface, p_library, r_initialization);
|
||||
|
||||
init_obj.register_initializer(register_webrtc_extension_types);
|
||||
|
||||
@@ -75,6 +75,21 @@ protected:
|
||||
};
|
||||
|
||||
public:
|
||||
enum GatheringState {
|
||||
GATHERING_STATE_NEW,
|
||||
GATHERING_STATE_GATHERING,
|
||||
GATHERING_STATE_COMPLETE,
|
||||
};
|
||||
|
||||
enum SignalingState {
|
||||
SIGNALING_STATE_STABLE,
|
||||
SIGNALING_STATE_HAVE_LOCAL_OFFER,
|
||||
SIGNALING_STATE_HAVE_REMOTE_OFFER,
|
||||
SIGNALING_STATE_HAVE_LOCAL_PRANSWER,
|
||||
SIGNALING_STATE_HAVE_REMOTE_PRANSWER,
|
||||
SIGNALING_STATE_CLOSED,
|
||||
};
|
||||
|
||||
static void _register_methods();
|
||||
static const godot_gdnative_ext_net_3_2_api_struct *_net_api;
|
||||
|
||||
@@ -82,6 +97,8 @@ public:
|
||||
void register_interface(const godot_net_webrtc_peer_connection *interface);
|
||||
|
||||
virtual ConnectionState _get_connection_state() const = 0;
|
||||
virtual GatheringState _get_gathering_state() const = 0;
|
||||
virtual SignalingState _get_signaling_state() const = 0;
|
||||
|
||||
virtual godot::Error _initialize(const godot::Dictionary &p_config) = 0;
|
||||
virtual godot::Object *_create_data_channel(const godot::String &p_channel, const godot::Dictionary &p_channel_config) = 0;
|
||||
|
||||
82
thirdparty/README.md
vendored
Normal file
82
thirdparty/README.md
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
# Third party libraries
|
||||
|
||||
Please keep categories (`##` level) listed alphabetically and matching their
|
||||
respective folder names. Use two empty lines to separate categories for
|
||||
readability.
|
||||
|
||||
|
||||
## json
|
||||
|
||||
- Upstream: https://github.com/nlohmann/json
|
||||
- Version: 3.10.5 (4f8fba14066156b73f1189a2b8bd568bde5284c5, 2022)
|
||||
- License: MIT
|
||||
|
||||
Module location:
|
||||
|
||||
- thirdparty/libdatachannel/deps/json
|
||||
|
||||
|
||||
## libdatachannel
|
||||
|
||||
- Upstream: https://github.com/paullouisageneau/libdatachannel
|
||||
- Version: 0.18.1 (595f0ebaac3974f17e5a5c63e7e7dc0c5edd163d, 2022)
|
||||
- License: MPL 2.0
|
||||
|
||||
Module location:
|
||||
|
||||
- thirdparty/libdatachannel
|
||||
|
||||
|
||||
# libjuice
|
||||
|
||||
- Upstream: https://github.com/paullouisageneau/libjuice
|
||||
- Version: 1.1.0 (0dabc046cd23da6908749e4c6add834ec29a7c49, 2022)
|
||||
- License: MPL 2.0
|
||||
|
||||
Module location:
|
||||
|
||||
- thirdparty/libdatachannel/deps/libjuice
|
||||
|
||||
|
||||
## libsrtp
|
||||
|
||||
- Upstream: https://github.com/cisco/libsrtp
|
||||
- Version: 2.4.2 (90d05bf8980d16e4ac3f16c19b77e296c4bc207b, 2021)
|
||||
- License: BSD-3-Clause
|
||||
|
||||
Module location:
|
||||
|
||||
- thirdparty/libdatachannel/deps/libsrtp
|
||||
|
||||
|
||||
## openssl
|
||||
|
||||
- Upstream: git://git.openssl.org/openssl.git
|
||||
- Version: 3.0.7 (19cc035b6c6f2283573d29c7ea7f7d675cf750ce, 2022)
|
||||
- License: Apache 2.0
|
||||
|
||||
Module location:
|
||||
|
||||
- thirdparty/openssl
|
||||
|
||||
|
||||
## plog
|
||||
|
||||
- Upstream: https://github.com/SergiusTheBest/plog
|
||||
- Version: git (d8461e9d473e59fbcc1f79eee021550dcf81e618, 2021)
|
||||
- License: MPL 2.0
|
||||
|
||||
Module location:
|
||||
|
||||
- thirdparty/libdatachannel/deps/plog
|
||||
|
||||
|
||||
## usrsctp
|
||||
|
||||
- Upstream: https://github.com/sctplab/usrsctp
|
||||
- Version: git (7c31bd35c79ba67084ce029511193a19ceb97447, 2021)
|
||||
- License: BSD-3-Clause
|
||||
|
||||
Module location:
|
||||
|
||||
- thirdparty/libdatachannel/deps/usrsctp
|
||||
1
thirdparty/libdatachannel
vendored
Submodule
1
thirdparty/libdatachannel
vendored
Submodule
Submodule thirdparty/libdatachannel added at 595f0ebaac
1
thirdparty/openssl
vendored
Submodule
1
thirdparty/openssl
vendored
Submodule
Submodule thirdparty/openssl added at 19cc035b6c
27
tools/cmake.py
Normal file
27
tools/cmake.py
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
def exists(env):
|
||||
return True
|
||||
|
||||
|
||||
def generate(env):
|
||||
env.AddMethod(cmake_configure, "CMakeConfigure")
|
||||
env.AddMethod(cmake_build, "CMakeBuild")
|
||||
|
||||
|
||||
def cmake_configure(env, source, target, opt_args):
|
||||
args = [
|
||||
"-B",
|
||||
target,
|
||||
]
|
||||
if env["platform"] == "windows" and env["use_mingw"]:
|
||||
args.extend(["-G", "Unix Makefiles"])
|
||||
for arg in opt_args:
|
||||
args.append(arg)
|
||||
args.append(source)
|
||||
return env.Execute("cmake " + " ".join(['"%s"' % a for a in 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))
|
||||
8
tools/common.py
Normal file
8
tools/common.py
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
def exists(env):
|
||||
return True
|
||||
|
||||
|
||||
def generate(env):
|
||||
env["DEPS_SOURCE"] = env.Dir("#thirdparty").abspath
|
||||
env["DEPS_BUILD"] = env.Dir("#bin/thirdparty").abspath + "/{}.{}.dir".format(env["suffix"][1:], "RelWithDebInfo" if env["debug_symbols"] else "Release")
|
||||
95
tools/rtc.py
Normal file
95
tools/rtc.py
Normal file
@@ -0,0 +1,95 @@
|
||||
import os
|
||||
|
||||
def rtc_cmake_config(env):
|
||||
config = {
|
||||
"USE_NICE": 0,
|
||||
"NO_WEBSOCKET": 1,
|
||||
"NO_EXAMPLES": 1,
|
||||
"NO_TESTS": 1,
|
||||
"OPENSSL_USE_STATIC_LIBS": 1,
|
||||
"OPENSSL_INCLUDE_DIR": env["SSL_INCLUDE"],
|
||||
"OPENSSL_SSL_LIBRARY": env["SSL_LIBRARY"],
|
||||
"OPENSSL_CRYPTO_LIBRARY": env["SSL_CRYPTO_LIBRARY"],
|
||||
"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"
|
||||
return config
|
||||
|
||||
|
||||
def rtc_emitter(target, source, env):
|
||||
env.Depends(env["RTC_LIBS"], env["SSL_LIBS"])
|
||||
env.Depends(env["RTC_LIBS"], [env.File(__file__), env.Dir(env["RTC_SOURCE"]), env.File(env["RTC_SOURCE"] + "/CMakeLists.txt")])
|
||||
return env["RTC_LIBS"], env.Dir(env["RTC_SOURCE"])
|
||||
|
||||
|
||||
def rtc_action(target, source, env):
|
||||
rtc_env = env.Clone()
|
||||
build_dir = env["RTC_BUILD"]
|
||||
source_dir = env["RTC_SOURCE"]
|
||||
opts = rtc_cmake_config(rtc_env)
|
||||
rtc_env.CMakeConfigure(source_dir, build_dir, ["-D%s=%s" % it for it in opts.items()])
|
||||
rtc_env.CMakeBuild(build_dir, "datachannel-static")
|
||||
return None
|
||||
|
||||
|
||||
def exists(env):
|
||||
return "CMakeConfigure" in env and "CMakeBuild" in env
|
||||
|
||||
|
||||
def generate(env):
|
||||
env["RTC_SOURCE"] = env["DEPS_SOURCE"] + "/libdatachannel"
|
||||
env["RTC_BUILD"] = env["DEPS_BUILD"] + "/libdatachannel"
|
||||
env["RTC_INCLUDE"] = env["RTC_SOURCE"] + "/include"
|
||||
env["RTC_LIBS"] = [env.File(env["RTC_BUILD"] + "/" + lib) for lib in [
|
||||
"libdatachannel-static.a",
|
||||
"deps/libjuice/libjuice-static.a",
|
||||
"deps/libsrtp/libsrtp2.a",
|
||||
"deps/usrsctp/usrsctplib/libusrsctp.a"
|
||||
]]
|
||||
env.Append(BUILDERS={
|
||||
"BuildLibDataChannel": env.Builder(action=rtc_action, emitter=rtc_emitter)
|
||||
})
|
||||
env.Append(LIBPATH=[env["RTC_BUILD"]])
|
||||
env.Append(CPPPATH=[env["RTC_INCLUDE"]])
|
||||
env.Prepend(LIBS=env["RTC_LIBS"])
|
||||
if env["platform"] == "windows":
|
||||
env.AppendUnique(LIBS=["iphlpapi", "bcrypt"])
|
||||
115
tools/ssl.py
Normal file
115
tools/ssl.py
Normal file
@@ -0,0 +1,115 @@
|
||||
import os
|
||||
from SCons.Defaults import Mkdir
|
||||
|
||||
def ssl_emitter(target, source, env):
|
||||
env.Depends(env["SSL_LIBS"], env.File(__file__))
|
||||
return env["SSL_LIBS"], [env.Dir(env["SSL_SOURCE"]), env.File(env["SSL_SOURCE"] + "/VERSION.dat")]
|
||||
|
||||
|
||||
def ssl_action(target, source, env):
|
||||
build_dir = env["SSL_BUILD"]
|
||||
source_dir = env["SSL_SOURCE"]
|
||||
install_dir = env["SSL_INSTALL"]
|
||||
|
||||
ssl_env = env.Clone()
|
||||
args = [
|
||||
"no-ssl2",
|
||||
"no-ssl3",
|
||||
"no-weak-ssl-ciphers",
|
||||
"no-legacy",
|
||||
"no-shared",
|
||||
"no-tests",
|
||||
"--prefix=%s" % install_dir,
|
||||
"--openssldir=%s" % install_dir,
|
||||
]
|
||||
if env["debug_symbols"]:
|
||||
args.append("-d")
|
||||
|
||||
if env["platform"] == "linux":
|
||||
if env["arch"] == "x86_32":
|
||||
args.extend(["linux-x86"])
|
||||
else:
|
||||
args.extend(["linux-x86_64"])
|
||||
|
||||
elif env["platform"] == "android":
|
||||
api = env["android_api_level"] if int(env["android_api_level"]) > 28 else "28"
|
||||
args.extend([
|
||||
{
|
||||
"arm64": "android-arm64",
|
||||
"arm32": "android-arm",
|
||||
"x86_32": "android-x86",
|
||||
"x86_64": "android-x86_64",
|
||||
}[env["arch"]],
|
||||
"-D__ANDROID_API__=%s" % api,
|
||||
])
|
||||
# Setup toolchain path.
|
||||
ssl_env.PrependENVPath("PATH", os.path.dirname(env["CC"]))
|
||||
ssl_env["ENV"]["ANDROID_NDK_ROOT"] = os.environ.get("ANDROID_NDK_ROOT", "")
|
||||
|
||||
elif env["platform"] == "macos":
|
||||
if env["arch"] == "x86_64":
|
||||
args.extend(["darwin64-x86_64"])
|
||||
elif env["arch"] == "arm64":
|
||||
args.extend(["darwin64-arm64"])
|
||||
else:
|
||||
raise ValueError("macOS architecture not supported: %s" % env["arch"])
|
||||
|
||||
elif env["platform"] == "ios":
|
||||
if env["ios_simulator"]:
|
||||
args.extend(["iossimulator-xcrun"])
|
||||
elif env["arch"] == "arm32":
|
||||
args.extend(["ios-xcrun"])
|
||||
elif env["arch"] == "arm64":
|
||||
args.extend(["ios64-xcrun"])
|
||||
else:
|
||||
raise ValueError("iOS architecture not supported: %s" % env["arch"])
|
||||
|
||||
elif env["platform"] == "windows":
|
||||
if env["arch"] == "x86_32":
|
||||
if env["use_mingw"]:
|
||||
args.extend([
|
||||
"mingw",
|
||||
"--cross-compile-prefix=i686-w64-mingw32-",
|
||||
])
|
||||
else:
|
||||
args.extend(["VC-WIN32"])
|
||||
else:
|
||||
if env["use_mingw"]:
|
||||
args.extend([
|
||||
"mingw64",
|
||||
"--cross-compile-prefix=x86_64-w64-mingw32-",
|
||||
])
|
||||
else:
|
||||
args.extend(["VC-WIN64A"])
|
||||
|
||||
jobs = env.GetOption("num_jobs")
|
||||
ssl_env.Execute([
|
||||
Mkdir(build_dir),
|
||||
"cd %s && perl %s/Configure %s" % (build_dir, source_dir, " ".join(['"%s"' % a for a in args])),
|
||||
"make -C %s -j%s" % (build_dir, jobs),
|
||||
"make -C %s install_sw install_ssldirs -j%s" % (build_dir, jobs),
|
||||
]
|
||||
)
|
||||
return None
|
||||
|
||||
|
||||
def exists(env):
|
||||
return True
|
||||
|
||||
|
||||
def generate(env):
|
||||
env["SSL_SOURCE"] = env["DEPS_SOURCE"] + "/openssl"
|
||||
env["SSL_BUILD"] = env["DEPS_BUILD"] + "/openssl"
|
||||
env["SSL_INSTALL"] = env["SSL_BUILD"] + "/dest"
|
||||
env["SSL_INCLUDE"] = env["SSL_INSTALL"] + "/include"
|
||||
env["SSL_LIBRARY"] = env.File(env["SSL_BUILD"] + "/libssl.a")
|
||||
env["SSL_CRYPTO_LIBRARY"] = env.File(env["SSL_BUILD"] + "/libcrypto.a")
|
||||
env["SSL_LIBS"] = [env["SSL_LIBRARY"], env["SSL_CRYPTO_LIBRARY"]]
|
||||
env.Append(BUILDERS={
|
||||
"BuildOpenSSL": env.Builder(action=ssl_action, emitter=ssl_emitter)
|
||||
})
|
||||
env.Prepend(CPPPATH=[env["SSL_INCLUDE"]])
|
||||
env.Prepend(LIBPATH=[env["SSL_BUILD"]])
|
||||
env.Append(LIBS=env["SSL_LIBS"])
|
||||
if env["platform"] == "windows":
|
||||
env.AppendUnique(LIBS=["ws2_32", "gdi32", "advapi32", "crypt32", "user32"])
|
||||
Reference in New Issue
Block a user