diff --git a/.github/workflows/build-addon-on-push.yml b/.github/workflows/build-addon-on-push.yml index fc50432f..7dab3f70 100644 --- a/.github/workflows/build-addon-on-push.yml +++ b/.github/workflows/build-addon-on-push.yml @@ -77,8 +77,8 @@ jobs: - name: Create extension library run: | cd aar - scons platform=${{ matrix.platform }} target=template_debug ${{ matrix.flags }} custom_api_file=thirdparty/godot_cpp_gdextension_api/extension_api.json - scons platform=${{ matrix.platform }} target=template_release ${{ matrix.flags }} custom_api_file=thirdparty/godot_cpp_gdextension_api/extension_api.json + scons platform=${{ matrix.platform }} target=template_debug ${{ matrix.flags }} custom_api_file=thirdparty/godot_cpp_gdextension_api/extension_api.json build_profile=thirdparty/godot_cpp_build_profile/build_profile.json + scons platform=${{ matrix.platform }} target=template_release ${{ matrix.flags }} custom_api_file=thirdparty/godot_cpp_gdextension_api/extension_api.json build_profile=thirdparty/godot_cpp_build_profile/build_profile.json cd .. # On Android we build our loaders and build our extension with gradlew @@ -94,10 +94,10 @@ jobs: - name: Create Godot-CPP library run: | cd aar/thirdparty/godot-cpp - scons platform=${{ matrix.platform }} target=template_debug arch=arm64 custom_api_file=../godot_cpp_gdextension_api/extension_api.json - scons platform=${{ matrix.platform }} target=template_release arch=arm64 custom_api_file=../godot_cpp_gdextension_api/extension_api.json - scons platform=${{ matrix.platform }} target=template_debug arch=x86_64 custom_api_file=../godot_cpp_gdextension_api/extension_api.json - scons platform=${{ matrix.platform }} target=template_release arch=x86_64 custom_api_file=../godot_cpp_gdextension_api/extension_api.json + scons platform=${{ matrix.platform }} target=template_debug arch=arm64 custom_api_file=../godot_cpp_gdextension_api/extension_api.json build_profile=../godot_cpp_build_profile/build_profile.json + scons platform=${{ matrix.platform }} target=template_release arch=arm64 custom_api_file=../godot_cpp_gdextension_api/extension_api.json build_profile=../godot_cpp_build_profile/build_profile.json + scons platform=${{ matrix.platform }} target=template_debug arch=x86_64 custom_api_file=../godot_cpp_gdextension_api/extension_api.json build_profile=../godot_cpp_build_profile/build_profile.json + scons platform=${{ matrix.platform }} target=template_release arch=x86_64 custom_api_file=../godot_cpp_gdextension_api/extension_api.json build_profile=../godot_cpp_build_profile/build_profile.json cd ../../.. if: matrix.platform == 'android' - name: Create Godot OpenXR Vendors AARs diff --git a/thirdparty/godot_cpp_build_profile/build_profile.json b/thirdparty/godot_cpp_build_profile/build_profile.json new file mode 100644 index 00000000..cdf0befa --- /dev/null +++ b/thirdparty/godot_cpp_build_profile/build_profile.json @@ -0,0 +1,63 @@ +{ + "enabled_classes": [ + "ArrayMesh", + "BaseMaterial3D", + "BoxMesh", + "BoxShape3D", + "CollisionShape3D", + "ConcavePolygonShape3D", + "Curve", + "EditorExportPlatform", + "EditorExportPlatformAndroid", + "EditorExportPlugin", + "EditorPlugin", + "Engine", + "FileAccess", + "GLTFDocument", + "GLTFState", + "GeometryInstance3D", + "Gradient", + "Image", + "MainLoop", + "Material", + "Mesh", + "MeshConvexDecompositionSettings", + "MeshInstance3D", + "Node", + "Node3D", + "OS", + "Object", + "OpenXRAPIExtension", + "OpenXRExtensionWrapperExtension", + "OpenXRInterface", + "PackedScene", + "PlaneMesh", + "PrimitiveMesh", + "ProjectSettings", + "RefCounted", + "Resource", + "SceneTree", + "Shader", + "ShaderMaterial", + "Shape3D", + "Shortcut", + "Skeleton3D", + "SkeletonModifier3D", + "StandardMaterial3D", + "SurfaceTool", + "Viewport", + "VisualInstance3D", + "XRAnchor3D", + "XRBodyTracker", + "XRFaceTracker", + "XRHandModifier3D", + "XRHandTracker", + "XRInterface", + "XRNode3D", + "XROrigin3D", + "XRPose", + "XRPositionalTracker", + "XRServer", + "XRTracker" + ] +} \ No newline at end of file diff --git a/thirdparty/godot_cpp_build_profile/create_build_profile.py b/thirdparty/godot_cpp_build_profile/create_build_profile.py new file mode 100644 index 00000000..41b906a5 --- /dev/null +++ b/thirdparty/godot_cpp_build_profile/create_build_profile.py @@ -0,0 +1,93 @@ +#!/usr/bin/env python + +import os +import re +import json + +SOURCE_DIRS = [ + '../../common', + '../../godotopenxrkhronos', + '../../godotopenxrlynx', + '../../godotopenxrmeta', + '../../godotopenxrpico', +] + +GODOT_CPP_HEADERS = "../godot-cpp/gen/include/godot_cpp/classes" +#GODOT_CPP_SOURCES = "../godot-cpp/gen/src/classes" + +INCLUDE_PATTERN = re.compile(r'#include ') +CLASS_PATTERN = re.compile(r'class\s+(\w+)\s*:\s*public') + +processed_files = {} +class_list = [] + +def find_includes(file_path): + """ + Finds all the includes in a given file and returns the list of CLASS names. + """ + includes = [] + try: + with open(file_path, 'r') as file: + content = file.read() + includes = INCLUDE_PATTERN.findall(content) + except FileNotFoundError: + print(f"File not found: {file_path}") + return includes + +def find_primary_class(file_path): + """ + Finds the primary class name in a given .hpp file by looking for 'class ClassName : public'. + """ + try: + with open(file_path, 'r') as file: + for line in file: + match = CLASS_PATTERN.search(line) + if match: + return match.group(1) + except FileNotFoundError: + print(f"File not found: {file_path}") + return None + +def process_file(file_path, top_level=False): + """ + Processes a given file for includes and processes the included files recursively. + """ + if file_path in processed_files: + return + + processed_files[file_path] = True + + if not top_level and file_path.endswith('.hpp'): + primary_class = find_primary_class(file_path) + if primary_class and primary_class not in class_list: + class_list.append(primary_class) + + includes = find_includes(file_path) + for include_name in includes: + hpp_file = f"{GODOT_CPP_HEADERS}/{include_name}.hpp" + #cpp_file = f"{GODOT_CPP_SOURCES}/{include_name}.cpp" + + if os.path.exists(hpp_file): + process_file(hpp_file) + #if os.path.exists(cpp_file): + # process_file(cpp_file) + +def main(): + for dir in SOURCE_DIRS: + for root, _, files in os.walk(dir): + for file in files: + if file.endswith('.cpp') or file.endswith('.h'): + file_path = os.path.join(root, file) + process_file(file_path, True) + + class_list.sort() + + build_profile = { + "enabled_classes": class_list + } + + with open("build_profile.json", "wt") as file: + json.dump(build_profile, file, indent=4) + +if __name__ == "__main__": + main() \ No newline at end of file