The Birdfont Source Code


All Repositories / birdfont.git / blob – RSS feed

dodo.py

This file is a part of the Birdfont project.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git

Revisions

View the latest version of dodo.py.
Remove old SVG parser code
1 """ 2 Copyright (C) 2012 - 2016 Eduardo Naufel Schettino and Johan Mattsson 3 4 This program is free software: you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation, either version 3 of the License, or 7 (at your option) any later version. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License 15 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 """ 17 18 import os 19 import glob 20 import subprocess 21 import sys 22 23 from scripts import version 24 from scripts.translations import compile_translations 25 from scripts import config 26 from scripts.builder import Builder 27 28 DOIT_CONFIG = { 29 'default_tasks': [ 30 'build', 31 'compile_translations', 32 'man', 33 'libbirdfont', 34 'libbirdgems', 35 'birdfont', 36 'birdfont-autotrace', 37 'birdfont-export', 38 'birdfont-import', 39 'birdfont-test' 40 ], 41 } 42 43 if "kfreebsd" in sys.platform: 44 LIBBIRDGEMS_SO_VERSION=version.LIBBIRDGEMS_SO_VERSION 45 elif "openbsd" in sys.platform: 46 LIBBIRDGEMS_SO_VERSION='${LIBbirdgems_VERSION}' 47 else: 48 LIBBIRDGEMS_SO_VERSION=version.LIBBIRDGEMS_SO_VERSION 49 50 if "kfreebsd" in sys.platform: 51 LIBSVGBIRD_SO_VERSION=version.LIBSVGBIRD_SO_VERSION 52 elif "openbsd" in sys.platform: 53 LIBSVGBIRD_SO_VERSION='${LIBbirdgems_VERSION}' 54 else: 55 LIBSVGBIRD_SO_VERSION=version.LIBSVGBIRD_SO_VERSION 56 57 if "kfreebsd" in sys.platform: 58 SO_VERSION=version.SO_VERSION 59 elif "openbsd" in sys.platform: 60 SO_VERSION='${LIBbirdfont_VERSION}' 61 else: 62 SO_VERSION=version.SO_VERSION 63 64 def soname(target_binary): 65 if "darwin" in sys.platform or "msys" in sys.platform: 66 return '' 67 68 return '-Wl,-soname,' + target_binary 69 70 def make_birdfont(target_binary, deps): 71 valac_command = config.VALAC + """\ 72 -C \ 73 --vapidir=./ \ 74 --basedir build/birdfont/ \ 75 """ + config.NON_NULL + """ \ 76 """ + config.VALACFLAGS.get("birdfont", "") + """ \ 77 --enable-experimental \ 78 birdfont/*.vala \ 79 --vapidir=./ \ 80 --pkg svgbirdpoint \ 81 --pkg """ + config.GEE + """ \ 82 --pkg gio-2.0 \ 83 --pkg cairo \ 84 --pkg libsoup-2.4 \ 85 --pkg gdk-pixbuf-2.0 \ 86 --pkg webkit2gtk-3.0 \ 87 --pkg libnotify \ 88 --pkg xmlbird \ 89 --pkg libbirdfont \ 90 --pkg svgbird \ 91 """ 92 93 cc_command = config.CC + " " + config.CFLAGS.get("birdfont", "") + """ \ 94 -c C_SOURCE \ 95 -D 'GETTEXT_PACKAGE="birdfont"' \ 96 -I./build/libbirdfont \ 97 -I./build/libsvgbird \ 98 $(pkg-config --cflags sqlite3) \ 99 $(pkg-config --cflags """ + config.GEE + """) \ 100 $(pkg-config --cflags gio-2.0) \ 101 $(pkg-config --cflags cairo) \ 102 $(pkg-config --cflags glib-2.0) \ 103 $(pkg-config --cflags gdk-pixbuf-2.0) \ 104 $(pkg-config --cflags webkit2gtk-3.0) \ 105 $(pkg-config --cflags libnotify) \ 106 -o OBJECT_FILE""" 107 108 linker_command = config.CC + " " + config.LDFLAGS.get("birdfont", "") + """ \ 109 build/birdfont/*.o \ 110 -L./build/bin -lbirdfont \ 111 $(pkg-config --libs sqlite3) \ 112 $(pkg-config --libs """ + config.GEE + """) \ 113 $(pkg-config --libs gio-2.0) \ 114 $(pkg-config --libs cairo) \ 115 $(pkg-config --libs glib-2.0) \ 116 $(pkg-config --libs gdk-pixbuf-2.0) \ 117 $(pkg-config --libs webkit2gtk-3.0) \ 118 $(pkg-config --libs xmlbird) \ 119 $(pkg-config --libs libnotify) \ 120 -L./build -L./build/bin -l birdgems -l svgbird \ 121 -o build/bin/""" + target_binary 122 123 birdfont = Builder('birdfont', 124 valac_command, 125 cc_command, 126 linker_command, 127 target_binary, 128 None, 129 deps) 130 131 yield birdfont.build() 132 133 def task_birdfont(): 134 yield make_birdfont('birdfont', ['libbirdgems.so', 'libbirdfont.so', 'libsvgbird.so']) 135 136 def make_birdfont_export(target_binary, deps): 137 valac_command = config.VALAC + """ \ 138 -C \ 139 --enable-experimental \ 140 --basedir build/birdfont-export/ \ 141 """ + config.NON_NULL + """ \ 142 """ + config.VALACFLAGS.get("birdfont-export", "") + """ \ 143 birdfont-export/*.vala \ 144 --vapidir=./ \ 145 --pkg svgbirdpoint \ 146 --pkg """ + config.GEE + """ \ 147 --pkg gio-2.0 \ 148 --pkg cairo \ 149 --pkg xmlbird \ 150 --pkg svgbird \ 151 --pkg libbirdfont \ 152 --pkg svgbird \ 153 """ 154 155 cc_command = config.CC + " " + config.CFLAGS.get("birdfont-export", "") + """ \ 156 -c C_SOURCE \ 157 -D 'GETTEXT_PACKAGE="birdfont"' \ 158 -I./build/libbirdfont \ 159 -I./build/libsvgbird \ 160 $(pkg-config --cflags sqlite3) \ 161 $(pkg-config --cflags """ + config.GEE + """) \ 162 $(pkg-config --cflags gio-2.0) \ 163 $(pkg-config --cflags cairo) \ 164 $(pkg-config --cflags glib-2.0) \ 165 -o OBJECT_FILE""" 166 167 linker_command = config.CC + " " + config.LDFLAGS.get("birdfont-export", "") + """ \ 168 build/birdfont-export/*.o \ 169 -Lbuild/bin/ -lbirdfont \ 170 -lm \ 171 $(pkg-config --libs sqlite3) \ 172 $(pkg-config --libs """ + config.GEE + """) \ 173 $(pkg-config --libs gio-2.0) \ 174 $(pkg-config --libs cairo) \ 175 $(pkg-config --libs glib-2.0) \ 176 $(pkg-config --libs xmlbird) \ 177 -L./build -L./build/bin -l birdgems -l svgbird \ 178 -o ./build/bin/""" + target_binary 179 180 birdfont_export = Builder('birdfont-export', 181 valac_command, 182 cc_command, 183 linker_command, 184 target_binary, 185 None, 186 deps) 187 188 yield birdfont_export.build() 189 190 def task_birdfont_export(): 191 yield make_birdfont_export('birdfont-export', ['libbirdgems.so', 'libbirdfont.so', 'libsvgbird.so']) 192 193 def make_birdfont_import(target_binary, deps): 194 valac_command = config.VALAC + """\ 195 -C \ 196 --enable-experimental \ 197 --basedir build/birdfont-import/ \ 198 """ + config.NON_NULL + """ \ 199 """ + config.VALACFLAGS.get("birdfont-import", "") + """ \ 200 birdfont-import/*.vala \ 201 --vapidir=./ \ 202 --pkg svgbirdpoint \ 203 --pkg """ + config.GEE + """ \ 204 --pkg gio-2.0 \ 205 --pkg cairo \ 206 --pkg xmlbird \ 207 --pkg libbirdfont \ 208 --pkg svgbird \ 209 """ 210 211 cc_command = config.CC + " " + config.CFLAGS.get("birdfont-import", "") + """ \ 212 -c C_SOURCE \ 213 -D 'GETTEXT_PACKAGE="birdfont"' \ 214 -I./build/libbirdfont \ 215 -I./build/libsvgbird \ 216 $(pkg-config --cflags sqlite3) \ 217 $(pkg-config --cflags """ + config.GEE + """) \ 218 $(pkg-config --cflags gio-2.0) \ 219 $(pkg-config --cflags cairo) \ 220 $(pkg-config --cflags glib-2.0) \ 221 -o OBJECT_FILE""" 222 223 linker_command = config.CC + " " + config.LDFLAGS.get("birdfont-import", "") + """ \ 224 build/birdfont-import/*.o \ 225 -Lbuild/bin/ -lbirdfont \ 226 -lm \ 227 $(pkg-config --libs sqlite3) \ 228 $(pkg-config --libs """ + config.GEE + """) \ 229 $(pkg-config --libs gio-2.0) \ 230 $(pkg-config --libs cairo) \ 231 $(pkg-config --libs glib-2.0) \ 232 $(pkg-config --libs xmlbird) \ 233 -L./build -L./build/bin -l birdgems -l svgbird \ 234 -o ./build/bin/""" + target_binary 235 236 birdfont_import = Builder('birdfont-import', 237 valac_command, 238 cc_command, 239 linker_command, 240 target_binary, 241 None, 242 deps) 243 244 yield birdfont_import.build() 245 246 def task_birdfont_import(): 247 yield make_birdfont_import('birdfont-import', ['libbirdgems.so', 'libbirdfont.so', 'libsvgbird.so']) 248 249 def make_birdfont_autotrace(target_binary, deps): 250 valac_command = config.VALAC + """\ 251 -C \ 252 --enable-experimental \ 253 --basedir build/birdfont-autotrace/ \ 254 """ + config.NON_NULL + """ \ 255 """ + config.VALACFLAGS.get("birdfont-autotrace", "") + """ \ 256 birdfont-autotrace/*.vala \ 257 --vapidir=./ \ 258 --pkg svgbirdpoint \ 259 --pkg """ + config.GEE + """ \ 260 --pkg gio-2.0 \ 261 --pkg cairo \ 262 --pkg xmlbird \ 263 --pkg libbirdfont \ 264 --pkg svgbird \ 265 """ 266 267 cc_command = config.CC + " " + config.CFLAGS.get("birdfont-autotrace", "") + """ \ 268 -c C_SOURCE \ 269 -D 'GETTEXT_PACKAGE="birdfont"' \ 270 -I./build/libbirdfont \ 271 -I./build/libsvgbird \ 272 $(pkg-config --cflags sqlite3) \ 273 $(pkg-config --cflags """ + config.GEE + """) \ 274 $(pkg-config --cflags gio-2.0) \ 275 $(pkg-config --cflags cairo) \ 276 $(pkg-config --cflags glib-2.0) \ 277 -o OBJECT_FILE""" 278 279 linker_command = config.CC + " " + config.LDFLAGS.get("birdfont-autotrace", "") + """ \ 280 build/birdfont-autotrace/*.o \ 281 -I./build/libbirdfont \ 282 -I./build/libsvgbird \ 283 -Lbuild/bin/ -lbirdfont \ 284 -lm \ 285 $(pkg-config --libs sqlite3) \ 286 $(pkg-config --libs """ + config.GEE + """) \ 287 $(pkg-config --libs gio-2.0) \ 288 $(pkg-config --libs cairo) \ 289 $(pkg-config --libs glib-2.0) \ 290 $(pkg-config --libs xmlbird) \ 291 -L./build -L./build/bin -l birdgems -l svgbird\ 292 -o ./build/bin/""" + target_binary 293 294 birdfont_autotrace = Builder('birdfont-autotrace', 295 valac_command, 296 cc_command, 297 linker_command, 298 target_binary, 299 None, 300 deps) 301 302 yield birdfont_autotrace.build() 303 304 def task_birdfont_autotrace(): 305 yield make_birdfont_autotrace('birdfont-autotrace', ['libbirdgems.so', 'libbirdfont.so', 'libsvgbird.so']) 306 307 def make_libbirdfont(target_binary, deps): 308 valac_command = config.VALAC + """\ 309 -C \ 310 --vapidir=./ \ 311 --basedir build/libbirdfont/ \ 312 """ + config.NON_NULL + """ \ 313 """ + config.VALACFLAGS.get("libbirdfont", "") + """ \ 314 --enable-experimental \ 315 --library libbirdfont \ 316 -H build/libbirdfont/birdfont.h \ 317 libbirdfont/*.vala \ 318 libbirdfont/OpenFontFormat/*.vala \ 319 libbirdfont/TextRendering/*.vala \ 320 --pkg posix \ 321 --pkg svgbirdpoint \ 322 --pkg """ + config.GEE + """ \ 323 --pkg gio-2.0 \ 324 --pkg cairo \ 325 --pkg xmlbird \ 326 --pkg libbirdgems \ 327 --pkg svgbird \ 328 --pkg sqlite3 \ 329 --pkg gdk-pixbuf-2.0 \ 330 """ 331 332 cc_command = config.CC + " " + config.CFLAGS.get("libbirdfont", "") + """ \ 333 -c C_SOURCE \ 334 -fPIC \ 335 -D 'GETTEXT_PACKAGE="birdfont"' \ 336 -I ./build/libbirdfont \ 337 -I ./build/libbirdgems \ 338 -I ./build/libsvgbird \ 339 $(pkg-config --cflags sqlite3) \ 340 $(pkg-config --cflags fontconfig) \ 341 $(pkg-config --cflags """ + config.GEE + """) \ 342 $(pkg-config --cflags gio-2.0) \ 343 $(pkg-config --cflags cairo) \ 344 $(pkg-config --cflags glib-2.0) \ 345 $(pkg-config --cflags xmlbird) \ 346 -o OBJECT_FILE""" 347 348 linker_command = config.CC + " " + config.LDFLAGS.get("libbirdfont", "") + """ \ 349 -shared \ 350 """ + soname(target_binary) + """ \ 351 build/libbirdfont/*.o \ 352 $(pkg-config --libs sqlite3) \ 353 $(freetype-config --libs) \ 354 $(pkg-config --libs """ + config.GEE + """) \ 355 $(pkg-config --libs gio-2.0) \ 356 $(pkg-config --libs fontconfig) \ 357 $(pkg-config --libs cairo) \ 358 $(pkg-config --libs glib-2.0) \ 359 $(pkg-config --libs xmlbird) \ 360 -L./build -L./build/bin -l birdgems -l svgbird \ 361 -o ./build/bin/""" + target_binary 362 363 libbirdfont = Builder('libbirdfont', 364 valac_command, 365 cc_command, 366 linker_command, 367 target_binary, 368 'libbirdfont.so', 369 deps) 370 371 yield libbirdfont.build() 372 373 def task_libbirdfont(): 374 yield make_libbirdfont('libbirdfont.so.' + SO_VERSION, ['libbirdgems.so', 'libsvgbird.so']) 375 376 def make_libsvgbird(target_binary, deps): 377 global version 378 379 valac_command = config.VALAC + """\ 380 -C \ 381 --vapidir=./ \ 382 --basedir build/libsvgbird/ \ 383 """ + config.NON_NULL + """ \ 384 """ + config.VALACFLAGS.get("libsvgbird", "") + """ \ 385 --enable-experimental \ 386 --library libsvgbird \ 387 -H build/libsvgbird/svgbird.h \ 388 libsvgbird/*.vala \ 389 --pkg posix \ 390 --pkg svgbirdpoint \ 391 --pkg """ + config.GEE + """ \ 392 --pkg gio-2.0 \ 393 --pkg cairo \ 394 --pkg xmlbird \ 395 --vapi=./svgbird.vapi \ 396 """ 397 398 cc_command = config.CC + " " + config.CFLAGS.get("libsvgbird", "") + """ \ 399 -c C_SOURCE \ 400 -fPIC \ 401 -I ./build/libsvgbird \ 402 $(pkg-config --cflags """ + config.GEE + """) \ 403 $(pkg-config --cflags gio-2.0) \ 404 $(pkg-config --cflags cairo) \ 405 $(pkg-config --cflags glib-2.0) \ 406 $(pkg-config --cflags xmlbird) \ 407 -o OBJECT_FILE""" 408 409 linker_command = config.CC + " " + config.LDFLAGS.get("libsvgbird", "") + """ \ 410 -shared \ 411 """ + soname(target_binary) + """ \ 412 build/libsvgbird/*.o \ 413 $(pkg-config --libs """ + config.GEE + """) \ 414 $(pkg-config --libs gio-2.0) \ 415 $(pkg-config --libs cairo) \ 416 $(pkg-config --libs glib-2.0) \ 417 $(pkg-config --libs xmlbird) \ 418 -L./build -L./build/bin \ 419 -o ./build/bin/""" + target_binary 420 421 link_name = 'libsvgbird.so' 422 source_directory = 'libsvgbird' 423 424 libsvgbird = Builder(source_directory, 425 valac_command, 426 cc_command, 427 linker_command, 428 target_binary, 429 link_name, 430 deps) 431 432 f = open('./build/svgbird.pc', 'w+') 433 f.write("""prefix=""" + config.PREFIX + """ 434 exec_prefix=${prefix} 435 includedir=${prefix}/include 436 libdir=${exec_prefix}/lib 437 438 Name: svgbird 439 Description: SVG library 440 Version: """ + version.LIBSVGBIRD_VERSION + """ 441 Cflags: -I${includedir} 442 Libs: -L${libdir} -lsvgbird 443 Requires: cairo, gobject-2.0, glib-2.0 444 """) 445 446 yield libsvgbird.build() 447 448 449 def task_libsvgbird(): 450 yield make_libsvgbird('libsvgbird.so.' + LIBSVGBIRD_SO_VERSION, []) 451 452 def make_libbirdgems(target_binary, deps): 453 valac_command = config.VALAC + """\ 454 -C \ 455 -H build/libbirdgems/birdgems.h \ 456 --pkg posix \ 457 --vapidir=./ \ 458 --basedir=build/libbirdgems/ \ 459 """ + config.NON_NULL + """ \ 460 """ + config.VALACFLAGS.get("libbirdgems", "") + """ \ 461 --enable-experimental \ 462 --library libbirdgems \ 463 libbirdgems/*.vala \ 464 """ 465 466 cc_command = config.CC + " " + config.CFLAGS.get("libbirdgems", "") + """ \ 467 -fPIC \ 468 $(pkg-config --cflags glib-2.0) \ 469 -c C_SOURCE \ 470 -o OBJECT_FILE \ 471 """ 472 473 linker_command = config.CC + " " + config.LDFLAGS.get("libbirdgems", "") + """ \ 474 -shared \ 475 """ + soname(target_binary) + """ \ 476 -fPIC \ 477 build/libbirdgems/*.o \ 478 $(pkg-config --libs glib-2.0) \ 479 $(pkg-config --libs gobject-2.0) \ 480 -o build/bin/""" + target_binary 481 482 libbirdgems = Builder('libbirdgems', 483 valac_command, 484 cc_command, 485 linker_command, 486 target_binary, 487 'libbirdgems.so', 488 deps) 489 490 yield libbirdgems.build() 491 492 def task_libbirdgems(): 493 yield make_libbirdgems('libbirdgems.so.' + LIBBIRDGEMS_SO_VERSION, []) 494 495 def task_compile_translations (): 496 """translate po files""" 497 return { 498 'actions': [compile_translations] 499 } 500 501 def task_man(): 502 """gzip linux man pages""" 503 for name in ("birdfont.1", "birdfont-export.1", 504 "birdfont-import.1", "birdfont-autotrace.1"): 505 yield { 506 'name': name, 507 'file_dep': ['resources/linux/' + name], 508 'targets': ['build/' + name + '.gz'], 509 'actions': ['gzip -9 -c resources/linux/' + name + ' > ' + 'build/' + name + '.gz'], 510 } 511 512 def task_distclean (): 513 return { 514 'actions': ['rm -rf .doit.db build scripts/config.py' 515 + ' libbirdfont/Config.vala' 516 + ' __pycache__ scripts/__pycache__'] 517 } 518 519 def task_build (): 520 if not os.path.exists ("build/configured"): 521 print ("Project is not configured") 522 exit (1) 523 524 subprocess.check_output ('mkdir -p build', shell=True) 525 subprocess.check_output ('touch build/installed', shell=True) 526 527 return { 528 'actions': ['echo "Build"'], 529 } 530 531 def make_birdfont_test(target_binary, deps): 532 valac_command = config.VALAC + """\ 533 -C \ 534 --vapidir=./ \ 535 --basedir build/birdfont-test/ \ 536 """ + config.NON_NULL + """ \ 537 """ + config.VALACFLAGS.get("birdfont-test", "") + """ \ 538 --enable-experimental \ 539 birdfont-test/*.vala \ 540 --vapidir=./ \ 541 --pkg svgbirdpoint \ 542 --pkg """ + config.GEE + """ \ 543 --pkg gio-2.0 \ 544 --pkg cairo \ 545 --pkg xmlbird \ 546 --pkg libbirdfont \ 547 --pkg svgbird \ 548 """ 549 550 cc_command = config.CC + " " + config.CFLAGS.get("birdfont-test", "") + """ \ 551 -c C_SOURCE \ 552 -D 'GETTEXT_PACKAGE="birdfont"' \ 553 -I./build/libbirdfont \ 554 -I./build/libsvgbird \ 555 $(pkg-config --cflags sqlite3) \ 556 $(pkg-config --cflags """ + config.GEE + """) \ 557 $(pkg-config --cflags gio-2.0) \ 558 $(pkg-config --cflags cairo) \ 559 $(pkg-config --cflags glib-2.0) \ 560 -o OBJECT_FILE""" 561 562 linker_command = config.CC + " " + config.LDFLAGS.get("birdfont-test", "") + """ \ 563 build/birdfont-test/*.o \ 564 -L./build/bin -lbirdfont \ 565 $(pkg-config --libs sqlite3) \ 566 $(pkg-config --libs """ + config.GEE + """) \ 567 $(pkg-config --libs gio-2.0) \ 568 $(pkg-config --libs cairo) \ 569 $(pkg-config --libs glib-2.0) \ 570 $(pkg-config --libs xmlbird) \ 571 -L./build -L./build/bin -l birdgems -l svgbird \ 572 -o build/bin/""" + target_binary 573 574 test = Builder('birdfont-test', 575 valac_command, 576 cc_command, 577 linker_command, 578 target_binary, 579 None, 580 deps) 581 582 yield test.build() 583 584 def task_birdfont_test(): 585 yield make_birdfont_test('birdfont-test', ['libbirdgems.so', 'libbirdfont.so']) 586 587