-
Notifications
You must be signed in to change notification settings - Fork 269
Expand file tree
/
Copy pathconfig.py
More file actions
112 lines (95 loc) · 3.94 KB
/
config.py
File metadata and controls
112 lines (95 loc) · 3.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
def can_build(env, platform):
return True
import methods
import os
import sys
import shutil
# A terrible hack to force-enable our dependent modules being included on non-editor builds.
# etcpak has dependencies our decompressor requires,
# astcenc has the decompression functions.
# without these, we can't decompress either astc or etc textures.
#
# astcenc and etcpak's can_build functions returns False if the editor_build flag is False,
# and it can't be overridden by any flags. Also, Since they come before us in the modules list,
# we can't monkey patch that.
#
# During configure, env.module_list isn't set, and it's not possible to add modules to it.
# sort_module_list is called right after after env.module_list is set with all the modules,
# so we can monkey patch that to add the modules we need.
def monkey_patch_sort_module_list():
old_sort_module_list = methods.sort_module_list
def sort_module_list(env):
if not "etcpak" in env.module_list:
env.module_list["etcpak"] = "modules/etcpak"
if not "astcenc" in env.module_list:
env.module_list["astcenc"] = "modules/astcenc"
# no need to run configure on etcpak
if not "tinyexr" in env.module_list:
env.module_list["tinyexr"] = "modules/tinyexr"
if not "xatlas_unwrap" in env.module_list:
env.module_list["xatlas_unwrap"] = "modules/xatlas_unwrap"
return old_sort_module_list(env)
methods.sort_module_list = sort_module_list
# A hack to have "generate_bundle" copy the library to the frameworks dir in the bundle
def monkey_patch_macos_generate_bundle():
# get the current directory
current_dir = os.path.dirname(os.path.abspath(__file__))
platform_macos_builders_dir = os.path.abspath(os.path.join(current_dir, "../../platform/macos"))
sys.path.insert(0, platform_macos_builders_dir)
import platform_macos_builders
old_generate_bundle = platform_macos_builders.generate_bundle
def generate_bundle(target, source, env):
if "disable_godot_mono_decomp" in env and env["disable_godot_mono_decomp"]:
old_generate_bundle(target, source, env)
return
frameworks_dir = ""
if env.editor_build:
templ = env.Dir("#misc/dist/macos_tools.app").abspath
frameworks_dir = os.path.join(templ, "Contents/Frameworks")
else:
templ = env.Dir("#misc/dist/macos_template.app").abspath
frameworks_dir = os.path.join(templ, "Contents/Frameworks")
remove_fw_dir = False
if not os.path.isdir(frameworks_dir):
remove_fw_dir = True
os.mkdir(frameworks_dir)
# Copy frameworks
monolib = env.Dir("#bin").abspath + "/libGodotMonoDecompNativeAOT.dylib"
shutil.copy(monolib, frameworks_dir + "/libGodotMonoDecompNativeAOT.dylib")
# run the original generate_bundle
old_generate_bundle(target, source, env)
# remove the library from the frameworks dir
os.remove(frameworks_dir + "/libGodotMonoDecompNativeAOT.dylib")
if remove_fw_dir:
os.rmdir(frameworks_dir)
platform_macos_builders.generate_bundle = generate_bundle
# remove the platform_macos_builders from the path
sys.path.remove(platform_macos_builders_dir)
def configure(env):
if not env.editor_build:
monkey_patch_sort_module_list()
if env["platform"] == "macos":
monkey_patch_macos_generate_bundle()
def get_doc_classes():
return [
"GDScriptDecomp",
"Glob",
"GodotVer",
"GodotREEditorStandalone",
"ImportExporter",
"ImportInfo",
"PckDumper",
"ImportExporter",
"ResourceCompatLoader",
"Exporter",
"ResourceExporter",
"CustomDecryptor",
"AESContextGDRE",
"CamelliaContext",
"AriaContext",
"GDRESettings",
"GDREConfig",
"PckCreator",
]
def get_doc_path():
return "doc_classes"