File: dodo.py

package info (click to toggle)
birdfont 2.18.3-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 12,584 kB
  • sloc: ansic: 1,860; python: 1,200; xml: 170; sh: 98; makefile: 10
file content (483 lines) | stat: -rw-r--r-- 15,364 bytes parent folder | download
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
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
"""
Copyright (C) 2012 2013 2014 2015 Eduardo Naufel Schettino and Johan Mattsson

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""

import os
import glob
import subprocess
import sys

from scripts import version
from scripts.translations import compile_translations
from scripts import config
from scripts.builder import Builder

DOIT_CONFIG = {
    'default_tasks': [
        'build',
        'compile_translations',
        'man',
        'libbirdfont', 
        'libbirdgems', 
        'birdfont', 
        'birdfont-autotrace',
        'birdfont-export',
        'birdfont-import',
        'birdfont-test'
        ],
    }

if "kfreebsd" in sys.platform:
    LIBBIRDGEMS_SO_VERSION=version.LIBBIRDGEMS_SO_VERSION
elif "openbsd" in sys.platform:
    LIBBIRDGEMS_SO_VERSION='${LIBbirdgems_VERSION}'
else:
    LIBBIRDGEMS_SO_VERSION=version.LIBBIRDGEMS_SO_VERSION

if "kfreebsd" in sys.platform:
    SO_VERSION=version.SO_VERSION
elif "openbsd" in sys.platform:
    SO_VERSION='${LIBbirdfont_VERSION}'
else:
    SO_VERSION=version.SO_VERSION

def soname(target_binary):
    if "darwin" in sys.platform or "msys" in sys.platform:
        return ''
        
    return '-Wl,-soname,' + target_binary

def make_birdfont(target_binary, deps):
    valac_command = config.VALAC + """\
        -C \
        --vapidir=./ \
        --basedir build/birdfont/ \
        """ + config.NON_NULL + """ \
        """ + config.VALACFLAGS.get("birdfont", "") + """ \
        --enable-experimental \
        birdfont/*.vala \
		--vapidir=./ \
		--pkg """ + config.GEE + """ \
		--pkg gio-2.0  \
		--pkg cairo \
		--pkg libsoup-2.4 \
		--pkg gdk-pixbuf-2.0 \
		--pkg webkit2gtk-4.0 \
		--pkg libnotify \
		--pkg xmlbird \
		--pkg libbirdfont
        """
        
    cc_command = config.CC + " " + config.CFLAGS.get("birdfont", "") + """ \
        -c C_SOURCE \
		-D 'GETTEXT_PACKAGE="birdfont"' \
        -I./build/libbirdfont \
		$(pkg-config --cflags sqlite3) \
		$(pkg-config --cflags """ + config.GEE + """) \
		$(pkg-config --cflags gio-2.0) \
		$(pkg-config --cflags cairo) \
		$(pkg-config --cflags glib-2.0) \
		$(pkg-config --cflags gdk-pixbuf-2.0) \
		$(pkg-config --cflags webkit2gtk-4.0) \
		$(pkg-config --cflags libnotify) \
        -o OBJECT_FILE"""
        
    linker_command = config.CC + " " + config.LDFLAGS.get("birdfont", "") + """ \
        build/birdfont/*.o \
		-L./build/bin -lbirdfont \
		$(pkg-config --libs sqlite3) \
		$(pkg-config --libs """ + config.GEE + """) \
		$(pkg-config --libs gio-2.0) \
		$(pkg-config --libs cairo) \
		$(pkg-config --libs glib-2.0) \
		$(pkg-config --libs gdk-pixbuf-2.0) \
		$(pkg-config --libs webkit2gtk-4.0) \
		$(pkg-config --libs xmlbird) \
		$(pkg-config --libs libnotify) \
		-L./build -L./build/bin -l birdgems\
        -o build/bin/""" + target_binary

    birdfont = Builder('birdfont',
                          valac_command, 
                          cc_command,
                          linker_command,
                          target_binary,
                          None,
                          deps)
			
    yield birdfont.build()

def task_birdfont():
    yield make_birdfont('birdfont', ['libbirdgems.so', 'libbirdfont.so'])

def make_birdfont_export(target_binary, deps):
    valac_command = config.VALAC + """ \
        -C \
		--enable-experimental \
        --basedir build/birdfont-export/ \
        """ + config.NON_NULL + """ \
        """ + config.VALACFLAGS.get("birdfont-export", "") + """ \
		birdfont-export/*.vala \
		--vapidir=./ \
		--pkg """ + config.GEE + """ \
		--pkg gio-2.0  \
		--pkg cairo \
		--pkg xmlbird \
		--pkg libbirdfont
        """

    cc_command = config.CC + " " + config.CFLAGS.get("birdfont-export", "") + """ \
        -c C_SOURCE \
		-D 'GETTEXT_PACKAGE="birdfont"' \
        -I./build/libbirdfont \
		$(pkg-config --cflags sqlite3) \
		$(pkg-config --cflags """ + config.GEE + """) \
		$(pkg-config --cflags gio-2.0) \
		$(pkg-config --cflags cairo) \
		$(pkg-config --cflags glib-2.0) \
        -o OBJECT_FILE"""
        
    linker_command = config.CC + " " + config.LDFLAGS.get("birdfont-export", "") + """ \
		build/birdfont-export/*.o \
		-Lbuild/bin/ -lbirdfont \
		-lm \
		$(pkg-config --libs sqlite3) \
		$(pkg-config --libs """ + config.GEE + """) \
		$(pkg-config --libs gio-2.0) \
		$(pkg-config --libs cairo) \
		$(pkg-config --libs glib-2.0) \
		$(pkg-config --libs xmlbird) \
		-L./build -L./build/bin -l birdgems\
		-o ./build/bin/""" + target_binary

    birdfont_export = Builder('birdfont-export',
                              valac_command, 
                              cc_command,
                              linker_command,
                              target_binary,
                              None,
                              deps)
			
    yield birdfont_export.build()

def task_birdfont_export():
    yield make_birdfont_export('birdfont-export', ['libbirdgems.so', 'libbirdfont.so'])

def make_birdfont_import(target_binary, deps):
    valac_command = config.VALAC + """\
        -C  \
		--enable-experimental \
        --basedir build/birdfont-import/ \
        """ + config.NON_NULL + """ \
        """ + config.VALACFLAGS.get("birdfont-import", "") + """ \
		birdfont-import/*.vala \
		--vapidir=./ \
		--pkg """ + config.GEE + """ \
		--pkg gio-2.0  \
		--pkg cairo \
		--pkg xmlbird \
		--pkg libbirdfont
        """
        
    cc_command = config.CC + " " + config.CFLAGS.get("birdfont-import", "") + """ \
        -c C_SOURCE \
		-D 'GETTEXT_PACKAGE="birdfont"' \
        -I./build/libbirdfont \
		$(pkg-config --cflags sqlite3) \
		$(pkg-config --cflags """ + config.GEE + """) \
		$(pkg-config --cflags gio-2.0) \
		$(pkg-config --cflags cairo) \
		$(pkg-config --cflags glib-2.0) \
        -o OBJECT_FILE"""

    linker_command = config.CC + " " + config.LDFLAGS.get("birdfont-import", "") + """ \
		build/birdfont-import/*.o \
		-Lbuild/bin/ -lbirdfont \
		-lm \
		$(pkg-config --libs sqlite3) \
		$(pkg-config --libs """ + config.GEE + """) \
		$(pkg-config --libs gio-2.0) \
		$(pkg-config --libs cairo) \
		$(pkg-config --libs glib-2.0) \
		$(pkg-config --libs xmlbird) \
		-L./build -L./build/bin -l birdgems\
		-o ./build/bin/""" + target_binary

    birdfont_import = Builder('birdfont-import',
                          valac_command, 
                          cc_command,
                          linker_command,
                          target_binary,
                          None,
                          deps)
			
    yield birdfont_import.build()

def task_birdfont_import():
    yield make_birdfont_import('birdfont-import', ['libbirdgems.so', 'libbirdfont.so'])
	
def make_birdfont_autotrace(target_binary, deps):
    valac_command = config.VALAC + """\
        -C \
		--enable-experimental \
        --basedir build/birdfont-autotrace/ \
        """ + config.NON_NULL + """ \
        """ + config.VALACFLAGS.get("birdfont-autotrace", "") + """ \
		birdfont-autotrace/*.vala \
		--vapidir=./ \
		--pkg """ + config.GEE + """ \
		--pkg gio-2.0  \
		--pkg cairo \
		--pkg xmlbird \
		--pkg libbirdfont \
        """
        
    cc_command = config.CC + " " + config.CFLAGS.get("birdfont-autotrace", "") + """ \
        -c C_SOURCE \
		-D 'GETTEXT_PACKAGE="birdfont"' \
        -I./build/libbirdfont \
		$(pkg-config --cflags sqlite3) \
		$(pkg-config --cflags """ + config.GEE + """) \
		$(pkg-config --cflags gio-2.0) \
		$(pkg-config --cflags cairo) \
		$(pkg-config --cflags glib-2.0) \
        -o OBJECT_FILE"""
        
    linker_command = config.CC + " " + config.LDFLAGS.get("birdfont-autotrace", "") + """ \
		build/birdfont-autotrace/*.o \
        -I./build/libbirdfont \
		-Lbuild/bin/ -lbirdfont \
		-lm \
		$(pkg-config --libs sqlite3) \
		$(pkg-config --libs """ + config.GEE + """) \
		$(pkg-config --libs gio-2.0) \
		$(pkg-config --libs cairo) \
		$(pkg-config --libs glib-2.0) \
		$(pkg-config --libs xmlbird) \
		-L./build -L./build/bin -l birdgems\
		-o ./build/bin/""" + target_binary

    birdfont_autotrace = Builder('birdfont-autotrace',
                          valac_command, 
                          cc_command,
                          linker_command,
                          target_binary,
                          None,
                          deps)
			
    yield birdfont_autotrace.build()

def task_birdfont_autotrace():
    yield make_birdfont_autotrace('birdfont-autotrace', ['libbirdgems.so', 'libbirdfont.so'])
    
def make_libbirdfont(target_binary, deps):
    valac_command = config.VALAC + """\
        -C \
        --vapidir=./ \
        --basedir build/libbirdfont/ \
        """ + config.NON_NULL + """ \
        """ + config.VALACFLAGS.get("libbirdfont", "") + """ \
        --enable-experimental \
        --library libbirdfont \
        -H build/libbirdfont/birdfont.h \
        libbirdfont/*.vala \
        libbirdfont/OpenFontFormat/*.vala \
        libbirdfont/Renderer/*.vala \
        --pkg """ + config.GEE + """ \
        --pkg gio-2.0 \
        --pkg cairo \
        --pkg xmlbird \
        --pkg libbirdgems \
        --pkg sqlite3 \
        """

    cc_command = config.CC + " " + config.CFLAGS.get("libbirdfont", "") + """ \
            -c C_SOURCE \
            -fPIC \
            -D 'GETTEXT_PACKAGE="birdfont"' \
            -I ./build/libbirdfont \
            -I ./build/libbirdgems \
            $(pkg-config --cflags sqlite3) \
            $(pkg-config --cflags fontconfig) \
            $(pkg-config --cflags """ + config.GEE + """) \
            $(pkg-config --cflags gio-2.0) \
            $(pkg-config --cflags cairo) \
            $(pkg-config --cflags glib-2.0) \
            $(pkg-config --cflags xmlbird) \
            -o OBJECT_FILE"""

    linker_command = config.CC + " " + config.LDFLAGS.get("libbirdfont", "") + """ \
            -shared \
            """ + soname(target_binary) + """ \
            build/libbirdfont/*.o \
            $(pkg-config --libs sqlite3) \
            $(freetype-config --libs) \
            $(pkg-config --libs """ + config.GEE + """) \
            $(pkg-config --libs gio-2.0) \
            $(pkg-config --libs fontconfig) \
            $(pkg-config --libs cairo) \
            $(pkg-config --libs glib-2.0) \
            $(pkg-config --libs xmlbird) \
            -L./build -L./build/bin -l birdgems\
            -o ./build/bin/""" + target_binary

    libbirdfont = Builder('libbirdfont',
                          valac_command, 
                          cc_command,
                          linker_command,
                          target_binary,
                          'libbirdfont.so',
                          deps)
			
    yield libbirdfont.build()

def task_libbirdfont():
    yield make_libbirdfont('libbirdfont.so.' + SO_VERSION, ['libbirdgems.so'])
    
def make_libbirdgems(target_binary, deps):
    valac_command = config.VALAC + """\
		-C \
		-H build/libbirdgems/birdgems.h \
		--pkg posix \
		--vapidir=./ \
		--basedir=build/libbirdgems/ \
		""" + config.NON_NULL + """ \
        """ + config.VALACFLAGS.get("libbirdgems", "") + """ \
		--enable-experimental \
		--library libbirdgems \
		libbirdgems/*.vala \
        """

    cc_command = config.CC + " " + config.CFLAGS.get("libbirdgems", "") + """ \
			-fPIC \
			$(pkg-config --cflags glib-2.0) \
			-c C_SOURCE \
            -o OBJECT_FILE \
			"""

    linker_command = config.CC + " " + config.LDFLAGS.get("libbirdgems", "") + """ \
			-shared \
			""" + soname(target_binary) + """ \
			-fPIC \
			build/libbirdgems/*.o \
			$(pkg-config --libs glib-2.0) \
			$(pkg-config --libs gobject-2.0) \
			-o build/bin/""" + target_binary

    libbirdgems = Builder('libbirdgems',
                          valac_command, 
                          cc_command,
                          linker_command,
                          target_binary,
						  'libbirdgems.so',
                          deps)
			
    yield libbirdgems.build()

def task_libbirdgems():
    yield make_libbirdgems('libbirdgems.so.' + LIBBIRDGEMS_SO_VERSION, []) 

def task_compile_translations ():
    """translate po files"""
    return  {
        'actions': [compile_translations]
        }
        
def task_man():
    """gzip linux man pages"""
    for name in ("birdfont.1", "birdfont-export.1", 
                 "birdfont-import.1", "birdfont-autotrace.1"):
        yield {
            'name': name,
            'file_dep': ['resources/linux/' + name],
            'targets': ['build/' + name + '.gz'],
            'actions': ['gzip -9 -c resources/linux/' + name + ' > ' + 'build/' + name + '.gz'],
            }

def task_distclean ():
    return  {
        'actions': ['rm -rf .doit.db build scripts/config.py'
                    + ' libbirdfont/Config.vala'
                    + ' __pycache__ scripts/__pycache__']
        }

def task_build ():
    if not os.path.exists ("build/configured"):
        print ("Project is not configured")
        exit (1)

    subprocess.check_output ('mkdir -p build', shell=True)
    subprocess.check_output ('touch build/installed', shell=True)

    return  {
        'actions': ['echo "Build"'],
        }

def make_birdfont_test(target_binary, deps):
    valac_command = config.VALAC + """\
        -C \
        --vapidir=./ \
        --basedir build/birdfont-test/ \
        """ + config.NON_NULL + """ \
        """ + config.VALACFLAGS.get("birdfont-test", "") + """ \
        --enable-experimental \
        birdfont-test/*.vala \
		--vapidir=./ \
		--pkg """ + config.GEE + """ \
		--pkg gio-2.0  \
		--pkg cairo \
		--pkg xmlbird \
		--pkg libbirdfont
        """

    cc_command = config.CC + " " + config.CFLAGS.get("birdfont-test", "") + """ \
        -c C_SOURCE \
		-D 'GETTEXT_PACKAGE="birdfont"' \
        -I./build/libbirdfont \
		$(pkg-config --cflags sqlite3) \
		$(pkg-config --cflags """ + config.GEE + """) \
		$(pkg-config --cflags gio-2.0) \
		$(pkg-config --cflags cairo) \
		$(pkg-config --cflags glib-2.0) \
		$(pkg-config --cflags xmlbird) \
        -o OBJECT_FILE"""
        
    linker_command = config.CC + " " + config.LDFLAGS.get("birdfont-test", "") + """ \
        build/birdfont-test/*.o \
		-L./build/bin -lbirdfont \
		$(pkg-config --libs sqlite3) \
		$(pkg-config --libs """ + config.GEE + """) \
		$(pkg-config --libs gio-2.0) \
		$(pkg-config --libs cairo) \
		$(pkg-config --libs glib-2.0) \
		$(pkg-config --libs xmlbird) \
		-L./build -L./build/bin -l birdgems\
        -o build/bin/""" + target_binary

    test = Builder('birdfont-test',
                   valac_command, 
                   cc_command,
                   linker_command,
                   target_binary,
                   None,
                   deps)
			
    yield test.build()

def task_birdfont_test():
    yield make_birdfont_test('birdfont-test', ['libbirdgems.so', 'libbirdfont.so'])