mirror of
https://github.com/godotengine/webrtc-native.git
synced 2026-01-03 14:09:58 +03:00
Compare commits
10 Commits
1.0.6-stab
...
1.0.8-stab
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
93e11a7343 | ||
|
|
ba46b25c00 | ||
|
|
31fd88dbf5 | ||
|
|
ea8b37fe29 | ||
|
|
cb1ef2e59c | ||
|
|
038bac82d6 | ||
|
|
effada6b45 | ||
|
|
26bc56f934 | ||
|
|
44ee53715d | ||
|
|
0b89ed885d |
14
.github/workflows/build_release.yml
vendored
14
.github/workflows/build_release.yml
vendored
@@ -64,13 +64,13 @@ jobs:
|
|||||||
arch: 'x86_64'
|
arch: 'x86_64'
|
||||||
gdnative_flags: 'ios_arch=x86_64'
|
gdnative_flags: 'ios_arch=x86_64'
|
||||||
sconsflags: 'ios_simulator=true'
|
sconsflags: 'ios_simulator=true'
|
||||||
os: 'macos-11'
|
os: 'macos-latest'
|
||||||
cache-name: ios-x86_64-simulator
|
cache-name: ios-x86_64-simulator
|
||||||
- platform: ios
|
- platform: ios
|
||||||
arch: 'arm64'
|
arch: 'arm64'
|
||||||
gdnative_flags: 'ios_arch=arm64'
|
gdnative_flags: 'ios_arch=arm64'
|
||||||
sconsflags: ''
|
sconsflags: ''
|
||||||
os: 'macos-11'
|
os: 'macos-latest'
|
||||||
cache-name: ios-arm64
|
cache-name: ios-arm64
|
||||||
|
|
||||||
# Linux
|
# Linux
|
||||||
@@ -108,7 +108,7 @@ jobs:
|
|||||||
arch: 'universal'
|
arch: 'universal'
|
||||||
gdnative_flags: 'macos_arch=universal bits=64'
|
gdnative_flags: 'macos_arch=universal bits=64'
|
||||||
sconsflags: ''
|
sconsflags: ''
|
||||||
os: 'macos-11'
|
os: 'macos-latest'
|
||||||
cache-name: macos-universal
|
cache-name: macos-universal
|
||||||
|
|
||||||
# Windows
|
# Windows
|
||||||
@@ -129,7 +129,7 @@ jobs:
|
|||||||
|
|
||||||
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:
|
||||||
@@ -196,6 +196,12 @@ jobs:
|
|||||||
patch -p1 < misc/patches/scons_path.diff
|
patch -p1 < misc/patches/scons_path.diff
|
||||||
patch -p1 < misc/patches/gdnantive_arm_warnings.diff
|
patch -p1 < misc/patches/gdnantive_arm_warnings.diff
|
||||||
|
|
||||||
|
- name: Patch godot-cpp to support build profile.
|
||||||
|
run: |
|
||||||
|
patch -p1 < misc/patches/build_profile.diff
|
||||||
|
patch -p1 < misc/patches/build_profile_4.0.diff
|
||||||
|
patch -p1 < misc/patches/build_profile_3.x.diff
|
||||||
|
|
||||||
- name: Print tools versions
|
- name: Print tools versions
|
||||||
run: |
|
run: |
|
||||||
python --version
|
python --version
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ opts.Update(env)
|
|||||||
|
|
||||||
# Minimum target platform versions.
|
# Minimum target platform versions.
|
||||||
if "ios_min_version" not in ARGUMENTS:
|
if "ios_min_version" not in ARGUMENTS:
|
||||||
ARGUMENTS["ios_min_version"] = "11.0"
|
ARGUMENTS["ios_min_version"] = "12.0"
|
||||||
if "macos_deployment_target" not in ARGUMENTS:
|
if "macos_deployment_target" not in ARGUMENTS:
|
||||||
ARGUMENTS["macos_deployment_target"] = "11.0"
|
ARGUMENTS["macos_deployment_target"] = "11.0"
|
||||||
if "android_api_level" not in ARGUMENTS:
|
if "android_api_level" not in ARGUMENTS:
|
||||||
@@ -61,8 +61,8 @@ if env["godot_version"] == "3":
|
|||||||
replace_flags(
|
replace_flags(
|
||||||
cpp_env["CCFLAGS"],
|
cpp_env["CCFLAGS"],
|
||||||
{
|
{
|
||||||
"-mios-simulator-version-min=10.0": "-mios-simulator-version-min=11.0",
|
"-mios-simulator-version-min=10.0": "-mios-simulator-version-min=12.0",
|
||||||
"-miphoneos-version-min=10.0": "-miphoneos-version-min=11.0",
|
"-miphoneos-version-min=10.0": "-miphoneos-version-min=12.0",
|
||||||
"/std:c++14": "/std:c++17",
|
"/std:c++14": "/std:c++17",
|
||||||
"-std=c++14": "-std=c++17",
|
"-std=c++14": "-std=c++17",
|
||||||
},
|
},
|
||||||
@@ -82,7 +82,7 @@ if env["godot_version"] == "3":
|
|||||||
env["CC"] = "clang" # CC is not set in 3.x and can result in it being "gcc".
|
env["CC"] = "clang" # CC is not set in 3.x and can result in it being "gcc".
|
||||||
|
|
||||||
if env["platform"] == "ios":
|
if env["platform"] == "ios":
|
||||||
env["ios_min_version"] = "11.0"
|
env["ios_min_version"] = "12.0"
|
||||||
|
|
||||||
# Normalize suffix
|
# Normalize suffix
|
||||||
if env["platform"] in ["windows", "linux"]:
|
if env["platform"] in ["windows", "linux"]:
|
||||||
|
|||||||
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"
|
||||||
|
]
|
||||||
|
}
|
||||||
238
misc/patches/build_profile.diff
Normal file
238
misc/patches/build_profile.diff
Normal file
@@ -0,0 +1,238 @@
|
|||||||
|
diff --git a/godot-cpp/SConstruct b/godot-cpp/SConstruct
|
||||||
|
index 42f8fc0..9d59d1f 100644
|
||||||
|
--- a/godot-cpp/SConstruct
|
||||||
|
+++ b/godot-cpp/SConstruct
|
||||||
|
@@ -121,6 +121,14 @@ opts.Add(
|
||||||
|
BoolVariable("generate_bindings", "Force GDExtension API bindings generation. Auto-detected by default.", False)
|
||||||
|
)
|
||||||
|
opts.Add(BoolVariable("generate_template_get_node", "Generate a template version of the Node class's get_node.", 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))
|
||||||
|
opts.Add(EnumVariable("precision", "Set the floating-point precision level", "single", ("single", "double")))
|
||||||
|
diff --git a/godot-cpp/binding_generator.py b/godot-cpp/binding_generator.py
|
||||||
|
index d04c698..41cf29b 100644
|
||||||
|
--- a/godot-cpp/binding_generator.py
|
||||||
|
+++ b/godot-cpp/binding_generator.py
|
||||||
|
@@ -70,12 +70,14 @@ def generate_wrappers(target):
|
||||||
|
f.write(txt)
|
||||||
|
|
||||||
|
|
||||||
|
-def get_file_list(api_filepath, output_dir, headers=False, sources=False):
|
||||||
|
+def get_file_list(api_filepath, output_dir, headers=False, sources=False, profile_filepath=""):
|
||||||
|
api = {}
|
||||||
|
files = []
|
||||||
|
with open(api_filepath, encoding="utf-8") as api_file:
|
||||||
|
api = json.load(api_file)
|
||||||
|
|
||||||
|
+ build_profile = parse_build_profile(profile_filepath, api)
|
||||||
|
+
|
||||||
|
core_gen_folder = Path(output_dir) / "gen" / "include" / "godot_cpp" / "core"
|
||||||
|
include_gen_folder = Path(output_dir) / "gen" / "include" / "godot_cpp"
|
||||||
|
source_gen_folder = Path(output_dir) / "gen" / "src"
|
||||||
|
@@ -104,7 +106,7 @@ def get_file_list(api_filepath, output_dir, headers=False, sources=False):
|
||||||
|
source_filename = source_gen_folder / "classes" / (camel_to_snake(engine_class["name"]) + ".cpp")
|
||||||
|
if headers:
|
||||||
|
files.append(str(header_filename.as_posix()))
|
||||||
|
- if sources:
|
||||||
|
+ if sources and is_class_included(engine_class["name"], build_profile):
|
||||||
|
files.append(str(source_filename.as_posix()))
|
||||||
|
|
||||||
|
for native_struct in api["native_structures"]:
|
||||||
|
@@ -134,14 +136,107 @@ def get_file_list(api_filepath, output_dir, headers=False, sources=False):
|
||||||
|
return files
|
||||||
|
|
||||||
|
|
||||||
|
-def print_file_list(api_filepath, output_dir, headers=False, sources=False):
|
||||||
|
+def print_file_list(api_filepath, output_dir, headers=False, sources=False, profile_filepath=""):
|
||||||
|
end = ";"
|
||||||
|
- for f in get_file_list(api_filepath, output_dir, headers, sources):
|
||||||
|
+ for f in get_file_list(api_filepath, output_dir, headers, sources, profile_filepath):
|
||||||
|
print(f, end=end)
|
||||||
|
|
||||||
|
|
||||||
|
+def parse_build_profile(profile_filepath, api):
|
||||||
|
+ if profile_filepath == "":
|
||||||
|
+ return {}
|
||||||
|
+ print("Using feature build profile: " + profile_filepath)
|
||||||
|
+
|
||||||
|
+ 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)
|
||||||
|
+
|
||||||
|
+ # Parse methods dependencies
|
||||||
|
+ deps = {}
|
||||||
|
+ reverse_deps = {}
|
||||||
|
+ for name, engine_class in api_dict.items():
|
||||||
|
+ ref_cls = set()
|
||||||
|
+ for method in engine_class.get("methods", []):
|
||||||
|
+ rtype = method.get("return_value", {}).get("type", "")
|
||||||
|
+ args = [a["type"] for a in method.get("arguments", [])]
|
||||||
|
+ if rtype in api_dict:
|
||||||
|
+ ref_cls.add(rtype)
|
||||||
|
+ elif is_enum(rtype) and get_enum_class(rtype) in api_dict:
|
||||||
|
+ ref_cls.add(get_enum_class(rtype))
|
||||||
|
+ for arg in args:
|
||||||
|
+ if arg in api_dict:
|
||||||
|
+ ref_cls.add(arg)
|
||||||
|
+ elif is_enum(arg) and get_enum_class(arg) in api_dict:
|
||||||
|
+ ref_cls.add(get_enum_class(arg))
|
||||||
|
+ deps[engine_class["name"]] = set(filter(lambda x: x != name, ref_cls))
|
||||||
|
+ for acls in ref_cls:
|
||||||
|
+ if acls == name:
|
||||||
|
+ continue
|
||||||
|
+ reverse_deps[acls] = reverse_deps.get(acls, set())
|
||||||
|
+ reverse_deps[acls].add(name)
|
||||||
|
+
|
||||||
|
+ included = []
|
||||||
|
+ front = list(profile.get("enabled_classes", []))
|
||||||
|
+ if front:
|
||||||
|
+ # These must always be included
|
||||||
|
+ front.append("WorkerThreadPool")
|
||||||
|
+ front.append("ClassDB")
|
||||||
|
+ front.append("ClassDBSingleton")
|
||||||
|
+ while front:
|
||||||
|
+ cls = front.pop()
|
||||||
|
+ if cls in included:
|
||||||
|
+ continue
|
||||||
|
+ included.append(cls)
|
||||||
|
+ parent = parents.get(cls, "")
|
||||||
|
+ if parent:
|
||||||
|
+ front.append(parent)
|
||||||
|
+ for rcls in deps.get(cls, set()):
|
||||||
|
+ if rcls in included or rcls in front:
|
||||||
|
+ continue
|
||||||
|
+ front.append(rcls)
|
||||||
|
+
|
||||||
|
+ excluded = []
|
||||||
|
+ front = list(profile.get("disabled_classes", []))
|
||||||
|
+ while front:
|
||||||
|
+ cls = front.pop()
|
||||||
|
+ if cls in excluded:
|
||||||
|
+ continue
|
||||||
|
+ excluded.append(cls)
|
||||||
|
+ front += children.get(cls, [])
|
||||||
|
+ for rcls in reverse_deps.get(cls, set()):
|
||||||
|
+ if rcls in excluded or rcls in front:
|
||||||
|
+ continue
|
||||||
|
+ front.append(rcls)
|
||||||
|
+
|
||||||
|
+ 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 scons_emit_files(target, source, env):
|
||||||
|
- files = [env.File(f) for f in get_file_list(str(source[0]), target[0].abspath, True, True)]
|
||||||
|
+ profile_filepath = env.get("build_profile", "")
|
||||||
|
+ if profile_filepath and not Path(profile_filepath).is_absolute():
|
||||||
|
+ profile_filepath = str((Path(env.Dir("#").abspath) / profile_filepath).as_posix())
|
||||||
|
+
|
||||||
|
+ files = [env.File(f) for f in get_file_list(str(source[0]), target[0].abspath, True, True, profile_filepath)]
|
||||||
|
env.Clean(target, files)
|
||||||
|
env["godot_cpp_gen_dir"] = target[0].abspath
|
||||||
|
return files, source
|
||||||
|
@@ -154,11 +249,12 @@ def scons_generate_bindings(target, source, env):
|
||||||
|
"32" if "32" in env["arch"] else "64",
|
||||||
|
env["precision"],
|
||||||
|
env["godot_cpp_gen_dir"],
|
||||||
|
+ env.get("build_profile", ""),
|
||||||
|
)
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
-def generate_bindings(api_filepath, use_template_get_node, bits="64", precision="single", output_dir="."):
|
||||||
|
+def generate_bindings(api_filepath, use_template_get_node, bits="64", precision="single", output_dir=".", profile_filepath=""):
|
||||||
|
api = None
|
||||||
|
|
||||||
|
target_dir = Path(output_dir) / "gen"
|
||||||
|
@@ -175,7 +271,7 @@ def generate_bindings(api_filepath, use_template_get_node, bits="64", precision=
|
||||||
|
generate_global_constants(api, target_dir)
|
||||||
|
generate_global_constant_binds(api, target_dir)
|
||||||
|
generate_builtin_bindings(api, target_dir, real_t + "_" + bits)
|
||||||
|
- generate_engine_classes_bindings(api, target_dir, use_template_get_node)
|
||||||
|
+ generate_engine_classes_bindings(api, target_dir, use_template_get_node, profile_filepath)
|
||||||
|
generate_utility_functions(api, target_dir)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1023,7 +1119,7 @@ def generate_builtin_class_source(builtin_api, size, used_classes, fully_used_cl
|
||||||
|
return "\n".join(result)
|
||||||
|
|
||||||
|
|
||||||
|
-def generate_engine_classes_bindings(api, output_dir, use_template_get_node):
|
||||||
|
+def generate_engine_classes_bindings(api, output_dir, use_template_get_node, profile_filepath=""):
|
||||||
|
global engine_classes
|
||||||
|
global singletons
|
||||||
|
global native_structures
|
||||||
|
@@ -1161,7 +1257,7 @@ def generate_engine_classes_bindings(api, output_dir, use_template_get_node):
|
||||||
|
|
||||||
|
register_engine_classes_filename = Path(output_dir) / "src" / "register_engine_classes.cpp"
|
||||||
|
with register_engine_classes_filename.open("w+", encoding="utf-8") as source_file:
|
||||||
|
- source_file.write(generate_register_engine_classes_source(api))
|
||||||
|
+ source_file.write(generate_register_engine_classes_source(api, profile_filepath))
|
||||||
|
|
||||||
|
for native_struct in api["native_structures"]:
|
||||||
|
struct_name = native_struct["name"]
|
||||||
|
@@ -1585,12 +1681,14 @@ def generate_engine_class_source(class_api, used_classes, fully_used_classes, us
|
||||||
|
return "\n".join(result)
|
||||||
|
|
||||||
|
|
||||||
|
-def generate_register_engine_classes_source(api):
|
||||||
|
+def generate_register_engine_classes_source(api, profile_filepath=""):
|
||||||
|
includes = []
|
||||||
|
registrations = []
|
||||||
|
|
||||||
|
+ build_profile = parse_build_profile(profile_filepath, api)
|
||||||
|
+
|
||||||
|
for class_api in api["classes"]:
|
||||||
|
- if class_api["name"] == "ClassDB":
|
||||||
|
+ if class_api["name"] == "ClassDB" or not is_class_included(class_api["name"], build_profile):
|
||||||
|
continue
|
||||||
|
|
||||||
|
class_name = class_api["name"]
|
||||||
|
@@ -2066,6 +2164,20 @@ def is_pod_type(type_name):
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
+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_included_type(type_name):
|
||||||
|
# Types which we already have implemented.
|
||||||
|
return is_included_struct_type(type_name) or type_name in ["ObjectID"]
|
||||||
196
misc/patches/build_profile_3.x.diff
Normal file
196
misc/patches/build_profile_3.x.diff
Normal file
@@ -0,0 +1,196 @@
|
|||||||
|
diff --git a/godot-cpp-3.x/SConstruct b/godot-cpp-3.x/SConstruct
|
||||||
|
index f653d54..44f66a5 100644
|
||||||
|
--- a/godot-cpp-3.x/SConstruct
|
||||||
|
+++ b/godot-cpp-3.x/SConstruct
|
||||||
|
@@ -170,6 +170,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: val if os.path.isabs(val) else os.path.join(env.Dir("#").abspath, 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..e5bd040 100644
|
||||||
|
--- a/godot-cpp-3.x/binding_generator.py
|
||||||
|
+++ b/godot-cpp-3.x/binding_generator.py
|
||||||
|
@@ -12,14 +12,115 @@ def correct_method_name(method_list):
|
||||||
|
method["name"] = "get_node_internal"
|
||||||
|
|
||||||
|
|
||||||
|
+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 parse_build_profile(profile_filepath, api):
|
||||||
|
+ if profile_filepath == "":
|
||||||
|
+ return {}
|
||||||
|
+ print("Using feature build profile: " + profile_filepath)
|
||||||
|
+
|
||||||
|
+ 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)
|
||||||
|
+
|
||||||
|
+ # Parse methods dependencies
|
||||||
|
+ deps = {}
|
||||||
|
+ reverse_deps = {}
|
||||||
|
+ for name, engine_class in api_dict.items():
|
||||||
|
+ ref_cls = set()
|
||||||
|
+ for method in engine_class.get("methods", []):
|
||||||
|
+ rtype = method.get("return_value", {}).get("type", "")
|
||||||
|
+ args = [a["type"] for a in method.get("arguments", [])]
|
||||||
|
+ if rtype in api_dict:
|
||||||
|
+ ref_cls.add(rtype)
|
||||||
|
+ for arg in args:
|
||||||
|
+ if arg in api_dict:
|
||||||
|
+ ref_cls.add(arg)
|
||||||
|
+ deps[engine_class["name"]] = set(filter(lambda x: x != name, ref_cls))
|
||||||
|
+ for acls in ref_cls:
|
||||||
|
+ if acls == name:
|
||||||
|
+ continue
|
||||||
|
+ reverse_deps[acls] = reverse_deps.get(acls, set())
|
||||||
|
+ reverse_deps[acls].add(name)
|
||||||
|
+
|
||||||
|
+ included = []
|
||||||
|
+ front = list(profile.get("enabled_classes", []))
|
||||||
|
+ if front:
|
||||||
|
+ # These must always be included
|
||||||
|
+ front.append("ConfigFile")
|
||||||
|
+ front.append("ClassDB")
|
||||||
|
+ while front:
|
||||||
|
+ cls = front.pop()
|
||||||
|
+ if cls in included:
|
||||||
|
+ continue
|
||||||
|
+ included.append(cls)
|
||||||
|
+ parent = parents.get(cls, "")
|
||||||
|
+ if parent:
|
||||||
|
+ front.append(parent)
|
||||||
|
+ for rcls in deps.get(cls, set()):
|
||||||
|
+ if rcls in included or rcls in front:
|
||||||
|
+ continue
|
||||||
|
+ front.append(rcls)
|
||||||
|
+
|
||||||
|
+ excluded = []
|
||||||
|
+ front = list(profile.get("disabled_classes", []))
|
||||||
|
+ while front:
|
||||||
|
+ cls = front.pop()
|
||||||
|
+ if cls in excluded:
|
||||||
|
+ continue
|
||||||
|
+ excluded.append(cls)
|
||||||
|
+ front += children.get(cls, [])
|
||||||
|
+ for rcls in reverse_deps.get(cls, set()):
|
||||||
|
+ if rcls in excluded or rcls in front:
|
||||||
|
+ continue
|
||||||
|
+ front.append(rcls)
|
||||||
|
+
|
||||||
|
+ 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,
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+
|
||||||
|
classes = []
|
||||||
|
|
||||||
|
|
||||||
|
-def get_file_list(api_filepath, output_dir, headers=False, sources=False):
|
||||||
|
+def get_file_list(api_filepath, output_dir, headers=False, sources=False, profile_filepath=""):
|
||||||
|
global classes
|
||||||
|
+
|
||||||
|
files = []
|
||||||
|
with open(api_filepath) as api_file:
|
||||||
|
classes = json.load(api_file)
|
||||||
|
+ build_profile = parse_build_profile(profile_filepath, classes)
|
||||||
|
+
|
||||||
|
include_gen_folder = Path(output_dir) / "include" / "gen"
|
||||||
|
source_gen_folder = Path(output_dir) / "src" / "gen"
|
||||||
|
for _class in classes:
|
||||||
|
@@ -27,7 +128,7 @@ def get_file_list(api_filepath, output_dir, headers=False, sources=False):
|
||||||
|
source_filename = source_gen_folder / (strip_name(_class["name"]) + ".cpp")
|
||||||
|
if headers:
|
||||||
|
files.append(str(header_filename.as_posix()))
|
||||||
|
- if sources:
|
||||||
|
+ if sources and is_class_included(_class["name"], build_profile):
|
||||||
|
files.append(str(source_filename.as_posix()))
|
||||||
|
icall_header_filename = include_gen_folder / "__icalls.hpp"
|
||||||
|
register_types_filename = source_gen_folder / "__register_types.cpp"
|
||||||
|
@@ -40,27 +141,32 @@ def get_file_list(api_filepath, output_dir, headers=False, sources=False):
|
||||||
|
return files
|
||||||
|
|
||||||
|
|
||||||
|
-def print_file_list(api_filepath, output_dir, headers=False, sources=False):
|
||||||
|
- for f in get_file_list(api_filepath, output_dir, headers, sources):
|
||||||
|
+def print_file_list(api_filepath, output_dir, headers=False, sources=False, profile_filepath=""):
|
||||||
|
+ for f in get_file_list(api_filepath, output_dir, headers, sources, profile_filepath):
|
||||||
|
print(f, end=";")
|
||||||
|
|
||||||
|
|
||||||
|
def scons_emit_files(target, source, env):
|
||||||
|
- files = [env.File(f) for f in get_file_list(str(source[0]), target[0].abspath, True, True)]
|
||||||
|
+ profile_filepath = env.get("build_profile", "")
|
||||||
|
+ if profile_filepath and not Path(profile_filepath).is_absolute():
|
||||||
|
+ profile_filepath = str((Path(env.Dir("#").abspath) / profile_filepath).as_posix())
|
||||||
|
+
|
||||||
|
+ files = [env.File(f) for f in get_file_list(str(source[0]), target[0].abspath, True, True, profile_filepath)]
|
||||||
|
env.Clean(target, files)
|
||||||
|
env["godot_cpp_gen_dir"] = target[0].abspath
|
||||||
|
return files, source
|
||||||
|
|
||||||
|
|
||||||
|
def scons_generate_bindings(target, source, env):
|
||||||
|
- generate_bindings(str(source[0]), env["generate_template_get_node"], env["godot_cpp_gen_dir"])
|
||||||
|
+ generate_bindings(str(source[0]), env["generate_template_get_node"], env["godot_cpp_gen_dir"], env["build_profile"])
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
-def generate_bindings(api_filepath, use_template_get_node, output_dir="."):
|
||||||
|
+def generate_bindings(api_filepath, use_template_get_node, output_dir=".", profile_filepath=""):
|
||||||
|
global classes
|
||||||
|
with open(api_filepath) as api_file:
|
||||||
|
classes = json.load(api_file)
|
||||||
|
+ build_profile = parse_build_profile(profile_filepath, classes)
|
||||||
|
|
||||||
|
icalls = set()
|
||||||
|
include_gen_folder = Path(output_dir) / "include" / "gen"
|
||||||
|
@@ -97,7 +203,7 @@ def generate_bindings(api_filepath, use_template_get_node, output_dir="."):
|
||||||
|
|
||||||
|
init_method_bindings_filename = source_gen_folder / "__init_method_bindings.cpp"
|
||||||
|
with init_method_bindings_filename.open("w+") as init_method_bindings_file:
|
||||||
|
- init_method_bindings_file.write(generate_init_method_bindings(classes))
|
||||||
|
+ init_method_bindings_file.write(generate_init_method_bindings(list(filter(lambda x: is_class_included(x["name"], build_profile), classes))))
|
||||||
|
|
||||||
|
|
||||||
|
def is_reference_type(t):
|
||||||
180
misc/patches/build_profile_4.0.diff
Normal file
180
misc/patches/build_profile_4.0.diff
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
diff --git a/godot-cpp-4.0/SConstruct b/godot-cpp-4.0/SConstruct
|
||||||
|
index 27ee137..ec2af72 100644
|
||||||
|
--- a/godot-cpp-4.0/SConstruct
|
||||||
|
+++ b/godot-cpp-4.0/SConstruct
|
||||||
|
@@ -119,6 +119,14 @@ opts.Add(
|
||||||
|
opts.Add(
|
||||||
|
BoolVariable("generate_bindings", "Force GDExtension API bindings generation. Auto-detected by default.", False)
|
||||||
|
)
|
||||||
|
+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("generate_template_get_node", "Generate a template version of the Node class's get_node.", True))
|
||||||
|
|
||||||
|
opts.Add(BoolVariable("build_library", "Build the godot-cpp library.", True))
|
||||||
|
diff --git a/godot-cpp-4.0/binding_generator.py b/godot-cpp-4.0/binding_generator.py
|
||||||
|
index 7634942..7ab51a5 100644
|
||||||
|
--- a/godot-cpp-4.0/binding_generator.py
|
||||||
|
+++ b/godot-cpp-4.0/binding_generator.py
|
||||||
|
@@ -70,12 +70,14 @@ def generate_wrappers(target):
|
||||||
|
f.write(txt)
|
||||||
|
|
||||||
|
|
||||||
|
-def get_file_list(api_filepath, output_dir, headers=False, sources=False):
|
||||||
|
+def get_file_list(api_filepath, output_dir, headers=False, sources=False, profile_filepath=""):
|
||||||
|
api = {}
|
||||||
|
files = []
|
||||||
|
with open(api_filepath) as api_file:
|
||||||
|
api = json.load(api_file)
|
||||||
|
|
||||||
|
+ build_profile = parse_build_profile(profile_filepath, api)
|
||||||
|
+
|
||||||
|
core_gen_folder = Path(output_dir) / "gen" / "include" / "godot_cpp" / "core"
|
||||||
|
include_gen_folder = Path(output_dir) / "gen" / "include" / "godot_cpp"
|
||||||
|
source_gen_folder = Path(output_dir) / "gen" / "src"
|
||||||
|
@@ -104,7 +106,7 @@ def get_file_list(api_filepath, output_dir, headers=False, sources=False):
|
||||||
|
source_filename = source_gen_folder / "classes" / (camel_to_snake(engine_class["name"]) + ".cpp")
|
||||||
|
if headers:
|
||||||
|
files.append(str(header_filename.as_posix()))
|
||||||
|
- if sources:
|
||||||
|
+ if sources and is_class_included(engine_class["name"], build_profile):
|
||||||
|
files.append(str(source_filename.as_posix()))
|
||||||
|
|
||||||
|
for native_struct in api["native_structures"]:
|
||||||
|
@@ -132,14 +134,107 @@ def get_file_list(api_filepath, output_dir, headers=False, sources=False):
|
||||||
|
return files
|
||||||
|
|
||||||
|
|
||||||
|
-def print_file_list(api_filepath, output_dir, headers=False, sources=False):
|
||||||
|
+def print_file_list(api_filepath, output_dir, headers=False, sources=False, profile_filepath=""):
|
||||||
|
end = ";"
|
||||||
|
- for f in get_file_list(api_filepath, output_dir, headers, sources):
|
||||||
|
+ for f in get_file_list(api_filepath, output_dir, headers, sources, profile_filepath):
|
||||||
|
print(f, end=end)
|
||||||
|
|
||||||
|
|
||||||
|
+def parse_build_profile(profile_filepath, api):
|
||||||
|
+ if profile_filepath == "":
|
||||||
|
+ return {}
|
||||||
|
+ print("Using feature build profile: " + profile_filepath)
|
||||||
|
+
|
||||||
|
+ 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)
|
||||||
|
+
|
||||||
|
+ # Parse methods dependencies
|
||||||
|
+ deps = {}
|
||||||
|
+ reverse_deps = {}
|
||||||
|
+ for name, engine_class in api_dict.items():
|
||||||
|
+ ref_cls = set()
|
||||||
|
+ for method in engine_class.get("methods", []):
|
||||||
|
+ rtype = method.get("return_value", {}).get("type", "")
|
||||||
|
+ args = [a["type"] for a in method.get("arguments", [])]
|
||||||
|
+ if rtype in api_dict:
|
||||||
|
+ ref_cls.add(rtype)
|
||||||
|
+ elif is_enum(rtype) and get_enum_class(rtype) in api_dict:
|
||||||
|
+ ref_cls.add(get_enum_class(rtype))
|
||||||
|
+ for arg in args:
|
||||||
|
+ if arg in api_dict:
|
||||||
|
+ ref_cls.add(arg)
|
||||||
|
+ elif is_enum(arg) and get_enum_class(arg) in api_dict:
|
||||||
|
+ ref_cls.add(get_enum_class(arg))
|
||||||
|
+ deps[engine_class["name"]] = set(filter(lambda x: x != name, ref_cls))
|
||||||
|
+ for acls in ref_cls:
|
||||||
|
+ if acls == name:
|
||||||
|
+ continue
|
||||||
|
+ reverse_deps[acls] = reverse_deps.get(acls, set())
|
||||||
|
+ reverse_deps[acls].add(name)
|
||||||
|
+
|
||||||
|
+ included = []
|
||||||
|
+ front = list(profile.get("enabled_classes", []))
|
||||||
|
+ if front:
|
||||||
|
+ # These must always be included
|
||||||
|
+ front.append("WorkerThreadPool")
|
||||||
|
+ front.append("ClassDB")
|
||||||
|
+ front.append("ClassDBSingleton")
|
||||||
|
+ while front:
|
||||||
|
+ cls = front.pop()
|
||||||
|
+ if cls in included:
|
||||||
|
+ continue
|
||||||
|
+ included.append(cls)
|
||||||
|
+ parent = parents.get(cls, "")
|
||||||
|
+ if parent:
|
||||||
|
+ front.append(parent)
|
||||||
|
+ for rcls in deps.get(cls, set()):
|
||||||
|
+ if rcls in included or rcls in front:
|
||||||
|
+ continue
|
||||||
|
+ front.append(rcls)
|
||||||
|
+
|
||||||
|
+ excluded = []
|
||||||
|
+ front = list(profile.get("disabled_classes", []))
|
||||||
|
+ while front:
|
||||||
|
+ cls = front.pop()
|
||||||
|
+ if cls in excluded:
|
||||||
|
+ continue
|
||||||
|
+ excluded.append(cls)
|
||||||
|
+ front += children.get(cls, [])
|
||||||
|
+ for rcls in reverse_deps.get(cls, set()):
|
||||||
|
+ if rcls in excluded or rcls in front:
|
||||||
|
+ continue
|
||||||
|
+ front.append(rcls)
|
||||||
|
+
|
||||||
|
+ 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 scons_emit_files(target, source, env):
|
||||||
|
- files = [env.File(f) for f in get_file_list(str(source[0]), target[0].abspath, True, True)]
|
||||||
|
+ profile_filepath = env.get("build_profile", "")
|
||||||
|
+ if profile_filepath and not Path(profile_filepath).is_absolute():
|
||||||
|
+ profile_filepath = str((Path(env.Dir("#").abspath) / profile_filepath).as_posix())
|
||||||
|
+
|
||||||
|
+ files = [env.File(f) for f in get_file_list(str(source[0]), target[0].abspath, True, True, profile_filepath)]
|
||||||
|
env.Clean(target, files)
|
||||||
|
env["godot_cpp_gen_dir"] = target[0].abspath
|
||||||
|
return files, source
|
||||||
|
@@ -1997,6 +2092,20 @@ def is_pod_type(type_name):
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
+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_included_type(type_name):
|
||||||
|
# Types which we already have implemented.
|
||||||
|
return is_included_struct_type(type_name) or type_name in ["ObjectID"]
|
||||||
6
thirdparty/README.md
vendored
6
thirdparty/README.md
vendored
@@ -19,7 +19,7 @@ Module location:
|
|||||||
## libdatachannel
|
## libdatachannel
|
||||||
|
|
||||||
- Upstream: https://github.com/paullouisageneau/libdatachannel
|
- Upstream: https://github.com/paullouisageneau/libdatachannel
|
||||||
- Version: 0.20.2 (0b1074a9effeb8d9d3f4eca704d3fe3d2f9bc7e5, 2024)
|
- Version: 0.22.2 (3c33ea0f49fff2630be080b2043052b4d3de5786, 2024)
|
||||||
- License: MPL 2.0
|
- License: MPL 2.0
|
||||||
|
|
||||||
Module location:
|
Module location:
|
||||||
@@ -30,7 +30,7 @@ Module location:
|
|||||||
# libjuice
|
# libjuice
|
||||||
|
|
||||||
- Upstream: https://github.com/paullouisageneau/libjuice
|
- Upstream: https://github.com/paullouisageneau/libjuice
|
||||||
- Version: 1.3.4 (0b6f958baba55e1a4eb31ec2137f62b2e07382ae, 2024)
|
- Version: 1.5.7 (70ba50cce33350b64404557ea63658e925758ce6, 2024)
|
||||||
- License: MPL 2.0
|
- License: MPL 2.0
|
||||||
|
|
||||||
Module location:
|
Module location:
|
||||||
@@ -52,7 +52,7 @@ Module location:
|
|||||||
## openssl
|
## openssl
|
||||||
|
|
||||||
- Upstream: git://git.openssl.org/openssl.git
|
- Upstream: git://git.openssl.org/openssl.git
|
||||||
- Version: 3.0.13 (85cf92f55d9e2ac5aacf92bedd33fb890b9f8b4c, 2024)
|
- Version: 3.4.0 (98acb6b02839c609ef5b837794e08d906d965335, 2024)
|
||||||
- License: Apache 2.0
|
- License: Apache 2.0
|
||||||
|
|
||||||
Module location:
|
Module location:
|
||||||
|
|||||||
2
thirdparty/libdatachannel
vendored
2
thirdparty/libdatachannel
vendored
Submodule thirdparty/libdatachannel updated: 0b1074a9ef...3c33ea0f49
2
thirdparty/openssl
vendored
2
thirdparty/openssl
vendored
Submodule thirdparty/openssl updated: 85cf92f55d...98acb6b028
@@ -49,10 +49,9 @@ def cmake_default_flags(env):
|
|||||||
config["CMAKE_OSX_ARCHITECTURES"] = '"x86_64;arm64"'
|
config["CMAKE_OSX_ARCHITECTURES"] = '"x86_64;arm64"'
|
||||||
else:
|
else:
|
||||||
config["CMAKE_OSX_ARCHITECTURES"] = env["arch"]
|
config["CMAKE_OSX_ARCHITECTURES"] = env["arch"]
|
||||||
if env["macos_deployment_target"] != "default":
|
if env.get("macos_deployment_target", "default") != "default":
|
||||||
config["CMAKE_OSX_DEPLOYMENT_TARGET"] = env["macos_deployment_target"]
|
config["CMAKE_OSX_DEPLOYMENT_TARGET"] = env["macos_deployment_target"]
|
||||||
|
if sys.platform != "darwin" and "OSXCROSS_ROOT" in os.environ:
|
||||||
if env["platform"] == "macos" and sys.platform != "darwin" and "OSXCROSS_ROOT" in os.environ:
|
|
||||||
config["CMAKE_AR"] = env["AR"]
|
config["CMAKE_AR"] = env["AR"]
|
||||||
config["CMAKE_RANLIB"] = env["RANLIB"]
|
config["CMAKE_RANLIB"] = env["RANLIB"]
|
||||||
if env["arch"] == "universal":
|
if env["arch"] == "universal":
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ def ssl_platform_target(env):
|
|||||||
elif platform == "ios":
|
elif platform == "ios":
|
||||||
if env["ios_simulator"]:
|
if env["ios_simulator"]:
|
||||||
targets = {
|
targets = {
|
||||||
"x86_64": "iossimulator-xcrun",
|
"x86_64": "iossimulator-x86_64-xcrun",
|
||||||
"arm64": "iossimulator-xcrun",
|
"arm64": "iossimulator-arm64-xcrun",
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
targets = {
|
targets = {
|
||||||
@@ -79,7 +79,15 @@ def ssl_platform_flags(env):
|
|||||||
if env.get("android_api_level", ""):
|
if env.get("android_api_level", ""):
|
||||||
api = int(env["android_api_level"])
|
api = int(env["android_api_level"])
|
||||||
args.append("-D__ANDROID_API__=%s" % api)
|
args.append("-D__ANDROID_API__=%s" % api)
|
||||||
|
elif env["platform"] == "ios":
|
||||||
|
if env.get("ios_min_version", "default") != "default":
|
||||||
|
if env.get("ios_simulator", False):
|
||||||
|
args.append("-mios-simulator-version-min=%s" % env["ios_min_version"])
|
||||||
|
else:
|
||||||
|
args.append("-miphoneos-version-min=%s" % env["ios_min_version"])
|
||||||
elif env["platform"] == "macos":
|
elif env["platform"] == "macos":
|
||||||
|
if env.get("macos_deployment_target", "default") != "default":
|
||||||
|
args.append("-mmacosx-version-min=%s" % env["macos_deployment_target"])
|
||||||
# OSXCross toolchain setup.
|
# OSXCross toolchain setup.
|
||||||
if sys.platform != "darwin" and "OSXCROSS_ROOT" in os.environ:
|
if sys.platform != "darwin" and "OSXCROSS_ROOT" in os.environ:
|
||||||
for k in ["CC", "CXX", "AR", "AS", "RANLIB"]:
|
for k in ["CC", "CXX", "AR", "AS", "RANLIB"]:
|
||||||
|
|||||||
Reference in New Issue
Block a user