-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathMakefile.toml
286 lines (261 loc) · 12.5 KB
/
Makefile.toml
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
{%- comment -%} dynamic make targets {%- endcomment -%}
{%- assign target_dir = "target" -%}
{%- assign lib_dir = "lib" -%}
{%- assign bin_dir = "bin" -%}
{%- assign aarch64-linux-android-debug = "aarch64-linux-android,Android,debug" | split: "|" -%}
{%- assign aarch64-linux-android-release = "aarch64-linux-android,Android,release" | split: "|" -%}
{%- assign armv7-linux-androideabi-debug = "armv7-linux-androideabi,Android,debug" | split: "|" -%}
{%- assign armv7-linux-androideabi-release = "armv7-linux-androideabi,Android,release" | split: "|" -%}
{%- assign arm_android_targets = aarch64-linux-android-debug | concat: aarch64-linux-android-release | concat: armv7-linux-androideabi-debug | concat: armv7-linux-androideabi-release | compact -%}
{%- assign i686-linux-android-debug = "i686-linux-android,Android,debug" | split: "|" -%}
{%- assign i686-linux-android-release = "i686-linux-android,Android,release" | split: "|" -%}
{%- assign x86_64-linux-android-debug = "x86_64-linux-android,Android,debug" | split: "|" -%}
{%- assign x86_64-linux-android-release = "x86_64-linux-android,Android,release" | split: "|" -%}
{%- assign x86_android_targets = i686-linux-android-debug | concat: i686-linux-android-release | concat: x86_64-linux-android-debug | concat: x86_64-linux-android-release | compact -%}
{%- assign android_targets = arm_android_targets | concat: x86_android_targets | compact -%}
{%- assign i686-unknown-linux-gnu-debug = "i686-unknown-linux-gnu,Linux/X11,debug" | split: "|" -%}
{%- assign i686-unknown-linux-gnu-release = "i686-unknown-linux-gnu,Linux/X11,release" | split: "|" -%}
{%- assign x86_64-unknown-linux-gnu-debug = "x86_64-unknown-linux-gnu,Linux/X11,debug" | split: "|" -%}
{%- assign x86_64-unknown-linux-gnu-release = "x86_64-unknown-linux-gnu,Linux/X11,release" | split: "|" -%}
{%- assign x86_linux_targets = i686-unknown-linux-gnu-debug | concat: i686-unknown-linux-gnu-release | concat: x86_64-unknown-linux-gnu-debug | concat: x86_64-unknown-linux-gnu-release | compact -%}
{%- assign x86_64-apple-darwin-debug = "x86_64-apple-darwin,Mac OSX,debug" | split: "|" -%}
{%- assign x86_64-apple-darwin-release = "x86_64-apple-darwin,Mac OSX,release" | split: "|" -%}
{%- assign aarch64-apple-darwin-debug = "aarch64-apple-darwin,Mac OSX,debug" | split: "|" -%}
{%- assign aarch64-apple-darwin-release = "aarch64-apple-darwin,Mac OSX,release" | split: "|" -%}
{%- assign mac_osx_targets = x86_64-apple-darwin-debug | concat: x86_64-apple-darwin-release | concat: aarch64-apple-darwin-debug | concat: aarch64-apple-darwin-release | compact -%}
{%- assign aarch64-apple-ios-debug = "aarch64-apple-ios,iOS,debug" | split: "|" -%}
{%- assign aarch64-apple-ios-release = "aarch64-apple-ios,iOS,release" | split: "|" -%}
{%- assign ios_targets = aarch64-apple-ios-debug | concat: aarch64-apple-ios-release | compact -%}
{%- assign i686-pc-windows-gnu-debug = "i686-pc-windows-gnu,Windows Desktop,debug" | split: "|" -%}
{%- assign i686-pc-windows-gnu-release = "i686-pc-windows-gnu,Windows Desktop,release" | split: "|" -%}
{%- assign x86_64-pc-windows-gnu-debug = "x86_64-pc-windows-gnu,Windows Desktop,debug" | split: "|" -%}
{%- assign x86_64-pc-windows-gnu-release = "x86_64-pc-windows-gnu,Windows Desktop,release" | split: "|" -%}
{%- assign i686-pc-windows-msvc-debug = "i686-pc-windows-msvc,Windows Desktop,debug" | split: "|" -%}
{%- assign i686-pc-windows-msvc-release = "i686-pc-windows-msvc,Windows Desktop,release" | split: "|" -%}
{%- assign x86_64-pc-windows-msvc-debug = "x86_64-pc-windows-msvc,Windows Desktop,debug" | split: "|" -%}
{%- assign x86_64-pc-windows-msvc-release = "x86_64-pc-windows-msvc,Windows Desktop,release" | split: "|" -%}
{%- assign windows_gnu_targets = i686-pc-windows-gnu-debug | concat: i686-pc-windows-gnu-release | concat: x86_64-pc-windows-gnu-debug | concat: x86_64-pc-windows-gnu-release | compact -%}
{%- assign windows_msvc_targets = i686-pc-windows-msvc-debug | concat: i686-pc-windows-msvc-release | concat: x86_64-pc-windows-msvc-debug | concat: x86_64-pc-windows-msvc-release | compact -%}
{%- assign wasm32-unknown-emscripten-debug = "wasm32-unknown-emscripten,HTML5,debug" | split: "|" -%}
{%- assign wasm32-unknown-emscripten-release = "wasm32-unknown-emscripten,HTML5,release" | split: "|" -%}
{%- assign wasm_targets = wasm32-unknown-emscripten-debug | concat: wasm32-unknown-emscripten-release | compact -%}
{%- assign all_targets = android_targets | concat: x86_linux_targets | concat: mac_osx_targets | concat: ios_targets | concat: windows_gnu_targets | concat: windows_msvc_targets | concat: wasm_targets | compact -%}
{%- assign godot_project_path_arg = "--path ../godot/" -%}
[tasks.build-debug]
script_runner = "@shell"
script = '''
{% for target in all_targets -%}
{%- assign t = target | split: "," -%}
{%- assign build_target = t[0] -%}
{%- assign target_type = t[2] -%}
{%- if target_type == "debug" -%}
# cargo make build-{{build_target}}-{{target_type}}
{% endif %}
{%- endfor -%}
'''
[tasks.build-release]
script_runner = "@shell"
script = '''
{% for target in all_targets -%}
{%- assign t = target | split: "," -%}
{%- assign build_target = t[0] -%}
{%- assign target_type = t[2] -%}
{%- if target_type == "release" -%}
# cargo make build-{{build_target}}-{{target_type}}
{% endif %}
{%- endfor -%}
'''
[tasks.export-debug]
script_runner = "@shell"
script = '''
{% for target in all_targets -%}
{%- assign t = target | split: "," -%}
{%- assign build_target = t[0] -%}
{%- assign target_type = t[2] -%}
{%- if target_type == "debug" -%}
# cargo make export-{{build_target}}-{{target_type}}
{% endif %}
{%- endfor -%}
'''
[tasks.export-release]
script_runner = "@shell"
script = '''
{% for target in all_targets -%}
{%- assign t = target | split: "," -%}
{%- assign build_target = t[0] -%}
{%- assign target_type = t[2] -%}
{%- if target_type == "release" -%}
# cargo make export-{{build_target}}-{{target_type}}
{% endif %}
{%- endfor -%}
'''
{% for target in all_targets %}
{%- assign t = target | split: "," -%}
{%- assign build_target = t[0] -%}
{%- assign export_target = t[1] -%}
{%- assign target_type = t[2] -%}
{%- capture exported_project -%}
{%- case export_target -%}
{%- when "Android" -%}
{{project-name}}.{{target_type}}.{{build_target}}.apk
{%- when "Linux/X11" -%}
{{project-name}}.{{target_type}}.{{build_target}}
{%- when "Mac OSX" -%}
{{project-name}}.{{target_type}}.{{build_target}}.dmg
{%- when "iOS" -%}
{{project-name}}.{{target_type}}.{{build_target}}
{%- when "Windows Desktop" -%}
{{project-name}}.{{target_type}}.{{build_target}}.exe
{%- when "HTML5" -%}
{{project-name}}.{{target_type}}.{{build_target}}.html
{%- endcase -%}
{%- endcapture -%}
{%- capture lib_ext -%}
{%- case export_target -%}
{%- when "Android" -%}
so
{%- when "Linux/X11" -%}
so
{%- when "Mac OSX" -%}
dylib
{%- when "iOS" -%}
a
{%- when "Windows Desktop" -%}
dll
{%- when "HTML5" -%}
wasm
{%- endcase -%}
{%- endcapture -%}
{%- capture build_arg -%}
{%- case target_type -%}
{%- when "debug" -%}
{%- when "release" -%}
--release
{%- endcase -%}
{%- endcapture -%}
{%- capture export_arg -%}
{%- case target_type -%}
{%- when "debug" -%}
--export-debug
{%- when "release" -%}
--export
{%- endcase -%}
{%- endcapture %}
[tasks.ps1-build-{{build_target}}-{{target_type}}]
script_runner = "@shell"
script = '''
cargo build --target {{build_target}} {{build_arg}}
mv ../{{target_dir}}/{{build_target}}/{{target_type}}/*.{{lib_ext}} ../{{lib_dir}}/{{build_target}}
'''
[tasks.sh-build-{{build_target}}-{{target_type}}]
script_runner = "@shell"
script = '''
cargo build --target {{build_target}} {{build_arg}}
if [[ -f ../{{lib_dir}}/{{build_target}}/*.{{lib_ext}} ]]; then
rm ../{{lib_dir}}/{{build_target}}/*.{{lib_ext}}
fi
mv ../{{target_dir}}/{{build_target}}/{{target_type}}/*.{{lib_ext}} ../{{lib_dir}}/{{build_target}}
'''
[tasks.build-{{build_target}}-{{target_type}}]
run_task = [
{ name = "ps1-build-{{build_target}}-{{target_type}}", condition = { platforms = ["windows"] } },
{ name = "sh-build-{{build_target}}-{{target_type}}", condition = { platforms = ["linux", "mac"] } }
]
[tasks.export-{{build_target}}-{{target_type}}]
dependencies = ["build-{{build_target}}-{{target_type}}"]
script_runner = "@shell"
script = '''
cd ../godot/
godot3 {{export_arg}} "{{export_target}}.{{build_target}}.{{target_type}}" ../{{bin_dir}}/{{build_target}}/{{exported_project}}
'''
{% endfor -%}
{% comment %} static make targets {% endcomment %}
[tasks.audit]
command = "cargo"
args = ["audit"]
[tasks.check]
command = "cargo"
args = ["check"]
dependencies = ["clean"]
[tasks.clean]
command = "cargo"
args = ["clean"]
[tasks.create-debug-keystore]
script_runner = "@shell"
script = '''
keytool -keyalg RSA -genkeypair -alias androiddebugkey -keypass android -keystore {{project-name}}.debug.keystore -storepass android -dname "CN=Android Debug,O=Android,C=US" -validity 9999 -deststoretype pkcs12
mv -b *.keystore ..
'''
[tasks.create-release-keystore]
script_runner = "@shell"
script = '''
keytool -keyalg RSA -genkeypair -alias {{project-name}} -keypass ${@} -keystore {{project-name}}.release.keystore -storepass ${@} -dname "CN={{project-name}},O=Android,C=US" -validity 10000 -deststoretype pkcs12
mv -b *.keystore ..
sed -i "s|keystore/release_password=\".*\"|keystore/release_password=\"${@}\"|g" ../godot/export_presets.cfg
'''
[tasks.switch-gdnlib-msvc-to-gnu-entry]
script_runner = "@shell"
script = '''
sed -i "s|Windows.64=\"res://../lib/x86_64-pc-windows-msvc/{{project-name}}.dll\"|# Windows.64=\"res://../lib/x86_64-pc-windows-msvc/{{project-name}}.dll\"|g" ../godot/native/game.gdnlib
sed -i "s|# Windows.64=\"res://../lib/x86_64-pc-windows-gnu/{{project-name}}.dll\"|Windows.64=\"res://../lib/x86_64-pc-windows-gnu/{{project-name}}.dll\"|g" ../godot/native/game.gdnlib
sed -i "s|Windows.32=\"res://../lib/i686-pc-windows-msvc/{{project-name}}.dll\"|# Windows.32=\"res://../lib/i686-pc-windows-msvc/{{project-name}}.dll\"|g" ../godot/native/game.gdnlib
sed -i "s|# Windows.32=\"res://../lib/i686-pc-windows-gnu/{{project-name}}.dll\"|Windows.32=\"res://../lib/i686-pc-windows-gnu/{{project-name}}.dll\"|g" ../godot/native/game.gdnlib
'''
[tasks.switch-gdnlib-gnu-to-msvc-entry]
script_runner = "@shell"
script = '''
sed -i "s|Windows.64=\"res://../lib/x86_64-pc-windows-gnu/{{project-name}}.dll\"|# Windows.64=\"res://../lib/x86_64-pc-windows-gnu/{{project-name}}.dll\"|g" ../godot/native/game.gdnlib
sed -i "s|# Windows.64=\"res://../lib/x86_64-pc-windows-msvc/{{project-name}}.dll\"|Windows.64=\"res://../lib/x86_64-pc-windows-msvc/{{project-name}}.dll\"|g" ../godot/native/game.gdnlib
sed -i "s|Windows.32=\"res://../lib/i686-pc-windows-gnu/{{project-name}}.dll\"|# Windows.32=\"res://../lib/i686-pc-windows-gnu/{{project-name}}.dll\"|g" ../godot/native/game.gdnlib
sed -i "s|# Windows.32=\"res://../lib/i686-pc-windows-msvc/{{project-name}}.dll\"|Windows.32=\"res://../lib/i686-pc-windows-msvc/{{project-name}}.dll\"|g" ../godot/native/game.gdnlib
'''
[tasks.doc]
command = "cargo"
args = ["doc", "--no-deps", "--open", "-v"]
dependencies = ["clean"]
[tasks.edit]
script_runner = "@shell"
script = '''
godot3 -e --path {{godot_project_path_arg}}
'''
[tasks.run-for-linux]
# dependencies = ["build-i686-unknown-linux-gnu-debug"]
dependencies = ["build-x86_64-unknown-linux-gnu-debug"]
run_task = "run-godot"
[tasks.run-for-macos]
dependencies = ["build-x86_64-apple-darwin-debug"]
run_task = "run-godot-macos"
[tasks.run-for-macos-apple-silicon]
dependencies = ["build-aarch64-apple-darwin-debug"]
run_task = "run-godot-macos"
[tasks.run-for-windows]
# dependencies = ["build-i686-pc-windows-gnu-debug"]
# dependencies = ["build-i686-pc-windows-msvc-debug"]
# dependencies = ["build-x86_64-pc-windows-gnu-debug"]
dependencies = ["build-x86_64-pc-windows-msvc-debug"]
run_task = "run-godot"
[tasks.run-godot]
script_runner = "@shell"
script = '''
cd ../godot/
godot3 -d
'''
[tasks.run-godot-macos]
script_runner = "@shell"
script = '''
cd ../godot/
/Applications/Godot.app/Contents/MacOS/Godot -d
'''
[tasks.run]
run_task = [
{ name = "run-for-windows", condition = { platforms = ["windows"] } },
{ name = "run-for-linux", condition = { platforms = ["linux"] } },
{ name = "run-for-macos", condition = { platforms = ["mac"], env = { "CARGO_MAKE_RUST_TARGET_ARCH" = "x86_64" } } },
{ name = "run-for-macos-apple-silicon", condition = { platforms = ["mac"], env = { "CARGO_MAKE_RUST_TARGET_ARCH" = "aarch64" } } }
]
[tasks.test]
command = "cargo"
args = ["test"]
dependencies = ["clean"]
[env]
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true