forked from GodotVR/godot_openxr_vendors
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use build_profile to improve build times (GodotVR#149)
- Loading branch information
Showing
3 changed files
with
162 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
] | ||
} |
93 changes: 93 additions & 0 deletions
93
thirdparty/godot_cpp_build_profile/create_build_profile.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <godot_cpp/classes/(\w+)\.hpp>') | ||
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() |