-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgodot_size_benchmarks.nim
executable file
·144 lines (129 loc) · 3.48 KB
/
godot_size_benchmarks.nim
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# Copyright © 2019 Hugo Locurcio and contributors - MIT License
# See `LICENSE.md` included in the source distribution for details.
import os
import osproc
import strformat
import terminal
import cligen
# SCons flags to use for all builds
let sconsFlagsAll = [
"tools=no",
"target=release",
"progress=no",
"debug_symbols=no",
"use_lto=yes",
&"-j{countProcessors() + 1}",
]
# Additional SCons flags to use for each build
const sconsFlagsExtra = {
"full": @[],
"micro": @[
"disable_advanced_gui=yes",
"module_bmp_enabled=no",
"module_bullet_enabled=no",
"module_dds_enabled=no",
"module_enet_enabled=no",
"module_etc_enabled=no",
"module_gdnative_enabled=no",
"module_hdr_enabled=no",
"module_mobile_vr_enabled=no",
"module_pvr_enabled=no",
"module_regex_enabled=no",
"module_squish_enabled=no",
"module_tga_enabled=no",
"module_thekla_unwrap_enabled=no",
"module_tinyexr_enabled=no",
"module_websocket_enabled=no",
],
"pico": @[
"optimize=size",
"disable_advanced_gui=yes",
"module_bmp_enabled=no",
"module_bullet_enabled=no",
"module_csg_enabled=no",
"module_dds_enabled=no",
"module_enet_enabled=no",
"module_etc_enabled=no",
"module_gdnative_enabled=no",
"module_gridmap_enabled=no",
"module_hdr_enabled=no",
"module_mbedtls_enabled=no",
"module_mobile_vr_enabled=no",
"module_opus_enabled=no",
"module_pvr_enabled=no",
"module_recast_enabled=no",
"module_regex_enabled=no",
"module_squish_enabled=no",
"module_tga_enabled=no",
"module_thekla_unwrap_enabled=no",
"module_theora_enabled=no",
"module_tinyexr_enabled=no",
"module_vorbis_enabled=no",
"module_webm_enabled=no",
"module_websocket_enabled=no",
],
}
# Flags to use for 2D-only builds
const sconsFlags2d = [
"disable_3d=yes",
]
proc main() =
for buildName, extraSconsFlags in sconsFlagsExtra.items:
for platform in ["android", "javascript", "x11", "windows"]:
for is2dBuild in [false, true]:
let flags2d =
if is2dBuild: @sconsFlags2d
else: @[]
let extraSuffix =
if is2dBuild: &"{buildName}_2d"
else: buildName
let sconsFlags =
@[&"platform={platform}", &"extra_suffix={extraSuffix}"] &
@sconsFlagsAll &
extraSconsFlags &
flags2d
styledEcho(
"Building for ",
styleBright,
fgCyan,
platform,
resetStyle,
" (",
styleBright,
extraSuffix,
resetStyle,
")…",
)
echo execProcess(
"scons",
"godot",
sconsFlags,
nil,
{poUsePath, poStdErrToStdOut}
)
if platform == "android":
echo execProcess(
"./gradlew",
"godot/platform/android/java",
["build"],
nil,
{poUsePath, poStdErrToStdOut}
)
# Rename the generated APK to contain the extra prefix as it's
# not done automatically by Gradle
moveFile(
"godot/bin/android_release.apk",
&"godot/bin/android_release.{extraSuffix}.apk"
)
# Strip binaries of any remaining debug symbols
for file in walkFiles("godot/bin/*"):
echo execProcess(
"strip",
"",
[file],
nil,
{poUsePath, poStdErrToStdOut}
)
when isMainModule:
dispatch(main)
system.addQuitProc(resetAttributes)