mirror of
https://github.com/godotengine/webrtc-native.git
synced 2026-01-03 14:09:58 +03:00
Compare commits
120 Commits
1.0.0-beta
...
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 | ||
|
|
bf8f6e4581 | ||
|
|
1443d02c8d | ||
|
|
431df320c4 | ||
|
|
762f7cc5d2 | ||
|
|
66a9c6bab3 | ||
|
|
e391109df2 | ||
|
|
762365d20a | ||
|
|
34ef1043ee | ||
|
|
7141bc487e | ||
|
|
9520b23a4c | ||
|
|
cdb4673f48 | ||
|
|
5b4221462b | ||
|
|
86d080b328 | ||
|
|
1831677f63 | ||
|
|
fa28efa51d | ||
|
|
6e33e43f36 | ||
|
|
81239d820d | ||
|
|
b0efc17d3b | ||
|
|
ec0ededcde | ||
|
|
308db19120 | ||
|
|
724910c734 | ||
|
|
7a4e27e5f0 | ||
|
|
d768508435 | ||
|
|
fb2c9c3687 | ||
|
|
cf23e5e740 | ||
|
|
668d0250a7 | ||
|
|
121ed5664d | ||
|
|
67a378a667 | ||
|
|
023c42d3b3 | ||
|
|
6d96092f88 | ||
|
|
77969f68d9 | ||
|
|
a9d8ea2a1c | ||
|
|
6e2262b6c3 | ||
|
|
cb2be8723a | ||
|
|
d278661d76 | ||
|
|
552d696e0a | ||
|
|
6f4d8f5238 | ||
|
|
8040565b0e | ||
|
|
38c83f667d | ||
|
|
1de32aa9ea | ||
|
|
ed3771ced0 | ||
|
|
ac3bdb3613 | ||
|
|
931a7551f5 | ||
|
|
0771084b54 | ||
|
|
ae0dd0626a | ||
|
|
0be6b671e5 | ||
|
|
d96b43b7ee | ||
|
|
ec8cd5c0e4 | ||
|
|
b03099f7b4 | ||
|
|
85efdfd6ce | ||
|
|
32ae1d1195 | ||
|
|
54c8586235 | ||
|
|
f19011f2fb | ||
|
|
86c27ec7ef | ||
|
|
f2ee596bd9 | ||
|
|
61299ca4b7 | ||
|
|
df643250f5 | ||
|
|
45549e020f | ||
|
|
ee40730c20 | ||
|
|
8f7cb77f34 | ||
|
|
eb65d88cd4 | ||
|
|
e8de07dbb1 | ||
|
|
e34000653b | ||
|
|
826a736176 | ||
|
|
b7098e7496 | ||
|
|
6de604ffee | ||
|
|
f0af5f9982 | ||
|
|
fbe4e06b9f | ||
|
|
9a9fc0953b | ||
|
|
c6b6f7e18c | ||
|
|
00f952bcf1 | ||
|
|
d7032f7b85 | ||
|
|
c9a1efc7a0 | ||
|
|
5bc4b79435 | ||
|
|
b7b76dddab | ||
|
|
0b1c55ed83 | ||
|
|
093ac7d489 | ||
|
|
84e9d6dd37 | ||
|
|
a49a2b03e1 | ||
|
|
656d3a9964 | ||
|
|
2bc2a5d162 | ||
|
|
7176344056 | ||
|
|
7d260b1b32 | ||
|
|
0c10a7f3e3 | ||
|
|
40962dbe19 | ||
|
|
bdd9d50745 | ||
|
|
5348407de9 | ||
|
|
5002991511 | ||
|
|
0fc992e0d5 | ||
|
|
fbadff454c | ||
|
|
61a6d25c47 | ||
|
|
dfaad6f5ba |
111
.clang-format
111
.clang-format
@@ -1,31 +1,40 @@
|
|||||||
# Commented out parameters are those with the same value as base LLVM style
|
# Commented out parameters are those with the same value as base LLVM style.
|
||||||
# We can uncomment them if we want to change their value, or enforce the
|
# We can uncomment them if we want to change their value, or enforce the
|
||||||
# chosen value in case the base style changes (last sync: Clang 6.0.1).
|
# chosen value in case the base style changes (last sync: Clang 14.0).
|
||||||
---
|
---
|
||||||
### General config, applies to all languages ###
|
### General config, applies to all languages ###
|
||||||
BasedOnStyle: LLVM
|
BasedOnStyle: LLVM
|
||||||
AccessModifierOffset: -4
|
AccessModifierOffset: -4
|
||||||
AlignAfterOpenBracket: DontAlign
|
AlignAfterOpenBracket: DontAlign
|
||||||
# AlignConsecutiveAssignments: false
|
# AlignArrayOfStructures: None
|
||||||
# AlignConsecutiveDeclarations: false
|
# AlignConsecutiveMacros: None
|
||||||
|
# AlignConsecutiveAssignments: None
|
||||||
|
# AlignConsecutiveBitFields: None
|
||||||
|
# AlignConsecutiveDeclarations: None
|
||||||
# AlignEscapedNewlines: Right
|
# AlignEscapedNewlines: Right
|
||||||
# AlignOperands: true
|
AlignOperands: DontAlign
|
||||||
AlignTrailingComments: false
|
AlignTrailingComments: false
|
||||||
|
# AllowAllArgumentsOnNextLine: true
|
||||||
AllowAllParametersOfDeclarationOnNextLine: false
|
AllowAllParametersOfDeclarationOnNextLine: false
|
||||||
# AllowShortBlocksOnASingleLine: false
|
# AllowShortEnumsOnASingleLine: true
|
||||||
|
# AllowShortBlocksOnASingleLine: Never
|
||||||
# AllowShortCaseLabelsOnASingleLine: false
|
# AllowShortCaseLabelsOnASingleLine: false
|
||||||
AllowShortFunctionsOnASingleLine: Inline
|
# AllowShortFunctionsOnASingleLine: All
|
||||||
# AllowShortIfStatementsOnASingleLine: false
|
# AllowShortLambdasOnASingleLine: All
|
||||||
|
# AllowShortIfStatementsOnASingleLine: Never
|
||||||
# AllowShortLoopsOnASingleLine: false
|
# AllowShortLoopsOnASingleLine: false
|
||||||
# AlwaysBreakAfterDefinitionReturnType: None
|
# AlwaysBreakAfterDefinitionReturnType: None
|
||||||
# AlwaysBreakAfterReturnType: None
|
# AlwaysBreakAfterReturnType: None
|
||||||
# AlwaysBreakBeforeMultilineStrings: false
|
# AlwaysBreakBeforeMultilineStrings: false
|
||||||
# AlwaysBreakTemplateDeclarations: false
|
# AlwaysBreakTemplateDeclarations: MultiLine
|
||||||
|
# AttributeMacros:
|
||||||
|
# - __capability
|
||||||
# BinPackArguments: true
|
# BinPackArguments: true
|
||||||
# BinPackParameters: true
|
# BinPackParameters: true
|
||||||
# BraceWrapping:
|
# BraceWrapping:
|
||||||
|
# AfterCaseLabel: false
|
||||||
# AfterClass: false
|
# AfterClass: false
|
||||||
# AfterControlStatement: false
|
# AfterControlStatement: Never
|
||||||
# AfterEnum: false
|
# AfterEnum: false
|
||||||
# AfterFunction: false
|
# AfterFunction: false
|
||||||
# AfterNamespace: false
|
# AfterNamespace: false
|
||||||
@@ -35,32 +44,44 @@ AllowShortFunctionsOnASingleLine: Inline
|
|||||||
# AfterExternBlock: false
|
# AfterExternBlock: false
|
||||||
# BeforeCatch: false
|
# BeforeCatch: false
|
||||||
# BeforeElse: false
|
# BeforeElse: false
|
||||||
|
# BeforeLambdaBody: false
|
||||||
|
# BeforeWhile: false
|
||||||
# IndentBraces: false
|
# IndentBraces: false
|
||||||
# SplitEmptyFunction: true
|
# SplitEmptyFunction: true
|
||||||
# SplitEmptyRecord: true
|
# SplitEmptyRecord: true
|
||||||
# SplitEmptyNamespace: true
|
# SplitEmptyNamespace: true
|
||||||
# BreakBeforeBinaryOperators: None
|
# BreakBeforeBinaryOperators: None
|
||||||
|
# BreakBeforeConceptDeclarations: true
|
||||||
# BreakBeforeBraces: Attach
|
# BreakBeforeBraces: Attach
|
||||||
# BreakBeforeInheritanceComma: false
|
# BreakBeforeInheritanceComma: false
|
||||||
BreakBeforeTernaryOperators: false
|
# BreakInheritanceList: BeforeColon
|
||||||
|
# BreakBeforeTernaryOperators: true
|
||||||
# BreakConstructorInitializersBeforeComma: false
|
# BreakConstructorInitializersBeforeComma: false
|
||||||
BreakConstructorInitializers: AfterColon
|
BreakConstructorInitializers: AfterColon
|
||||||
# BreakStringLiterals: true
|
# BreakStringLiterals: true
|
||||||
ColumnLimit: 0
|
ColumnLimit: 0
|
||||||
# CommentPragmas: '^ IWYU pragma:'
|
# CommentPragmas: '^ IWYU pragma:'
|
||||||
|
# QualifierAlignment: Leave
|
||||||
# CompactNamespaces: false
|
# CompactNamespaces: false
|
||||||
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
|
||||||
ConstructorInitializerIndentWidth: 8
|
ConstructorInitializerIndentWidth: 8
|
||||||
ContinuationIndentWidth: 8
|
ContinuationIndentWidth: 8
|
||||||
Cpp11BracedListStyle: false
|
Cpp11BracedListStyle: false
|
||||||
|
# DeriveLineEnding: true
|
||||||
# DerivePointerAlignment: false
|
# DerivePointerAlignment: false
|
||||||
# DisableFormat: false
|
# DisableFormat: false
|
||||||
|
# EmptyLineAfterAccessModifier: Never
|
||||||
|
# EmptyLineBeforeAccessModifier: LogicalBlock
|
||||||
# ExperimentalAutoDetectBinPacking: false
|
# ExperimentalAutoDetectBinPacking: false
|
||||||
|
# PackConstructorInitializers: BinPack
|
||||||
|
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||||
|
# AllowAllConstructorInitializersOnNextLine: true
|
||||||
# FixNamespaceComments: true
|
# FixNamespaceComments: true
|
||||||
# ForEachMacros:
|
# ForEachMacros:
|
||||||
# - foreach
|
# - foreach
|
||||||
# - Q_FOREACH
|
# - Q_FOREACH
|
||||||
# - BOOST_FOREACH
|
# - BOOST_FOREACH
|
||||||
|
# IfMacros:
|
||||||
|
# - KJ_IF_MAYBE
|
||||||
# IncludeBlocks: Preserve
|
# IncludeBlocks: Preserve
|
||||||
IncludeCategories:
|
IncludeCategories:
|
||||||
- Regex: '".*"'
|
- Regex: '".*"'
|
||||||
@@ -70,13 +91,21 @@ IncludeCategories:
|
|||||||
- Regex: '^<.*'
|
- Regex: '^<.*'
|
||||||
Priority: 3
|
Priority: 3
|
||||||
# IncludeIsMainRegex: '(Test)?$'
|
# IncludeIsMainRegex: '(Test)?$'
|
||||||
|
# IncludeIsMainSourceRegex: ''
|
||||||
|
# IndentAccessModifiers: false
|
||||||
IndentCaseLabels: true
|
IndentCaseLabels: true
|
||||||
|
# IndentCaseBlocks: false
|
||||||
|
# IndentGotoLabels: true
|
||||||
# IndentPPDirectives: None
|
# IndentPPDirectives: None
|
||||||
|
# IndentExternBlock: AfterExternBlock
|
||||||
|
# IndentRequires: false
|
||||||
IndentWidth: 4
|
IndentWidth: 4
|
||||||
# IndentWrappedFunctionNames: false
|
# IndentWrappedFunctionNames: false
|
||||||
|
# InsertTrailingCommas: None
|
||||||
# JavaScriptQuotes: Leave
|
# JavaScriptQuotes: Leave
|
||||||
# JavaScriptWrapImports: true
|
# JavaScriptWrapImports: true
|
||||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||||
|
# LambdaBodyIndentation: Signature
|
||||||
# MacroBlockBegin: ''
|
# MacroBlockBegin: ''
|
||||||
# MacroBlockEnd: ''
|
# MacroBlockEnd: ''
|
||||||
# MaxEmptyLinesToKeep: 1
|
# MaxEmptyLinesToKeep: 1
|
||||||
@@ -85,39 +114,81 @@ KeepEmptyLinesAtTheStartOfBlocks: false
|
|||||||
# PenaltyBreakBeforeFirstCallParameter: 19
|
# PenaltyBreakBeforeFirstCallParameter: 19
|
||||||
# PenaltyBreakComment: 300
|
# PenaltyBreakComment: 300
|
||||||
# PenaltyBreakFirstLessLess: 120
|
# PenaltyBreakFirstLessLess: 120
|
||||||
|
# PenaltyBreakOpenParenthesis: 0
|
||||||
# PenaltyBreakString: 1000
|
# PenaltyBreakString: 1000
|
||||||
|
# PenaltyBreakTemplateDeclaration: 10
|
||||||
# PenaltyExcessCharacter: 1000000
|
# PenaltyExcessCharacter: 1000000
|
||||||
# PenaltyReturnTypeOnItsOwnLine: 60
|
# PenaltyReturnTypeOnItsOwnLine: 60
|
||||||
|
# PenaltyIndentedWhitespace: 0
|
||||||
# PointerAlignment: Right
|
# PointerAlignment: Right
|
||||||
# RawStringFormats:
|
# PPIndentWidth: -1
|
||||||
# - Delimiter: pb
|
# ReferenceAlignment: Pointer
|
||||||
# Language: TextProto
|
|
||||||
# BasedOnStyle: google
|
|
||||||
# ReflowComments: true
|
# ReflowComments: true
|
||||||
# SortIncludes: true
|
# RemoveBracesLLVM: false
|
||||||
|
# SeparateDefinitionBlocks: Leave
|
||||||
|
# ShortNamespaceLines: 1
|
||||||
|
# SortIncludes: CaseSensitive
|
||||||
|
# SortJavaStaticImport: Before
|
||||||
# SortUsingDeclarations: true
|
# SortUsingDeclarations: true
|
||||||
# SpaceAfterCStyleCast: false
|
# SpaceAfterCStyleCast: false
|
||||||
|
# SpaceAfterLogicalNot: false
|
||||||
# SpaceAfterTemplateKeyword: true
|
# SpaceAfterTemplateKeyword: true
|
||||||
# SpaceBeforeAssignmentOperators: true
|
# SpaceBeforeAssignmentOperators: true
|
||||||
|
# SpaceBeforeCaseColon: false
|
||||||
|
# SpaceBeforeCpp11BracedList: false
|
||||||
|
# SpaceBeforeCtorInitializerColon: true
|
||||||
|
# SpaceBeforeInheritanceColon: true
|
||||||
# SpaceBeforeParens: ControlStatements
|
# SpaceBeforeParens: ControlStatements
|
||||||
|
# SpaceBeforeParensOptions:
|
||||||
|
# AfterControlStatements: true
|
||||||
|
# AfterForeachMacros: true
|
||||||
|
# AfterFunctionDefinitionName: false
|
||||||
|
# AfterFunctionDeclarationName: false
|
||||||
|
# AfterIfMacros: true
|
||||||
|
# AfterOverloadedOperator: false
|
||||||
|
# BeforeNonEmptyParentheses: false
|
||||||
|
# SpaceAroundPointerQualifiers: Default
|
||||||
|
# SpaceBeforeRangeBasedForLoopColon: true
|
||||||
|
# SpaceInEmptyBlock: false
|
||||||
# SpaceInEmptyParentheses: false
|
# SpaceInEmptyParentheses: false
|
||||||
# SpacesBeforeTrailingComments: 1
|
# SpacesBeforeTrailingComments: 1
|
||||||
# SpacesInAngles: false
|
# SpacesInAngles: Never
|
||||||
|
# SpacesInConditionalStatement: false
|
||||||
# SpacesInContainerLiterals: true
|
# SpacesInContainerLiterals: true
|
||||||
# SpacesInCStyleCastParentheses: false
|
# SpacesInCStyleCastParentheses: false
|
||||||
|
## Godot TODO: We'll want to use a min of 1, but we need to see how to fix
|
||||||
|
## our comment capitalization at the same time.
|
||||||
|
SpacesInLineCommentPrefix:
|
||||||
|
Minimum: 0
|
||||||
|
Maximum: -1
|
||||||
# SpacesInParentheses: false
|
# SpacesInParentheses: false
|
||||||
# SpacesInSquareBrackets: false
|
# SpacesInSquareBrackets: false
|
||||||
|
# SpaceBeforeSquareBrackets: false
|
||||||
|
# BitFieldColonSpacing: Both
|
||||||
|
# StatementAttributeLikeMacros:
|
||||||
|
# - Q_EMIT
|
||||||
|
# StatementMacros:
|
||||||
|
# - Q_UNUSED
|
||||||
|
# - QT_REQUIRE_VERSION
|
||||||
TabWidth: 4
|
TabWidth: 4
|
||||||
|
# UseCRLF: false
|
||||||
UseTab: Always
|
UseTab: Always
|
||||||
|
# WhitespaceSensitiveMacros:
|
||||||
|
# - STRINGIZE
|
||||||
|
# - PP_STRINGIZE
|
||||||
|
# - BOOST_PP_STRINGIZE
|
||||||
|
# - NS_SWIFT_NAME
|
||||||
|
# - CF_SWIFT_NAME
|
||||||
---
|
---
|
||||||
### C++ specific config ###
|
### C++ specific config ###
|
||||||
Language: Cpp
|
Language: Cpp
|
||||||
Standard: Cpp11
|
Standard: c++17
|
||||||
---
|
---
|
||||||
### ObjC specific config ###
|
### ObjC specific config ###
|
||||||
Language: ObjC
|
Language: ObjC
|
||||||
Standard: Cpp11
|
# ObjCBinPackProtocolList: Auto
|
||||||
ObjCBlockIndentWidth: 4
|
ObjCBlockIndentWidth: 4
|
||||||
|
# ObjCBreakBeforeNestedBlockParam: true
|
||||||
# ObjCSpaceAfterProperty: false
|
# ObjCSpaceAfterProperty: false
|
||||||
# ObjCSpaceBeforeProtocolList: true
|
# ObjCSpaceBeforeProtocolList: true
|
||||||
---
|
---
|
||||||
|
|||||||
22
.github/actions/godot-cache/action.yml
vendored
Normal file
22
.github/actions/godot-cache/action.yml
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
name: Setup Godot build cache
|
||||||
|
description: Setup Godot build cache.
|
||||||
|
inputs:
|
||||||
|
cache-name:
|
||||||
|
description: The cache base name (job name by default).
|
||||||
|
default: "${{github.job}}"
|
||||||
|
scons-cache:
|
||||||
|
description: The scons cache path.
|
||||||
|
default: "${{github.workspace}}/.scons-cache/"
|
||||||
|
runs:
|
||||||
|
using: "composite"
|
||||||
|
steps:
|
||||||
|
# Upload cache on completion and check it out now
|
||||||
|
- name: Load .scons_cache directory
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: ${{inputs.scons-cache}}
|
||||||
|
key: ${{inputs.cache-name}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}}
|
||||||
|
restore-keys: |
|
||||||
|
${{inputs.cache-name}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}}
|
||||||
|
${{inputs.cache-name}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}
|
||||||
|
${{inputs.cache-name}}-${{env.GODOT_BASE_BRANCH}}
|
||||||
148
.github/workflows/build_release.yml
vendored
148
.github/workflows/build_release.yml
vendored
@@ -4,21 +4,28 @@ 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@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get install -qq dos2unix recode clang-format-11
|
# Add clang repository (so we have clang-format-14)
|
||||||
|
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
|
||||||
|
sudo apt-add-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main"
|
||||||
|
sudo apt-get update
|
||||||
|
# Install required deps
|
||||||
|
sudo apt-get install -qq dos2unix moreutils recode clang-format-14
|
||||||
sudo update-alternatives --remove-all clang-format
|
sudo update-alternatives --remove-all clang-format
|
||||||
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-11 100
|
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-14 100
|
||||||
sudo pip3 install black==20.8b1 pygments
|
sudo pip3 install black==22.3.0 pygments
|
||||||
|
|
||||||
- name: File formatting checks (file_format.sh)
|
- name: File formatting checks (file_format.sh)
|
||||||
run: |
|
run: |
|
||||||
@@ -45,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
|
||||||
@@ -59,74 +66,84 @@ 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
|
||||||
- platform: linux
|
- platform: linux
|
||||||
arch: 'x86_32'
|
arch: 'x86_32'
|
||||||
|
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'
|
||||||
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
|
||||||
|
arch: 'arm32'
|
||||||
|
buildroot: 'arm-godot-linux-gnueabihf_sdk-buildroot'
|
||||||
|
gdnative_flags: 'bits=32'
|
||||||
|
sconsflags: ''
|
||||||
|
os: 'ubuntu-22.04'
|
||||||
|
cache-name: linux-arm32
|
||||||
|
- platform: linux
|
||||||
|
arch: 'arm64'
|
||||||
|
buildroot: 'aarch64-godot-linux-gnu_sdk-buildroot'
|
||||||
|
gdnative_flags: 'bits=64'
|
||||||
|
sconsflags: ''
|
||||||
|
os: 'ubuntu-22.04'
|
||||||
|
cache-name: linux-arm64
|
||||||
|
|
||||||
# macOS
|
# macOS
|
||||||
- platform: macos
|
- platform: macos
|
||||||
arch: 'x86_64'
|
arch: 'universal'
|
||||||
gdnative_flags: 'macos_arch=x86_64 bits=64'
|
gdnative_flags: 'macos_arch=universal bits=64'
|
||||||
sconsflags: ''
|
sconsflags: ''
|
||||||
os: 'macos-11'
|
os: 'macos-latest'
|
||||||
cache-name: macos-x86_64
|
cache-name: macos-universal
|
||||||
- platform: macos
|
|
||||||
gdnative_flags: 'macos_arch=arm64 bits=64'
|
|
||||||
arch: 'arm64'
|
|
||||||
sconsflags: ''
|
|
||||||
os: 'macos-11'
|
|
||||||
cache-name: macos-arm64
|
|
||||||
|
|
||||||
# Windows
|
# Windows
|
||||||
- platform: windows
|
- platform: windows
|
||||||
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:
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
- name: Setup Godot build cache
|
- name: Setup Godot build cache
|
||||||
uses: ./godot-cpp/.github/actions/godot-cache
|
uses: ./.github/actions/godot-cache
|
||||||
with:
|
with:
|
||||||
cache-name: ${{ matrix.cache-name }}
|
cache-name: ${{ matrix.cache-name }}
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
@@ -146,10 +163,19 @@ jobs:
|
|||||||
- name: Install Linux build dependencies
|
- name: Install Linux build dependencies
|
||||||
if: ${{ matrix.platform == 'linux' }}
|
if: ${{ matrix.platform == 'linux' }}
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get install build-essential gcc-multilib g++-multilib
|
sudo apt-get update
|
||||||
|
sudo apt-get install build-essential gcc-multilib g++-multilib wget
|
||||||
|
|
||||||
|
- name: Setup Linux buildroot toolchain cache
|
||||||
|
if: ${{ matrix.platform == 'linux' }}
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
${{ matrix.buildroot }}.tar.bz2
|
||||||
|
key: linux-${{ matrix.buildroot }}-buildroot
|
||||||
|
|
||||||
- name: Set up Python 3.x
|
- name: Set up Python 3.x
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: '3.x'
|
python-version: '3.x'
|
||||||
architecture: 'x64'
|
architecture: 'x64'
|
||||||
@@ -158,50 +184,80 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
python -c "import sys; print(sys.version)"
|
python -c "import sys; print(sys.version)"
|
||||||
python -m pip install scons
|
python -m pip install scons
|
||||||
|
|
||||||
|
- name: Setup Linux toolchains
|
||||||
|
if: ${{ matrix.platform == 'linux' }}
|
||||||
|
run: |
|
||||||
|
if [ ! -f ${{ matrix.buildroot }}.tar.bz2 ]; then
|
||||||
|
wget https://github.com/godotengine/buildroot/releases/download/godot-2023.08.x-4/${{ matrix.buildroot }}.tar.bz2
|
||||||
|
fi
|
||||||
|
tar -xjf ${{ matrix.buildroot }}.tar.bz2
|
||||||
|
${{ matrix.buildroot }}/relocate-sdk.sh
|
||||||
|
rm ${{ matrix.buildroot }}/bin/cmake
|
||||||
|
echo "$GITHUB_WORKSPACE/${{ matrix.buildroot }}/bin" >> $GITHUB_PATH
|
||||||
|
echo "PKG_CONFIG=$GITHUB_WORKSPACE/${{ matrix.buildroot }}/share/pkgconfig/" >> $GITHUB_ENV
|
||||||
|
patch -p1 < misc/patches/scons_path.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
|
||||||
|
run: |
|
||||||
python --version
|
python --version
|
||||||
scons --version
|
scons --version
|
||||||
cmake --version
|
cmake --version
|
||||||
|
|
||||||
- name: Compile Extension - template_debug - ${{ matrix.platform }} - ${{ matrix.arch }}
|
- name: Compile Extension (4.1+) - template_debug - ${{ matrix.platform }} - ${{ matrix.arch }}
|
||||||
run: |
|
run: |
|
||||||
scons target=template_debug generate_bindings=yes
|
scons target=template_debug godot_version=4
|
||||||
|
|
||||||
- name: Compile Extension - template_release - ${{ matrix.platform }} - ${{ matrix.arch }}
|
- name: Compile Extension (4.1+) - template_release - ${{ matrix.platform }} - ${{ matrix.arch }}
|
||||||
run: |
|
run: |
|
||||||
scons target=template_release
|
scons target=template_release godot_version=4
|
||||||
|
|
||||||
- name: Compile GDNative - release ${{ matrix.platform }} - ${{ matrix.arch }}
|
- name: Compile GDNative (3.5+) - release ${{ matrix.platform }} - ${{ matrix.arch }}
|
||||||
run: |
|
run: |
|
||||||
scons target=release generate_bindings=yes ${{ matrix.gdnative_flags }} godot_version=3
|
scons target=release generate_bindings=yes ${{ matrix.gdnative_flags }} godot_version=3
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: ${{ github.job }}-${{ matrix.platform }}-${{ matrix.arch }}
|
name: ${{ github.job }}-${{ matrix.platform }}-${{ matrix.arch }}
|
||||||
path: bin/*
|
path: |
|
||||||
|
bin/
|
||||||
|
!bin/thirdparty/
|
||||||
|
|
||||||
package:
|
package:
|
||||||
name: 📦 Package
|
name: 📦 Package
|
||||||
needs: build
|
needs: build
|
||||||
runs-on: "ubuntu-latest"
|
runs-on: "ubuntu-latest"
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
- uses: actions/download-artifact@v3
|
- uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
path: artifacts
|
path: artifacts
|
||||||
|
|
||||||
- name: Bundle licenses.
|
- name: Bundle licenses.
|
||||||
run: |
|
run: |
|
||||||
cp LICENSE artifacts/LICENSE.webrtc-native
|
cp LICENSE artifacts/LICENSE.webrtc-native
|
||||||
cp deps/libdatachannel/LICENSE artifacts/LICENSE.libdatachannel
|
cp thirdparty/libdatachannel/LICENSE artifacts/LICENSE.libdatachannel
|
||||||
cp deps/openssl/LICENSE.txt artifacts/LICENSE.openssl
|
cp thirdparty/mbedtls/LICENSE artifacts/LICENSE.mbedtls
|
||||||
cp deps/libdatachannel/deps/libjuice/LICENSE artifacts/LICENSE.libjuice
|
cp thirdparty/libdatachannel/deps/libjuice/LICENSE artifacts/LICENSE.libjuice
|
||||||
cp deps/libdatachannel/deps/usrsctp/LICENSE.md artifacts/LICENSE.usrsctp
|
cp thirdparty/libdatachannel/deps/usrsctp/LICENSE.md artifacts/LICENSE.usrsctp
|
||||||
cp deps/libdatachannel/deps/libsrtp/LICENSE artifacts/LICENSE.libsrtp
|
cp thirdparty/libdatachannel/deps/libsrtp/LICENSE artifacts/LICENSE.libsrtp
|
||||||
cp deps/libdatachannel/deps/json/LICENSE.MIT artifacts/LICENSE.json
|
cp thirdparty/libdatachannel/deps/plog/LICENSE artifacts/LICENSE.plog
|
||||||
cp deps/libdatachannel/deps/plog/LICENSE artifacts/LICENSE.plog
|
|
||||||
|
|
||||||
- name: Package artifacts for release
|
- name: Package artifacts for release
|
||||||
env:
|
env:
|
||||||
@@ -214,12 +270,12 @@ jobs:
|
|||||||
|
|
||||||
ls -R release
|
ls -R release
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: godot-webrtc-extension
|
name: godot-webrtc-extension
|
||||||
path: release/*-extension-*.zip
|
path: release/*-extension-*.zip
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: godot-webrtc-gdnative
|
name: godot-webrtc-gdnative
|
||||||
path: release/*-gdnative-*.zip
|
path: release/*-gdnative-*.zip
|
||||||
|
|||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -5,3 +5,5 @@ bin/*
|
|||||||
.sconsign.dblite
|
.sconsign.dblite
|
||||||
*.obj
|
*.obj
|
||||||
*.swp
|
*.swp
|
||||||
|
__pycache__/*
|
||||||
|
*.pyc
|
||||||
|
|||||||
14
.gitmodules
vendored
14
.gitmodules
vendored
@@ -1,12 +1,12 @@
|
|||||||
[submodule "godot-cpp-3.x"]
|
|
||||||
path = godot-cpp-3.x
|
|
||||||
url = https://github.com/godotengine/godot-cpp.git
|
|
||||||
[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-3.x"]
|
||||||
|
path = godot-cpp-3.x
|
||||||
|
url = https://github.com/godotengine/godot-cpp.git
|
||||||
[submodule "libdatachannel"]
|
[submodule "libdatachannel"]
|
||||||
path = deps/libdatachannel
|
path = thirdparty/libdatachannel
|
||||||
url = https://github.com/paullouisageneau/libdatachannel.git
|
url = https://github.com/paullouisageneau/libdatachannel.git
|
||||||
[submodule "openssl"]
|
[submodule "mbedtls"]
|
||||||
path = deps/openssl
|
path = thirdparty/mbedtls
|
||||||
url = https://github.com/openssl/openssl.git
|
url = https://github.com/Mbed-TLS/mbedtls.git
|
||||||
|
|||||||
14
README.md
14
README.md
@@ -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
|
||||||
@@ -21,7 +21,7 @@ $ git submodule update --init --recursive
|
|||||||
|
|
||||||
### Compiling the extension.
|
### Compiling the extension.
|
||||||
|
|
||||||
To build the GDExtension version of the plugin (Godot 4.0) run the following command from the `webrtc-native` folder:
|
To build the GDExtension version of the plugin (Godot 4.1+) run the following command from the `webrtc-native` folder:
|
||||||
|
|
||||||
```
|
```
|
||||||
$ scons platform=<your platform>
|
$ scons platform=<your platform>
|
||||||
@@ -29,6 +29,12 @@ $ scons platform=<your platform>
|
|||||||
|
|
||||||
This will build all the required dependencies into a single shared library.
|
This will build all the required dependencies into a single shared library.
|
||||||
|
|
||||||
|
To build the "legacy" GDExtension version of the plugin (Godot 4.0) run the following command instead:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ scons platform=<your platform> godot_version=4.0
|
||||||
|
```
|
||||||
|
|
||||||
To build the GDNative version of the plugin (Godot 3.x) run the following command instead:
|
To build the GDNative version of the plugin (Godot 3.x) run the following command instead:
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -45,6 +51,4 @@ You simply need to copy that folder to the root folder of your project. Note tha
|
|||||||
|
|
||||||
### License
|
### 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).
|
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.
|
||||||
|
|
||||||
Make sure you understand and comply with the LGPLv2.1 license when redistributing this plugin.
|
|
||||||
|
|||||||
208
SConstruct
208
SConstruct
@@ -1,8 +1,7 @@
|
|||||||
#!python
|
#!python
|
||||||
|
|
||||||
import os, sys, platform, json, subprocess
|
import os, sys, platform, json, subprocess
|
||||||
|
import SCons
|
||||||
import builders
|
|
||||||
|
|
||||||
|
|
||||||
def add_sources(sources, dirpath, extension):
|
def add_sources(sources, dirpath, extension):
|
||||||
@@ -13,35 +12,63 @@ def add_sources(sources, dirpath, extension):
|
|||||||
|
|
||||||
def replace_flags(flags, replaces):
|
def replace_flags(flags, replaces):
|
||||||
for k, v in replaces.items():
|
for k, v in replaces.items():
|
||||||
if k in flags:
|
if k not in flags:
|
||||||
|
continue
|
||||||
|
if v is None:
|
||||||
|
flags.remove(k)
|
||||||
|
else:
|
||||||
flags[flags.index(k)] = v
|
flags[flags.index(k)] = v
|
||||||
|
|
||||||
|
|
||||||
|
def validate_godotcpp_dir(key, val, env):
|
||||||
|
normalized = val if os.path.isabs(val) else os.path.join(env.Dir("#").abspath, val)
|
||||||
|
if not os.path.isdir(normalized):
|
||||||
|
raise UserError("GDExtension directory ('%s') does not exist: %s" % (key, val))
|
||||||
|
|
||||||
|
|
||||||
env = Environment()
|
env = Environment()
|
||||||
opts = Variables(["customs.py"], ARGUMENTS)
|
opts = Variables(["customs.py"], ARGUMENTS)
|
||||||
opts.Add(EnumVariable("godot_version", "The Godot target version", "4", ["3", "4"]))
|
opts.Add(EnumVariable("godot_version", "The Godot target version", "4", ["3", "4"], {"4.1+": "4", "4.1": "4"}))
|
||||||
|
opts.Add(
|
||||||
|
PathVariable(
|
||||||
|
"godot_cpp",
|
||||||
|
"Path to the directory containing Godot CPP folder",
|
||||||
|
None,
|
||||||
|
validate_godotcpp_dir,
|
||||||
|
)
|
||||||
|
)
|
||||||
opts.Update(env)
|
opts.Update(env)
|
||||||
|
|
||||||
|
# Minimum target platform versions.
|
||||||
|
if "ios_min_version" not in ARGUMENTS:
|
||||||
|
ARGUMENTS["ios_min_version"] = "12.0"
|
||||||
|
if "macos_deployment_target" not in ARGUMENTS:
|
||||||
|
ARGUMENTS["macos_deployment_target"] = "11.0"
|
||||||
|
if "android_api_level" not in ARGUMENTS:
|
||||||
|
ARGUMENTS["android_api_level"] = "28"
|
||||||
|
|
||||||
|
# Recent godot-cpp versions disables exceptions by default, but libdatachannel requires them.
|
||||||
|
ARGUMENTS["disable_exceptions"] = "no"
|
||||||
|
|
||||||
if env["godot_version"] == "3":
|
if env["godot_version"] == "3":
|
||||||
if "platform" in ARGUMENTS and ARGUMENTS["platform"] == "macos":
|
if "platform" in ARGUMENTS and ARGUMENTS["platform"] == "macos":
|
||||||
ARGUMENTS["platform"] = "osx" # compatibility with old osx name
|
ARGUMENTS["platform"] = "osx" # compatibility with old osx name
|
||||||
|
|
||||||
scons_cache_path = os.environ.get("SCONS_CACHE")
|
sconstruct = env.get("godot_cpp", "godot-cpp-3.x") + "/SConstruct"
|
||||||
if scons_cache_path is not None:
|
cpp_env = SConscript(sconstruct)
|
||||||
CacheDir(scons_cache_path)
|
|
||||||
Decider("MD5")
|
|
||||||
|
|
||||||
env = SConscript("godot-cpp-3.x/SConstruct")
|
|
||||||
|
|
||||||
# Patch base env
|
# Patch base env
|
||||||
replace_flags(env["CCFLAGS"], {
|
replace_flags(
|
||||||
"-mios-simulator-version-min=10.0": "-mios-simulator-version-min=11.0",
|
cpp_env["CCFLAGS"],
|
||||||
"-miphoneos-version-min=10.0": "-miphoneos-version-min=11.0",
|
{
|
||||||
"/std:c++14": "/std:c++17",
|
"-mios-simulator-version-min=10.0": "-mios-simulator-version-min=12.0",
|
||||||
"-std=c++14": "-std=c++17",
|
"-miphoneos-version-min=10.0": "-miphoneos-version-min=12.0",
|
||||||
})
|
"/std:c++14": "/std:c++17",
|
||||||
|
"-std=c++14": "-std=c++17",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
env = env.Clone()
|
env = cpp_env.Clone()
|
||||||
|
|
||||||
if env["target"] == "debug":
|
if env["target"] == "debug":
|
||||||
env.Append(CPPDEFINES=["DEBUG_ENABLED"])
|
env.Append(CPPDEFINES=["DEBUG_ENABLED"])
|
||||||
@@ -52,10 +79,14 @@ if env["godot_version"] == "3":
|
|||||||
if env["platform"] == "osx":
|
if env["platform"] == "osx":
|
||||||
env["platform"] = "macos" # compatibility with old osx name
|
env["platform"] = "macos" # compatibility with old osx name
|
||||||
ARGUMENTS["platform"] = "macos"
|
ARGUMENTS["platform"] = "macos"
|
||||||
|
env["CC"] = "clang" # CC is not set in 3.x and can result in it being "gcc".
|
||||||
|
|
||||||
|
if env["platform"] == "ios":
|
||||||
|
env["ios_min_version"] = "12.0"
|
||||||
|
|
||||||
# Normalize suffix
|
# Normalize suffix
|
||||||
if env["platform"] in ["windows", "linux"]:
|
if env["platform"] in ["windows", "linux"]:
|
||||||
env["arch"] = "x86_32" if env["bits"] == "32" else "x86_64"
|
env["arch"] = ARGUMENTS.get("arch", "x86_32" if env["bits"] == "32" else "x86_64")
|
||||||
env["arch_suffix"] = env["arch"]
|
env["arch_suffix"] = env["arch"]
|
||||||
elif env["platform"] == "macos":
|
elif env["platform"] == "macos":
|
||||||
env["arch"] = env["macos_arch"]
|
env["arch"] = env["macos_arch"]
|
||||||
@@ -75,9 +106,37 @@ if env["godot_version"] == "3":
|
|||||||
target_compat = "template_" + env["target"]
|
target_compat = "template_" + env["target"]
|
||||||
env["suffix"] = ".{}.{}.{}".format(env["platform"], target_compat, env["arch_suffix"])
|
env["suffix"] = ".{}.{}.{}".format(env["platform"], target_compat, env["arch_suffix"])
|
||||||
env["debug_symbols"] = False
|
env["debug_symbols"] = False
|
||||||
|
|
||||||
|
# Some windows specific hacks.
|
||||||
|
if env["platform"] == "windows":
|
||||||
|
if sys.platform not in ["win32", "msys"]:
|
||||||
|
# Set missing CC for MinGW from upstream build module.
|
||||||
|
if env["bits"] == "64":
|
||||||
|
env["CC"] = "x86_64-w64-mingw32-gcc"
|
||||||
|
elif env["bits"] == "32":
|
||||||
|
env["CC"] = "i686-w64-mingw32-gcc"
|
||||||
|
elif not env["use_mingw"]:
|
||||||
|
# Mark as MSVC build (would have failed to build the library otherwise).
|
||||||
|
env["is_msvc"] = True
|
||||||
|
# Some linux specific hacks to allow cross-compiling for non-x86 machines.
|
||||||
|
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"]):
|
||||||
|
replace_flags(flags, {"-m32": None, "-m64": None})
|
||||||
else:
|
else:
|
||||||
ARGUMENTS["ios_min_version"] = "11.0"
|
sconstruct = env.get("godot_cpp", "godot-cpp") + "/SConstruct"
|
||||||
env = SConscript("godot-cpp/SConstruct").Clone()
|
cpp_env = SConscript(sconstruct)
|
||||||
|
env = cpp_env.Clone()
|
||||||
|
|
||||||
|
if cpp_env.get("is_msvc", False):
|
||||||
|
# Make sure we don't build with static cpp on MSVC (default in recent godot-cpp versions).
|
||||||
|
replace_flags(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
|
||||||
@@ -85,13 +144,19 @@ else:
|
|||||||
# Then we prepend PATH to make it take precedence, while preserving SCons' own entries.
|
# Then we prepend PATH to make it take precedence, while preserving SCons' own entries.
|
||||||
env.PrependENVPath("PATH", os.getenv("PATH"))
|
env.PrependENVPath("PATH", os.getenv("PATH"))
|
||||||
env.PrependENVPath("PKG_CONFIG_PATH", os.getenv("PKG_CONFIG_PATH"))
|
env.PrependENVPath("PKG_CONFIG_PATH", os.getenv("PKG_CONFIG_PATH"))
|
||||||
if "TERM" in os.environ: # Used for colored output.
|
if "TERM" in os.environ: # Used for colored output.
|
||||||
env["ENV"]["TERM"] = os.environ["TERM"]
|
env["ENV"]["TERM"] = os.environ["TERM"]
|
||||||
|
|
||||||
# Patch mingw SHLIBSUFFIX.
|
# Patch mingw SHLIBSUFFIX.
|
||||||
if env["platform"] == "windows" and env["use_mingw"]:
|
if env["platform"] == "windows" and env["use_mingw"]:
|
||||||
env["SHLIBSUFFIX"] = ".dll"
|
env["SHLIBSUFFIX"] = ".dll"
|
||||||
|
|
||||||
|
# Patch OSXCross config.
|
||||||
|
if env["platform"] == "macos" and os.environ.get("OSXCROSS_ROOT", ""):
|
||||||
|
env["SHLIBSUFFIX"] = ".dylib"
|
||||||
|
if env["macos_deployment_target"] != "default":
|
||||||
|
env["ENV"]["MACOSX_DEPLOYMENT_TARGET"] = env["macos_deployment_target"]
|
||||||
|
|
||||||
opts.Update(env)
|
opts.Update(env)
|
||||||
|
|
||||||
target = env["target"]
|
target = env["target"]
|
||||||
@@ -100,32 +165,9 @@ if env["godot_version"] == "3":
|
|||||||
else:
|
else:
|
||||||
result_path = os.path.join("bin", "extension", "webrtc")
|
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),
|
|
||||||
})
|
|
||||||
|
|
||||||
# SSL
|
|
||||||
ssl = env.BuildOpenSSL(env.Dir(builders.get_ssl_build_dir(env)), env.Dir(builders.get_ssl_source_dir(env)))
|
|
||||||
env.Depends(ssl, [env.File("builders.py"), env.File(builders.get_ssl_source_dir(env) + "/VERSION.dat")])
|
|
||||||
env.NoCache(ssl) # Needs refactoring to properly cache generated headers.
|
|
||||||
|
|
||||||
env.Prepend(CPPPATH=[builders.get_ssl_include_dir(env)])
|
|
||||||
env.Prepend(LIBPATH=[builders.get_ssl_build_dir(env)])
|
|
||||||
env.Append(LIBS=[builders.get_ssl_libs(env)])
|
|
||||||
|
|
||||||
# RTC
|
|
||||||
rtc = env.BuildLibDataChannel(env.Dir(builders.get_rtc_build_dir(env)), [env.Dir(builders.get_rtc_source_dir(env))] + ssl)
|
|
||||||
env.Depends(rtc, [env.File("builders.py"), env.File(builders.get_rtc_source_dir(env) + "/CMakeLists.txt")])
|
|
||||||
|
|
||||||
env.Append(LIBPATH=[builders.get_rtc_build_dir(env)])
|
|
||||||
env.Append(CPPPATH=[builders.get_rtc_include_dir(env)])
|
|
||||||
env.Prepend(LIBS=[builders.get_rtc_libs(env)])
|
|
||||||
|
|
||||||
# Our includes and sources
|
# Our includes and sources
|
||||||
env.Append(CPPPATH=["src/"])
|
env.Append(CPPPATH=["src/"])
|
||||||
|
env.Append(CPPDEFINES=["RTC_STATIC"])
|
||||||
sources = []
|
sources = []
|
||||||
sources.append(
|
sources.append(
|
||||||
[
|
[
|
||||||
@@ -133,33 +175,81 @@ sources.append(
|
|||||||
"src/WebRTCLibPeerConnection.cpp",
|
"src/WebRTCLibPeerConnection.cpp",
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
if env["godot_version"] == "4":
|
if env["godot_version"] == "3":
|
||||||
sources.append("src/init_gdextension.cpp")
|
|
||||||
else:
|
|
||||||
env.Append(CPPDEFINES=["GDNATIVE_WEBRTC"])
|
env.Append(CPPDEFINES=["GDNATIVE_WEBRTC"])
|
||||||
sources.append("src/init_gdnative.cpp")
|
sources.append("src/init_gdnative.cpp")
|
||||||
add_sources(sources, "src/net/", "cpp")
|
add_sources(sources, "src/net/", "cpp")
|
||||||
|
else:
|
||||||
|
sources.append("src/init_gdextension.cpp")
|
||||||
|
|
||||||
env.Depends(sources, [builders.get_ssl_libs(env), builders.get_rtc_libs(env)])
|
# Add our build tools
|
||||||
|
for tool in ["cmake", "mbedtls", "rtc"]:
|
||||||
|
env.Tool(tool, toolpath=["tools"])
|
||||||
|
|
||||||
|
# Make sure Substfile is also loaded
|
||||||
|
env.Tool("textfile")
|
||||||
|
|
||||||
|
mbedtls = env.BuildMbedTLS()
|
||||||
|
|
||||||
|
rtc = env.BuildLibDataChannel(mbedtls)
|
||||||
|
|
||||||
|
# Forces building our sources after OpenSSL and libdatachannel.
|
||||||
|
# This is because OpenSSL headers are generated by their build system and SCons doesn't know about them.
|
||||||
|
# Note: This might not be necessary in this specific case since our sources doesn't include OpenSSL headers directly,
|
||||||
|
# but it's better to be safe in case of indirect inclusions by one of our other dependencies.
|
||||||
|
env.Depends(sources, rtc + mbedtls)
|
||||||
|
|
||||||
|
# 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.
|
||||||
|
# Using "-fvisibility=hidden" will not work, since libstdc++ explicitly exports its symbols.
|
||||||
|
symbols_file = None
|
||||||
|
if env["platform"] == "linux" or (
|
||||||
|
env["platform"] == "windows" and env.get("use_mingw", False) and not env.get("use_llvm", False)
|
||||||
|
):
|
||||||
|
if env["godot_version"] == "3":
|
||||||
|
symbols_file = env.File("misc/gcc/symbols-gdnative.map")
|
||||||
|
else:
|
||||||
|
symbols_file = env.File("misc/gcc/symbols-extension.map")
|
||||||
|
env.Append(
|
||||||
|
LINKFLAGS=[
|
||||||
|
"-Wl,--no-undefined,--version-script=" + symbols_file.abspath,
|
||||||
|
"-static-libgcc",
|
||||||
|
"-static-libstdc++",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
env.Depends(sources, symbols_file)
|
||||||
|
|
||||||
# Make the shared library
|
# Make the shared library
|
||||||
result_name = "webrtc_native{}{}".format(env["suffix"], env["SHLIBSUFFIX"])
|
result_name = "libwebrtc_native{}{}".format(env["suffix"], env["SHLIBSUFFIX"])
|
||||||
env.Depends(sources, ssl)
|
if env["godot_version"] != "3" and env["platform"] == "macos":
|
||||||
|
framework_path = os.path.join(
|
||||||
|
result_path, "lib", "libwebrtc_native.macos.{}.{}.framework".format(env["target"], env["arch"])
|
||||||
|
)
|
||||||
|
library_file = env.SharedLibrary(target=os.path.join(framework_path, result_name), source=sources)
|
||||||
|
plist_file = env.Substfile(
|
||||||
|
os.path.join(framework_path, "Resources", "Info.plist"),
|
||||||
|
"misc/dist/macos/Info.plist",
|
||||||
|
SUBST_DICT={"{LIBRARY_NAME}": result_name, "{DISPLAY_NAME}": "libwebrtc_native" + env["suffix"]},
|
||||||
|
)
|
||||||
|
library = [library_file, plist_file]
|
||||||
|
else:
|
||||||
|
library = env.SharedLibrary(target=os.path.join(result_path, "lib", result_name), source=sources)
|
||||||
|
|
||||||
if env["platform"] == "windows" and env["use_mingw"]:
|
|
||||||
env.Append(LIBS=["iphlpapi", "ws2_32", "bcrypt"])
|
|
||||||
|
|
||||||
library = env.SharedLibrary(target=os.path.join(result_path, "lib", result_name), source=sources)
|
|
||||||
Default(library)
|
Default(library)
|
||||||
|
|
||||||
# GDNativeLibrary
|
# GDNativeLibrary
|
||||||
if env["godot_version"] == "3":
|
if env["godot_version"] == "3":
|
||||||
gdnlib = "webrtc" if target != "debug" else "webrtc_debug"
|
gdnlib = "webrtc" if target != "debug" else "webrtc_debug"
|
||||||
ext = ".tres"
|
ext = ".tres"
|
||||||
extfile = env.Substfile(os.path.join(result_path, gdnlib + ext), "misc/webrtc" + ext, SUBST_DICT={
|
extfile = env.Substfile(
|
||||||
"{GDNATIVE_PATH}": gdnlib,
|
os.path.join(result_path, gdnlib + ext),
|
||||||
"{TARGET}": "template_" + env["target"],
|
"misc/webrtc" + ext,
|
||||||
})
|
SUBST_DICT={
|
||||||
|
"{GDNATIVE_PATH}": gdnlib,
|
||||||
|
"{TARGET}": "template_" + env["target"],
|
||||||
|
},
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
extfile = env.InstallAs(os.path.join(result_path, "webrtc.gdextension"), "misc/webrtc.gdextension")
|
extfile = env.InstallAs(os.path.join(result_path, "webrtc.gdextension"), "misc/webrtc.gdextension")
|
||||||
|
|
||||||
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"
|
||||||
|
]
|
||||||
|
}
|
||||||
247
builders.py
247
builders.py
@@ -1,247 +0,0 @@
|
|||||||
import os
|
|
||||||
from SCons.Defaults import Mkdir
|
|
||||||
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/build{}.{}.dir".format(env["suffix"], "RelWithDebInfo" if env["debug_symbols"] else "Release")
|
|
||||||
|
|
||||||
|
|
||||||
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_rtc_libs(env):
|
|
||||||
bdir = get_rtc_build_dir(env)
|
|
||||||
libs = [
|
|
||||||
"libdatachannel-static.a",
|
|
||||||
"deps/libjuice/libjuice-static.a",
|
|
||||||
"deps/libsrtp/libsrtp2.a",
|
|
||||||
"deps/usrsctp/usrsctplib/libusrsctp.a"
|
|
||||||
]
|
|
||||||
return [env.File(bdir + "/" + lib) for lib in libs]
|
|
||||||
|
|
||||||
|
|
||||||
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 get_ssl_libs(env):
|
|
||||||
bdir = get_ssl_build_dir(env)
|
|
||||||
return [env.File(bdir + "/" + lib) for lib in ["libssl.a", "libcrypto.a"]]
|
|
||||||
|
|
||||||
|
|
||||||
def ssl_emitter(target, source, env):
|
|
||||||
return get_ssl_libs(env), source
|
|
||||||
|
|
||||||
|
|
||||||
def ssl_action(target, source, env):
|
|
||||||
build_dir = get_ssl_build_dir(env)
|
|
||||||
source_dir = source[0].abspath
|
|
||||||
|
|
||||||
ssl_env = env.Clone()
|
|
||||||
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["debug_symbols"]:
|
|
||||||
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(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 rtc_emitter(target, source, env):
|
|
||||||
return get_rtc_libs(env), source
|
|
||||||
|
|
||||||
|
|
||||||
def rtc_action(target, source, env):
|
|
||||||
build_dir = get_rtc_build_dir(env)
|
|
||||||
source_dir = source[0].abspath
|
|
||||||
args = [
|
|
||||||
"cmake",
|
|
||||||
"-B",
|
|
||||||
build_dir,
|
|
||||||
"-DUSE_NICE=0",
|
|
||||||
"-DNO_WEBSOCKET=1",
|
|
||||||
#"-DNO_MEDIA=1", # Windows builds fail without it.
|
|
||||||
"-DNO_EXAMPLES=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" % ("RelWithDebInfo" if env["debug_symbols"] else "Release"),
|
|
||||||
]
|
|
||||||
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 = env.Clone()
|
|
||||||
rtc_env.Execute([
|
|
||||||
" ".join(['"%s"' % a for a in 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 1ec2a2f519
1
deps/openssl
vendored
1
deps/openssl
vendored
Submodule deps/openssl deleted from 19cc035b6c
Submodule godot-cpp updated: 576bd17285...631cd5fe37
Submodule godot-cpp-3.x updated: ac572d5f84...7c09b5484d
28
misc/dist/macos/Info.plist
vendored
Normal file
28
misc/dist/macos/Info.plist
vendored
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>{LIBRARY_NAME}</string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>org.godotengine.webrtc-native</string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundleDisplayName</key>
|
||||||
|
<string>{DISPLAY_NAME}</string>
|
||||||
|
<key>CFBundleName</key>
|
||||||
|
<string>webrtc_native</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>FMWK</string>
|
||||||
|
<key>CFBundleShortVersionString</key>
|
||||||
|
<string>1.0.0</string>
|
||||||
|
<key>CFBundleSupportedPlatforms</key>
|
||||||
|
<array>
|
||||||
|
<string>MacOSX</string>
|
||||||
|
</array>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>1.0.0</string>
|
||||||
|
<key>LSMinimumSystemVersion</key>
|
||||||
|
<string>11.0</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
6
misc/gcc/symbols-extension.map
Normal file
6
misc/gcc/symbols-extension.map
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
global:
|
||||||
|
webrtc_extension_init;
|
||||||
|
local:
|
||||||
|
*;
|
||||||
|
};
|
||||||
9
misc/gcc/symbols-gdnative.map
Normal file
9
misc/gcc/symbols-gdnative.map
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
global:
|
||||||
|
godot_gdnative_singleton;
|
||||||
|
godot_gdnative_init;
|
||||||
|
godot_gdnative_terminate;
|
||||||
|
godot_nativescript_init;
|
||||||
|
local:
|
||||||
|
*;
|
||||||
|
};
|
||||||
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)
|
||||||
34
misc/patches/gdnantive_arm_warnings.diff
Normal file
34
misc/patches/gdnantive_arm_warnings.diff
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
diff --git a/godot-cpp-3.x/godot-headers/gdnative/gdnative.h b/godot-cpp-3.x/godot-headers/gdnative/gdnative.h
|
||||||
|
index c0573d21b5d7a..ec95c4c4ebfcc 100644
|
||||||
|
--- a/godot-cpp-3.x/godot-headers/gdnative/gdnative.h
|
||||||
|
+++ b/godot-cpp-3.x/godot-headers/gdnative/gdnative.h
|
||||||
|
@@ -37,20 +37,24 @@ extern "C" {
|
||||||
|
|
||||||
|
#if defined(_WIN32) || defined(__ANDROID__)
|
||||||
|
#define GDCALLINGCONV
|
||||||
|
-#define GDAPI GDCALLINGCONV
|
||||||
|
+
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
#include "TargetConditionals.h"
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
|
#define GDCALLINGCONV __attribute__((visibility("default")))
|
||||||
|
-#define GDAPI GDCALLINGCONV
|
||||||
|
#elif TARGET_OS_MAC
|
||||||
|
#define GDCALLINGCONV __attribute__((sysv_abi))
|
||||||
|
-#define GDAPI GDCALLINGCONV
|
||||||
|
#endif
|
||||||
|
-#else // !_WIN32 && !__APPLE__
|
||||||
|
+
|
||||||
|
+#else // Linux/BSD/Web
|
||||||
|
+#if defined(__aarch64__) || defined(__arm__)
|
||||||
|
+#define GDCALLINGCONV
|
||||||
|
+#else
|
||||||
|
#define GDCALLINGCONV __attribute__((sysv_abi))
|
||||||
|
-#define GDAPI GDCALLINGCONV
|
||||||
|
#endif
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
+#define GDAPI GDCALLINGCONV
|
||||||
|
|
||||||
|
// This is for libraries *using* the header, NOT GODOT EXPOSING STUFF!!
|
||||||
|
#if !defined(GDN_EXPORT)
|
||||||
15
misc/patches/scons_path.diff
Normal file
15
misc/patches/scons_path.diff
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
diff --git a/godot-cpp-3.x/SConstruct b/godot-cpp-3.x/SConstruct
|
||||||
|
index f653d54..6f40377 100644
|
||||||
|
--- a/godot-cpp-3.x/SConstruct
|
||||||
|
+++ b/godot-cpp-3.x/SConstruct
|
||||||
|
@@ -194,6 +194,9 @@ if host_platform == "windows" and env["platform"] != "android":
|
||||||
|
|
||||||
|
opts.Update(env)
|
||||||
|
|
||||||
|
+# Allows us to use Godot buildroot toolchain
|
||||||
|
+env.PrependENVPath("PATH", os.getenv("PATH"))
|
||||||
|
+
|
||||||
|
# Require C++14
|
||||||
|
if host_platform == "windows" and env["platform"] == "windows" and not env["use_mingw"]:
|
||||||
|
# MSVC
|
||||||
|
|
||||||
@@ -6,29 +6,21 @@ set -uo pipefail
|
|||||||
|
|
||||||
# Apply black.
|
# Apply black.
|
||||||
echo -e "Formatting Python files..."
|
echo -e "Formatting Python files..."
|
||||||
PY_FILES=$(find \( -path "./.git" \
|
PY_FILES=$(git ls-files -- '*SConstruct' '*SCsub' '*.py' ':!:.git/*' ':!:thirdparty/*')
|
||||||
-o -path "./webrtc" \
|
|
||||||
-o -path "./godot-cpp" \
|
|
||||||
\) -prune \
|
|
||||||
-o \( -name "SConstruct" \
|
|
||||||
-o -name "SCsub" \
|
|
||||||
-o -name "*.py" \
|
|
||||||
\) -print)
|
|
||||||
black -l 120 $PY_FILES
|
black -l 120 $PY_FILES
|
||||||
|
|
||||||
git diff > patch.patch
|
diff=$(git diff --color)
|
||||||
|
|
||||||
# If no patch has been generated all is OK, clean up, and exit.
|
# If no diff has been generated all is OK, clean up, and exit.
|
||||||
if [ ! -s patch.patch ] ; then
|
if [ -z "$diff" ] ; then
|
||||||
printf "Files in this commit comply with the black style rules.\n"
|
printf "\e[1;32m*** Files in this commit comply with the black style rules.\e[0m\n"
|
||||||
rm -f patch.patch
|
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# A patch has been created, notify the user, clean up, and exit.
|
# A diff has been created, notify the user, clean up, and exit.
|
||||||
printf "\n*** The following differences were found between the code "
|
printf "\n\e[1;33m*** The following changes must be made to comply with the formatting rules:\e[0m\n\n"
|
||||||
printf "and the formatting rules:\n\n"
|
# Perl commands replace trailing spaces with `·` and tabs with `<TAB>`.
|
||||||
cat patch.patch
|
printf "$diff\n" | perl -pe 's/(.*[^ ])( +)(\e\[m)$/my $spaces="·" x length($2); sprintf("$1$spaces$3")/ge' | perl -pe 's/(.*[^\t])(\t+)(\e\[m)$/my $tabs="<TAB>" x length($2); sprintf("$1$tabs$3")/ge'
|
||||||
printf "\n*** Aborting, please fix your commit(s) with 'git commit --amend' or 'git rebase -i <hash>'\n"
|
|
||||||
rm -f patch.patch
|
printf "\n\e[1;91m*** Please fix your commit(s) with 'git commit --amend' or 'git rebase -i <hash>'\e[0m\n"
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
@@ -4,55 +4,50 @@
|
|||||||
# This is the primary script responsible for fixing style violations.
|
# This is the primary script responsible for fixing style violations.
|
||||||
|
|
||||||
set -uo pipefail
|
set -uo pipefail
|
||||||
IFS=$'\n\t'
|
|
||||||
|
|
||||||
CLANG_FORMAT_FILE_EXTS=(".c" ".h" ".cpp" ".hpp" ".cc" ".hh" ".cxx" ".m" ".mm" ".inc" ".java" ".glsl")
|
if [ $# -eq 0 ]; then
|
||||||
|
# Loop through all code files tracked by Git.
|
||||||
|
files=$(git ls-files -- '*.c' '*.h' '*.cpp' '*.hpp' '*.cc' '*.hh' '*.cxx' '*.m' '*.mm' '*.inc' '*.java' '*.glsl' \
|
||||||
|
':!:.git/*' ':!:thirdparty/*' ':!:*/thirdparty/*' ':!:platform/android/java/lib/src/com/google/*' \
|
||||||
|
':!:*-so_wrap.*' ':!:tests/python_build/*')
|
||||||
|
else
|
||||||
|
# $1 should be a file listing file paths to process. Used in CI.
|
||||||
|
files=$(cat "$1" | grep -v "thirdparty/" | grep -E "\.(c|h|cpp|hpp|cc|hh|cxx|m|mm|inc|java|glsl)$" | grep -v "platform/android/java/lib/src/com/google/" | grep -v "\-so_wrap\." | grep -v "tests/python_build/")
|
||||||
|
fi
|
||||||
|
|
||||||
# Loops through all text files tracked by Git.
|
if [ ! -z "$files" ]; then
|
||||||
git grep -zIl '' |
|
clang-format --Wno-error=unknown -i $files
|
||||||
while IFS= read -rd '' f; do
|
fi
|
||||||
# Exclude some files.
|
|
||||||
if [[ "$f" == "thirdparty"* ]]; then
|
# Fix copyright headers, but not all files get them.
|
||||||
|
for f in $files; do
|
||||||
|
if [[ "$f" == *"inc" ]]; then
|
||||||
continue
|
continue
|
||||||
elif [[ "$f" == "platform/android/java/lib/src/com/google"* ]]; then
|
elif [[ "$f" == *"glsl" ]]; then
|
||||||
continue
|
continue
|
||||||
elif [[ "$f" == *"-so_wrap."* ]]; then
|
elif [[ "$f" == "platform/android/java/lib/src/org/godotengine/godot/gl/GLSurfaceView"* ]]; then
|
||||||
|
continue
|
||||||
|
elif [[ "$f" == "platform/android/java/lib/src/org/godotengine/godot/gl/EGLLogWrapper"* ]]; then
|
||||||
|
continue
|
||||||
|
elif [[ "$f" == "platform/android/java/lib/src/org/godotengine/godot/utils/ProcessPhoenix"* ]]; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for extension in ${CLANG_FORMAT_FILE_EXTS[@]}; do
|
python misc/scripts/copyright_headers.py "$f"
|
||||||
if [[ "$f" == *"$extension" ]]; then
|
|
||||||
# Run clang-format.
|
|
||||||
clang-format -i "$f"
|
|
||||||
# Fix copyright headers, but not all files get them.
|
|
||||||
if [[ "$f" == *"inc" ]]; then
|
|
||||||
continue 2
|
|
||||||
elif [[ "$f" == *"glsl" ]]; then
|
|
||||||
continue 2
|
|
||||||
elif [[ "$f" == *"theme_data.h" ]]; then
|
|
||||||
continue 2
|
|
||||||
elif [[ "$f" == "platform/android/java/lib/src/org/godotengine/godot/input/InputManager"* ]]; then
|
|
||||||
continue 2
|
|
||||||
fi
|
|
||||||
python misc/scripts/copyright_headers.py "$f"
|
|
||||||
continue 2
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
done
|
done
|
||||||
|
|
||||||
git diff > patch.patch
|
diff=$(git diff --color)
|
||||||
|
|
||||||
# If no patch has been generated all is OK, clean up, and exit.
|
# If no diff has been generated all is OK, clean up, and exit.
|
||||||
if [ ! -s patch.patch ] ; then
|
if [ -z "$diff" ] ; then
|
||||||
printf "Files in this commit comply with the clang-format style rules.\n"
|
printf "\e[1;32m*** Files in this commit comply with the clang-format style rules.\e[0m\n"
|
||||||
rm -f patch.patch
|
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# A patch has been created, notify the user, clean up, and exit.
|
# A diff has been created, notify the user, clean up, and exit.
|
||||||
printf "\n*** The following differences were found between the code "
|
printf "\n\e[1;33m*** The following changes must be made to comply with the formatting rules:\e[0m\n\n"
|
||||||
printf "and the formatting rules:\n\n"
|
# Perl commands replace trailing spaces with `·` and tabs with `<TAB>`.
|
||||||
cat patch.patch
|
printf "$diff\n" | perl -pe 's/(.*[^ ])( +)(\e\[m)$/my $spaces="·" x length($2); sprintf("$1$spaces$3")/ge' | perl -pe 's/(.*[^\t])(\t+)(\e\[m)$/my $tabs="<TAB>" x length($2); sprintf("$1$tabs$3")/ge'
|
||||||
printf "\n*** Aborting, please fix your commit(s) with 'git commit --amend' or 'git rebase -i <hash>'\n"
|
|
||||||
rm -f patch.patch
|
printf "\n\e[1;91m*** Please fix your commit(s) with 'git commit --amend' or 'git rebase -i <hash>'\e[0m\n"
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
@@ -4,35 +4,35 @@
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
header = """\
|
header = """\
|
||||||
/*************************************************************************/
|
/**************************************************************************/
|
||||||
/* $filename */
|
/* $filename */
|
||||||
/*************************************************************************/
|
/**************************************************************************/
|
||||||
/* This file is part of: */
|
/* This file is part of: */
|
||||||
/* GODOT ENGINE */
|
/* GODOT ENGINE */
|
||||||
/* https://godotengine.org */
|
/* https://godotengine.org */
|
||||||
/*************************************************************************/
|
/**************************************************************************/
|
||||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||||
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
|
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||||
/* */
|
/* */
|
||||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||||
/* a copy of this software and associated documentation files (the */
|
/* a copy of this software and associated documentation files (the */
|
||||||
/* "Software"), to deal in the Software without restriction, including */
|
/* "Software"), to deal in the Software without restriction, including */
|
||||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||||
/* the following conditions: */
|
/* the following conditions: */
|
||||||
/* */
|
/* */
|
||||||
/* The above copyright notice and this permission notice shall be */
|
/* The above copyright notice and this permission notice shall be */
|
||||||
/* included in all copies or substantial portions of the Software. */
|
/* included in all copies or substantial portions of the Software. */
|
||||||
/* */
|
/* */
|
||||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
/*************************************************************************/
|
/**************************************************************************/
|
||||||
"""
|
"""
|
||||||
|
|
||||||
fname = sys.argv[1]
|
fname = sys.argv[1]
|
||||||
|
|||||||
@@ -4,27 +4,54 @@
|
|||||||
# This is supplementary to clang_format.sh and black_format.sh, but should be
|
# This is supplementary to clang_format.sh and black_format.sh, but should be
|
||||||
# run before them.
|
# run before them.
|
||||||
|
|
||||||
# We need dos2unix and recode.
|
# We need dos2unix and isutf8.
|
||||||
if [ ! -x "$(command -v dos2unix)" -o ! -x "$(command -v recode)" ]; then
|
if [ ! -x "$(command -v dos2unix)" -o ! -x "$(command -v isutf8)" ]; then
|
||||||
printf "Install 'dos2unix' and 'recode' to use this script.\n"
|
printf "Install 'dos2unix' and 'isutf8' (moreutils package) to use this script.\n"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
set -uo pipefail
|
set -uo pipefail
|
||||||
IFS=$'\n\t'
|
|
||||||
|
|
||||||
# Loops through all text files tracked by Git.
|
if [ $# -eq 0 ]; then
|
||||||
git grep -zIl '' |
|
# Loop through all code files tracked by Git.
|
||||||
while IFS= read -rd '' f; do
|
mapfile -d '' files < <(git grep -zIl '')
|
||||||
|
else
|
||||||
|
# $1 should be a file listing file paths to process. Used in CI.
|
||||||
|
mapfile -d ' ' < <(cat "$1")
|
||||||
|
fi
|
||||||
|
|
||||||
|
for f in "${files[@]}"; do
|
||||||
# Exclude some types of files.
|
# Exclude some types of files.
|
||||||
if [[ "$f" == "webrtc"* ]]; then
|
if [[ "$f" == *"csproj" ]]; then
|
||||||
continue
|
continue
|
||||||
elif [[ "$f" == "godot-cpp"* ]]; then
|
elif [[ "$f" == *"sln" ]]; then
|
||||||
continue
|
continue
|
||||||
elif [[ "$f" == "misc/patches"* ]]; then
|
elif [[ "$f" == *".bat" ]]; then
|
||||||
|
continue
|
||||||
|
elif [[ "$f" == *".out" ]]; then
|
||||||
|
# GDScript integration testing files.
|
||||||
|
continue
|
||||||
|
elif [[ "$f" == *"patch" ]]; then
|
||||||
|
continue
|
||||||
|
elif [[ "$f" == *"pot" ]]; then
|
||||||
|
continue
|
||||||
|
elif [[ "$f" == *"po" ]]; then
|
||||||
|
continue
|
||||||
|
elif [[ "$f" == "thirdparty/"* ]]; then
|
||||||
|
continue
|
||||||
|
elif [[ "$f" == "misc/patches/"* ]]; then
|
||||||
|
continue
|
||||||
|
elif [[ "$f" == *"/thirdparty/"* ]]; then
|
||||||
|
continue
|
||||||
|
elif [[ "$f" == "platform/android/java/lib/src/com/google"* ]]; then
|
||||||
|
continue
|
||||||
|
elif [[ "$f" == *"-so_wrap."* ]]; then
|
||||||
|
continue
|
||||||
|
elif [[ "$f" == *".test.txt" ]]; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
# Ensure that files are UTF-8 formatted.
|
# Ensure that files are UTF-8 formatted.
|
||||||
recode UTF-8 "$f" 2> /dev/null
|
isutf8 "$f" >> utf8-validation.txt 2>&1
|
||||||
# Ensure that files have LF line endings and do not contain a BOM.
|
# Ensure that files have LF line endings and do not contain a BOM.
|
||||||
dos2unix "$f" 2> /dev/null
|
dos2unix "$f" 2> /dev/null
|
||||||
# Remove trailing space characters and ensures that files end
|
# Remove trailing space characters and ensures that files end
|
||||||
@@ -32,19 +59,33 @@ while IFS= read -rd '' f; do
|
|||||||
perl -i -ple 's/\s*$//g' "$f"
|
perl -i -ple 's/\s*$//g' "$f"
|
||||||
done
|
done
|
||||||
|
|
||||||
git diff > patch.patch
|
diff=$(git diff --color)
|
||||||
|
|
||||||
# If no patch has been generated all is OK, clean up, and exit.
|
if [ ! -s utf8-validation.txt ] && [ -z "$diff" ] ; then
|
||||||
if [ ! -s patch.patch ] ; then
|
# If no UTF-8 violations were collected (the file is empty) and
|
||||||
printf "Files in this commit comply with the formatting rules.\n"
|
# no diff has been generated all is OK, clean up, and exit.
|
||||||
rm -f patch.patch
|
printf "\e[1;32m*** Files in this commit comply with the file formatting rules.\e[0m\n"
|
||||||
|
rm -f utf8-validation.txt
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# A patch has been created, notify the user, clean up, and exit.
|
if [ -s utf8-validation.txt ]
|
||||||
printf "\n*** The following differences were found between the code "
|
then
|
||||||
printf "and the formatting rules:\n\n"
|
# If the file has content and is not empty, violations
|
||||||
cat patch.patch
|
# detected, notify the user, clean up, and exit.
|
||||||
printf "\n*** Aborting, please fix your commit(s) with 'git commit --amend' or 'git rebase -i <hash>'\n"
|
printf "\n\e[1;33m*** The following files contain invalid UTF-8 character sequences:\e[0m\n\n"
|
||||||
rm -f patch.patch
|
cat utf8-validation.txt
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -f utf8-validation.txt
|
||||||
|
|
||||||
|
if [ ! -z "$diff" ]
|
||||||
|
then
|
||||||
|
# A diff has been created, notify the user, clean up, and exit.
|
||||||
|
printf "\n\e[1;33m*** The following changes must be made to comply with the formatting rules:\e[0m\n\n"
|
||||||
|
# Perl commands replace trailing spaces with `·` and tabs with `<TAB>`.
|
||||||
|
printf "$diff\n" | perl -pe 's/(.*[^ ])( +)(\e\[m)$/my $spaces="·" x length($2); sprintf("$1$spaces$3")/ge' | perl -pe 's/(.*[^\t])(\t+)(\e\[m)$/my $tabs="<TAB>" x length($2); sprintf("$1$tabs$3")/ge'
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf "\n\e[1;91m*** Please fix your commit(s) with 'git commit --amend' or 'git rebase -i <hash>'\e[0m\n"
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
@@ -10,18 +10,19 @@ TYPE=${TYPE:-"webrtc"}
|
|||||||
|
|
||||||
mkdir -p ${DESTINATION}
|
mkdir -p ${DESTINATION}
|
||||||
ls -R ${DESTINATION}
|
ls -R ${DESTINATION}
|
||||||
|
ls -R ${ARTIFACTS}
|
||||||
|
|
||||||
DESTDIR="${DESTINATION}/${VERSION}/${TYPE}"
|
DESTDIR="${DESTINATION}/${VERSION}/${TYPE}"
|
||||||
|
|
||||||
mkdir -p ${DESTDIR}/lib
|
mkdir -p ${DESTDIR}/lib
|
||||||
|
|
||||||
find "${ARTIFACTS}" -wholename "*/${VERSION}/${TYPE}/lib/*" | xargs cp -t "${DESTDIR}/lib/"
|
find "${ARTIFACTS}" -maxdepth 5 -wholename "*/${VERSION}/${TYPE}/lib/*" | xargs cp -r -t "${DESTDIR}/lib/"
|
||||||
find "${ARTIFACTS}" -wholename "*/LICENSE*" | xargs cp -t "${DESTDIR}/"
|
find "${ARTIFACTS}" -wholename "*/LICENSE*" | xargs cp -t "${DESTDIR}/"
|
||||||
|
|
||||||
if [ $VERSION = "extension" ]; then
|
if [ $VERSION = "gdnative" ]; 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}/"
|
find "${ARTIFACTS}" -wholename "*/${VERSION}/${TYPE}/${TYPE}.tres" | head -n 1 | xargs cp -t "${DESTDIR}/"
|
||||||
|
else
|
||||||
|
find "${ARTIFACTS}" -wholename "*/${VERSION}/${TYPE}/${TYPE}.gdextension" | head -n 1 | xargs cp -t "${DESTDIR}/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
CURDIR=$(pwd)
|
CURDIR=$(pwd)
|
||||||
|
|||||||
@@ -1,27 +1,30 @@
|
|||||||
[configuration]
|
[configuration]
|
||||||
|
|
||||||
entry_symbol = "webrtc_extension_init"
|
entry_symbol = "webrtc_extension_init"
|
||||||
|
compatibility_minimum = 4.1
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
|
|
||||||
linux.debug.x86_64 = "res://webrtc/lib/libwebrtc_native.linux.template_debug.x86_64.so"
|
linux.debug.x86_64 = "lib/libwebrtc_native.linux.template_debug.x86_64.so"
|
||||||
linux.debug.x86_32 = "res://webrtc/lib/libwebrtc_native.linux.template_debug.x86_32.so"
|
linux.debug.x86_32 = "lib/libwebrtc_native.linux.template_debug.x86_32.so"
|
||||||
macos.debug.x86_64 = "res://webrtc/lib/libwebrtc_native.macos.template_debug.x86_64.dylib"
|
linux.debug.arm64 = "lib/libwebrtc_native.linux.template_debug.arm64.so"
|
||||||
macos.debug.arm64 = "res://webrtc/lib/libwebrtc_native.macos.template_debug.arm64.dylib"
|
linux.debug.arm32 = "lib/libwebrtc_native.linux.template_debug.arm32.so"
|
||||||
windows.debug.x86_64 = "res://webrtc/lib/libwebrtc_native.windows.template_debug.x86_64.dll"
|
macos.debug = "lib/libwebrtc_native.macos.template_debug.universal.framework"
|
||||||
windows.debug.x86_32 = "res://webrtc/lib/libwebrtc_native.windows.template_debug.x86_32.dll"
|
windows.debug.x86_64 = "lib/libwebrtc_native.windows.template_debug.x86_64.dll"
|
||||||
android.debug.arm64 = "res://webrtc/lib/libwebrtc_native.android.template_debug.arm64.so"
|
windows.debug.x86_32 = "lib/libwebrtc_native.windows.template_debug.x86_32.dll"
|
||||||
android.debug.x86_64 = "res://webrtc/lib/libwebrtc_native.android.template_debug.x86_64.so"
|
android.debug.arm64 = "lib/libwebrtc_native.android.template_debug.arm64.so"
|
||||||
ios.debug.arm64 = "res://webrtc/lib/libwebrtc_native.ios.template_debug.arm64.dylib"
|
android.debug.x86_64 = "lib/libwebrtc_native.android.template_debug.x86_64.so"
|
||||||
ios.debug.x86_64 = "res://webrtc/lib/libwebrtc_native.ios.template_debug.x86_64.simulator.dylib"
|
ios.debug.arm64 = "lib/libwebrtc_native.ios.template_debug.arm64.dylib"
|
||||||
|
ios.debug.x86_64 = "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_64 = "lib/libwebrtc_native.linux.template_release.x86_64.so"
|
||||||
linux.release.x86_32 = "res://webrtc/lib/libwebrtc_native.linux.template_release.x86_32.so"
|
linux.release.x86_32 = "lib/libwebrtc_native.linux.template_release.x86_32.so"
|
||||||
macos.release.x86_64 = "res://webrtc/lib/libwebrtc_native.macos.template_release.x86_64.dylib"
|
linux.release.arm64 = "lib/libwebrtc_native.linux.template_release.arm64.so"
|
||||||
macos.release.arm64 = "res://webrtc/lib/libwebrtc_native.macos.template_release.arm64.dylib"
|
linux.release.arm32 = "lib/libwebrtc_native.linux.template_release.arm32.so"
|
||||||
windows.release.x86_64 = "res://webrtc/lib/libwebrtc_native.windows.template_release.x86_64.dll"
|
macos.release = "lib/libwebrtc_native.macos.template_release.universal.framework"
|
||||||
windows.release.x86_32 = "res://webrtc/lib/libwebrtc_native.windows.template_release.x86_32.dll"
|
windows.release.x86_64 = "lib/libwebrtc_native.windows.template_release.x86_64.dll"
|
||||||
android.release.arm64 = "res://webrtc/lib/libwebrtc_native.android.template_release.arm64.so"
|
windows.release.x86_32 = "lib/libwebrtc_native.windows.template_release.x86_32.dll"
|
||||||
android.release.x86_64 = "res://webrtc/lib/libwebrtc_native.android.template_release.x86_64.so"
|
android.release.arm64 = "lib/libwebrtc_native.android.template_release.arm64.so"
|
||||||
ios.release.arm64 = "res://webrtc/lib/libwebrtc_native.ios.template_release.arm64.dylib"
|
android.release.x86_64 = "lib/libwebrtc_native.android.template_release.x86_64.so"
|
||||||
ios.release.x86_64 = "res://webrtc/lib/libwebrtc_native.ios.template_release.x86_64.simulator.dylib"
|
ios.release.arm64 = "lib/libwebrtc_native.ios.template_release.arm64.dylib"
|
||||||
|
ios.release.x86_64 = "lib/libwebrtc_native.ios.template_release.x86_64.simulator.dylib"
|
||||||
|
|||||||
@@ -3,24 +3,19 @@
|
|||||||
[resource]
|
[resource]
|
||||||
singleton = true
|
singleton = true
|
||||||
reloadable = false
|
reloadable = false
|
||||||
entry/OSX.64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.osx.{TARGET}.x86_64.dylib"
|
entry/OSX.64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.macos.{TARGET}.universal.dylib"
|
||||||
entry/OSX.arm64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.osx.{TARGET}.arm64.dylib"
|
|
||||||
entry/Windows.64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.windows.{TARGET}.x86_64.dll"
|
entry/Windows.64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.windows.{TARGET}.x86_64.dll"
|
||||||
entry/Windows.32 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.windows.{TARGET}.x86_32.dll"
|
entry/Windows.32 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.windows.{TARGET}.x86_32.dll"
|
||||||
entry/X11.64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.linux.{TARGET}.x86_64.so"
|
entry/X11.64.x86_64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.linux.{TARGET}.x86_64.so"
|
||||||
entry/X11.32 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.linux.{TARGET}.x86_32.so"
|
entry/X11.32.x86_32 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.linux.{TARGET}.x86_32.so"
|
||||||
entry/Server.64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.linux.{TARGET}.x86_64.so"
|
entry/X11.64.arm64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.linux.{TARGET}.arm64.so"
|
||||||
entry/Server.32 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.linux.{TARGET}.x86_32.so"
|
entry/X11.32.arm32 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.linux.{TARGET}.arm32.so"
|
||||||
|
entry/Server.64.x86_64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.linux.{TARGET}.x86_64.so"
|
||||||
|
entry/Server.32.x86_32 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.linux.{TARGET}.x86_32.so"
|
||||||
|
entry/Server.64.arm64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.linux.{TARGET}.arm64.so"
|
||||||
|
entry/Server.32.arm32 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.linux.{TARGET}.arm32.so"
|
||||||
entry/Android.arm64-v8a = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.android.{TARGET}.arm64.so"
|
entry/Android.arm64-v8a = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.android.{TARGET}.arm64.so"
|
||||||
entry/Android.x64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.android.{TARGET}.x86_64.so"
|
entry/Android.x64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.android.{TARGET}.x86_64.so"
|
||||||
entry/iOS.armv7 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.ios.{TARGET}.armv32.dylib"
|
entry/iOS.armv7 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.ios.{TARGET}.armv32.dylib"
|
||||||
entry/iOS.arm64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.ios.{TARGET}.arm64.dylib"
|
entry/iOS.arm64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.ios.{TARGET}.arm64.dylib"
|
||||||
entry/iOS.x86_64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.ios.{TARGET}.x86_64.simulator.dylib"
|
entry/iOS.x86_64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.ios.{TARGET}.x86_64.simulator.dylib"
|
||||||
dependency/Windows.64 = [ ]
|
|
||||||
dependency/Windows.32 = [ ]
|
|
||||||
dependency/X11.64 = [ ]
|
|
||||||
dependency/X11.32 = [ ]
|
|
||||||
dependency/Server.64 = [ ]
|
|
||||||
dependency/Server.32 = [ ]
|
|
||||||
dependency/Android.armeabi-v7a = [ ]
|
|
||||||
dependency/Android.arm64-v8a = [ ]
|
|
||||||
|
|||||||
@@ -1,32 +1,32 @@
|
|||||||
/*************************************************************************/
|
/**************************************************************************/
|
||||||
/* WebRTCLibDataChannel.cpp */
|
/* WebRTCLibDataChannel.cpp */
|
||||||
/*************************************************************************/
|
/**************************************************************************/
|
||||||
/* This file is part of: */
|
/* This file is part of: */
|
||||||
/* GODOT ENGINE */
|
/* GODOT ENGINE */
|
||||||
/* https://godotengine.org */
|
/* https://godotengine.org */
|
||||||
/*************************************************************************/
|
/**************************************************************************/
|
||||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||||
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
|
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||||
/* */
|
/* */
|
||||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||||
/* a copy of this software and associated documentation files (the */
|
/* a copy of this software and associated documentation files (the */
|
||||||
/* "Software"), to deal in the Software without restriction, including */
|
/* "Software"), to deal in the Software without restriction, including */
|
||||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||||
/* the following conditions: */
|
/* the following conditions: */
|
||||||
/* */
|
/* */
|
||||||
/* The above copyright notice and this permission notice shall be */
|
/* The above copyright notice and this permission notice shall be */
|
||||||
/* included in all copies or substantial portions of the Software. */
|
/* included in all copies or substantial portions of the Software. */
|
||||||
/* */
|
/* */
|
||||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
/*************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
#include "WebRTCLibDataChannel.hpp"
|
#include "WebRTCLibDataChannel.hpp"
|
||||||
|
|
||||||
@@ -136,19 +136,19 @@ bool WebRTCLibDataChannel::_is_ordered() const {
|
|||||||
return channel->reliability().unordered == false;
|
return channel->reliability().unordered == false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t WebRTCLibDataChannel::_get_id() const {
|
int32_t WebRTCLibDataChannel::_get_id() const {
|
||||||
ERR_FAIL_COND_V(!channel, -1);
|
ERR_FAIL_COND_V(!channel, -1);
|
||||||
return channel->id().value_or(-1);
|
return channel->id().value_or(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t WebRTCLibDataChannel::_get_max_packet_life_time() const {
|
int32_t WebRTCLibDataChannel::_get_max_packet_life_time() const {
|
||||||
ERR_FAIL_COND_V(!channel, 0);
|
ERR_FAIL_COND_V(!channel, 0);
|
||||||
return channel->reliability().type == rtc::Reliability::Type::Timed ? std::get<std::chrono::milliseconds>(channel->reliability().rexmit).count() : -1;
|
return channel->reliability().maxPacketLifeTime.has_value() ? channel->reliability().maxPacketLifeTime.value().count() : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t WebRTCLibDataChannel::_get_max_retransmits() const {
|
int32_t WebRTCLibDataChannel::_get_max_retransmits() const {
|
||||||
ERR_FAIL_COND_V(!channel, 0);
|
ERR_FAIL_COND_V(!channel, 0);
|
||||||
return channel->reliability().type == rtc::Reliability::Type::Rexmit ? std::get<int>(channel->reliability().rexmit) : -1;
|
return channel->reliability().maxRetransmits.value_or(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
String WebRTCLibDataChannel::_get_protocol() const {
|
String WebRTCLibDataChannel::_get_protocol() const {
|
||||||
@@ -161,7 +161,7 @@ bool WebRTCLibDataChannel::_is_negotiated() const {
|
|||||||
return negotiated;
|
return negotiated;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t WebRTCLibDataChannel::_get_buffered_amount() const {
|
int32_t WebRTCLibDataChannel::_get_buffered_amount() const {
|
||||||
ERR_FAIL_COND_V(!channel, 0);
|
ERR_FAIL_COND_V(!channel, 0);
|
||||||
return channel->bufferedAmount();
|
return channel->bufferedAmount();
|
||||||
}
|
}
|
||||||
@@ -194,7 +194,7 @@ Error WebRTCLibDataChannel::_get_packet(const uint8_t **r_buffer, int32_t *r_len
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
Error WebRTCLibDataChannel::_put_packet(const uint8_t *p_buffer, int64_t p_len) try {
|
Error WebRTCLibDataChannel::_put_packet(const uint8_t *p_buffer, int32_t p_len) try {
|
||||||
ERR_FAIL_COND_V(!channel, FAILED);
|
ERR_FAIL_COND_V(!channel, FAILED);
|
||||||
ERR_FAIL_COND_V(channel->isClosed(), FAILED);
|
ERR_FAIL_COND_V(channel->isClosed(), FAILED);
|
||||||
if (write_mode == WRITE_MODE_TEXT) {
|
if (write_mode == WRITE_MODE_TEXT) {
|
||||||
@@ -212,11 +212,11 @@ Error WebRTCLibDataChannel::_put_packet(const uint8_t *p_buffer, int64_t p_len)
|
|||||||
ERR_FAIL_V(FAILED);
|
ERR_FAIL_V(FAILED);
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t WebRTCLibDataChannel::_get_available_packet_count() const {
|
int32_t WebRTCLibDataChannel::_get_available_packet_count() const {
|
||||||
return packet_queue.size();
|
return packet_queue.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t WebRTCLibDataChannel::_get_max_packet_size() const {
|
int32_t WebRTCLibDataChannel::_get_max_packet_size() const {
|
||||||
return 16384; // See RFC-8831 section 6.6: https://datatracker.ietf.org/doc/rfc8831/
|
return 16384; // See RFC-8831 section 6.6: https://datatracker.ietf.org/doc/rfc8831/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,32 +1,32 @@
|
|||||||
/*************************************************************************/
|
/**************************************************************************/
|
||||||
/* WebRTCLibDataChannel.hpp */
|
/* WebRTCLibDataChannel.hpp */
|
||||||
/*************************************************************************/
|
/**************************************************************************/
|
||||||
/* This file is part of: */
|
/* This file is part of: */
|
||||||
/* GODOT ENGINE */
|
/* GODOT ENGINE */
|
||||||
/* https://godotengine.org */
|
/* https://godotengine.org */
|
||||||
/*************************************************************************/
|
/**************************************************************************/
|
||||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||||
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
|
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||||
/* */
|
/* */
|
||||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||||
/* a copy of this software and associated documentation files (the */
|
/* a copy of this software and associated documentation files (the */
|
||||||
/* "Software"), to deal in the Software without restriction, including */
|
/* "Software"), to deal in the Software without restriction, including */
|
||||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||||
/* the following conditions: */
|
/* the following conditions: */
|
||||||
/* */
|
/* */
|
||||||
/* The above copyright notice and this permission notice shall be */
|
/* The above copyright notice and this permission notice shall be */
|
||||||
/* included in all copies or substantial portions of the Software. */
|
/* included in all copies or substantial portions of the Software. */
|
||||||
/* */
|
/* */
|
||||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
/*************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
#ifndef WEBRTC_DATA_CHANNEL_H
|
#ifndef WEBRTC_DATA_CHANNEL_H
|
||||||
#define WEBRTC_DATA_CHANNEL_H
|
#define WEBRTC_DATA_CHANNEL_H
|
||||||
@@ -74,14 +74,18 @@ private:
|
|||||||
protected:
|
protected:
|
||||||
static void _bind_methods() {}
|
static void _bind_methods() {}
|
||||||
|
|
||||||
|
godot::String _to_string() const {
|
||||||
|
return "WebRTCLibDataChannel";
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static WebRTCLibDataChannel *new_data_channel(std::shared_ptr<rtc::DataChannel> p_channel, bool p_negotiated);
|
static WebRTCLibDataChannel *new_data_channel(std::shared_ptr<rtc::DataChannel> p_channel, bool p_negotiated);
|
||||||
|
|
||||||
/* PacketPeer */
|
/* PacketPeer */
|
||||||
virtual godot::Error _get_packet(const uint8_t **r_buffer, int32_t *r_len) override;
|
virtual godot::Error _get_packet(const uint8_t **r_buffer, int32_t *r_len) override;
|
||||||
virtual godot::Error _put_packet(const uint8_t *p_buffer, int64_t p_len) override;
|
virtual godot::Error _put_packet(const uint8_t *p_buffer, int32_t p_len) override;
|
||||||
virtual int64_t _get_available_packet_count() const override;
|
virtual int32_t _get_available_packet_count() const override;
|
||||||
virtual int64_t _get_max_packet_size() const override;
|
virtual int32_t _get_max_packet_size() const override;
|
||||||
|
|
||||||
/* WebRTCDataChannel */
|
/* WebRTCDataChannel */
|
||||||
godot::Error _poll() override;
|
godot::Error _poll() override;
|
||||||
@@ -94,12 +98,12 @@ public:
|
|||||||
ChannelState _get_ready_state() const override;
|
ChannelState _get_ready_state() const override;
|
||||||
godot::String _get_label() const override;
|
godot::String _get_label() const override;
|
||||||
bool _is_ordered() const override;
|
bool _is_ordered() const override;
|
||||||
int64_t _get_id() const override;
|
int32_t _get_id() const override;
|
||||||
int64_t _get_max_packet_life_time() const override;
|
int32_t _get_max_packet_life_time() const override;
|
||||||
int64_t _get_max_retransmits() const override;
|
int32_t _get_max_retransmits() const override;
|
||||||
godot::String _get_protocol() const override;
|
godot::String _get_protocol() const override;
|
||||||
bool _is_negotiated() const override;
|
bool _is_negotiated() const override;
|
||||||
int64_t _get_buffered_amount() const override;
|
int32_t _get_buffered_amount() const override;
|
||||||
|
|
||||||
WebRTCLibDataChannel();
|
WebRTCLibDataChannel();
|
||||||
~WebRTCLibDataChannel();
|
~WebRTCLibDataChannel();
|
||||||
|
|||||||
@@ -1,32 +1,32 @@
|
|||||||
/*************************************************************************/
|
/**************************************************************************/
|
||||||
/* WebRTCLibPeerConnection.cpp */
|
/* WebRTCLibPeerConnection.cpp */
|
||||||
/*************************************************************************/
|
/**************************************************************************/
|
||||||
/* This file is part of: */
|
/* This file is part of: */
|
||||||
/* GODOT ENGINE */
|
/* GODOT ENGINE */
|
||||||
/* https://godotengine.org */
|
/* https://godotengine.org */
|
||||||
/*************************************************************************/
|
/**************************************************************************/
|
||||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||||
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
|
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||||
/* */
|
/* */
|
||||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||||
/* a copy of this software and associated documentation files (the */
|
/* a copy of this software and associated documentation files (the */
|
||||||
/* "Software"), to deal in the Software without restriction, including */
|
/* "Software"), to deal in the Software without restriction, including */
|
||||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||||
/* the following conditions: */
|
/* the following conditions: */
|
||||||
/* */
|
/* */
|
||||||
/* The above copyright notice and this permission notice shall be */
|
/* The above copyright notice and this permission notice shall be */
|
||||||
/* included in all copies or substantial portions of the Software. */
|
/* included in all copies or substantial portions of the Software. */
|
||||||
/* */
|
/* */
|
||||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
/*************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
#include "WebRTCLibPeerConnection.hpp"
|
#include "WebRTCLibPeerConnection.hpp"
|
||||||
#include "WebRTCLibDataChannel.hpp"
|
#include "WebRTCLibDataChannel.hpp"
|
||||||
@@ -39,15 +39,36 @@ using namespace godot_webrtc;
|
|||||||
#define FAILED Error::FAILED
|
#define FAILED Error::FAILED
|
||||||
#define ERR_UNCONFIGURED Error::ERR_UNCONFIGURED
|
#define ERR_UNCONFIGURED Error::ERR_UNCONFIGURED
|
||||||
#define ERR_INVALID_PARAMETER Error::ERR_INVALID_PARAMETER
|
#define ERR_INVALID_PARAMETER Error::ERR_INVALID_PARAMETER
|
||||||
|
#define VERBOSE_PRINT(str) Godot::print(str)
|
||||||
|
#else
|
||||||
|
#include <godot_cpp/variant/utility_functions.hpp>
|
||||||
|
#define VERBOSE_PRINT(str) UtilityFunctions::print_verbose(str)
|
||||||
#endif
|
#endif
|
||||||
|
void LogCallback(rtc::LogLevel level, std::string message) {
|
||||||
|
switch (level) {
|
||||||
|
case rtc::LogLevel::Fatal:
|
||||||
|
case rtc::LogLevel::Error:
|
||||||
|
ERR_PRINT(message.c_str());
|
||||||
|
return;
|
||||||
|
case rtc::LogLevel::Warning:
|
||||||
|
WARN_PRINT(message.c_str());
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
VERBOSE_PRINT(message.c_str());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void WebRTCLibPeerConnection::initialize_signaling() {
|
void WebRTCLibPeerConnection::initialize_signaling() {
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
rtc::InitLogger(rtc::LogLevel::Debug);
|
rtc::InitLogger(rtc::LogLevel::Debug, LogCallback);
|
||||||
|
#else
|
||||||
|
rtc::InitLogger(rtc::LogLevel::Warning, LogCallback);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebRTCLibPeerConnection::deinitialize_signaling() {
|
void WebRTCLibPeerConnection::deinitialize_signaling() {
|
||||||
|
rtc::Cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
Error WebRTCLibPeerConnection::_parse_ice_server(rtc::Configuration &r_config, Dictionary p_server) {
|
Error WebRTCLibPeerConnection::_parse_ice_server(rtc::Configuration &r_config, Dictionary p_server) {
|
||||||
@@ -95,11 +116,9 @@ Error WebRTCLibPeerConnection::_parse_channel_config(rtc::DataChannelInit &r_con
|
|||||||
// Channels cannot be both time-constrained and retry-constrained.
|
// Channels cannot be both time-constrained and retry-constrained.
|
||||||
ERR_FAIL_COND_V(p_dict.has("maxPacketLifeTime") && p_dict.has("maxRetransmits"), ERR_INVALID_PARAMETER);
|
ERR_FAIL_COND_V(p_dict.has("maxPacketLifeTime") && p_dict.has("maxRetransmits"), ERR_INVALID_PARAMETER);
|
||||||
if (p_dict.has("maxPacketLifeTime")) {
|
if (p_dict.has("maxPacketLifeTime")) {
|
||||||
r_config.reliability.type = rtc::Reliability::Type::Timed;
|
r_config.reliability.maxPacketLifeTime = std::chrono::milliseconds(p_dict["maxPacketLifeTime"].operator int32_t());
|
||||||
r_config.reliability.rexmit = std::chrono::milliseconds(p_dict["maxPacketLifeTime"].operator int32_t());
|
|
||||||
} else if (p_dict.has("maxRetransmits")) {
|
} else if (p_dict.has("maxRetransmits")) {
|
||||||
r_config.reliability.type = rtc::Reliability::Type::Rexmit;
|
r_config.reliability.maxRetransmits = p_dict["maxRetransmits"].operator int32_t();
|
||||||
r_config.reliability.rexmit = p_dict["maxRetransmits"].operator int32_t();
|
|
||||||
}
|
}
|
||||||
if (p_dict.has("ordered") && p_dict["ordered"].operator bool() == false) {
|
if (p_dict.has("ordered") && p_dict["ordered"].operator bool() == false) {
|
||||||
r_config.reliability.unordered = true;
|
r_config.reliability.unordered = true;
|
||||||
@@ -180,7 +199,11 @@ Error WebRTCLibPeerConnection::_initialize(const Dictionary &p_config) {
|
|||||||
return _create_pc(config);
|
return _create_pc(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#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
|
||||||
|
Ref<WebRTCDataChannel> WebRTCLibPeerConnection::_create_data_channel(const String &p_channel, const Dictionary &p_channel_config) try {
|
||||||
|
#endif
|
||||||
ERR_FAIL_COND_V(!peer_connection, nullptr);
|
ERR_FAIL_COND_V(!peer_connection, nullptr);
|
||||||
|
|
||||||
// Read config from dictionary
|
// Read config from dictionary
|
||||||
@@ -230,11 +253,15 @@ Error WebRTCLibPeerConnection::_set_local_description(const String &p_type, cons
|
|||||||
ERR_FAIL_COND_V(!peer_connection, ERR_UNCONFIGURED);
|
ERR_FAIL_COND_V(!peer_connection, ERR_UNCONFIGURED);
|
||||||
// XXX Library quirk. It doesn't seem possible to create offers/answers without setting the local description.
|
// XXX Library quirk. It doesn't seem possible to create offers/answers without setting the local description.
|
||||||
// Ignore this call for now to avoid crash (it's already set automatically!).
|
// Ignore this call for now to avoid crash (it's already set automatically!).
|
||||||
//peer_connection->setLocalDescription(p_type == String("offer") ? rtc::Description::Type::Offer : rtc::Description::Type::Answer);
|
// peer_connection->setLocalDescription(p_type == String("offer") ? rtc::Description::Type::Offer : rtc::Description::Type::Answer);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef GDNATIVE_WEBRTC
|
||||||
Error WebRTCLibPeerConnection::_add_ice_candidate(const String &sdpMidName, int64_t sdpMlineIndexName, const String &sdpName) try {
|
Error WebRTCLibPeerConnection::_add_ice_candidate(const String &sdpMidName, int64_t sdpMlineIndexName, const String &sdpName) try {
|
||||||
|
#else
|
||||||
|
Error WebRTCLibPeerConnection::_add_ice_candidate(const String &sdpMidName, int32_t sdpMlineIndexName, const String &sdpName) try {
|
||||||
|
#endif
|
||||||
ERR_FAIL_COND_V(!peer_connection, ERR_UNCONFIGURED);
|
ERR_FAIL_COND_V(!peer_connection, ERR_UNCONFIGURED);
|
||||||
rtc::Candidate candidate(sdpName.utf8().get_data(), sdpMidName.utf8().get_data());
|
rtc::Candidate candidate(sdpName.utf8().get_data(), sdpMidName.utf8().get_data());
|
||||||
peer_connection->addRemoteCandidate(candidate);
|
peer_connection->addRemoteCandidate(candidate);
|
||||||
|
|||||||
@@ -1,32 +1,32 @@
|
|||||||
/*************************************************************************/
|
/**************************************************************************/
|
||||||
/* WebRTCLibPeerConnection.hpp */
|
/* WebRTCLibPeerConnection.hpp */
|
||||||
/*************************************************************************/
|
/**************************************************************************/
|
||||||
/* This file is part of: */
|
/* This file is part of: */
|
||||||
/* GODOT ENGINE */
|
/* GODOT ENGINE */
|
||||||
/* https://godotengine.org */
|
/* https://godotengine.org */
|
||||||
/*************************************************************************/
|
/**************************************************************************/
|
||||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||||
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
|
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||||
/* */
|
/* */
|
||||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||||
/* a copy of this software and associated documentation files (the */
|
/* a copy of this software and associated documentation files (the */
|
||||||
/* "Software"), to deal in the Software without restriction, including */
|
/* "Software"), to deal in the Software without restriction, including */
|
||||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||||
/* the following conditions: */
|
/* the following conditions: */
|
||||||
/* */
|
/* */
|
||||||
/* The above copyright notice and this permission notice shall be */
|
/* The above copyright notice and this permission notice shall be */
|
||||||
/* included in all copies or substantial portions of the Software. */
|
/* included in all copies or substantial portions of the Software. */
|
||||||
/* */
|
/* */
|
||||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
/*************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
#ifndef WEBRTC_PEER_H
|
#ifndef WEBRTC_PEER_H
|
||||||
#define WEBRTC_PEER_H
|
#define WEBRTC_PEER_H
|
||||||
@@ -67,6 +67,10 @@ private:
|
|||||||
protected:
|
protected:
|
||||||
static void _bind_methods() {}
|
static void _bind_methods() {}
|
||||||
|
|
||||||
|
godot::String _to_string() const {
|
||||||
|
return "WebRTCLibPeerConnection";
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void _register_methods() {}
|
static void _register_methods() {}
|
||||||
static void initialize_signaling();
|
static void initialize_signaling();
|
||||||
@@ -79,11 +83,19 @@ 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)
|
||||||
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
|
||||||
|
godot::Ref<godot::WebRTCDataChannel> _create_data_channel(const godot::String &p_channel, const godot::Dictionary &p_channel_config) override;
|
||||||
|
#endif
|
||||||
godot::Error _create_offer() override;
|
godot::Error _create_offer() override;
|
||||||
godot::Error _set_remote_description(const godot::String &type, const godot::String &sdp) override;
|
godot::Error _set_remote_description(const godot::String &type, const godot::String &sdp) override;
|
||||||
godot::Error _set_local_description(const godot::String &type, const godot::String &sdp) override;
|
godot::Error _set_local_description(const godot::String &type, const godot::String &sdp) override;
|
||||||
|
#ifdef GDNATIVE_WEBRTC
|
||||||
godot::Error _add_ice_candidate(const godot::String &sdpMidName, int64_t sdpMlineIndexName, const godot::String &sdpName) override;
|
godot::Error _add_ice_candidate(const godot::String &sdpMidName, int64_t sdpMlineIndexName, const godot::String &sdpName) override;
|
||||||
|
#else
|
||||||
|
godot::Error _add_ice_candidate(const godot::String &sdpMidName, int32_t sdpMlineIndexName, const godot::String &sdpName) override;
|
||||||
|
#endif
|
||||||
godot::Error _poll() override;
|
godot::Error _poll() override;
|
||||||
void _close() override;
|
void _close() override;
|
||||||
|
|
||||||
|
|||||||
@@ -1,34 +1,34 @@
|
|||||||
/*************************************************************************/
|
/**************************************************************************/
|
||||||
/* init_gdextension.cpp */
|
/* init_gdextension.cpp */
|
||||||
/*************************************************************************/
|
/**************************************************************************/
|
||||||
/* This file is part of: */
|
/* This file is part of: */
|
||||||
/* GODOT ENGINE */
|
/* GODOT ENGINE */
|
||||||
/* https://godotengine.org */
|
/* https://godotengine.org */
|
||||||
/*************************************************************************/
|
/**************************************************************************/
|
||||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||||
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
|
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||||
/* */
|
/* */
|
||||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||||
/* a copy of this software and associated documentation files (the */
|
/* a copy of this software and associated documentation files (the */
|
||||||
/* "Software"), to deal in the Software without restriction, including */
|
/* "Software"), to deal in the Software without restriction, including */
|
||||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||||
/* the following conditions: */
|
/* the following conditions: */
|
||||||
/* */
|
/* */
|
||||||
/* The above copyright notice and this permission notice shall be */
|
/* The above copyright notice and this permission notice shall be */
|
||||||
/* included in all copies or substantial portions of the Software. */
|
/* included in all copies or substantial portions of the Software. */
|
||||||
/* */
|
/* */
|
||||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
/* 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/class_db.hpp>
|
||||||
#include <godot_cpp/core/defs.hpp>
|
#include <godot_cpp/core/defs.hpp>
|
||||||
@@ -66,7 +66,7 @@ void unregister_webrtc_extension_types(ModuleInitializationLevel p_level) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern "C" {
|
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 GDExtensionInterfaceGetProcAddress p_interface, const GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) {
|
||||||
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);
|
||||||
|
|||||||
@@ -1,32 +1,32 @@
|
|||||||
/*************************************************************************/
|
/**************************************************************************/
|
||||||
/* init_gdnative.cpp */
|
/* init_gdnative.cpp */
|
||||||
/*************************************************************************/
|
/**************************************************************************/
|
||||||
/* This file is part of: */
|
/* This file is part of: */
|
||||||
/* GODOT ENGINE */
|
/* GODOT ENGINE */
|
||||||
/* https://godotengine.org */
|
/* https://godotengine.org */
|
||||||
/*************************************************************************/
|
/**************************************************************************/
|
||||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||||
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
|
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||||
/* */
|
/* */
|
||||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||||
/* a copy of this software and associated documentation files (the */
|
/* a copy of this software and associated documentation files (the */
|
||||||
/* "Software"), to deal in the Software without restriction, including */
|
/* "Software"), to deal in the Software without restriction, including */
|
||||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||||
/* the following conditions: */
|
/* the following conditions: */
|
||||||
/* */
|
/* */
|
||||||
/* The above copyright notice and this permission notice shall be */
|
/* The above copyright notice and this permission notice shall be */
|
||||||
/* included in all copies or substantial portions of the Software. */
|
/* included in all copies or substantial portions of the Software. */
|
||||||
/* */
|
/* */
|
||||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
/*************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
#include "WebRTCLibDataChannel.hpp"
|
#include "WebRTCLibDataChannel.hpp"
|
||||||
#include "WebRTCLibPeerConnection.hpp"
|
#include "WebRTCLibPeerConnection.hpp"
|
||||||
|
|||||||
@@ -1,32 +1,32 @@
|
|||||||
/*************************************************************************/
|
/**************************************************************************/
|
||||||
/* WebRTCDataChannelNative.cpp */
|
/* WebRTCDataChannelNative.cpp */
|
||||||
/*************************************************************************/
|
/**************************************************************************/
|
||||||
/* This file is part of: */
|
/* This file is part of: */
|
||||||
/* GODOT ENGINE */
|
/* GODOT ENGINE */
|
||||||
/* https://godotengine.org */
|
/* https://godotengine.org */
|
||||||
/*************************************************************************/
|
/**************************************************************************/
|
||||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||||
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
|
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||||
/* */
|
/* */
|
||||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||||
/* a copy of this software and associated documentation files (the */
|
/* a copy of this software and associated documentation files (the */
|
||||||
/* "Software"), to deal in the Software without restriction, including */
|
/* "Software"), to deal in the Software without restriction, including */
|
||||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||||
/* the following conditions: */
|
/* the following conditions: */
|
||||||
/* */
|
/* */
|
||||||
/* The above copyright notice and this permission notice shall be */
|
/* The above copyright notice and this permission notice shall be */
|
||||||
/* included in all copies or substantial portions of the Software. */
|
/* included in all copies or substantial portions of the Software. */
|
||||||
/* */
|
/* */
|
||||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
/*************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
#include "WebRTCDataChannelNative.hpp"
|
#include "WebRTCDataChannelNative.hpp"
|
||||||
#include "net/WebRTCPeerConnectionNative.hpp"
|
#include "net/WebRTCPeerConnectionNative.hpp"
|
||||||
|
|||||||
@@ -1,32 +1,32 @@
|
|||||||
/*************************************************************************/
|
/**************************************************************************/
|
||||||
/* WebRTCDataChannelNative.hpp */
|
/* WebRTCDataChannelNative.hpp */
|
||||||
/*************************************************************************/
|
/**************************************************************************/
|
||||||
/* This file is part of: */
|
/* This file is part of: */
|
||||||
/* GODOT ENGINE */
|
/* GODOT ENGINE */
|
||||||
/* https://godotengine.org */
|
/* https://godotengine.org */
|
||||||
/*************************************************************************/
|
/**************************************************************************/
|
||||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||||
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
|
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||||
/* */
|
/* */
|
||||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||||
/* a copy of this software and associated documentation files (the */
|
/* a copy of this software and associated documentation files (the */
|
||||||
/* "Software"), to deal in the Software without restriction, including */
|
/* "Software"), to deal in the Software without restriction, including */
|
||||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||||
/* the following conditions: */
|
/* the following conditions: */
|
||||||
/* */
|
/* */
|
||||||
/* The above copyright notice and this permission notice shall be */
|
/* The above copyright notice and this permission notice shall be */
|
||||||
/* included in all copies or substantial portions of the Software. */
|
/* included in all copies or substantial portions of the Software. */
|
||||||
/* */
|
/* */
|
||||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
/*************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
#ifndef WEBRTC_DATA_CHANNEL_NATIVE
|
#ifndef WEBRTC_DATA_CHANNEL_NATIVE
|
||||||
#define WEBRTC_DATA_CHANNEL_NATIVE
|
#define WEBRTC_DATA_CHANNEL_NATIVE
|
||||||
@@ -119,21 +119,21 @@ public:
|
|||||||
virtual ChannelState _get_ready_state() const = 0;
|
virtual ChannelState _get_ready_state() const = 0;
|
||||||
virtual godot::String _get_label() const = 0;
|
virtual godot::String _get_label() const = 0;
|
||||||
virtual bool _is_ordered() const = 0;
|
virtual bool _is_ordered() const = 0;
|
||||||
virtual int64_t _get_id() const = 0;
|
virtual int32_t _get_id() const = 0;
|
||||||
virtual int64_t _get_max_packet_life_time() const = 0;
|
virtual int32_t _get_max_packet_life_time() const = 0;
|
||||||
virtual int64_t _get_max_retransmits() const = 0;
|
virtual int32_t _get_max_retransmits() const = 0;
|
||||||
virtual godot::String _get_protocol() const = 0;
|
virtual godot::String _get_protocol() const = 0;
|
||||||
virtual bool _is_negotiated() const = 0;
|
virtual bool _is_negotiated() const = 0;
|
||||||
virtual int64_t _get_buffered_amount() const = 0;
|
virtual int32_t _get_buffered_amount() const = 0;
|
||||||
|
|
||||||
virtual godot::Error _poll() = 0;
|
virtual godot::Error _poll() = 0;
|
||||||
virtual void _close() = 0;
|
virtual void _close() = 0;
|
||||||
|
|
||||||
/* PacketPeer */
|
/* PacketPeer */
|
||||||
virtual godot::Error _get_packet(const uint8_t **r_buffer, int32_t *r_len) = 0;
|
virtual godot::Error _get_packet(const uint8_t **r_buffer, int32_t *r_len) = 0;
|
||||||
virtual godot::Error _put_packet(const uint8_t *p_buffer, int64_t p_len) = 0;
|
virtual godot::Error _put_packet(const uint8_t *p_buffer, int32_t p_len) = 0;
|
||||||
virtual int64_t _get_available_packet_count() const = 0;
|
virtual int32_t _get_available_packet_count() const = 0;
|
||||||
virtual int64_t _get_max_packet_size() const = 0;
|
virtual int32_t _get_max_packet_size() const = 0;
|
||||||
|
|
||||||
~WebRTCDataChannelNative();
|
~WebRTCDataChannelNative();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,32 +1,32 @@
|
|||||||
/*************************************************************************/
|
/**************************************************************************/
|
||||||
/* WebRTCPeerConnectionNative.cpp */
|
/* WebRTCPeerConnectionNative.cpp */
|
||||||
/*************************************************************************/
|
/**************************************************************************/
|
||||||
/* This file is part of: */
|
/* This file is part of: */
|
||||||
/* GODOT ENGINE */
|
/* GODOT ENGINE */
|
||||||
/* https://godotengine.org */
|
/* https://godotengine.org */
|
||||||
/*************************************************************************/
|
/**************************************************************************/
|
||||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||||
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
|
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||||
/* */
|
/* */
|
||||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||||
/* a copy of this software and associated documentation files (the */
|
/* a copy of this software and associated documentation files (the */
|
||||||
/* "Software"), to deal in the Software without restriction, including */
|
/* "Software"), to deal in the Software without restriction, including */
|
||||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||||
/* the following conditions: */
|
/* the following conditions: */
|
||||||
/* */
|
/* */
|
||||||
/* The above copyright notice and this permission notice shall be */
|
/* The above copyright notice and this permission notice shall be */
|
||||||
/* included in all copies or substantial portions of the Software. */
|
/* included in all copies or substantial portions of the Software. */
|
||||||
/* */
|
/* */
|
||||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
/*************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
#include "WebRTCPeerConnectionNative.hpp"
|
#include "WebRTCPeerConnectionNative.hpp"
|
||||||
|
|
||||||
|
|||||||
@@ -1,32 +1,32 @@
|
|||||||
/*************************************************************************/
|
/**************************************************************************/
|
||||||
/* WebRTCPeerConnectionNative.hpp */
|
/* WebRTCPeerConnectionNative.hpp */
|
||||||
/*************************************************************************/
|
/**************************************************************************/
|
||||||
/* This file is part of: */
|
/* This file is part of: */
|
||||||
/* GODOT ENGINE */
|
/* GODOT ENGINE */
|
||||||
/* https://godotengine.org */
|
/* https://godotengine.org */
|
||||||
/*************************************************************************/
|
/**************************************************************************/
|
||||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||||
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
|
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||||
/* */
|
/* */
|
||||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||||
/* a copy of this software and associated documentation files (the */
|
/* a copy of this software and associated documentation files (the */
|
||||||
/* "Software"), to deal in the Software without restriction, including */
|
/* "Software"), to deal in the Software without restriction, including */
|
||||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||||
/* the following conditions: */
|
/* the following conditions: */
|
||||||
/* */
|
/* */
|
||||||
/* The above copyright notice and this permission notice shall be */
|
/* The above copyright notice and this permission notice shall be */
|
||||||
/* included in all copies or substantial portions of the Software. */
|
/* included in all copies or substantial portions of the Software. */
|
||||||
/* */
|
/* */
|
||||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
/*************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
#ifndef WEBRTC_PEER_NATIVE
|
#ifndef WEBRTC_PEER_NATIVE
|
||||||
#define WEBRTC_PEER_NATIVE
|
#define WEBRTC_PEER_NATIVE
|
||||||
|
|||||||
71
thirdparty/README.md
vendored
Normal file
71
thirdparty/README.md
vendored
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
# Third party libraries
|
||||||
|
|
||||||
|
Please keep categories (`##` level) listed alphabetically and matching their
|
||||||
|
respective folder names. Use two empty lines to separate categories for
|
||||||
|
readability.
|
||||||
|
|
||||||
|
|
||||||
|
## libdatachannel
|
||||||
|
|
||||||
|
- Upstream: https://github.com/paullouisageneau/libdatachannel
|
||||||
|
- Version: 0.22.6 (0d6adc021953d7263fd4503482ea7bde33553724, 2025)
|
||||||
|
- License: MPL 2.0
|
||||||
|
|
||||||
|
Module location:
|
||||||
|
|
||||||
|
- thirdparty/libdatachannel
|
||||||
|
|
||||||
|
|
||||||
|
# libjuice
|
||||||
|
|
||||||
|
- Upstream: https://github.com/paullouisageneau/libjuice
|
||||||
|
- Version: 1.5.9 (8d1a99a0683a811876c03a73ff764a92774027ad, 2025)
|
||||||
|
- License: MPL 2.0
|
||||||
|
|
||||||
|
Module location:
|
||||||
|
|
||||||
|
- thirdparty/libdatachannel/deps/libjuice
|
||||||
|
|
||||||
|
|
||||||
|
## libsrtp
|
||||||
|
|
||||||
|
- Upstream: https://github.com/cisco/libsrtp
|
||||||
|
- Version: 2.5.0 (a566a9cfcd619e8327784aa7cff4a1276dc1e895, 2023)
|
||||||
|
- License: BSD-3-Clause
|
||||||
|
|
||||||
|
Module location:
|
||||||
|
|
||||||
|
- thirdparty/libdatachannel/deps/libsrtp
|
||||||
|
|
||||||
|
|
||||||
|
## mbedTLS
|
||||||
|
|
||||||
|
- Upstream: https://github.com/Mbed-TLS/mbedtls.git
|
||||||
|
- Version: 3.6.3 (22098d41c6620ce07cf8a0134d37302355e1e5ef, 2025)
|
||||||
|
- License: Apache 2.0
|
||||||
|
|
||||||
|
Module location:
|
||||||
|
|
||||||
|
- thirdparty/mbedtls
|
||||||
|
|
||||||
|
|
||||||
|
## plog
|
||||||
|
|
||||||
|
- Upstream: https://github.com/SergiusTheBest/plog
|
||||||
|
- Version: 1.1.10 (e21baecd4753f14da64ede979c5a19302618b752, 2023)
|
||||||
|
- License: MIT
|
||||||
|
|
||||||
|
Module location:
|
||||||
|
|
||||||
|
- thirdparty/libdatachannel/deps/plog
|
||||||
|
|
||||||
|
|
||||||
|
## usrsctp
|
||||||
|
|
||||||
|
- Upstream: https://github.com/sctplab/usrsctp
|
||||||
|
- Version: git (ebb18adac6501bad4501b1f6dccb67a1c85cc299, 2023)
|
||||||
|
- 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 0d6adc0219
1
thirdparty/mbedtls
vendored
Submodule
1
thirdparty/mbedtls
vendored
Submodule
Submodule thirdparty/mbedtls added at 22098d41c6
177
tools/cmake.py
Normal file
177
tools/cmake.py
Normal file
@@ -0,0 +1,177 @@
|
|||||||
|
import os
|
||||||
|
import shlex
|
||||||
|
import sys
|
||||||
|
|
||||||
|
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):
|
||||||
|
if env.get("cmake_default_flags", ""):
|
||||||
|
return shlex.split(env["cmake_default_flags"])
|
||||||
|
|
||||||
|
config = {}
|
||||||
|
|
||||||
|
if "CC" in env:
|
||||||
|
config["CMAKE_C_COMPILER"] = env["CC"]
|
||||||
|
if "CXX" in env:
|
||||||
|
config["CMAKE_CXX_COMPILER"] = env["CXX"]
|
||||||
|
|
||||||
|
if env["platform"] == "android":
|
||||||
|
api = env["android_api_level"]
|
||||||
|
abi = {
|
||||||
|
"arm64": "arm64-v8a",
|
||||||
|
"arm32": "armeabi-v7a",
|
||||||
|
"x86_32": "x86",
|
||||||
|
"x86_64": "x86_64",
|
||||||
|
}[env["arch"]]
|
||||||
|
config["CMAKE_SYSTEM_NAME"] = "Android"
|
||||||
|
config["CMAKE_SYSTEM_VERSION"] = api
|
||||||
|
config["CMAKE_ANDROID_ARCH_ABI"] = abi
|
||||||
|
config["ANDROID_ABI"] = abi
|
||||||
|
ndk_root = os.environ.get("ANDROID_NDK_ROOT", env.get("ANDROID_HOME", "") + "/ndk/" + get_ndk_version())
|
||||||
|
config["CMAKE_TOOLCHAIN_FILE"] = "%s/build/cmake/android.toolchain.cmake" % ndk_root
|
||||||
|
config["CMAKE_ANDROID_STL_TYPE"] = "c++_static"
|
||||||
|
|
||||||
|
elif env["platform"] == "linux":
|
||||||
|
linux_flags = {
|
||||||
|
"x86_64": "-m64",
|
||||||
|
"x86_32": "-m32",
|
||||||
|
"arm32": "-march=armv7-a",
|
||||||
|
"arm64": "-march=armv8-a",
|
||||||
|
}.get(env["arch"], "")
|
||||||
|
if linux_flags:
|
||||||
|
config["CMAKE_C_FLAGS"] = linux_flags
|
||||||
|
config["CMAKE_CXX_FLAGS"] = linux_flags
|
||||||
|
|
||||||
|
elif env["platform"] == "macos":
|
||||||
|
if env["arch"] == "universal":
|
||||||
|
config["CMAKE_OSX_ARCHITECTURES"] = '"x86_64;arm64"'
|
||||||
|
else:
|
||||||
|
config["CMAKE_OSX_ARCHITECTURES"] = env["arch"]
|
||||||
|
if env.get("macos_deployment_target", "default") != "default":
|
||||||
|
config["CMAKE_OSX_DEPLOYMENT_TARGET"] = env["macos_deployment_target"]
|
||||||
|
if sys.platform != "darwin" and "OSXCROSS_ROOT" in os.environ:
|
||||||
|
config["CMAKE_AR"] = env["AR"]
|
||||||
|
config["CMAKE_RANLIB"] = env["RANLIB"]
|
||||||
|
if env["arch"] == "universal":
|
||||||
|
flags = "-arch x86_64 -arch arm64"
|
||||||
|
else:
|
||||||
|
flags = "-arch " + env["arch"]
|
||||||
|
if env["macos_deployment_target"] != "default":
|
||||||
|
flags += " -mmacosx-version-min=" + env["macos_deployment_target"]
|
||||||
|
config["CMAKE_C_FLAGS"] = flags
|
||||||
|
config["CMAKE_CXX_FLAGS"] = flags
|
||||||
|
|
||||||
|
elif env["platform"] == "ios":
|
||||||
|
if env["arch"] == "universal":
|
||||||
|
raise ValueError("iOS architecture not supported: %s" % env["arch"])
|
||||||
|
config["CMAKE_SYSTEM_NAME"] = "iOS"
|
||||||
|
config["CMAKE_OSX_ARCHITECTURES"] = env["arch"]
|
||||||
|
if env.get("ios_min_version", "default") != "default":
|
||||||
|
config["CMAKE_OSX_DEPLOYMENT_TARGET"] = env["ios_min_version"]
|
||||||
|
if env["ios_simulator"]:
|
||||||
|
config["CMAKE_OSX_SYSROOT"] = "iphonesimulator"
|
||||||
|
|
||||||
|
elif env["platform"] == "windows":
|
||||||
|
config["CMAKE_SYSTEM_NAME"] = "Windows"
|
||||||
|
if env.get("is_msvc", False):
|
||||||
|
config["CMAKE_POLICY_DEFAULT_CMP0091"] = "NEW"
|
||||||
|
if env.get("debug_crt", False):
|
||||||
|
config["CMAKE_MSVC_RUNTIME_LIBRARY"] = "MultiThreadedDebugDLL"
|
||||||
|
else:
|
||||||
|
if env.get("use_static_cpp", False):
|
||||||
|
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):
|
||||||
|
return [str(target[0]) + "/CMakeCache.txt"] + target[1:], [str(source[0]) + "/CMakeLists.txt"] + source[1:]
|
||||||
|
|
||||||
|
|
||||||
|
def cmake_generator(target, source, env, for_signature):
|
||||||
|
# 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"]
|
||||||
|
actions = [
|
||||||
|
SCons.Action.Action("$CMAKECONFCOM", "$CMAKECONFCOMSTR"),
|
||||||
|
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=[], install=False
|
||||||
|
):
|
||||||
|
cmake_env = env.Clone()
|
||||||
|
target = env.Dir("{}/{}/{}".format(target_dir, env["platform"], env["arch"]))
|
||||||
|
source = env.Dir(source_dir)
|
||||||
|
builder_targets = [target] + [str(target) + "/" + f for f in cmake_outputs]
|
||||||
|
builder_sources = [source] + dependencies
|
||||||
|
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:
|
||||||
|
cmake_env.Append(CMAKEBUILDFLAGS=["-t"] + [t for t in cmake_targets])
|
||||||
|
cmake_env["CMAKE_INSTALL"] = install
|
||||||
|
return cmake_env.CMake(builder_targets, builder_sources)
|
||||||
|
|
||||||
|
|
||||||
|
def options(opts):
|
||||||
|
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):
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def generate(env):
|
||||||
|
env["CMAKE"] = env["cmake"]
|
||||||
|
env["CMAKECONFFLAGS"] = SCons.Util.CLVar("")
|
||||||
|
env["CMAKECONFCOM"] = "$CMAKE -B ${TARGET.dir} $CMAKECONFFLAGS ${SOURCE.dir}"
|
||||||
|
env["CMAKEBUILDJOBS"] = "${__env__.GetOption('num_jobs')}"
|
||||||
|
env["CMAKEBUILDFLAGS"] = SCons.Util.CLVar("")
|
||||||
|
env["CMAKEINSTALLFLAGS"] = SCons.Util.CLVar("")
|
||||||
|
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.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
|
||||||
53
tools/rtc.py
Normal file
53
tools/rtc.py
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
def build_library(env, mbedtls):
|
||||||
|
rtc_config = {
|
||||||
|
"CMAKE_BUILD_TYPE": "RelWithDebInfo" if env["debug_symbols"] else "Release",
|
||||||
|
"CMAKE_CXX_FLAGS": "-DMBEDTLS_SSL_DTLS_SRTP",
|
||||||
|
"USE_NICE": 0,
|
||||||
|
"NO_WEBSOCKET": 1,
|
||||||
|
"NO_EXAMPLES": 1,
|
||||||
|
"NO_TESTS": 1,
|
||||||
|
"BUILD_WITH_WARNINGS": "0", # Disables werror in libsrtp.
|
||||||
|
"USE_MBEDTLS": 1,
|
||||||
|
"MbedTLS_LIBRARY": env["MBEDTLS_LIBRARY"],
|
||||||
|
"MbedCrypto_LIBRARY": env["MBEDTLS_CRYPTO_LIBRARY"],
|
||||||
|
"MbedX509_LIBRARY": env["MBEDTLS_X509_LIBRARY"],
|
||||||
|
"MbedTLS_INCLUDE_DIR": env["MBEDTLS_INCLUDE"],
|
||||||
|
}
|
||||||
|
is_msvc = env.get("is_msvc", False)
|
||||||
|
lib_ext = ".lib" if is_msvc else ".a"
|
||||||
|
lib_prefix = "" if is_msvc else "lib"
|
||||||
|
rtc_libs = [
|
||||||
|
"{}datachannel-static{}".format(lib_prefix, lib_ext),
|
||||||
|
"deps/libjuice/{}juice-static{}".format(lib_prefix, lib_ext),
|
||||||
|
"deps/libsrtp/{}srtp2{}".format(lib_prefix, lib_ext),
|
||||||
|
"deps/usrsctp/usrsctplib/{}usrsctp{}".format(lib_prefix, lib_ext),
|
||||||
|
]
|
||||||
|
|
||||||
|
# Build libdatachannel
|
||||||
|
rtc = env.CMakeBuild(
|
||||||
|
env.Dir("bin/thirdparty/libdatachannel/"),
|
||||||
|
env.Dir("thirdparty/libdatachannel"),
|
||||||
|
cmake_options=rtc_config,
|
||||||
|
cmake_outputs=rtc_libs,
|
||||||
|
cmake_targets=["datachannel-static"],
|
||||||
|
dependencies=mbedtls,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Configure env.
|
||||||
|
if env["platform"] == "windows":
|
||||||
|
env.PrependUnique(LIBS=["iphlpapi", "ws2_32", "bcrypt"])
|
||||||
|
if env["platform"] == "linux":
|
||||||
|
env.PrependUnique(LIBS=["pthread"])
|
||||||
|
env.Prepend(LIBS=list(filter(lambda f: str(f).endswith(lib_ext), rtc)))
|
||||||
|
env.Append(CPPPATH=[env.Dir("thirdparty/libdatachannel/include")])
|
||||||
|
env.Append(CPPDEFINES=["RTC_STATIC"]) # For Windows MSVC
|
||||||
|
|
||||||
|
return rtc
|
||||||
|
|
||||||
|
|
||||||
|
def exists(env):
|
||||||
|
return "CMake" in env
|
||||||
|
|
||||||
|
|
||||||
|
def generate(env):
|
||||||
|
env.AddMethod(build_library, "BuildLibDataChannel")
|
||||||
Reference in New Issue
Block a user