-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathbuild.py
88 lines (60 loc) · 3.71 KB
/
build.py
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
import sys
import os
import shutil
import subprocess
import multiprocessing
script_path = os.path.abspath(__file__)
def replace_word(file_name, target_str, replace_str):
text = ""
with open(file_name, "r") as file:
text = file.read()
text = text.replace(target_str, replace_str)
with open(file_name, "w") as file:
file.write(text)
def import_generate_bindings():
binding_generator = __import__("godot-cpp.binding_generator").binding_generator
cwd = os.getcwd()
os.chdir(os.path.join(os.path.dirname(script_path), "godot-cpp"))
binding_generator.generate_bindings("gdextension/extension_api.json", False)
os.chdir(cwd)
import_generate_bindings()
os.chdir(os.path.dirname(script_path))
job_opt = " -j" + str(multiprocessing.cpu_count())
if "platform=windows" in sys.argv:
replace_word("godot-cpp/Sconstruct", "/MD", "/MT")
subprocess.run("scons platform=windows bits=32 target=release" + job_opt, shell = True)
subprocess.run("scons platform=windows bits=64 target=release" + job_opt, shell = True)
os.makedirs("addons/godot-flexbox/bin/windows", exist_ok = True)
shutil.copy2("bin/libgdflexbox.x86_32.dll", "addons/godot-flexbox/bin/windows/")
shutil.copy2("bin/libgdflexbox.x86_64.dll", "addons/godot-flexbox/bin/windows/")
elif "platform=macos" in sys.argv:
subprocess.run("scons platform=macos bits=64 target=release" + job_opt, shell = True)
os.makedirs("addons/godot-flexbox/bin/macos", exist_ok = True)
shutil.copy2("bin/libgdflexbox.dylib", "addons/godot-flexbox/bin/macos/")
elif "platform=android" in sys.argv:
subprocess.run("scons platform=android android_arch=armv7 target=release" + job_opt, shell = True)
subprocess.run("scons platform=android android_arch=arm64v8 target=release" + job_opt, shell = True)
subprocess.run("scons platform=android android_arch=x86 target=release" + job_opt, shell = True)
subprocess.run("scons platform=android android_arch=x86_64 target=release" + job_opt, shell = True)
os.makedirs("addons/godot-flexbox/bin/android", exist_ok = True)
shutil.copy2("bin/libgdflexbox.arm32.so", "addons/godot-flexbox/bin/android/")
shutil.copy2("bin/libgdflexbox.arm64.so", "addons/godot-flexbox/bin/android/")
shutil.copy2("bin/libgdflexbox.x86_32.so", "addons/godot-flexbox/bin/android/")
shutil.copy2("bin/libgdflexbox.x86_64.so", "addons/godot-flexbox/bin/android/")
elif "platform=ios" in sys.argv:
subprocess.run("scons platform=ios ios_arch=arm64 target=release" + job_opt, shell = True)
# subprocess.run("scons platform=ios ios_arch=x86_64 target=release" + job_opt, shell = True)
subprocess.run("lipo -create bin/libgdflexbox.arm64.dylib -output bin/libgdflexbox.dylib", shell = True)
# subprocess.run("lipo -create bin/libgdflexbox.arm64.dylib bin/libgdflexbox.x86_64.dylib -output bin/libgdflexbox.dylib", shell = True)
os.makedirs("addons/godot-flexbox/bin/ios", exist_ok = True)
shutil.copy2("bin/libgdflexbox.dylib", "addons/godot-flexbox/bin/ios/")
elif "platform=linux" in sys.argv:
subprocess.run("scons platform=linux bits=32 target=release use_llvm=1" + job_opt, shell = True)
subprocess.run("scons platform=linux bits=64 target=release use_llvm=1" + job_opt, shell = True)
os.makedirs("addons/godot-flexbox/bin/linux", exist_ok = True)
shutil.copy2("bin/libgdflexbox.x86_32.so", "addons/godot-flexbox/bin/linux/")
shutil.copy2("bin/libgdflexbox.x86_64.so", "addons/godot-flexbox/bin/linux/")
elif "platform=web" in sys.argv:
subprocess.run("scons platform=web bits=32 target=release" + job_opt, shell = True)
os.makedirs("addons/godot-flexbox/bin/web", exist_ok = True)
shutil.copy2("bin/libgdflexbox.wasm", "addons/godot-flexbox/bin/web/")