mirror of
https://github.com/godotengine/webrtc-native.git
synced 2026-01-03 14:09:58 +03:00
Compare commits
28 Commits
1.0.6-stab
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f3ca94ae0e | ||
|
|
40e5c0c733 | ||
|
|
b45d3a3f46 | ||
|
|
41648bbf60 | ||
|
|
a77bf9bdb0 | ||
|
|
b1ee39e6c4 | ||
|
|
29fc1bb84d | ||
|
|
4567fb22c1 | ||
|
|
13a934298a | ||
|
|
68338ed576 | ||
|
|
f149f97815 | ||
|
|
cf038b2788 | ||
|
|
1992779387 | ||
|
|
25bb44730e | ||
|
|
79bae8e0d5 | ||
|
|
355fdd9051 | ||
|
|
49de259a08 | ||
|
|
9afa5c3a48 | ||
|
|
93e11a7343 | ||
|
|
ba46b25c00 | ||
|
|
31fd88dbf5 | ||
|
|
ea8b37fe29 | ||
|
|
cb1ef2e59c | ||
|
|
038bac82d6 | ||
|
|
effada6b45 | ||
|
|
26bc56f934 | ||
|
|
44ee53715d | ||
|
|
0b89ed885d |
70
.github/workflows/build_release.yml
vendored
70
.github/workflows/build_release.yml
vendored
@@ -4,11 +4,13 @@ on: [push, pull_request]
|
|||||||
env:
|
env:
|
||||||
# Only used for the cache key. Increment version to force clean build.
|
# Only used for the cache key. Increment version to force clean build.
|
||||||
GODOT_BASE_BRANCH: master
|
GODOT_BASE_BRANCH: master
|
||||||
|
# Hardcoding this seem to be the only way
|
||||||
|
ANDROID_NDK_ROOT: /usr/local/lib/android/sdk/ndk/23.2.8568313/
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
static-checks:
|
static-checks:
|
||||||
name: 📊 Static Checks (clang-format, black format, file format)
|
name: 📊 Static Checks (clang-format, black format, file format)
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -50,13 +52,13 @@ jobs:
|
|||||||
arch: 'x86_64'
|
arch: 'x86_64'
|
||||||
gdnative_flags: 'android_arch=x86_64'
|
gdnative_flags: 'android_arch=x86_64'
|
||||||
sconsflags: ''
|
sconsflags: ''
|
||||||
os: 'ubuntu-20.04'
|
os: 'ubuntu-22.04'
|
||||||
cache-name: android-x86_64
|
cache-name: android-x86_64
|
||||||
- platform: android
|
- platform: android
|
||||||
arch: 'arm64'
|
arch: 'arm64'
|
||||||
gdnative_flags: 'android_arch=arm64v8'
|
gdnative_flags: 'android_arch=arm64v8'
|
||||||
sconsflags: ''
|
sconsflags: ''
|
||||||
os: 'ubuntu-20.04'
|
os: 'ubuntu-22.04'
|
||||||
cache-name: android-arm64
|
cache-name: android-arm64
|
||||||
|
|
||||||
# iOS
|
# iOS
|
||||||
@@ -64,13 +66,13 @@ jobs:
|
|||||||
arch: 'x86_64'
|
arch: 'x86_64'
|
||||||
gdnative_flags: 'ios_arch=x86_64'
|
gdnative_flags: 'ios_arch=x86_64'
|
||||||
sconsflags: 'ios_simulator=true'
|
sconsflags: 'ios_simulator=true'
|
||||||
os: 'macos-11'
|
os: 'macos-latest'
|
||||||
cache-name: ios-x86_64-simulator
|
cache-name: ios-x86_64-simulator
|
||||||
- platform: ios
|
- platform: ios
|
||||||
arch: 'arm64'
|
arch: 'arm64'
|
||||||
gdnative_flags: 'ios_arch=arm64'
|
gdnative_flags: 'ios_arch=arm64'
|
||||||
sconsflags: ''
|
sconsflags: ''
|
||||||
os: 'macos-11'
|
os: 'macos-latest'
|
||||||
cache-name: ios-arm64
|
cache-name: ios-arm64
|
||||||
|
|
||||||
# Linux
|
# Linux
|
||||||
@@ -79,28 +81,28 @@ jobs:
|
|||||||
buildroot: 'i686-godot-linux-gnu_sdk-buildroot'
|
buildroot: 'i686-godot-linux-gnu_sdk-buildroot'
|
||||||
gdnative_flags: 'bits=32'
|
gdnative_flags: 'bits=32'
|
||||||
sconsflags: ''
|
sconsflags: ''
|
||||||
os: 'ubuntu-20.04'
|
os: 'ubuntu-22.04'
|
||||||
cache-name: linux-x86_32
|
cache-name: linux-x86_32
|
||||||
- platform: linux
|
- platform: linux
|
||||||
arch: 'x86_64'
|
arch: 'x86_64'
|
||||||
buildroot: 'x86_64-godot-linux-gnu_sdk-buildroot'
|
buildroot: 'x86_64-godot-linux-gnu_sdk-buildroot'
|
||||||
gdnative_flags: 'bits=64'
|
gdnative_flags: 'bits=64'
|
||||||
sconsflags: ''
|
sconsflags: ''
|
||||||
os: 'ubuntu-20.04'
|
os: 'ubuntu-22.04'
|
||||||
cache-name: linux-x86_64
|
cache-name: linux-x86_64
|
||||||
- platform: linux
|
- platform: linux
|
||||||
arch: 'arm32'
|
arch: 'arm32'
|
||||||
buildroot: 'arm-godot-linux-gnueabihf_sdk-buildroot'
|
buildroot: 'arm-godot-linux-gnueabihf_sdk-buildroot'
|
||||||
gdnative_flags: 'bits=32'
|
gdnative_flags: 'bits=32'
|
||||||
sconsflags: ''
|
sconsflags: ''
|
||||||
os: 'ubuntu-20.04'
|
os: 'ubuntu-22.04'
|
||||||
cache-name: linux-arm32
|
cache-name: linux-arm32
|
||||||
- platform: linux
|
- platform: linux
|
||||||
arch: 'arm64'
|
arch: 'arm64'
|
||||||
buildroot: 'aarch64-godot-linux-gnu_sdk-buildroot'
|
buildroot: 'aarch64-godot-linux-gnu_sdk-buildroot'
|
||||||
gdnative_flags: 'bits=64'
|
gdnative_flags: 'bits=64'
|
||||||
sconsflags: ''
|
sconsflags: ''
|
||||||
os: 'ubuntu-20.04'
|
os: 'ubuntu-22.04'
|
||||||
cache-name: linux-arm64
|
cache-name: linux-arm64
|
||||||
|
|
||||||
# macOS
|
# macOS
|
||||||
@@ -108,7 +110,7 @@ jobs:
|
|||||||
arch: 'universal'
|
arch: 'universal'
|
||||||
gdnative_flags: 'macos_arch=universal bits=64'
|
gdnative_flags: 'macos_arch=universal bits=64'
|
||||||
sconsflags: ''
|
sconsflags: ''
|
||||||
os: 'macos-11'
|
os: 'macos-latest'
|
||||||
cache-name: macos-universal
|
cache-name: macos-universal
|
||||||
|
|
||||||
# Windows
|
# Windows
|
||||||
@@ -116,20 +118,20 @@ jobs:
|
|||||||
arch: 'x86_32'
|
arch: 'x86_32'
|
||||||
gdnative_flags: 'bits=32'
|
gdnative_flags: 'bits=32'
|
||||||
sconsflags: 'use_mingw=yes'
|
sconsflags: 'use_mingw=yes'
|
||||||
os: 'ubuntu-20.04'
|
os: 'ubuntu-22.04'
|
||||||
msvc_arch: amd64_x86
|
msvc_arch: amd64_x86
|
||||||
cache-name: win-x86_32
|
cache-name: win-x86_32
|
||||||
- platform: windows
|
- platform: windows
|
||||||
arch: 'x86_64'
|
arch: 'x86_64'
|
||||||
gdnative_flags: 'bits=64'
|
gdnative_flags: 'bits=64'
|
||||||
sconsflags: 'use_mingw=yes'
|
sconsflags: 'use_mingw=yes'
|
||||||
os: 'ubuntu-20.04'
|
os: 'ubuntu-22.04'
|
||||||
msvc_arch: amd64
|
msvc_arch: amd64
|
||||||
cache-name: win-x86_64
|
cache-name: win-x86_64
|
||||||
|
|
||||||
env:
|
env:
|
||||||
SCONS_CACHE: ${{ github.workspace }}/.scons-cache/
|
SCONS_CACHE: ${{ github.workspace }}/.scons-cache/
|
||||||
SCONSFLAGS: ${{ matrix.sconsflags }} platform=${{ matrix.platform }} arch=${{ matrix.arch }} --jobs=2
|
SCONSFLAGS: ${{ matrix.sconsflags }} platform=${{ matrix.platform }} arch=${{ matrix.arch }} build_profile=build_profile.json --jobs=2
|
||||||
|
|
||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
@@ -187,15 +189,28 @@ jobs:
|
|||||||
if: ${{ matrix.platform == 'linux' }}
|
if: ${{ matrix.platform == 'linux' }}
|
||||||
run: |
|
run: |
|
||||||
if [ ! -f ${{ matrix.buildroot }}.tar.bz2 ]; then
|
if [ ! -f ${{ matrix.buildroot }}.tar.bz2 ]; then
|
||||||
wget https://downloads.tuxfamily.org/godotengine/toolchains/linux/${{ matrix.buildroot }}.tar.bz2
|
wget https://github.com/godotengine/buildroot/releases/download/godot-2023.08.x-4/${{ matrix.buildroot }}.tar.bz2
|
||||||
fi
|
fi
|
||||||
tar -xjf ${{ matrix.buildroot }}.tar.bz2
|
tar -xjf ${{ matrix.buildroot }}.tar.bz2
|
||||||
${{ matrix.buildroot }}/relocate-sdk.sh
|
${{ matrix.buildroot }}/relocate-sdk.sh
|
||||||
|
rm ${{ matrix.buildroot }}/bin/cmake
|
||||||
echo "$GITHUB_WORKSPACE/${{ matrix.buildroot }}/bin" >> $GITHUB_PATH
|
echo "$GITHUB_WORKSPACE/${{ matrix.buildroot }}/bin" >> $GITHUB_PATH
|
||||||
echo "PKG_CONFIG=$GITHUB_WORKSPACE/${{ matrix.buildroot }}/share/pkgconfig/" >> $GITHUB_ENV
|
echo "PKG_CONFIG=$GITHUB_WORKSPACE/${{ matrix.buildroot }}/share/pkgconfig/" >> $GITHUB_ENV
|
||||||
patch -p1 < misc/patches/scons_path.diff
|
patch -p1 < misc/patches/scons_path.diff
|
||||||
patch -p1 < misc/patches/gdnantive_arm_warnings.diff
|
patch -p1 < misc/patches/gdnantive_arm_warnings.diff
|
||||||
|
|
||||||
|
- name: Setup Android dependencies
|
||||||
|
if: ${{ matrix.platform == 'android' }}
|
||||||
|
uses: nttld/setup-ndk@v1
|
||||||
|
with:
|
||||||
|
ndk-version: r23c
|
||||||
|
link-to-sdk: true
|
||||||
|
|
||||||
|
- name: Patch godot-cpp to support build profile.
|
||||||
|
run: |
|
||||||
|
patch -p1 < misc/patches/build_profile.diff
|
||||||
|
patch -p1 < misc/patches/build_profile_3.x.diff
|
||||||
|
|
||||||
- name: Print tools versions
|
- name: Print tools versions
|
||||||
run: |
|
run: |
|
||||||
python --version
|
python --version
|
||||||
@@ -204,19 +219,11 @@ jobs:
|
|||||||
|
|
||||||
- name: Compile Extension (4.1+) - template_debug - ${{ matrix.platform }} - ${{ matrix.arch }}
|
- name: Compile Extension (4.1+) - template_debug - ${{ matrix.platform }} - ${{ matrix.arch }}
|
||||||
run: |
|
run: |
|
||||||
scons target=template_debug godot_version=4.1
|
scons target=template_debug godot_version=4
|
||||||
|
|
||||||
- name: Compile Extension (4.1+) - template_release - ${{ matrix.platform }} - ${{ matrix.arch }}
|
- name: Compile Extension (4.1+) - template_release - ${{ matrix.platform }} - ${{ matrix.arch }}
|
||||||
run: |
|
run: |
|
||||||
scons target=template_release godot_version=4.1
|
scons target=template_release godot_version=4
|
||||||
|
|
||||||
- name: Compile Extension (4.0) - template_debug - ${{ matrix.platform }} - ${{ matrix.arch }}
|
|
||||||
run: |
|
|
||||||
scons target=template_debug godot_version=4.0
|
|
||||||
|
|
||||||
- name: Compile Extension (4.0) - template_release - ${{ matrix.platform }} - ${{ matrix.arch }}
|
|
||||||
run: |
|
|
||||||
scons target=template_release godot_version=4.0
|
|
||||||
|
|
||||||
- name: Compile GDNative (3.5+) - release ${{ matrix.platform }} - ${{ matrix.arch }}
|
- name: Compile GDNative (3.5+) - release ${{ matrix.platform }} - ${{ matrix.arch }}
|
||||||
run: |
|
run: |
|
||||||
@@ -246,11 +253,10 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
cp LICENSE artifacts/LICENSE.webrtc-native
|
cp LICENSE artifacts/LICENSE.webrtc-native
|
||||||
cp thirdparty/libdatachannel/LICENSE artifacts/LICENSE.libdatachannel
|
cp thirdparty/libdatachannel/LICENSE artifacts/LICENSE.libdatachannel
|
||||||
cp thirdparty/openssl/LICENSE.txt artifacts/LICENSE.openssl
|
cp thirdparty/mbedtls/LICENSE artifacts/LICENSE.mbedtls
|
||||||
cp thirdparty/libdatachannel/deps/libjuice/LICENSE artifacts/LICENSE.libjuice
|
cp thirdparty/libdatachannel/deps/libjuice/LICENSE artifacts/LICENSE.libjuice
|
||||||
cp thirdparty/libdatachannel/deps/usrsctp/LICENSE.md artifacts/LICENSE.usrsctp
|
cp thirdparty/libdatachannel/deps/usrsctp/LICENSE.md artifacts/LICENSE.usrsctp
|
||||||
cp thirdparty/libdatachannel/deps/libsrtp/LICENSE artifacts/LICENSE.libsrtp
|
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
|
cp thirdparty/libdatachannel/deps/plog/LICENSE artifacts/LICENSE.plog
|
||||||
|
|
||||||
- name: Package artifacts for release
|
- name: Package artifacts for release
|
||||||
@@ -259,21 +265,15 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
mkdir release
|
mkdir release
|
||||||
|
|
||||||
VERSION="extension-4.1" TYPE="webrtc" ./misc/scripts/package_release.sh
|
VERSION="extension" TYPE="webrtc" ./misc/scripts/package_release.sh
|
||||||
VERSION="extension-4.0" TYPE="webrtc" ./misc/scripts/package_release.sh
|
|
||||||
VERSION="gdnative" TYPE="webrtc" ./misc/scripts/package_release.sh
|
VERSION="gdnative" TYPE="webrtc" ./misc/scripts/package_release.sh
|
||||||
|
|
||||||
ls -R release
|
ls -R release
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v4
|
- uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: godot-webrtc-extension-4.1
|
name: godot-webrtc-extension
|
||||||
path: release/*-extension-4.1-*.zip
|
path: release/*-extension-*.zip
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: godot-webrtc-extension-4.0
|
|
||||||
path: release/*-extension-4.0-*.zip
|
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v4
|
- uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
|
|||||||
9
.gitmodules
vendored
9
.gitmodules
vendored
@@ -1,15 +1,12 @@
|
|||||||
[submodule "godot-cpp"]
|
[submodule "godot-cpp"]
|
||||||
path = godot-cpp
|
path = godot-cpp
|
||||||
url = https://github.com/godotengine/godot-cpp.git
|
url = https://github.com/godotengine/godot-cpp.git
|
||||||
[submodule "godot-cpp-4.0"]
|
|
||||||
path = godot-cpp-4.0
|
|
||||||
url = https://github.com/godotengine/godot-cpp.git
|
|
||||||
[submodule "godot-cpp-3.x"]
|
[submodule "godot-cpp-3.x"]
|
||||||
path = godot-cpp-3.x
|
path = godot-cpp-3.x
|
||||||
url = https://github.com/godotengine/godot-cpp.git
|
url = https://github.com/godotengine/godot-cpp.git
|
||||||
[submodule "libdatachannel"]
|
[submodule "libdatachannel"]
|
||||||
path = thirdparty/libdatachannel
|
path = thirdparty/libdatachannel
|
||||||
url = https://github.com/paullouisageneau/libdatachannel.git
|
url = https://github.com/paullouisageneau/libdatachannel.git
|
||||||
[submodule "openssl"]
|
[submodule "mbedtls"]
|
||||||
path = thirdparty/openssl
|
path = thirdparty/mbedtls
|
||||||
url = https://github.com/openssl/openssl.git
|
url = https://github.com/Mbed-TLS/mbedtls.git
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
### Compiling
|
### Compiling
|
||||||
|
|
||||||
Clone this repository with the following command to checkout all the dependencies: [godot-cpp](https://github.com/godotengine/godot-cpp), [openssl](https://www.openssl.org/) and [libdatachannel](https://github.com/paullouisageneau/libdatachannel) (and sub-dependencies).
|
Clone this repository with the following command to checkout all the dependencies: [godot-cpp](https://github.com/godotengine/godot-cpp), [mbedTLS](https://github.com/Mbed-TLS/mbedtls) and [libdatachannel](https://github.com/paullouisageneau/libdatachannel) (and sub-dependencies).
|
||||||
|
|
||||||
```
|
```
|
||||||
$ git clone --recurse-submodules https://github.com/godotengine/webrtc-native.git
|
$ git clone --recurse-submodules https://github.com/godotengine/webrtc-native.git
|
||||||
|
|||||||
43
SConstruct
43
SConstruct
@@ -28,7 +28,7 @@ def validate_godotcpp_dir(key, val, env):
|
|||||||
|
|
||||||
env = Environment()
|
env = Environment()
|
||||||
opts = Variables(["customs.py"], ARGUMENTS)
|
opts = Variables(["customs.py"], ARGUMENTS)
|
||||||
opts.Add(EnumVariable("godot_version", "The Godot target version", "4.1", ["3", "4.0", "4.1"]))
|
opts.Add(EnumVariable("godot_version", "The Godot target version", "4", ["3", "4"], {"4.1+": "4", "4.1": "4"}))
|
||||||
opts.Add(
|
opts.Add(
|
||||||
PathVariable(
|
PathVariable(
|
||||||
"godot_cpp",
|
"godot_cpp",
|
||||||
@@ -41,7 +41,7 @@ opts.Update(env)
|
|||||||
|
|
||||||
# Minimum target platform versions.
|
# Minimum target platform versions.
|
||||||
if "ios_min_version" not in ARGUMENTS:
|
if "ios_min_version" not in ARGUMENTS:
|
||||||
ARGUMENTS["ios_min_version"] = "11.0"
|
ARGUMENTS["ios_min_version"] = "12.0"
|
||||||
if "macos_deployment_target" not in ARGUMENTS:
|
if "macos_deployment_target" not in ARGUMENTS:
|
||||||
ARGUMENTS["macos_deployment_target"] = "11.0"
|
ARGUMENTS["macos_deployment_target"] = "11.0"
|
||||||
if "android_api_level" not in ARGUMENTS:
|
if "android_api_level" not in ARGUMENTS:
|
||||||
@@ -61,8 +61,8 @@ if env["godot_version"] == "3":
|
|||||||
replace_flags(
|
replace_flags(
|
||||||
cpp_env["CCFLAGS"],
|
cpp_env["CCFLAGS"],
|
||||||
{
|
{
|
||||||
"-mios-simulator-version-min=10.0": "-mios-simulator-version-min=11.0",
|
"-mios-simulator-version-min=10.0": "-mios-simulator-version-min=12.0",
|
||||||
"-miphoneos-version-min=10.0": "-miphoneos-version-min=11.0",
|
"-miphoneos-version-min=10.0": "-miphoneos-version-min=12.0",
|
||||||
"/std:c++14": "/std:c++17",
|
"/std:c++14": "/std:c++17",
|
||||||
"-std=c++14": "-std=c++17",
|
"-std=c++14": "-std=c++17",
|
||||||
},
|
},
|
||||||
@@ -82,7 +82,7 @@ if env["godot_version"] == "3":
|
|||||||
env["CC"] = "clang" # CC is not set in 3.x and can result in it being "gcc".
|
env["CC"] = "clang" # CC is not set in 3.x and can result in it being "gcc".
|
||||||
|
|
||||||
if env["platform"] == "ios":
|
if env["platform"] == "ios":
|
||||||
env["ios_min_version"] = "11.0"
|
env["ios_min_version"] = "12.0"
|
||||||
|
|
||||||
# Normalize suffix
|
# Normalize suffix
|
||||||
if env["platform"] in ["windows", "linux"]:
|
if env["platform"] in ["windows", "linux"]:
|
||||||
@@ -122,10 +122,6 @@ if env["godot_version"] == "3":
|
|||||||
if env["platform"] == "linux" and env["arch"] not in ("x86_32", "x86_64"):
|
if env["platform"] == "linux" and env["arch"] not in ("x86_32", "x86_64"):
|
||||||
for flags in (env["CCFLAGS"], env["LINKFLAGS"], cpp_env["CCFLAGS"], cpp_env["LINKFLAGS"]):
|
for flags in (env["CCFLAGS"], env["LINKFLAGS"], cpp_env["CCFLAGS"], cpp_env["LINKFLAGS"]):
|
||||||
replace_flags(flags, {"-m32": None, "-m64": None})
|
replace_flags(flags, {"-m32": None, "-m64": None})
|
||||||
elif env["godot_version"] == "4.0":
|
|
||||||
sconstruct = env.get("godot_cpp", "godot-cpp-4.0") + "/SConstruct"
|
|
||||||
cpp_env = SConscript(sconstruct)
|
|
||||||
env = cpp_env.Clone()
|
|
||||||
else:
|
else:
|
||||||
sconstruct = env.get("godot_cpp", "godot-cpp") + "/SConstruct"
|
sconstruct = env.get("godot_cpp", "godot-cpp") + "/SConstruct"
|
||||||
cpp_env = SConscript(sconstruct)
|
cpp_env = SConscript(sconstruct)
|
||||||
@@ -136,6 +132,12 @@ if cpp_env.get("is_msvc", False):
|
|||||||
replace_flags(env["CCFLAGS"], {"/MT": "/MD"})
|
replace_flags(env["CCFLAGS"], {"/MT": "/MD"})
|
||||||
replace_flags(cpp_env["CCFLAGS"], {"/MT": "/MD"})
|
replace_flags(cpp_env["CCFLAGS"], {"/MT": "/MD"})
|
||||||
|
|
||||||
|
if env["platform"] == "ios":
|
||||||
|
if env["ios_simulator"]:
|
||||||
|
env.AppendUnique(LINKFLAGS=["-mios-simulator-version-min=" + ARGUMENTS["ios_min_version"]])
|
||||||
|
else:
|
||||||
|
env.AppendUnique(LINKFLAGS=["-miphoneos-version-min=" + ARGUMENTS["ios_min_version"]])
|
||||||
|
|
||||||
# Should probably go to upstream godot-cpp.
|
# Should probably go to upstream godot-cpp.
|
||||||
# We let SCons build its default ENV as it includes OS-specific things which we don't
|
# We let SCons build its default ENV as it includes OS-specific things which we don't
|
||||||
# want to have to pull in manually.
|
# want to have to pull in manually.
|
||||||
@@ -160,10 +162,8 @@ opts.Update(env)
|
|||||||
target = env["target"]
|
target = env["target"]
|
||||||
if env["godot_version"] == "3":
|
if env["godot_version"] == "3":
|
||||||
result_path = os.path.join("bin", "gdnative", "webrtc" if env["target"] == "release" else "webrtc_debug")
|
result_path = os.path.join("bin", "gdnative", "webrtc" if env["target"] == "release" else "webrtc_debug")
|
||||||
elif env["godot_version"] == "4.0":
|
|
||||||
result_path = os.path.join("bin", "extension-4.0", "webrtc")
|
|
||||||
else:
|
else:
|
||||||
result_path = os.path.join("bin", "extension-4.1", "webrtc")
|
result_path = os.path.join("bin", "extension", "webrtc")
|
||||||
|
|
||||||
# Our includes and sources
|
# Our includes and sources
|
||||||
env.Append(CPPPATH=["src/"])
|
env.Append(CPPPATH=["src/"])
|
||||||
@@ -181,22 +181,23 @@ if env["godot_version"] == "3":
|
|||||||
add_sources(sources, "src/net/", "cpp")
|
add_sources(sources, "src/net/", "cpp")
|
||||||
else:
|
else:
|
||||||
sources.append("src/init_gdextension.cpp")
|
sources.append("src/init_gdextension.cpp")
|
||||||
if env["godot_version"] == "4.0":
|
|
||||||
env.Append(CPPDEFINES=["GDEXTENSION_WEBRTC_40"])
|
|
||||||
|
|
||||||
# Add our build tools
|
# Add our build tools
|
||||||
for tool in ["openssl", "cmake", "rtc"]:
|
for tool in ["cmake", "mbedtls", "rtc"]:
|
||||||
env.Tool(tool, toolpath=["tools"])
|
env.Tool(tool, toolpath=["tools"])
|
||||||
|
|
||||||
ssl = env.OpenSSL()
|
# Make sure Substfile is also loaded
|
||||||
|
env.Tool("textfile")
|
||||||
|
|
||||||
rtc = env.BuildLibDataChannel(ssl)
|
mbedtls = env.BuildMbedTLS()
|
||||||
|
|
||||||
|
rtc = env.BuildLibDataChannel(mbedtls)
|
||||||
|
|
||||||
# Forces building our sources after OpenSSL and libdatachannel.
|
# 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.
|
# 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,
|
# 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.
|
# but it's better to be safe in case of indirect inclusions by one of our other dependencies.
|
||||||
env.Depends(sources, ssl + rtc)
|
env.Depends(sources, rtc + mbedtls)
|
||||||
|
|
||||||
# We want to statically link against libstdc++ on Linux to maximize compatibility, but we must restrict the exported
|
# We want to statically link against libstdc++ on Linux to maximize compatibility, but we must restrict the exported
|
||||||
# symbols using a GCC version script, or we might end up overriding symbols from other libraries.
|
# symbols using a GCC version script, or we might end up overriding symbols from other libraries.
|
||||||
@@ -249,10 +250,6 @@ if env["godot_version"] == "3":
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
extfile = env.Substfile(
|
extfile = env.InstallAs(os.path.join(result_path, "webrtc.gdextension"), "misc/webrtc.gdextension")
|
||||||
os.path.join(result_path, "webrtc.gdextension"),
|
|
||||||
"misc/webrtc.gdextension",
|
|
||||||
SUBST_DICT={"{GODOT_VERSION}": env["godot_version"]},
|
|
||||||
)
|
|
||||||
|
|
||||||
Default(extfile)
|
Default(extfile)
|
||||||
|
|||||||
11
build_profile.json
Normal file
11
build_profile.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"enabled_classes": [
|
||||||
|
"WebRTCDataChannelExtension",
|
||||||
|
"WebRTCPeerConnectionExtension",
|
||||||
|
"WebRTCDataChannelGDNative",
|
||||||
|
"WebRTCPeerConnectionGDNative",
|
||||||
|
"NativeScript",
|
||||||
|
"GDNativeLibrary",
|
||||||
|
"Window"
|
||||||
|
]
|
||||||
|
}
|
||||||
Submodule godot-cpp updated: d627942b64...631cd5fe37
Submodule godot-cpp-4.0 deleted from 9d1c396c54
297
misc/patches/build_profile.diff
Normal file
297
misc/patches/build_profile.diff
Normal file
@@ -0,0 +1,297 @@
|
|||||||
|
diff --git a/godot-cpp/binding_generator.py b/godot-cpp/binding_generator.py
|
||||||
|
index 18db9fd..e0c8caf 100644
|
||||||
|
--- a/godot-cpp/binding_generator.py
|
||||||
|
+++ b/godot-cpp/binding_generator.py
|
||||||
|
@@ -72,9 +72,13 @@ def generate_wrappers(target):
|
||||||
|
|
||||||
|
def get_file_list(api_filepath, output_dir, headers=False, sources=False):
|
||||||
|
api = {}
|
||||||
|
- files = []
|
||||||
|
with open(api_filepath, encoding="utf-8") as api_file:
|
||||||
|
api = json.load(api_file)
|
||||||
|
+ return _get_file_list(api, output_dir, headers, sources)
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+def _get_file_list(api, output_dir, headers=False, sources=False):
|
||||||
|
+ files = []
|
||||||
|
|
||||||
|
core_gen_folder = Path(output_dir) / "gen" / "include" / "godot_cpp" / "core"
|
||||||
|
include_gen_folder = Path(output_dir) / "gen" / "include" / "godot_cpp"
|
||||||
|
@@ -158,13 +162,15 @@ def scons_generate_bindings(target, source, env):
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
-def generate_bindings(api_filepath, use_template_get_node, bits="64", precision="single", output_dir="."):
|
||||||
|
- api = None
|
||||||
|
-
|
||||||
|
- target_dir = Path(output_dir) / "gen"
|
||||||
|
-
|
||||||
|
+def _generate_bindings(api_filepath, use_template_get_node, bits="64", precision="single", output_dir="."):
|
||||||
|
+ api = {}
|
||||||
|
with open(api_filepath, encoding="utf-8") as api_file:
|
||||||
|
api = json.load(api_file)
|
||||||
|
+ _generate_bindings(api, use_template_get_node, bits, precision, output_dir)
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+def _generate_bindings(api, use_template_get_node, bits="64", precision="single", output_dir="."):
|
||||||
|
+ target_dir = Path(output_dir) / "gen"
|
||||||
|
|
||||||
|
shutil.rmtree(target_dir, ignore_errors=True)
|
||||||
|
target_dir.mkdir(parents=True)
|
||||||
|
diff --git a/godot-cpp/build_profile.py b/godot-cpp/build_profile.py
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..b4d19de
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/godot-cpp/build_profile.py
|
||||||
|
@@ -0,0 +1,183 @@
|
||||||
|
+import json
|
||||||
|
+import sys
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+def parse_build_profile(profile_filepath, api):
|
||||||
|
+ if profile_filepath == "":
|
||||||
|
+ return {}
|
||||||
|
+
|
||||||
|
+ with open(profile_filepath, encoding="utf-8") as profile_file:
|
||||||
|
+ profile = json.load(profile_file)
|
||||||
|
+
|
||||||
|
+ api_dict = {}
|
||||||
|
+ parents = {}
|
||||||
|
+ children = {}
|
||||||
|
+ for engine_class in api["classes"]:
|
||||||
|
+ api_dict[engine_class["name"]] = engine_class
|
||||||
|
+ parent = engine_class.get("inherits", "")
|
||||||
|
+ child = engine_class["name"]
|
||||||
|
+ parents[child] = parent
|
||||||
|
+ if parent == "":
|
||||||
|
+ continue
|
||||||
|
+ children[parent] = children.get(parent, [])
|
||||||
|
+ children[parent].append(child)
|
||||||
|
+
|
||||||
|
+ included = []
|
||||||
|
+ front = list(profile.get("enabled_classes", []))
|
||||||
|
+ if front:
|
||||||
|
+ # These must always be included
|
||||||
|
+ front.append("WorkerThreadPool")
|
||||||
|
+ front.append("ClassDB")
|
||||||
|
+ front.append("ClassDBSingleton")
|
||||||
|
+ # In src/classes/low_level.cpp
|
||||||
|
+ front.append("FileAccess")
|
||||||
|
+ front.append("Image")
|
||||||
|
+ front.append("XMLParser")
|
||||||
|
+ # In include/godot_cpp/templates/thread_work_pool.hpp
|
||||||
|
+ front.append("Semaphore")
|
||||||
|
+ while front:
|
||||||
|
+ cls = front.pop()
|
||||||
|
+ if cls in included:
|
||||||
|
+ continue
|
||||||
|
+ included.append(cls)
|
||||||
|
+ parent = parents.get(cls, "")
|
||||||
|
+ if parent:
|
||||||
|
+ front.append(parent)
|
||||||
|
+
|
||||||
|
+ excluded = []
|
||||||
|
+ front = list(profile.get("disabled_classes", []))
|
||||||
|
+ while front:
|
||||||
|
+ cls = front.pop()
|
||||||
|
+ if cls in excluded:
|
||||||
|
+ continue
|
||||||
|
+ excluded.append(cls)
|
||||||
|
+ front += children.get(cls, [])
|
||||||
|
+
|
||||||
|
+ if included and excluded:
|
||||||
|
+ print(
|
||||||
|
+ "WARNING: Cannot specify both 'enabled_classes' and 'disabled_classes' in build profile. 'disabled_classes' will be ignored."
|
||||||
|
+ )
|
||||||
|
+
|
||||||
|
+ return {
|
||||||
|
+ "enabled_classes": included,
|
||||||
|
+ "disabled_classes": excluded,
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+def generate_trimmed_api(source_api_filepath, profile_filepath):
|
||||||
|
+ with open(source_api_filepath, encoding="utf-8") as api_file:
|
||||||
|
+ api = json.load(api_file)
|
||||||
|
+
|
||||||
|
+ if profile_filepath == "":
|
||||||
|
+ return api
|
||||||
|
+
|
||||||
|
+ build_profile = parse_build_profile(profile_filepath, api)
|
||||||
|
+
|
||||||
|
+ engine_classes = {}
|
||||||
|
+ for class_api in api["classes"]:
|
||||||
|
+ engine_classes[class_api["name"]] = class_api["is_refcounted"]
|
||||||
|
+ for native_struct in api["native_structures"]:
|
||||||
|
+ if native_struct["name"] == "ObjectID":
|
||||||
|
+ continue
|
||||||
|
+ engine_classes[native_struct["name"]] = False
|
||||||
|
+
|
||||||
|
+ classes = []
|
||||||
|
+ for class_api in api["classes"]:
|
||||||
|
+ if not is_class_included(class_api["name"], build_profile):
|
||||||
|
+ continue
|
||||||
|
+ if "methods" in class_api:
|
||||||
|
+ methods = []
|
||||||
|
+ for method in class_api["methods"]:
|
||||||
|
+ if not is_method_included(method, build_profile, engine_classes):
|
||||||
|
+ continue
|
||||||
|
+ methods.append(method)
|
||||||
|
+ class_api["methods"] = methods
|
||||||
|
+ classes.append(class_api)
|
||||||
|
+ api["classes"] = classes
|
||||||
|
+
|
||||||
|
+ return api
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+def is_class_included(class_name, build_profile):
|
||||||
|
+ """
|
||||||
|
+ Check if an engine class should be included.
|
||||||
|
+ This removes classes according to a build profile of enabled or disabled classes.
|
||||||
|
+ """
|
||||||
|
+ included = build_profile.get("enabled_classes", [])
|
||||||
|
+ excluded = build_profile.get("disabled_classes", [])
|
||||||
|
+ if included:
|
||||||
|
+ return class_name in included
|
||||||
|
+ if excluded:
|
||||||
|
+ return class_name not in excluded
|
||||||
|
+ return True
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+def is_method_included(method, build_profile, engine_classes):
|
||||||
|
+ """
|
||||||
|
+ Check if an engine class method should be included.
|
||||||
|
+ This removes methods according to a build profile of enabled or disabled classes.
|
||||||
|
+ """
|
||||||
|
+ included = build_profile.get("enabled_classes", [])
|
||||||
|
+ excluded = build_profile.get("disabled_classes", [])
|
||||||
|
+ ref_cls = set()
|
||||||
|
+ rtype = get_base_type(method.get("return_value", {}).get("type", ""))
|
||||||
|
+ args = [get_base_type(a["type"]) for a in method.get("arguments", [])]
|
||||||
|
+ if rtype in engine_classes:
|
||||||
|
+ ref_cls.add(rtype)
|
||||||
|
+ elif is_enum(rtype) and get_enum_class(rtype) in engine_classes:
|
||||||
|
+ ref_cls.add(get_enum_class(rtype))
|
||||||
|
+ for arg in args:
|
||||||
|
+ if arg in engine_classes:
|
||||||
|
+ ref_cls.add(arg)
|
||||||
|
+ elif is_enum(arg) and get_enum_class(arg) in engine_classes:
|
||||||
|
+ ref_cls.add(get_enum_class(arg))
|
||||||
|
+ for acls in ref_cls:
|
||||||
|
+ if len(included) > 0 and acls not in included:
|
||||||
|
+ return False
|
||||||
|
+ elif len(excluded) > 0 and acls in excluded:
|
||||||
|
+ return False
|
||||||
|
+ return True
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+def is_enum(type_name):
|
||||||
|
+ return type_name.startswith("enum::") or type_name.startswith("bitfield::")
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+def get_enum_class(enum_name: str):
|
||||||
|
+ if "." in enum_name:
|
||||||
|
+ if is_bitfield(enum_name):
|
||||||
|
+ return enum_name.replace("bitfield::", "").split(".")[0]
|
||||||
|
+ else:
|
||||||
|
+ return enum_name.replace("enum::", "").split(".")[0]
|
||||||
|
+ else:
|
||||||
|
+ return "GlobalConstants"
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+def get_base_type(type_name):
|
||||||
|
+ if type_name.startswith("const "):
|
||||||
|
+ type_name = type_name[6:]
|
||||||
|
+ if type_name.endswith("*"):
|
||||||
|
+ type_name = type_name[:-1]
|
||||||
|
+ if type_name.startswith("typedarray::"):
|
||||||
|
+ type_name = type_name.replace("typedarray::", "")
|
||||||
|
+ return type_name
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+def is_bitfield(type_name):
|
||||||
|
+ return type_name.startswith("bitfield::")
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+if __name__ == "__main__":
|
||||||
|
+ if len(sys.argv) < 3 or len(sys.argv) > 4:
|
||||||
|
+ print("Usage: %s BUILD_PROFILE INPUT_JSON [OUTPUT_JSON]" % (sys.argv[0]))
|
||||||
|
+ sys.exit(1)
|
||||||
|
+ profile = sys.argv[1]
|
||||||
|
+ infile = sys.argv[2]
|
||||||
|
+ outfile = sys.argv[3] if len(sys.argv) > 3 else ""
|
||||||
|
+ api = generate_trimmed_api(infile, profile)
|
||||||
|
+
|
||||||
|
+ if outfile:
|
||||||
|
+ with open(outfile, "w", encoding="utf-8") as f:
|
||||||
|
+ json.dump(api, f)
|
||||||
|
+ else:
|
||||||
|
+ json.dump(api, sys.stdout)
|
||||||
|
diff --git a/godot-cpp/tools/godotcpp.py b/godot-cpp/tools/godotcpp.py
|
||||||
|
index efe632a..993aa81 100644
|
||||||
|
--- a/godot-cpp/tools/godotcpp.py
|
||||||
|
+++ b/godot-cpp/tools/godotcpp.py
|
||||||
|
@@ -5,7 +5,8 @@ from SCons.Tool import Tool
|
||||||
|
from SCons.Builder import Builder
|
||||||
|
from SCons.Errors import UserError
|
||||||
|
|
||||||
|
-from binding_generator import scons_generate_bindings, scons_emit_files
|
||||||
|
+from binding_generator import _generate_bindings, _get_file_list, get_file_list
|
||||||
|
+from build_profile import generate_trimmed_api
|
||||||
|
|
||||||
|
|
||||||
|
def add_sources(sources, dir, extension):
|
||||||
|
@@ -14,6 +15,37 @@ def add_sources(sources, dir, extension):
|
||||||
|
sources.append(dir + "/" + f)
|
||||||
|
|
||||||
|
|
||||||
|
+def scons_emit_files(target, source, env):
|
||||||
|
+ profile_filepath = env.get("build_profile", "")
|
||||||
|
+ if profile_filepath:
|
||||||
|
+ profile_filepath = normalize_path(profile_filepath, env)
|
||||||
|
+
|
||||||
|
+ # Always clean all files
|
||||||
|
+ env.Clean(target, [env.File(f) for f in get_file_list(str(source[0]), target[0].abspath, True, True)])
|
||||||
|
+
|
||||||
|
+ api = generate_trimmed_api(str(source[0]), profile_filepath)
|
||||||
|
+ files = [env.File(f) for f in _get_file_list(api, target[0].abspath, True, True)]
|
||||||
|
+ env["godot_cpp_gen_dir"] = target[0].abspath
|
||||||
|
+ return files, source
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+def scons_generate_bindings(target, source, env):
|
||||||
|
+ profile_filepath = env.get("build_profile", "")
|
||||||
|
+ if profile_filepath:
|
||||||
|
+ profile_filepath = normalize_path(profile_filepath, env)
|
||||||
|
+
|
||||||
|
+ api = generate_trimmed_api(str(source[0]), profile_filepath)
|
||||||
|
+
|
||||||
|
+ _generate_bindings(
|
||||||
|
+ api,
|
||||||
|
+ env["generate_template_get_node"],
|
||||||
|
+ "32" if "32" in env["arch"] else "64",
|
||||||
|
+ env["precision"],
|
||||||
|
+ env["godot_cpp_gen_dir"],
|
||||||
|
+ )
|
||||||
|
+ return None
|
||||||
|
+
|
||||||
|
+
|
||||||
|
def normalize_path(val, env):
|
||||||
|
return val if os.path.isabs(val) else os.path.join(env.Dir("#").abspath, val)
|
||||||
|
|
||||||
|
@@ -175,6 +207,15 @@ def options(opts, env):
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
+ opts.Add(
|
||||||
|
+ PathVariable(
|
||||||
|
+ "build_profile",
|
||||||
|
+ "Path to a file containing a feature build profile",
|
||||||
|
+ default=env.get("build_profile", None),
|
||||||
|
+ validator=validate_file,
|
||||||
|
+ )
|
||||||
|
+ )
|
||||||
|
+
|
||||||
|
opts.Add(
|
||||||
|
BoolVariable(
|
||||||
|
"disable_exceptions",
|
||||||
286
misc/patches/build_profile_3.x.diff
Normal file
286
misc/patches/build_profile_3.x.diff
Normal file
@@ -0,0 +1,286 @@
|
|||||||
|
diff --git a/godot-cpp-3.x/SConstruct b/godot-cpp-3.x/SConstruct
|
||||||
|
index f653d54..483f190 100644
|
||||||
|
--- a/godot-cpp-3.x/SConstruct
|
||||||
|
+++ b/godot-cpp-3.x/SConstruct
|
||||||
|
@@ -3,7 +3,42 @@
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import subprocess
|
||||||
|
-from binding_generator import scons_generate_bindings, scons_emit_files
|
||||||
|
+from binding_generator import _generate_bindings, _get_file_list, get_file_list
|
||||||
|
+from build_profile import generate_trimmed_api
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+def normalize_path(val):
|
||||||
|
+ return val if os.path.isabs(val) else os.path.join(env.Dir("#").abspath, val)
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+def scons_emit_files(target, source, env):
|
||||||
|
+ profile_filepath = env.get("build_profile", "")
|
||||||
|
+ if profile_filepath:
|
||||||
|
+ profile_filepath = normalize_path(profile_filepath)
|
||||||
|
+
|
||||||
|
+ # Always clean all files
|
||||||
|
+ env.Clean(target, [env.File(f) for f in get_file_list(str(source[0]), target[0].abspath, True, True)])
|
||||||
|
+
|
||||||
|
+ api = generate_trimmed_api(str(source[0]), profile_filepath)
|
||||||
|
+ files = [env.File(f) for f in _get_file_list(api, target[0].abspath, True, True)]
|
||||||
|
+ env["godot_cpp_gen_dir"] = target[0].abspath
|
||||||
|
+ return files, source
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+def scons_generate_bindings(target, source, env):
|
||||||
|
+ profile_filepath = env.get("build_profile", "")
|
||||||
|
+ if profile_filepath:
|
||||||
|
+ profile_filepath = normalize_path(profile_filepath)
|
||||||
|
+
|
||||||
|
+ api = generate_trimmed_api(str(source[0]), profile_filepath)
|
||||||
|
+
|
||||||
|
+ _generate_bindings(
|
||||||
|
+ api,
|
||||||
|
+ env["generate_template_get_node"],
|
||||||
|
+ env["godot_cpp_gen_dir"],
|
||||||
|
+ )
|
||||||
|
+ return None
|
||||||
|
+
|
||||||
|
|
||||||
|
if sys.version_info < (3,):
|
||||||
|
|
||||||
|
@@ -170,6 +205,14 @@ opts.Add(
|
||||||
|
True,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
+opts.Add(
|
||||||
|
+ PathVariable(
|
||||||
|
+ "build_profile",
|
||||||
|
+ "Path to a file containing a feature build profile",
|
||||||
|
+ default=env.get("build_profile", None),
|
||||||
|
+ validator=lambda key, val, env: os.path.isfile(normalize_path(val)),
|
||||||
|
+ )
|
||||||
|
+)
|
||||||
|
|
||||||
|
opts.Add(BoolVariable("build_library", "Build the godot-cpp library.", True))
|
||||||
|
|
||||||
|
diff --git a/godot-cpp-3.x/binding_generator.py b/godot-cpp-3.x/binding_generator.py
|
||||||
|
index da4bb61..1348a51 100644
|
||||||
|
--- a/godot-cpp-3.x/binding_generator.py
|
||||||
|
+++ b/godot-cpp-3.x/binding_generator.py
|
||||||
|
@@ -16,10 +16,16 @@ classes = []
|
||||||
|
|
||||||
|
|
||||||
|
def get_file_list(api_filepath, output_dir, headers=False, sources=False):
|
||||||
|
- global classes
|
||||||
|
- files = []
|
||||||
|
+ api = {}
|
||||||
|
with open(api_filepath) as api_file:
|
||||||
|
classes = json.load(api_file)
|
||||||
|
+ return _get_file_list(classes, output_dir, headers, sources)
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+def _get_file_list(api, output_dir, headers=False, sources=False):
|
||||||
|
+ global classes
|
||||||
|
+ classes = api
|
||||||
|
+ files = []
|
||||||
|
include_gen_folder = Path(output_dir) / "include" / "gen"
|
||||||
|
source_gen_folder = Path(output_dir) / "src" / "gen"
|
||||||
|
for _class in classes:
|
||||||
|
@@ -58,9 +64,15 @@ def scons_generate_bindings(target, source, env):
|
||||||
|
|
||||||
|
|
||||||
|
def generate_bindings(api_filepath, use_template_get_node, output_dir="."):
|
||||||
|
- global classes
|
||||||
|
+ classes = {}
|
||||||
|
with open(api_filepath) as api_file:
|
||||||
|
classes = json.load(api_file)
|
||||||
|
+ _generate_bindings(classes, use_template_get_node, output_dir)
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+def _generate_bindings(api, use_template_get_node, output_dir="."):
|
||||||
|
+ global classes
|
||||||
|
+ classes = api
|
||||||
|
|
||||||
|
icalls = set()
|
||||||
|
include_gen_folder = Path(output_dir) / "include" / "gen"
|
||||||
|
diff --git a/godot-cpp-3.x/build_profile.py b/godot-cpp-3.x/build_profile.py
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..5518f64
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/godot-cpp-3.x/build_profile.py
|
||||||
|
@@ -0,0 +1,177 @@
|
||||||
|
+import json
|
||||||
|
+import sys
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+def parse_build_profile(profile_filepath, api):
|
||||||
|
+ if profile_filepath == "":
|
||||||
|
+ return {}
|
||||||
|
+
|
||||||
|
+ with open(profile_filepath, encoding="utf-8") as profile_file:
|
||||||
|
+ profile = json.load(profile_file)
|
||||||
|
+
|
||||||
|
+ api_dict = {}
|
||||||
|
+ parents = {}
|
||||||
|
+ children = {}
|
||||||
|
+ for engine_class in api:
|
||||||
|
+ api_dict[engine_class["name"]] = engine_class
|
||||||
|
+ parent = engine_class.get("base_class", "")
|
||||||
|
+ child = engine_class["name"]
|
||||||
|
+ parents[child] = parent
|
||||||
|
+ if parent == "":
|
||||||
|
+ continue
|
||||||
|
+ children[parent] = children.get(parent, [])
|
||||||
|
+ children[parent].append(child)
|
||||||
|
+
|
||||||
|
+ included = []
|
||||||
|
+ front = list(profile.get("enabled_classes", []))
|
||||||
|
+ if front:
|
||||||
|
+ # These must always be included
|
||||||
|
+ front.append("WorkerThreadPool")
|
||||||
|
+ front.append("ClassDB")
|
||||||
|
+ front.append("ClassDBSingleton")
|
||||||
|
+ # In src/classes/low_level.cpp
|
||||||
|
+ front.append("FileAccess")
|
||||||
|
+ front.append("Image")
|
||||||
|
+ front.append("XMLParser")
|
||||||
|
+ # In include/godot_cpp/templates/thread_work_pool.hpp
|
||||||
|
+ front.append("Semaphore")
|
||||||
|
+ while front:
|
||||||
|
+ cls = front.pop()
|
||||||
|
+ if cls in included:
|
||||||
|
+ continue
|
||||||
|
+ included.append(cls)
|
||||||
|
+ parent = parents.get(cls, "")
|
||||||
|
+ if parent:
|
||||||
|
+ front.append(parent)
|
||||||
|
+
|
||||||
|
+ excluded = []
|
||||||
|
+ front = list(profile.get("disabled_classes", []))
|
||||||
|
+ while front:
|
||||||
|
+ cls = front.pop()
|
||||||
|
+ if cls in excluded:
|
||||||
|
+ continue
|
||||||
|
+ excluded.append(cls)
|
||||||
|
+ front += children.get(cls, [])
|
||||||
|
+
|
||||||
|
+ if included and excluded:
|
||||||
|
+ print(
|
||||||
|
+ "WARNING: Cannot specify both 'enabled_classes' and 'disabled_classes' in build profile. 'disabled_classes' will be ignored."
|
||||||
|
+ )
|
||||||
|
+
|
||||||
|
+ return {
|
||||||
|
+ "enabled_classes": included,
|
||||||
|
+ "disabled_classes": excluded,
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+def generate_trimmed_api(source_api_filepath, profile_filepath):
|
||||||
|
+ with open(source_api_filepath, encoding="utf-8") as api_file:
|
||||||
|
+ api = json.load(api_file)
|
||||||
|
+
|
||||||
|
+ if profile_filepath == "":
|
||||||
|
+ return api
|
||||||
|
+
|
||||||
|
+ build_profile = parse_build_profile(profile_filepath, api)
|
||||||
|
+
|
||||||
|
+ engine_classes = {}
|
||||||
|
+ for class_api in api:
|
||||||
|
+ engine_classes[class_api["name"]] = class_api["is_reference"]
|
||||||
|
+
|
||||||
|
+ classes = []
|
||||||
|
+ for class_api in api:
|
||||||
|
+ if not is_class_included(class_api["name"], build_profile):
|
||||||
|
+ continue
|
||||||
|
+ if "methods" in class_api:
|
||||||
|
+ methods = []
|
||||||
|
+ for method in class_api["methods"]:
|
||||||
|
+ if not is_method_included(method, build_profile, engine_classes):
|
||||||
|
+ continue
|
||||||
|
+ methods.append(method)
|
||||||
|
+ class_api["methods"] = methods
|
||||||
|
+ classes.append(class_api)
|
||||||
|
+ return classes
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+def is_class_included(class_name, build_profile):
|
||||||
|
+ """
|
||||||
|
+ Check if an engine class should be included.
|
||||||
|
+ This removes classes according to a build profile of enabled or disabled classes.
|
||||||
|
+ """
|
||||||
|
+ included = build_profile.get("enabled_classes", [])
|
||||||
|
+ excluded = build_profile.get("disabled_classes", [])
|
||||||
|
+ if included:
|
||||||
|
+ return class_name in included
|
||||||
|
+ if excluded:
|
||||||
|
+ return class_name not in excluded
|
||||||
|
+ return True
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+def is_method_included(method, build_profile, engine_classes):
|
||||||
|
+ """
|
||||||
|
+ Check if an engine class method should be included.
|
||||||
|
+ This removes methods according to a build profile of enabled or disabled classes.
|
||||||
|
+ """
|
||||||
|
+ included = build_profile.get("enabled_classes", [])
|
||||||
|
+ excluded = build_profile.get("disabled_classes", [])
|
||||||
|
+ ref_cls = set()
|
||||||
|
+ rtype = get_base_type(method.get("return_type", ""))
|
||||||
|
+ args = [get_base_type(a["type"]) for a in method.get("arguments", [])]
|
||||||
|
+ if rtype in engine_classes:
|
||||||
|
+ ref_cls.add(rtype)
|
||||||
|
+ elif is_enum(rtype) and get_enum_class(rtype) in engine_classes:
|
||||||
|
+ ref_cls.add(get_enum_class(rtype))
|
||||||
|
+ for arg in args:
|
||||||
|
+ if arg in engine_classes:
|
||||||
|
+ ref_cls.add(arg)
|
||||||
|
+ elif is_enum(arg) and get_enum_class(arg) in engine_classes:
|
||||||
|
+ ref_cls.add(get_enum_class(arg))
|
||||||
|
+ for acls in ref_cls:
|
||||||
|
+ if len(included) > 0 and acls not in included:
|
||||||
|
+ return False
|
||||||
|
+ elif len(excluded) > 0 and acls in excluded:
|
||||||
|
+ return False
|
||||||
|
+ return True
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+def is_enum(type_name):
|
||||||
|
+ return type_name.startswith("enum::") or type_name.startswith("bitfield::")
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+def get_enum_class(enum_name: str):
|
||||||
|
+ if "." in enum_name:
|
||||||
|
+ if is_bitfield(enum_name):
|
||||||
|
+ return enum_name.replace("bitfield::", "").split(".")[0]
|
||||||
|
+ else:
|
||||||
|
+ return enum_name.replace("enum::", "").split(".")[0]
|
||||||
|
+ else:
|
||||||
|
+ return "GlobalConstants"
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+def get_base_type(type_name):
|
||||||
|
+ if type_name.startswith("const "):
|
||||||
|
+ type_name = type_name[6:]
|
||||||
|
+ if type_name.endswith("*"):
|
||||||
|
+ type_name = type_name[:-1]
|
||||||
|
+ if type_name.startswith("typedarray::"):
|
||||||
|
+ type_name = type_name.replace("typedarray::", "")
|
||||||
|
+ return type_name
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+def is_bitfield(type_name):
|
||||||
|
+ return type_name.startswith("bitfield::")
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+if __name__ == "__main__":
|
||||||
|
+ if len(sys.argv) < 3 or len(sys.argv) > 4:
|
||||||
|
+ print("Usage: %s BUILD_PROFILE INPUT_JSON [OUTPUT_JSON]" % (sys.argv[0]))
|
||||||
|
+ sys.exit(1)
|
||||||
|
+ profile = sys.argv[1]
|
||||||
|
+ infile = sys.argv[2]
|
||||||
|
+ outfile = sys.argv[3] if len(sys.argv) > 3 else ""
|
||||||
|
+ api = generate_trimmed_api(infile, profile)
|
||||||
|
+
|
||||||
|
+ if outfile:
|
||||||
|
+ with open(outfile, "w", encoding="utf-8") as f:
|
||||||
|
+ json.dump(api, f)
|
||||||
|
+ else:
|
||||||
|
+ json.dump(api, sys.stdout)
|
||||||
@@ -1,17 +1,3 @@
|
|||||||
diff --git a/godot-cpp-4.0/SConstruct b/godot-cpp-4.0/SConstruct
|
|
||||||
index 27ee137..32b425e 100644
|
|
||||||
--- a/godot-cpp-4.0/SConstruct
|
|
||||||
+++ b/godot-cpp-4.0/SConstruct
|
|
||||||
@@ -54,6 +54,8 @@ else:
|
|
||||||
# Default tools with no platform defaults to gnu toolchain.
|
|
||||||
# We apply platform specific toolchains via our custom tools.
|
|
||||||
env = Environment(tools=["default"], PLATFORM="")
|
|
||||||
+# Allows us to use Godot buildroot toolchain
|
|
||||||
+env.PrependENVPath("PATH", os.getenv("PATH"))
|
|
||||||
|
|
||||||
# Default num_jobs to local cpu count if not user specified.
|
|
||||||
# SCons has a peculiarity where user-specified options won't be overridden
|
|
||||||
|
|
||||||
diff --git a/godot-cpp-3.x/SConstruct b/godot-cpp-3.x/SConstruct
|
diff --git a/godot-cpp-3.x/SConstruct b/godot-cpp-3.x/SConstruct
|
||||||
index f653d54..6f40377 100644
|
index f653d54..6f40377 100644
|
||||||
--- a/godot-cpp-3.x/SConstruct
|
--- a/godot-cpp-3.x/SConstruct
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
[configuration]
|
[configuration]
|
||||||
|
|
||||||
entry_symbol = "webrtc_extension_init"
|
entry_symbol = "webrtc_extension_init"
|
||||||
compatibility_minimum = {GODOT_VERSION}
|
compatibility_minimum = 4.1
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
|
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ Error WebRTCLibPeerConnection::_initialize(const Dictionary &p_config) {
|
|||||||
return _create_pc(config);
|
return _create_pc(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(GDNATIVE_WEBRTC) || defined(GDEXTENSION_WEBRTC_40)
|
#if defined(GDNATIVE_WEBRTC)
|
||||||
Object *WebRTCLibPeerConnection::_create_data_channel(const String &p_channel, const Dictionary &p_channel_config) try {
|
Object *WebRTCLibPeerConnection::_create_data_channel(const String &p_channel, const Dictionary &p_channel_config) try {
|
||||||
#else
|
#else
|
||||||
Ref<WebRTCDataChannel> WebRTCLibPeerConnection::_create_data_channel(const String &p_channel, const Dictionary &p_channel_config) try {
|
Ref<WebRTCDataChannel> WebRTCLibPeerConnection::_create_data_channel(const String &p_channel, const Dictionary &p_channel_config) try {
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ public:
|
|||||||
SignalingState _get_signaling_state() const override;
|
SignalingState _get_signaling_state() const override;
|
||||||
|
|
||||||
godot::Error _initialize(const godot::Dictionary &p_config) override;
|
godot::Error _initialize(const godot::Dictionary &p_config) override;
|
||||||
#if defined(GDNATIVE_WEBRTC) || defined(GDEXTENSION_WEBRTC_40)
|
#if defined(GDNATIVE_WEBRTC)
|
||||||
godot::Object *_create_data_channel(const godot::String &p_channel, const godot::Dictionary &p_channel_config) override;
|
godot::Object *_create_data_channel(const godot::String &p_channel, const godot::Dictionary &p_channel_config) override;
|
||||||
#else
|
#else
|
||||||
godot::Ref<godot::WebRTCDataChannel> _create_data_channel(const godot::String &p_channel, const godot::Dictionary &p_channel_config) override;
|
godot::Ref<godot::WebRTCDataChannel> _create_data_channel(const godot::String &p_channel, const godot::Dictionary &p_channel_config) override;
|
||||||
|
|||||||
@@ -66,11 +66,7 @@ void unregister_webrtc_extension_types(ModuleInitializationLevel p_level) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#ifdef GDEXTENSION_WEBRTC_40
|
|
||||||
GDExtensionBool GDE_EXPORT webrtc_extension_init(const GDExtensionInterface *p_interface, const GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) {
|
|
||||||
#else
|
|
||||||
GDExtensionBool GDE_EXPORT webrtc_extension_init(const GDExtensionInterfaceGetProcAddress p_interface, const GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) {
|
GDExtensionBool GDE_EXPORT webrtc_extension_init(const GDExtensionInterfaceGetProcAddress p_interface, const GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) {
|
||||||
#endif
|
|
||||||
GDExtensionBinding::InitObject init_obj(p_interface, p_library, r_initialization);
|
GDExtensionBinding::InitObject init_obj(p_interface, p_library, r_initialization);
|
||||||
|
|
||||||
init_obj.register_initializer(register_webrtc_extension_types);
|
init_obj.register_initializer(register_webrtc_extension_types);
|
||||||
|
|||||||
23
thirdparty/README.md
vendored
23
thirdparty/README.md
vendored
@@ -5,21 +5,10 @@ respective folder names. Use two empty lines to separate categories for
|
|||||||
readability.
|
readability.
|
||||||
|
|
||||||
|
|
||||||
## json
|
|
||||||
|
|
||||||
- Upstream: https://github.com/nlohmann/json
|
|
||||||
- Version: 3.11.3 (9cca280a4d0ccf0c08f47a99aa71d1b0e52f8d03, 2023)
|
|
||||||
- License: MIT
|
|
||||||
|
|
||||||
Module location:
|
|
||||||
|
|
||||||
- thirdparty/libdatachannel/deps/json
|
|
||||||
|
|
||||||
|
|
||||||
## libdatachannel
|
## libdatachannel
|
||||||
|
|
||||||
- Upstream: https://github.com/paullouisageneau/libdatachannel
|
- Upstream: https://github.com/paullouisageneau/libdatachannel
|
||||||
- Version: 0.20.2 (0b1074a9effeb8d9d3f4eca704d3fe3d2f9bc7e5, 2024)
|
- Version: 0.22.6 (0d6adc021953d7263fd4503482ea7bde33553724, 2025)
|
||||||
- License: MPL 2.0
|
- License: MPL 2.0
|
||||||
|
|
||||||
Module location:
|
Module location:
|
||||||
@@ -30,7 +19,7 @@ Module location:
|
|||||||
# libjuice
|
# libjuice
|
||||||
|
|
||||||
- Upstream: https://github.com/paullouisageneau/libjuice
|
- Upstream: https://github.com/paullouisageneau/libjuice
|
||||||
- Version: 1.3.4 (0b6f958baba55e1a4eb31ec2137f62b2e07382ae, 2024)
|
- Version: 1.5.9 (8d1a99a0683a811876c03a73ff764a92774027ad, 2025)
|
||||||
- License: MPL 2.0
|
- License: MPL 2.0
|
||||||
|
|
||||||
Module location:
|
Module location:
|
||||||
@@ -49,15 +38,15 @@ Module location:
|
|||||||
- thirdparty/libdatachannel/deps/libsrtp
|
- thirdparty/libdatachannel/deps/libsrtp
|
||||||
|
|
||||||
|
|
||||||
## openssl
|
## mbedTLS
|
||||||
|
|
||||||
- Upstream: git://git.openssl.org/openssl.git
|
- Upstream: https://github.com/Mbed-TLS/mbedtls.git
|
||||||
- Version: 3.0.13 (85cf92f55d9e2ac5aacf92bedd33fb890b9f8b4c, 2024)
|
- Version: 3.6.3 (22098d41c6620ce07cf8a0134d37302355e1e5ef, 2025)
|
||||||
- License: Apache 2.0
|
- License: Apache 2.0
|
||||||
|
|
||||||
Module location:
|
Module location:
|
||||||
|
|
||||||
- thirdparty/openssl
|
- thirdparty/mbedtls
|
||||||
|
|
||||||
|
|
||||||
## plog
|
## plog
|
||||||
|
|||||||
2
thirdparty/libdatachannel
vendored
2
thirdparty/libdatachannel
vendored
Submodule thirdparty/libdatachannel updated: 0b1074a9ef...0d6adc0219
1
thirdparty/mbedtls
vendored
Submodule
1
thirdparty/mbedtls
vendored
Submodule
Submodule thirdparty/mbedtls added at 22098d41c6
1
thirdparty/openssl
vendored
1
thirdparty/openssl
vendored
Submodule thirdparty/openssl deleted from 85cf92f55d
@@ -1,13 +1,20 @@
|
|||||||
import os, sys
|
import os
|
||||||
|
import shlex
|
||||||
|
import sys
|
||||||
|
|
||||||
import SCons.Util
|
|
||||||
import SCons.Builder
|
|
||||||
import SCons.Action
|
import SCons.Action
|
||||||
|
import SCons.Builder
|
||||||
|
import SCons.Util
|
||||||
|
|
||||||
|
|
||||||
|
# This must be kept in sync with the value in https://github.com/godotengine/godot/blob/master/platform/android/detect.py#L58.
|
||||||
|
def get_ndk_version():
|
||||||
|
return "23.2.8568313"
|
||||||
|
|
||||||
|
|
||||||
def cmake_default_flags(env):
|
def cmake_default_flags(env):
|
||||||
if env.get("cmake_default_flags", ""):
|
if env.get("cmake_default_flags", ""):
|
||||||
return SCons.Util.CLVar(env["cmake_default_flags"])
|
return shlex.split(env["cmake_default_flags"])
|
||||||
|
|
||||||
config = {}
|
config = {}
|
||||||
|
|
||||||
@@ -28,9 +35,8 @@ def cmake_default_flags(env):
|
|||||||
config["CMAKE_SYSTEM_VERSION"] = api
|
config["CMAKE_SYSTEM_VERSION"] = api
|
||||||
config["CMAKE_ANDROID_ARCH_ABI"] = abi
|
config["CMAKE_ANDROID_ARCH_ABI"] = abi
|
||||||
config["ANDROID_ABI"] = abi
|
config["ANDROID_ABI"] = abi
|
||||||
config["CMAKE_TOOLCHAIN_FILE"] = "%s/build/cmake/android.toolchain.cmake" % env.get(
|
ndk_root = os.environ.get("ANDROID_NDK_ROOT", env.get("ANDROID_HOME", "") + "/ndk/" + get_ndk_version())
|
||||||
"ANDROID_NDK_ROOT", os.environ.get("ANDROID_NDK_ROOT", "")
|
config["CMAKE_TOOLCHAIN_FILE"] = "%s/build/cmake/android.toolchain.cmake" % ndk_root
|
||||||
)
|
|
||||||
config["CMAKE_ANDROID_STL_TYPE"] = "c++_static"
|
config["CMAKE_ANDROID_STL_TYPE"] = "c++_static"
|
||||||
|
|
||||||
elif env["platform"] == "linux":
|
elif env["platform"] == "linux":
|
||||||
@@ -49,10 +55,9 @@ def cmake_default_flags(env):
|
|||||||
config["CMAKE_OSX_ARCHITECTURES"] = '"x86_64;arm64"'
|
config["CMAKE_OSX_ARCHITECTURES"] = '"x86_64;arm64"'
|
||||||
else:
|
else:
|
||||||
config["CMAKE_OSX_ARCHITECTURES"] = env["arch"]
|
config["CMAKE_OSX_ARCHITECTURES"] = env["arch"]
|
||||||
if env["macos_deployment_target"] != "default":
|
if env.get("macos_deployment_target", "default") != "default":
|
||||||
config["CMAKE_OSX_DEPLOYMENT_TARGET"] = env["macos_deployment_target"]
|
config["CMAKE_OSX_DEPLOYMENT_TARGET"] = env["macos_deployment_target"]
|
||||||
|
if sys.platform != "darwin" and "OSXCROSS_ROOT" in os.environ:
|
||||||
if env["platform"] == "macos" and sys.platform != "darwin" and "OSXCROSS_ROOT" in os.environ:
|
|
||||||
config["CMAKE_AR"] = env["AR"]
|
config["CMAKE_AR"] = env["AR"]
|
||||||
config["CMAKE_RANLIB"] = env["RANLIB"]
|
config["CMAKE_RANLIB"] = env["RANLIB"]
|
||||||
if env["arch"] == "universal":
|
if env["arch"] == "universal":
|
||||||
@@ -76,18 +81,17 @@ def cmake_default_flags(env):
|
|||||||
|
|
||||||
elif env["platform"] == "windows":
|
elif env["platform"] == "windows":
|
||||||
config["CMAKE_SYSTEM_NAME"] = "Windows"
|
config["CMAKE_SYSTEM_NAME"] = "Windows"
|
||||||
|
|
||||||
flags = ["-D%s=%s" % it for it in config.items()]
|
|
||||||
if env["CMAKEGENERATOR"]:
|
|
||||||
flags.extend(["-G", env["CMAKEGENERATOR"]])
|
|
||||||
elif env["platform"] == "windows":
|
|
||||||
if env.get("is_msvc", False):
|
if env.get("is_msvc", False):
|
||||||
flags.extend(["-G", "NMake Makefiles"])
|
config["CMAKE_POLICY_DEFAULT_CMP0091"] = "NEW"
|
||||||
elif sys.platform in ["win32", "msys", "cygwin"]:
|
if env.get("debug_crt", False):
|
||||||
flags.extend(["-G", "Ninja"])
|
config["CMAKE_MSVC_RUNTIME_LIBRARY"] = "MultiThreadedDebugDLL"
|
||||||
else:
|
else:
|
||||||
flags.extend(["-G", "Unix Makefiles"])
|
if env.get("use_static_cpp", False):
|
||||||
return flags
|
config["CMAKE_MSVC_RUNTIME_LIBRARY"] = "MultiThreaded"
|
||||||
|
else:
|
||||||
|
config["CMAKE_MSVC_RUNTIME_LIBRARY"] = "MultiThreadedDLL"
|
||||||
|
|
||||||
|
return ["-D%s=%s" % it for it in config.items()]
|
||||||
|
|
||||||
|
|
||||||
def cmake_emitter(target, source, env):
|
def cmake_emitter(target, source, env):
|
||||||
@@ -97,26 +101,63 @@ def cmake_emitter(target, source, env):
|
|||||||
def cmake_generator(target, source, env, for_signature):
|
def cmake_generator(target, source, env, for_signature):
|
||||||
# Strip the -j option for signature to avoid rebuilding when num_jobs changes.
|
# Strip the -j option for signature to avoid rebuilding when num_jobs changes.
|
||||||
build = env["CMAKEBUILDCOM"].replace("-j$CMAKEBUILDJOBS", "") if for_signature else env["CMAKEBUILDCOM"]
|
build = env["CMAKEBUILDCOM"].replace("-j$CMAKEBUILDJOBS", "") if for_signature else env["CMAKEBUILDCOM"]
|
||||||
return [
|
actions = [
|
||||||
SCons.Action.Action("$CMAKECONFCOM", "$CMAKECONFCOMSTR"),
|
SCons.Action.Action("$CMAKECONFCOM", "$CMAKECONFCOMSTR"),
|
||||||
SCons.Action.Action(build, "$CMAKEBUILDCOMSTR"),
|
SCons.Action.Action(build, "$CMAKEBUILDCOMSTR"),
|
||||||
]
|
]
|
||||||
|
if env["CMAKE_INSTALL"]:
|
||||||
|
actions.append(
|
||||||
|
SCons.Action.Action("$CMAKEINSTALLCOM", "$CMAKEINSTALLCOMSTR"),
|
||||||
|
)
|
||||||
|
return actions
|
||||||
|
|
||||||
|
|
||||||
def cmake_build(env, target_dir, source_dir, cmake_outputs=[], cmake_targets=[], cmake_options=[], dependencies=[]):
|
def cmake_build(
|
||||||
|
env, target_dir, source_dir, cmake_outputs=[], cmake_targets=[], cmake_options=[], dependencies=[], install=False
|
||||||
|
):
|
||||||
cmake_env = env.Clone()
|
cmake_env = env.Clone()
|
||||||
target = env.Dir("{}/{}/{}".format(target_dir, env["platform"], env["arch"]))
|
target = env.Dir("{}/{}/{}".format(target_dir, env["platform"], env["arch"]))
|
||||||
source = env.Dir(source_dir)
|
source = env.Dir(source_dir)
|
||||||
builder_targets = [target] + [str(target) + "/" + f for f in cmake_outputs]
|
builder_targets = [target] + [str(target) + "/" + f for f in cmake_outputs]
|
||||||
builder_sources = [source] + dependencies
|
builder_sources = [source] + dependencies
|
||||||
cmake_env.Append(CMAKECONFFLAGS=["-D%s=%s" % it for it in cmake_options.items()])
|
default_flags = cmake_default_flags(env)
|
||||||
|
|
||||||
|
# Merge flags
|
||||||
|
flags = []
|
||||||
|
for df in default_flags:
|
||||||
|
if not df.startswith("-D"):
|
||||||
|
flags.append(df)
|
||||||
|
else:
|
||||||
|
f = df[2:].split("=")[0]
|
||||||
|
if f in cmake_options:
|
||||||
|
df += " " + cmake_options[f]
|
||||||
|
cmake_options.pop(f)
|
||||||
|
flags.append(df)
|
||||||
|
for opt in cmake_options:
|
||||||
|
flags.append("-D%s=%s" % (opt, cmake_options[opt]))
|
||||||
|
|
||||||
|
# Select generator
|
||||||
|
if env["cmake_generator"]:
|
||||||
|
flags.extend(["-G", env["cmake_generator"]])
|
||||||
|
elif env["platform"] == "windows":
|
||||||
|
if env.get("is_msvc", False):
|
||||||
|
flags.extend(["-G", "NMake Makefiles"])
|
||||||
|
elif sys.platform in ["win32", "msys", "cygwin"]:
|
||||||
|
flags.extend(["-G", "Ninja"])
|
||||||
|
else:
|
||||||
|
flags.extend(["-G", "Unix Makefiles"])
|
||||||
|
|
||||||
|
cmake_env.Append(CMAKECONFFLAGS=flags)
|
||||||
if len(cmake_targets) > 0:
|
if len(cmake_targets) > 0:
|
||||||
cmake_env.Append(CMAKEBUILDFLAGS=["-t"] + [t for t in cmake_targets])
|
cmake_env.Append(CMAKEBUILDFLAGS=["-t"] + [t for t in cmake_targets])
|
||||||
|
cmake_env["CMAKE_INSTALL"] = install
|
||||||
return cmake_env.CMake(builder_targets, builder_sources)
|
return cmake_env.CMake(builder_targets, builder_sources)
|
||||||
|
|
||||||
|
|
||||||
def options(opts):
|
def options(opts):
|
||||||
opts.Add("cmake_default_flags", "Default CMake platform flags override, will be autodetected if not specified.", "")
|
opts.Add("cmake_default_flags", "Default CMake platform flags override, will be autodetected if not specified.", "")
|
||||||
|
opts.Add("cmake_generator", "CMake generator override, will be autodetected from platform if not specified.", "")
|
||||||
|
opts.Add("cmake", "CMake binary to use", "cmake")
|
||||||
|
|
||||||
|
|
||||||
def exists(env):
|
def exists(env):
|
||||||
@@ -124,14 +165,13 @@ def exists(env):
|
|||||||
|
|
||||||
|
|
||||||
def generate(env):
|
def generate(env):
|
||||||
env["CMAKE"] = "cmake"
|
env["CMAKE"] = env["cmake"]
|
||||||
env["_cmake_default_flags"] = cmake_default_flags
|
|
||||||
env["CMAKEDEFAULTFLAGS"] = "${_cmake_default_flags(__env__)}"
|
|
||||||
env["CMAKEGENERATOR"] = ""
|
|
||||||
env["CMAKECONFFLAGS"] = SCons.Util.CLVar("")
|
env["CMAKECONFFLAGS"] = SCons.Util.CLVar("")
|
||||||
env["CMAKECONFCOM"] = "$CMAKE -B ${TARGET.dir} $CMAKEDEFAULTFLAGS $CMAKECONFFLAGS ${SOURCE.dir}"
|
env["CMAKECONFCOM"] = "$CMAKE -B ${TARGET.dir} $CMAKECONFFLAGS ${SOURCE.dir}"
|
||||||
env["CMAKEBUILDJOBS"] = "${__env__.GetOption('num_jobs')}"
|
env["CMAKEBUILDJOBS"] = "${__env__.GetOption('num_jobs')}"
|
||||||
env["CMAKEBUILDFLAGS"] = SCons.Util.CLVar("")
|
env["CMAKEBUILDFLAGS"] = SCons.Util.CLVar("")
|
||||||
|
env["CMAKEINSTALLFLAGS"] = SCons.Util.CLVar("")
|
||||||
env["CMAKEBUILDCOM"] = "$CMAKE --build ${TARGET.dir} $CMAKEBUILDFLAGS -j$CMAKEBUILDJOBS"
|
env["CMAKEBUILDCOM"] = "$CMAKE --build ${TARGET.dir} $CMAKEBUILDFLAGS -j$CMAKEBUILDJOBS"
|
||||||
|
env["CMAKEINSTALLCOM"] = "$CMAKE --install ${TARGET.dir} $CMAKEINSTALLFLAGS"
|
||||||
env["BUILDERS"]["CMake"] = SCons.Builder.Builder(generator=cmake_generator, emitter=cmake_emitter)
|
env["BUILDERS"]["CMake"] = SCons.Builder.Builder(generator=cmake_generator, emitter=cmake_emitter)
|
||||||
env.AddMethod(cmake_build, "CMakeBuild")
|
env.AddMethod(cmake_build, "CMakeBuild")
|
||||||
|
|||||||
69
tools/mbedtls.py
Normal file
69
tools/mbedtls.py
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
def build_library(env):
|
||||||
|
mbedtls_bin = env.Dir("bin/thirdparty/mbedtls/{}/{}/install".format(env["platform"], env["arch"]))
|
||||||
|
is_msvc = env.get("is_msvc", False)
|
||||||
|
c_flags = "-DMBEDTLS_SSL_DTLS_SRTP"
|
||||||
|
if env["platform"] == "linux":
|
||||||
|
# This is needed on some arch when building with the godot buildroot toolchain
|
||||||
|
c_flags += " -fPIC"
|
||||||
|
elif env["platform"] == "windows" and not is_msvc:
|
||||||
|
c_flags += " -D__USE_MINGW_ANSI_STDIO=0" # See https://github.com/Mbed-TLS/mbedtls/issues/10161
|
||||||
|
|
||||||
|
mbedtls_config = {
|
||||||
|
"CMAKE_BUILD_TYPE": "RelWithDebInfo" if env["debug_symbols"] else "Release",
|
||||||
|
"ENABLE_TESTING": 0,
|
||||||
|
"ENABLE_PROGRAMS": 0,
|
||||||
|
"CMAKE_INSTALL_PREFIX": env.Dir(mbedtls_bin).abspath,
|
||||||
|
"CMAKE_INSTALL_LIBDIR": "lib",
|
||||||
|
"CMAKE_C_FLAGS": c_flags,
|
||||||
|
"MBEDTLS_FATAL_WARNINGS": 0,
|
||||||
|
}
|
||||||
|
lib_ext = ".lib" if is_msvc else ".a"
|
||||||
|
lib_prefix = "" if is_msvc else "lib"
|
||||||
|
mbedtls_libs = [
|
||||||
|
"/install/lib/{}mbedtls{}".format(lib_prefix, lib_ext),
|
||||||
|
"/install/lib/{}mbedx509{}".format(lib_prefix, lib_ext),
|
||||||
|
"/install/lib/{}mbedcrypto{}".format(lib_prefix, lib_ext),
|
||||||
|
]
|
||||||
|
|
||||||
|
mbedtls_cmake_config = [
|
||||||
|
"/install/lib/cmake/MbedTLS/MbedTLSConfig.cmake",
|
||||||
|
"/install/lib/cmake/MbedTLS/MbedTLSConfigVersion.cmake",
|
||||||
|
"/install/lib/cmake/MbedTLS/MbedTLSTargets.cmake",
|
||||||
|
]
|
||||||
|
|
||||||
|
# Build libdatachannel
|
||||||
|
mbedtls = env.CMakeBuild(
|
||||||
|
env.Dir("bin/thirdparty/mbedtls/"),
|
||||||
|
env.Dir("thirdparty/mbedtls"),
|
||||||
|
cmake_options=mbedtls_config,
|
||||||
|
cmake_outputs=mbedtls_libs + mbedtls_cmake_config,
|
||||||
|
install=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Configure env.
|
||||||
|
if env["platform"] == "windows":
|
||||||
|
env.PrependUnique(LIBS=["bcrypt", "ws2_32", "iphlpapi"])
|
||||||
|
if env["platform"] == "linux":
|
||||||
|
env.PrependUnique(LIBS=["pthread"])
|
||||||
|
env.Prepend(LIBS=list(filter(lambda f: str(f).endswith(lib_ext), mbedtls)))
|
||||||
|
env.Append(CPPPATH=[env.Dir("thirdparty/mbedtls/include")])
|
||||||
|
|
||||||
|
return mbedtls
|
||||||
|
|
||||||
|
|
||||||
|
def exists(env):
|
||||||
|
return "CMake" in env
|
||||||
|
|
||||||
|
|
||||||
|
def generate(env):
|
||||||
|
mbedtls_install_dir = "bin/thirdparty/mbedtls/{}/{}/install".format(env["platform"], env["arch"])
|
||||||
|
lib_ext = ".lib" if env.get("is_msvc", False) else ".a"
|
||||||
|
mbedtls = env.File(mbedtls_install_dir + "/lib/libmbedtls" + lib_ext)
|
||||||
|
crypto = env.File(mbedtls_install_dir + "/lib/libmbedcrypto" + lib_ext)
|
||||||
|
x509 = env.File(mbedtls_install_dir + "/lib/libmbedx509" + lib_ext)
|
||||||
|
includes = env.Dir("thirdparty/mbedtls/include")
|
||||||
|
env.AddMethod(build_library, "BuildMbedTLS")
|
||||||
|
env["MBEDTLS_LIBRARY"] = mbedtls.abspath
|
||||||
|
env["MBEDTLS_CRYPTO_LIBRARY"] = crypto.abspath
|
||||||
|
env["MBEDTLS_X509_LIBRARY"] = x509.abspath
|
||||||
|
env["MBEDTLS_INCLUDE"] = includes.abspath
|
||||||
290
tools/openssl.py
290
tools/openssl.py
@@ -1,290 +0,0 @@
|
|||||||
import os, sys
|
|
||||||
import SCons.Util
|
|
||||||
import SCons.Builder
|
|
||||||
import SCons.Action
|
|
||||||
from SCons.Defaults import Mkdir
|
|
||||||
from SCons.Variables import PathVariable, BoolVariable
|
|
||||||
|
|
||||||
|
|
||||||
def ssl_platform_target(env):
|
|
||||||
targets = {}
|
|
||||||
platform = env["platform"]
|
|
||||||
if platform == "linux":
|
|
||||||
targets = {
|
|
||||||
"x86_32": "linux-x86",
|
|
||||||
"x86_64": "linux-x86_64",
|
|
||||||
"arm64": "linux-aarch64",
|
|
||||||
"arm32": "linux-armv4",
|
|
||||||
"rv64": "linux64-riscv64",
|
|
||||||
}
|
|
||||||
elif platform == "android":
|
|
||||||
targets = {
|
|
||||||
"arm64": "android-arm64",
|
|
||||||
"arm32": "android-arm",
|
|
||||||
"x86_32": "android-x86",
|
|
||||||
"x86_64": "android-x86_64",
|
|
||||||
}
|
|
||||||
elif platform == "macos":
|
|
||||||
targets = {
|
|
||||||
"x86_64": "darwin64-x86_64",
|
|
||||||
"arm64": "darwin64-arm64",
|
|
||||||
}
|
|
||||||
elif platform == "ios":
|
|
||||||
if env["ios_simulator"]:
|
|
||||||
targets = {
|
|
||||||
"x86_64": "iossimulator-xcrun",
|
|
||||||
"arm64": "iossimulator-xcrun",
|
|
||||||
}
|
|
||||||
else:
|
|
||||||
targets = {
|
|
||||||
"arm64": "ios64-xcrun",
|
|
||||||
"arm32": "ios-xcrun",
|
|
||||||
}
|
|
||||||
elif platform == "windows":
|
|
||||||
if env.get("is_msvc", False):
|
|
||||||
targets = {
|
|
||||||
"x86_32": "VC-WIN32",
|
|
||||||
"x86_64": "VC-WIN64A",
|
|
||||||
}
|
|
||||||
else:
|
|
||||||
targets = {
|
|
||||||
"x86_32": "mingw",
|
|
||||||
"x86_64": "mingw64",
|
|
||||||
}
|
|
||||||
|
|
||||||
arch = env["arch"]
|
|
||||||
target = targets.get(arch, "")
|
|
||||||
if target == "":
|
|
||||||
raise ValueError("Architecture '%s' not supported for platform: '%s'" % (arch, platform))
|
|
||||||
return target
|
|
||||||
|
|
||||||
|
|
||||||
def ssl_platform_options(env):
|
|
||||||
ssl_config_options = [
|
|
||||||
"no-ssl2",
|
|
||||||
"no-ssl3",
|
|
||||||
"no-weak-ssl-ciphers",
|
|
||||||
"no-legacy",
|
|
||||||
"no-shared",
|
|
||||||
"no-tests",
|
|
||||||
]
|
|
||||||
if env["platform"] == "windows":
|
|
||||||
ssl_config_options.append("enable-capieng")
|
|
||||||
return ssl_config_options
|
|
||||||
|
|
||||||
|
|
||||||
def ssl_platform_flags(env):
|
|
||||||
args = []
|
|
||||||
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:
|
|
||||||
for k in ["CC", "CXX", "AR", "AS", "RANLIB"]:
|
|
||||||
args.append("%s=%s" % (k, env[k]))
|
|
||||||
elif env["platform"] == "windows":
|
|
||||||
is_win_host = sys.platform in ["win32", "msys", "cygwin"]
|
|
||||||
if not (is_win_host or env.get("is_msvc", False)):
|
|
||||||
mingw_prefixes = {
|
|
||||||
"x86_32": "--cross-compile-prefix=i686-w64-mingw32-",
|
|
||||||
"x86_64": "--cross-compile-prefix=x86_64-w64-mingw32-",
|
|
||||||
}
|
|
||||||
args.append(mingw_prefixes[env["arch"]])
|
|
||||||
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):
|
|
||||||
return env["SSL_LIBS"], [env.File(env["SSL_SOURCE"] + "/Configure"), env.File(env["SSL_SOURCE"] + "/VERSION.dat")]
|
|
||||||
|
|
||||||
|
|
||||||
def build_openssl(env, jobs=None):
|
|
||||||
if env["SSL_EXTERNAL"]:
|
|
||||||
# Setup the env to use the provided libraries, and return them without building.
|
|
||||||
env.Prepend(CPPPATH=[env["SSL_INCLUDE"]])
|
|
||||||
env.Prepend(LIBPATH=[env["SSL_BUILD"]])
|
|
||||||
if env["platform"] == "windows":
|
|
||||||
env.PrependUnique(LIBS=["crypt32", "ws2_32", "advapi32", "user32"])
|
|
||||||
if env["platform"] == "linux":
|
|
||||||
env.PrependUnique(LIBS=["pthread", "dl"])
|
|
||||||
env.Prepend(LIBS=env["SSL_LIBS"])
|
|
||||||
return [env["SSL_CRYPTO_LIBRARY"], env["SSL_LIBRARY"]]
|
|
||||||
|
|
||||||
if jobs is None:
|
|
||||||
jobs = int(env.GetOption("num_jobs"))
|
|
||||||
|
|
||||||
# Since the OpenSSL build system does not support macOS universal binaries, we first need to build the two libraries
|
|
||||||
# separately, then we join them together using lipo.
|
|
||||||
if env["platform"] == "macos" and env["arch"] == "universal":
|
|
||||||
build_envs = {
|
|
||||||
"x86_64": env.Clone(),
|
|
||||||
"arm64": env.Clone(),
|
|
||||||
}
|
|
||||||
arch_ssl = []
|
|
||||||
for arch in build_envs:
|
|
||||||
benv = build_envs[arch]
|
|
||||||
benv["arch"] = arch
|
|
||||||
generate(benv)
|
|
||||||
benv["SSLBUILDJOBS"] = max([1, int(jobs / len(build_envs))])
|
|
||||||
ssl = benv.OpenSSLBuilder()
|
|
||||||
arch_ssl.extend(ssl)
|
|
||||||
benv.NoCache(ssl) # Needs refactoring to properly cache generated headers.
|
|
||||||
|
|
||||||
# x86_64 and arm64 includes are equivalent.
|
|
||||||
env["SSL_INCLUDE"] = build_envs["arm64"]["SSL_INCLUDE"]
|
|
||||||
|
|
||||||
# Join libraries using lipo.
|
|
||||||
lipo_action = "lipo $SOURCES -create -output $TARGET"
|
|
||||||
ssl_libs = list(map(lambda arch: build_envs[arch]["SSL_LIBRARY"], build_envs))
|
|
||||||
ssl_crypto_libs = list(map(lambda arch: build_envs[arch]["SSL_CRYPTO_LIBRARY"], build_envs))
|
|
||||||
ssl = env.Command(env["SSL_LIBRARY"], ssl_libs, lipo_action)
|
|
||||||
ssl += env.Command(env["SSL_CRYPTO_LIBRARY"], ssl_crypto_libs, lipo_action)
|
|
||||||
env.Depends(ssl, arch_ssl)
|
|
||||||
else:
|
|
||||||
benv = env.Clone()
|
|
||||||
benv["SSLBUILDJOBS"] = jobs
|
|
||||||
ssl = benv.OpenSSLBuilder()
|
|
||||||
benv.NoCache(ssl) # Needs refactoring to properly cache generated headers.
|
|
||||||
|
|
||||||
# Setup the environment to use the freshly built openssl.
|
|
||||||
env.Prepend(CPPPATH=[env["SSL_INCLUDE"]])
|
|
||||||
env.Prepend(LIBPATH=[env["SSL_BUILD"]])
|
|
||||||
if env["platform"] == "windows":
|
|
||||||
env.PrependUnique(LIBS=["crypt32", "ws2_32", "advapi32", "user32"])
|
|
||||||
if env["platform"] == "linux":
|
|
||||||
env.PrependUnique(LIBS=["pthread", "dl"])
|
|
||||||
env.Prepend(LIBS=env["SSL_LIBS"])
|
|
||||||
|
|
||||||
return ssl
|
|
||||||
|
|
||||||
|
|
||||||
def ssl_generator(target, source, env, for_signature):
|
|
||||||
# Strip the -j option for signature to avoid rebuilding when num_jobs changes.
|
|
||||||
build = env["SSLBUILDCOM"].replace("-j$SSLBUILDJOBS", "") if for_signature else env["SSLBUILDCOM"]
|
|
||||||
return [
|
|
||||||
Mkdir("$SSL_BUILD"),
|
|
||||||
Mkdir("$SSL_INSTALL"),
|
|
||||||
SCons.Action.Action("$SSLCONFIGCOM", "$SSLCONFIGCOMSTR"),
|
|
||||||
SCons.Action.Action(build, "$SSLBUILDCOMSTR"),
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
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(
|
|
||||||
"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.",
|
|
||||||
"",
|
|
||||||
)
|
|
||||||
opts.Add(
|
|
||||||
"openssl_external_crypto",
|
|
||||||
'An external libcrypto static library (e.g. "/usr/lib/x86_64-linux-gnu/libcrypto.a"). If not provided, OpenSSL will be built from source.',
|
|
||||||
"",
|
|
||||||
)
|
|
||||||
opts.Add(
|
|
||||||
"openssl_external_ssl",
|
|
||||||
'An external libssl static library (e.g. "/usr/lib/x86_64-linux-gnu/libssl.a"). If not provided, OpenSSL will be built from source.',
|
|
||||||
"",
|
|
||||||
)
|
|
||||||
opts.Add(
|
|
||||||
"openssl_external_include",
|
|
||||||
'An external OpenSSL "include" folder (e.g. "/usr/include/openssl").',
|
|
||||||
"",
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def exists(env):
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
def generate(env):
|
|
||||||
env.AddMethod(build_openssl, "OpenSSL")
|
|
||||||
|
|
||||||
# Check if the user specified infos about external OpenSSL files.
|
|
||||||
external_opts = ["openssl_external_crypto", "openssl_external_ssl", "openssl_external_include"]
|
|
||||||
is_set = lambda k: env.get(k, "") != ""
|
|
||||||
if any(map(is_set, external_opts)):
|
|
||||||
# Need provide the whole (crypto, ssl, include) triple to proceed.
|
|
||||||
if not all(map(is_set, external_opts)):
|
|
||||||
print('Error: The options "%s" must all be set to use a external library.' % '", "'.join(external_opts))
|
|
||||||
sys.exit(255)
|
|
||||||
|
|
||||||
env["SSL_CRYPTO_LIBRARY"] = env.File("${openssl_external_crypto}")
|
|
||||||
env["SSL_LIBRARY"] = env.File("${openssl_external_ssl}")
|
|
||||||
env["SSL_BUILD"] = env.Dir("${SSL_LIBRARY.dir}").abspath
|
|
||||||
env["SSL_INSTALL"] = env.Dir("${SSL_LIBRARY.dir}").abspath
|
|
||||||
env["SSL_INCLUDE"] = env.Dir("${openssl_external_include}").abspath
|
|
||||||
env["SSL_LIBS"] = [env["SSL_LIBRARY"], env["SSL_CRYPTO_LIBRARY"]]
|
|
||||||
env["SSL_EXTERNAL"] = True
|
|
||||||
return
|
|
||||||
|
|
||||||
# We will need to build our own OpenSSL library.
|
|
||||||
env["SSL_EXTERNAL"] = False
|
|
||||||
|
|
||||||
# Android needs the NDK in ENV, and proper PATH setup.
|
|
||||||
if env["platform"] == "android" and env["ENV"].get("ANDROID_NDK_ROOT", "") == "":
|
|
||||||
cc_path = os.path.dirname(env["CC"])
|
|
||||||
if cc_path and cc_path not in env["ENV"]:
|
|
||||||
env.PrependENVPath("PATH", cc_path)
|
|
||||||
if "ANDROID_NDK_ROOT" not in env["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"])).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"
|
|
||||||
env["SSL_LIBRARY"] = env.File(env["SSL_BUILD"] + "/libssl" + lib_ext)
|
|
||||||
env["SSL_CRYPTO_LIBRARY"] = env.File(env["SSL_BUILD"] + "/libcrypto" + lib_ext)
|
|
||||||
env["SSL_LIBS"] = [env["SSL_LIBRARY"], env["SSL_CRYPTO_LIBRARY"]]
|
|
||||||
|
|
||||||
# Configure action
|
|
||||||
env["PERL"] = env.get("PERL", "perl")
|
|
||||||
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'
|
|
||||||
# fmt: on
|
|
||||||
|
|
||||||
# Build action
|
|
||||||
env["SSLBUILDJOBS"] = "${__env__.GetOption('num_jobs')}"
|
|
||||||
# fmt: off
|
|
||||||
env["SSLBUILDCOM"] = "make -j$SSLBUILDJOBS -C ${TARGET.dir} && make -j$SSLBUILDJOBS -C ${TARGET.dir} install_sw install_ssldirs"
|
|
||||||
# fmt: on
|
|
||||||
|
|
||||||
# Windows MSVC needs to build using NMake
|
|
||||||
if env["platform"] == "windows" and env.get("is_msvc", False):
|
|
||||||
env["SSLBUILDCOM"] = "cd ${TARGET.dir} && nmake install_sw install_ssldirs"
|
|
||||||
|
|
||||||
env["BUILDERS"]["OpenSSLBuilder"] = SCons.Builder.Builder(generator=ssl_generator, emitter=ssl_emitter)
|
|
||||||
env.AddMethod(build_openssl, "OpenSSL")
|
|
||||||
28
tools/rtc.py
28
tools/rtc.py
@@ -1,19 +1,17 @@
|
|||||||
import os
|
def build_library(env, mbedtls):
|
||||||
|
|
||||||
|
|
||||||
def build_library(env, ssl):
|
|
||||||
rtc_config = {
|
rtc_config = {
|
||||||
"CMAKE_BUILD_TYPE": "RelWithDebInfo" if env["debug_symbols"] else "Release",
|
"CMAKE_BUILD_TYPE": "RelWithDebInfo" if env["debug_symbols"] else "Release",
|
||||||
|
"CMAKE_CXX_FLAGS": "-DMBEDTLS_SSL_DTLS_SRTP",
|
||||||
"USE_NICE": 0,
|
"USE_NICE": 0,
|
||||||
"NO_WEBSOCKET": 1,
|
"NO_WEBSOCKET": 1,
|
||||||
"NO_EXAMPLES": 1,
|
"NO_EXAMPLES": 1,
|
||||||
"NO_TESTS": 1,
|
"NO_TESTS": 1,
|
||||||
"BUILD_WITH_WARNINGS": "0", # Disables werror in libsrtp.
|
"BUILD_WITH_WARNINGS": "0", # Disables werror in libsrtp.
|
||||||
"OPENSSL_USE_STATIC_LIBS": 1,
|
"USE_MBEDTLS": 1,
|
||||||
"OPENSSL_INCLUDE_DIR": env["SSL_INCLUDE"],
|
"MbedTLS_LIBRARY": env["MBEDTLS_LIBRARY"],
|
||||||
"OPENSSL_SSL_LIBRARY": env["SSL_LIBRARY"],
|
"MbedCrypto_LIBRARY": env["MBEDTLS_CRYPTO_LIBRARY"],
|
||||||
"OPENSSL_CRYPTO_LIBRARY": env["SSL_CRYPTO_LIBRARY"],
|
"MbedX509_LIBRARY": env["MBEDTLS_X509_LIBRARY"],
|
||||||
"OPENSSL_ROOT_DIR": env["SSL_INSTALL"],
|
"MbedTLS_INCLUDE_DIR": env["MBEDTLS_INCLUDE"],
|
||||||
}
|
}
|
||||||
is_msvc = env.get("is_msvc", False)
|
is_msvc = env.get("is_msvc", False)
|
||||||
lib_ext = ".lib" if is_msvc else ".a"
|
lib_ext = ".lib" if is_msvc else ".a"
|
||||||
@@ -24,23 +22,25 @@ def build_library(env, ssl):
|
|||||||
"deps/libsrtp/{}srtp2{}".format(lib_prefix, lib_ext),
|
"deps/libsrtp/{}srtp2{}".format(lib_prefix, lib_ext),
|
||||||
"deps/usrsctp/usrsctplib/{}usrsctp{}".format(lib_prefix, lib_ext),
|
"deps/usrsctp/usrsctplib/{}usrsctp{}".format(lib_prefix, lib_ext),
|
||||||
]
|
]
|
||||||
|
|
||||||
# Build libdatachannel
|
# Build libdatachannel
|
||||||
rtc = env.CMakeBuild(
|
rtc = env.CMakeBuild(
|
||||||
"#bin/thirdparty/libdatachannel/",
|
env.Dir("bin/thirdparty/libdatachannel/"),
|
||||||
"#thirdparty/libdatachannel",
|
env.Dir("thirdparty/libdatachannel"),
|
||||||
cmake_options=rtc_config,
|
cmake_options=rtc_config,
|
||||||
cmake_outputs=rtc_libs,
|
cmake_outputs=rtc_libs,
|
||||||
cmake_targets=["datachannel-static"],
|
cmake_targets=["datachannel-static"],
|
||||||
dependencies=ssl,
|
dependencies=mbedtls,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Configure env.
|
# Configure env.
|
||||||
if env["platform"] == "windows":
|
if env["platform"] == "windows":
|
||||||
env.PrependUnique(LIBS=["iphlpapi", "bcrypt"])
|
env.PrependUnique(LIBS=["iphlpapi", "ws2_32", "bcrypt"])
|
||||||
if env["platform"] == "linux":
|
if env["platform"] == "linux":
|
||||||
env.PrependUnique(LIBS=["pthread"])
|
env.PrependUnique(LIBS=["pthread"])
|
||||||
env.Prepend(LIBS=list(filter(lambda f: str(f).endswith(lib_ext), rtc)))
|
env.Prepend(LIBS=list(filter(lambda f: str(f).endswith(lib_ext), rtc)))
|
||||||
env.Append(CPPPATH=["#thirdparty/libdatachannel/include"])
|
env.Append(CPPPATH=[env.Dir("thirdparty/libdatachannel/include")])
|
||||||
|
env.Append(CPPDEFINES=["RTC_STATIC"]) # For Windows MSVC
|
||||||
|
|
||||||
return rtc
|
return rtc
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user