-
Notifications
You must be signed in to change notification settings - Fork 4
/
dodo.py
326 lines (293 loc) · 10.1 KB
/
dodo.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
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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
# dodo file for building HGamer3D components
# HGamer3D Library (A project to enable 3D game development in Haskell)
# Copyright 2015 Peter Althainz
#
# Distributed under the Apache License, Version 2.0
# (See attached file LICENSE or copy at
# http://www.apache.org/licenses/LICENSE-2.0)
#
# file: dodo.py
import os, os.path, platform, string, sys
from doit.tools import config_changed, run_once
# version information for all subcomponents
version_gamegio = "0.7.0"
version_media = "1.5.0"
version_engine = "1.5.0"
version_media_pack1 = "1.0.0"
version_hgamer3d = "0.7.1"
version_intonaco = "0.1.0"
# where is Urho3D located
urho3d_home = os.path.abspath("../Urho3D-1.5").replace(os.sep, "/")
urho3d_build = os.path.abspath("../Urho3D-Build").replace(os.sep, "/")
def make_dir(d, targets):
d = d.replace("/", os.sep)
if not os.path.exists(d):
os.makedirs(d)
def get_os():
os_name = platform.system()
if os_name == "Linux":
return "linux"
if os_name == "Windows":
return "windows"
print "don't know, which platform this is: ", os_name
sys.exit()
def get_arch():
ar = platform.machine()
if ar == "AMD64" or ar == "x86_64":
return "amd64"
if ar == "i386":
return "386"
print "don't know, which arch this is: ", ar
sys.exit()
arch_os = get_arch() + "-" + get_os()
def short_version(version):
return string.join(string.split(version, '.')[0:2], '.')
def copy_file_replace(file_in, replace_dict, targets):
with open(targets[0], "wt") as fout:
with open(file_in, "rt") as fin:
for line in fin:
line_out = line
for k in replace_dict.keys():
line_out = line_out.replace(k, replace_dict[k])
fout.write(line_out)
def task_gamegio():
if platform.system() == "Windows":
cmake_cmd = 'cd build-gamegio && cmake -D URHO3D_64BIT=1 -D URHO3D_LIB_TYPE=SHARED -D URHO3D_SRC=' + urho3d_home + ' -D URHO3D_HOME=' + urho3d_build + ' ../fresco/game-giornata -G "Visual Studio 14 2015 Win64"'
copy_cmd = 'cp build-gamegio/Release/game_gio_lib.dll build-gamegio/gamegio-' + arch_os + '-' + version_gamegio + '/game_engine.gio'
else:
# cmake_cmd = 'cd build-gamegio && cmake ../fresco/game-giornata'
cmake_cmd = 'cd build-gamegio && cmake -D URHO3D_64BIT=1 -D URHO3D_LIB_TYPE=SHARED -D URHO3D_SRC=' + urho3d_home + ' -D URHO3D_HOME=' + urho3d_build + ' ../fresco/game-giornata'
copy_cmd = 'cp build-gamegio/libgame_gio_lib.so build-gamegio/gamegio-' + arch_os + '-' + version_gamegio + '/game_engine.gio'
yield {
'name' : 'build-dir',
'actions' : [
(make_dir, ['build-gamegio']),
cmake_cmd
],
'file_dep': [
'fresco/game-giornata/CMakeLists.txt',
],
'targets' : ['build-gamegio']
}
yield {
'name' : 'library',
'actions': [
(make_dir, ['build-gamegio/gamegio-' + arch_os + '-' + version_gamegio]),
'cd build-gamegio && cmake --build . --config Release',
copy_cmd
],
'file_dep': [
'fresco/game-giornata/gui.hpp',
'fresco/game-giornata/audio.hpp',
'fresco/game-giornata/input.cpp',
'fresco/game-giornata/errors.hpp',
'fresco/game-giornata/gui.cpp',
'fresco/game-giornata/graphics3d.cpp',
'fresco/game-giornata/CMakeLists.txt',
'fresco/game-giornata/graphics3d.hpp',
'fresco/game-giornata/input.hpp',
'fresco/game-giornata/audio.cpp',
'fresco/game-giornata/interface.cpp',
'fresco/game-giornata/interface.h',
'fresco/game-giornata/Slider2.hpp',
'fresco/game-giornata/Slider2.cpp',
'fresco/game-giornata/LineEdit2.hpp',
'fresco/game-giornata/LineEdit2.cpp',
],
'targets': ['build-gamegio/gamegio-' + arch_os + '-' + version_gamegio + '/game_engine.gio',
],
}
yield {
'name' : 'arriccio',
'actions': [
(copy_file_replace, ['component/GameEngineGio', {'{version}' : version_gamegio, '{version_engine}' : short_version(version_engine)} ]),
'aio local http://www.hgamer3d.org/component/GameEngineGio build-gamegio || true'
],
'targets': ['build-gamegio/arriccio.toml'],
'uptodate': [config_changed(version_gamegio)],
'file_dep': [
'component/GameEngineGio',
]
}
def task_engine():
targetdir = 'build-engine/engine-' + arch_os + '-' + version_engine
if platform.system() == "Windows":
yield {
'name' : 'build-dir',
'actions' : [
(make_dir, [targetdir]),
'cp -r ../Urho3D-Build/bin/Urho3D.dll ' + targetdir,
'cp -r ../Urho3D-Build/bin/d3dcompiler_47.dll ' + targetdir,
],
'uptodate' : [run_once],
'targets' : ['build-engine']
}
else:
yield {
'name' : 'build-dir',
'actions' : [
(make_dir, [targetdir]),
'cp -r ../Urho3D-Build/lib/libUrho3D.so* ' + targetdir,
],
'uptodate' : [run_once],
'targets' : ['build-engine']
}
yield {
'name' : 'arriccio',
'actions': [
(copy_file_replace, ['component/Engine', {'{version}' : version_engine, '{version_media}' : short_version(version_media)} ]),
'aio local http://www.hgamer3d.org/component/Engine build-engine || true'
],
'targets': ['build-engine/arriccio.toml'],
'uptodate': [config_changed(version_engine)],
'file_dep': [
'component/Engine',
]
}
def task_media():
for (tdir, mdir, mversion, msource, mcomponent) in [
('build-media', 'build-media/media-', version_media, '../HGamer3D-Media/Plain-1.5', 'MediaPlain'),
('build-media-pack1', 'build-media-pack1/media-pack1-', version_media_pack1, '../HGamer3D-Media/MediaPack1', 'MediaPack1')
]:
yield {
'name' : 'build-dir-' + mcomponent,
'actions' : [
(make_dir, [mdir + mversion]),
'cp -r ' + msource + '/* ' + mdir + mversion,
],
'uptodate' : [run_once],
'targets' : [mdir + mversion]
}
yield {
'name' : 'arriccio-plain-' + mcomponent,
'actions': [
(copy_file_replace, ['component/' + mcomponent, {'{version}' : mversion} ]),
'aio local http://www.hgamer3d.org/component/' + mcomponent + ' ' + tdir + ' || true'
],
'targets': [tdir + '/arriccio.toml'],
'file_dep': [
'component/' + mcomponent,
]
}
def task_hgamer3d():
yield {
'name' : 'cabal',
'actions': [
(copy_file_replace, ['library/HGamer3D.cabal.tmpl', {'{version}' : version_hgamer3d} ]),
],
'targets': ['library/HGamer3D.cabal'],
'uptodate': [config_changed(version_hgamer3d)],
'file_dep': [
'library/HGamer3D.cabal.tmpl',
]
}
yield {
'name' : 'library',
'actions' : [
'cd library && stack build',
'cd library && stack sdist',
(make_dir, ['build-hgamer3d']),
'cd library && bash -c "cp `find .stack-work | grep .tar.gz` ../build-hgamer3d"'
],
'targets' : ['build-hgamer3d/HGamer3D-' + version_hgamer3d + '.tar.gz'],
'file_dep': [
'library/HGamer3D.cabal',
'library/LICENSE',
'library/stack.yaml',
'library/HGamer3D/Data/Angle.hs',
'library/HGamer3D/Data/Colour.hs',
'library/HGamer3D/Data/LMH.hs',
'library/HGamer3D/Data/GameTime.hs',
'library/HGamer3D/Data/Geometry2D.hs',
'library/HGamer3D/Data/Transform3D.hs',
'library/HGamer3D/Data/TypeSynonyms.hs',
'library/HGamer3D/Data/Vector.hs',
'library/HGamer3D/Data/Window.hs',
'library/HGamer3D/Data/PlayCmd.hs',
'library/HGamer3D/Data.hs',
'library/HGamer3D/Util/FileLocation.hs',
'library/HGamer3D/Util/UniqueName.hs',
'library/HGamer3D/Util/Variable.hs',
'library/HGamer3D/Util.hs',
'library/HGamer3D/Graphics3D.hs',
'library/HGamer3D/Graphics3D/Camera.hs',
'library/HGamer3D/Graphics3D/Geometry.hs',
'library/HGamer3D/Graphics3D/Light.hs',
'library/HGamer3D/Graphics3D/Material.hs',
'library/HGamer3D/Graphics3D/Window.hs',
'library/HGamer3D/Graphics3D/Graphics3DCommand.hs',
'library/HGamer3D/Graphics3D/Graphics3DConfig.hs',
'library/HGamer3D/Input/Mouse.hs',
'library/HGamer3D/Input/Keyboard.hs',
'library/HGamer3D/Input/Joystick.hs',
'library/HGamer3D/Input/InputEventHandler.hs',
'library/HGamer3D/Input.hs',
'library/HGamer3D/GUI/Button.hs',
'library/HGamer3D/GUI/EditText.hs',
'library/HGamer3D/GUI/Text.hs',
'library/HGamer3D/GUI/Slider.hs',
'library/HGamer3D/GUI/CheckBox.hs',
'library/HGamer3D/GUI/DropDownList.hs',
'library/HGamer3D/GUI.hs',
'library/HGamer3D/Audio/SoundSource.hs',
'library/HGamer3D/Audio/SoundListener.hs',
'library/HGamer3D/Audio/Volume.hs',
'library/HGamer3D/Audio.hs',
'library/HGamer3D.hs',
],
}
def task_examples():
yield {
'name' : 'build-dir',
'actions' : [
(make_dir, ['build-examples']),
],
'targets' : ['build-examples'],
'uptodate' : [run_once],
}
yield {
'name' : "compile",
'actions' : [
'cd examples && stack build',
'cd examples && bash -c "cp `find .stack-work | grep bin/RotatingCube` ../build-examples"',
'cd examples && bash -c "cp `find .stack-work | grep bin/Gui1` ../build-examples"',
'cd examples && bash -c "cp `find .stack-work | grep bin/SoundEffects` ../build-examples"',
'cd examples && bash -c "cp `find .stack-work | grep bin/Cuboid2` ../build-examples"',
'cd examples && bash -c "cp `find .stack-work | grep bin/Materials` ../build-examples"',
],
'targets' : [
'build-examples/RotatingCube',
'build-examples/Gui1',
'build-examples/SoundEffects',
'build-examples/Cuboid2',
'build-examples/Materials',
],
'file_dep': [
'examples/RotatingCube.hs',
'examples/Gui1.hs',
'examples/SoundEffects.hs',
'examples/Cuboid2.hs',
'examples/Materials.hs',
],
}
def task_runner():
yield {
'name' : 'build-dir',
'actions' : [
(make_dir, ['build-runner']),
],
'targets' : ['build-runner'],
'uptodate' : [run_once],
}
yield {
'name' : 'runner',
'actions': [
(copy_file_replace, ['component/Run', {'{version}' : version_hgamer3d, '{version_media_examples}' : short_version(version_media_pack1), '{version_gamegio}' : short_version(version_gamegio), '{version_intonaco}' : short_version(version_intonaco)}]),
'aio local http://www.hgamer3d.org/component/Run build-runner || true',
'aio alias Run http://www.hgamer3d.org/component/Run || true'
],
'targets': ['build-runner/arriccio.toml'],
'file_dep': [
'component/Run',
]
}