Skip to content

Commit 8ed3aeb

Browse files
committed
Use build_profile to improve build times
1 parent 94c2d3e commit 8ed3aeb

File tree

3 files changed

+162
-6
lines changed

3 files changed

+162
-6
lines changed

.github/workflows/build-addon-on-push.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ jobs:
7777
- name: Create extension library
7878
run: |
7979
cd aar
80-
scons platform=${{ matrix.platform }} target=template_debug ${{ matrix.flags }} custom_api_file=thirdparty/godot_cpp_gdextension_api/extension_api.json
81-
scons platform=${{ matrix.platform }} target=template_release ${{ matrix.flags }} custom_api_file=thirdparty/godot_cpp_gdextension_api/extension_api.json
80+
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
81+
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
8282
cd ..
8383
8484
# On Android we build our loaders and build our extension with gradlew
@@ -94,10 +94,10 @@ jobs:
9494
- name: Create Godot-CPP library
9595
run: |
9696
cd aar/thirdparty/godot-cpp
97-
scons platform=${{ matrix.platform }} target=template_debug arch=arm64 custom_api_file=../godot_cpp_gdextension_api/extension_api.json
98-
scons platform=${{ matrix.platform }} target=template_release arch=arm64 custom_api_file=../godot_cpp_gdextension_api/extension_api.json
99-
scons platform=${{ matrix.platform }} target=template_debug arch=x86_64 custom_api_file=../godot_cpp_gdextension_api/extension_api.json
100-
scons platform=${{ matrix.platform }} target=template_release arch=x86_64 custom_api_file=../godot_cpp_gdextension_api/extension_api.json
97+
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
98+
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
99+
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
100+
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
101101
cd ../../..
102102
if: matrix.platform == 'android'
103103
- name: Create Godot OpenXR Vendors AARs
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"enabled_classes": [
3+
"ArrayMesh",
4+
"BaseMaterial3D",
5+
"BoxMesh",
6+
"BoxShape3D",
7+
"CollisionShape3D",
8+
"ConcavePolygonShape3D",
9+
"Curve",
10+
"EditorExportPlatform",
11+
"EditorExportPlatformAndroid",
12+
"EditorExportPlugin",
13+
"EditorPlugin",
14+
"Engine",
15+
"FileAccess",
16+
"GLTFDocument",
17+
"GLTFState",
18+
"GeometryInstance3D",
19+
"Gradient",
20+
"Image",
21+
"MainLoop",
22+
"Material",
23+
"Mesh",
24+
"MeshConvexDecompositionSettings",
25+
"MeshInstance3D",
26+
"Node",
27+
"Node3D",
28+
"OS",
29+
"Object",
30+
"OpenXRAPIExtension",
31+
"OpenXRExtensionWrapperExtension",
32+
"OpenXRInterface",
33+
"PackedScene",
34+
"PlaneMesh",
35+
"PrimitiveMesh",
36+
"ProjectSettings",
37+
"RefCounted",
38+
"Resource",
39+
"SceneTree",
40+
"Shader",
41+
"ShaderMaterial",
42+
"Shape3D",
43+
"Shortcut",
44+
"Skeleton3D",
45+
"SkeletonModifier3D",
46+
"StandardMaterial3D",
47+
"SurfaceTool",
48+
"Viewport",
49+
"VisualInstance3D",
50+
"XRAnchor3D",
51+
"XRBodyTracker",
52+
"XRFaceTracker",
53+
"XRHandModifier3D",
54+
"XRHandTracker",
55+
"XRInterface",
56+
"XRNode3D",
57+
"XROrigin3D",
58+
"XRPose",
59+
"XRPositionalTracker",
60+
"XRServer",
61+
"XRTracker"
62+
]
63+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#!/usr/bin/env python
2+
3+
import os
4+
import re
5+
import json
6+
7+
SOURCE_DIRS = [
8+
'../../common',
9+
'../../godotopenxrkhronos',
10+
'../../godotopenxrlynx',
11+
'../../godotopenxrmeta',
12+
'../../godotopenxrpico',
13+
]
14+
15+
GODOT_CPP_HEADERS = "../godot-cpp/gen/include/godot_cpp/classes"
16+
#GODOT_CPP_SOURCES = "../godot-cpp/gen/src/classes"
17+
18+
INCLUDE_PATTERN = re.compile(r'#include <godot_cpp/classes/(\w+)\.hpp>')
19+
CLASS_PATTERN = re.compile(r'class\s+(\w+)\s*:\s*public')
20+
21+
processed_files = {}
22+
class_list = []
23+
24+
def find_includes(file_path):
25+
"""
26+
Finds all the includes in a given file and returns the list of CLASS names.
27+
"""
28+
includes = []
29+
try:
30+
with open(file_path, 'r') as file:
31+
content = file.read()
32+
includes = INCLUDE_PATTERN.findall(content)
33+
except FileNotFoundError:
34+
print(f"File not found: {file_path}")
35+
return includes
36+
37+
def find_primary_class(file_path):
38+
"""
39+
Finds the primary class name in a given .hpp file by looking for 'class ClassName : public'.
40+
"""
41+
try:
42+
with open(file_path, 'r') as file:
43+
for line in file:
44+
match = CLASS_PATTERN.search(line)
45+
if match:
46+
return match.group(1)
47+
except FileNotFoundError:
48+
print(f"File not found: {file_path}")
49+
return None
50+
51+
def process_file(file_path, top_level=False):
52+
"""
53+
Processes a given file for includes and processes the included files recursively.
54+
"""
55+
if file_path in processed_files:
56+
return
57+
58+
processed_files[file_path] = True
59+
60+
if not top_level and file_path.endswith('.hpp'):
61+
primary_class = find_primary_class(file_path)
62+
if primary_class and primary_class not in class_list:
63+
class_list.append(primary_class)
64+
65+
includes = find_includes(file_path)
66+
for include_name in includes:
67+
hpp_file = f"{GODOT_CPP_HEADERS}/{include_name}.hpp"
68+
#cpp_file = f"{GODOT_CPP_SOURCES}/{include_name}.cpp"
69+
70+
if os.path.exists(hpp_file):
71+
process_file(hpp_file)
72+
#if os.path.exists(cpp_file):
73+
# process_file(cpp_file)
74+
75+
def main():
76+
for dir in SOURCE_DIRS:
77+
for root, _, files in os.walk(dir):
78+
for file in files:
79+
if file.endswith('.cpp') or file.endswith('.h'):
80+
file_path = os.path.join(root, file)
81+
process_file(file_path, True)
82+
83+
class_list.sort()
84+
85+
build_profile = {
86+
"enabled_classes": class_list
87+
}
88+
89+
with open("build_profile.json", "wt") as file:
90+
json.dump(build_profile, file, indent=4)
91+
92+
if __name__ == "__main__":
93+
main()

0 commit comments

Comments
 (0)