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.
SVG boundaries for ellipses
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 """ + config.GEE + """ \ 81 --pkg gio-2.0 \ 82 --pkg cairo \ 83 --pkg libsoup-2.4 \ 84 --pkg gdk-pixbuf-2.0 \ 85 --pkg webkitgtk-3.0 \ 86 --pkg libnotify \ 87 --pkg xmlbird \ 88 --pkg libbirdfont \ 89 --pkg libsvgbird \ 90 """ 91 92 cc_command = config.CC + " " + config.CFLAGS.get("birdfont", "") + """ \ 93 -c C_SOURCE \ 94 -D 'GETTEXT_PACKAGE="birdfont"' \ 95 -I./build/libbirdfont \ 96 -I./build/libsvgbird \ 97 $(pkg-config --cflags sqlite3) \ 98 $(pkg-config --cflags """ + config.GEE + """) \ 99 $(pkg-config --cflags gio-2.0) \ 100 $(pkg-config --cflags cairo) \ 101 $(pkg-config --cflags glib-2.0) \ 102 $(pkg-config --cflags gdk-pixbuf-2.0) \ 103 $(pkg-config --cflags webkitgtk-3.0) \ 104 $(pkg-config --cflags libnotify) \ 105 -o OBJECT_FILE""" 106 107 linker_command = config.CC + " " + config.LDFLAGS.get("birdfont", "") + """ \ 108 build/birdfont/*.o \ 109 -L./build/bin -lbirdfont \ 110 $(pkg-config --libs sqlite3) \ 111 $(pkg-config --libs """ + config.GEE + """) \ 112 $(pkg-config --libs gio-2.0) \ 113 $(pkg-config --libs cairo) \ 114 $(pkg-config --libs glib-2.0) \ 115 $(pkg-config --libs gdk-pixbuf-2.0) \ 116 $(pkg-config --libs webkitgtk-3.0) \ 117 $(pkg-config --libs xmlbird) \ 118 $(pkg-config --libs libnotify) \ 119 -L./build -L./build/bin -l birdgems -l svgbird \ 120 -o build/bin/""" + target_binary 121 122 birdfont = Builder('birdfont', 123 valac_command, 124 cc_command, 125 linker_command, 126 target_binary, 127 None, 128 deps) 129 130 yield birdfont.build() 131 132 def task_birdfont(): 133 yield make_birdfont('birdfont', ['libbirdgems.so', 'libbirdfont.so', 'libsvgbird.so']) 134 135 def make_birdfont_export(target_binary, deps): 136 valac_command = config.VALAC + """ \ 137 -C \ 138 --enable-experimental \ 139 --basedir build/birdfont-export/ \ 140 """ + config.NON_NULL + """ \ 141 """ + config.VALACFLAGS.get("birdfont-export", "") + """ \ 142 birdfont-export/*.vala \ 143 --vapidir=./ \ 144 --pkg """ + config.GEE + """ \ 145 --pkg gio-2.0 \ 146 --pkg cairo \ 147 --pkg xmlbird \ 148 --pkg libsvgbird \ 149 --pkg libbirdfont \ 150 --pkg libsvgbird \ 151 """ 152 153 cc_command = config.CC + " " + config.CFLAGS.get("birdfont-export", "") + """ \ 154 -c C_SOURCE \ 155 -D 'GETTEXT_PACKAGE="birdfont"' \ 156 -I./build/libbirdfont \ 157 -I./build/libsvgbird \ 158 $(pkg-config --cflags sqlite3) \ 159 $(pkg-config --cflags """ + config.GEE + """) \ 160 $(pkg-config --cflags gio-2.0) \ 161 $(pkg-config --cflags cairo) \ 162 $(pkg-config --cflags glib-2.0) \ 163 -o OBJECT_FILE""" 164 165 linker_command = config.CC + " " + config.LDFLAGS.get("birdfont-export", "") + """ \ 166 build/birdfont-export/*.o \ 167 -Lbuild/bin/ -lbirdfont \ 168 -lm \ 169 $(pkg-config --libs sqlite3) \ 170 $(pkg-config --libs """ + config.GEE + """) \ 171 $(pkg-config --libs gio-2.0) \ 172 $(pkg-config --libs cairo) \ 173 $(pkg-config --libs glib-2.0) \ 174 $(pkg-config --libs xmlbird) \ 175 -L./build -L./build/bin -l birdgems -l svgbird \ 176 -o ./build/bin/""" + target_binary 177 178 birdfont_export = Builder('birdfont-export', 179 valac_command, 180 cc_command, 181 linker_command, 182 target_binary, 183 None, 184 deps) 185 186 yield birdfont_export.build() 187 188 def task_birdfont_export(): 189 yield make_birdfont_export('birdfont-export', ['libbirdgems.so', 'libbirdfont.so', 'libsvgbird.so']) 190 191 def make_birdfont_import(target_binary, deps): 192 valac_command = config.VALAC + """\ 193 -C \ 194 --enable-experimental \ 195 --basedir build/birdfont-import/ \ 196 """ + config.NON_NULL + """ \ 197 """ + config.VALACFLAGS.get("birdfont-import", "") + """ \ 198 birdfont-import/*.vala \ 199 --vapidir=./ \ 200 --pkg """ + config.GEE + """ \ 201 --pkg gio-2.0 \ 202 --pkg cairo \ 203 --pkg xmlbird \ 204 --pkg libbirdfont \ 205 --pkg libsvgbird \ 206 """ 207 208 cc_command = config.CC + " " + config.CFLAGS.get("birdfont-import", "") + """ \ 209 -c C_SOURCE \ 210 -D 'GETTEXT_PACKAGE="birdfont"' \ 211 -I./build/libbirdfont \ 212 -I./build/libsvgbird \ 213 $(pkg-config --cflags sqlite3) \ 214 $(pkg-config --cflags """ + config.GEE + """) \ 215 $(pkg-config --cflags gio-2.0) \ 216 $(pkg-config --cflags cairo) \ 217 $(pkg-config --cflags glib-2.0) \ 218 -o OBJECT_FILE""" 219 220 linker_command = config.CC + " " + config.LDFLAGS.get("birdfont-import", "") + """ \ 221 build/birdfont-import/*.o \ 222 -Lbuild/bin/ -lbirdfont \ 223 -lm \ 224 $(pkg-config --libs sqlite3) \ 225 $(pkg-config --libs """ + config.GEE + """) \ 226 $(pkg-config --libs gio-2.0) \ 227 $(pkg-config --libs cairo) \ 228 $(pkg-config --libs glib-2.0) \ 229 $(pkg-config --libs xmlbird) \ 230 -L./build -L./build/bin -l birdgems -l svgbird \ 231 -o ./build/bin/""" + target_binary 232 233 birdfont_import = Builder('birdfont-import', 234 valac_command, 235 cc_command, 236 linker_command, 237 target_binary, 238 None, 239 deps) 240 241 yield birdfont_import.build() 242 243 def task_birdfont_import(): 244 yield make_birdfont_import('birdfont-import', ['libbirdgems.so', 'libbirdfont.so', 'libsvgbird.so']) 245 246 def make_birdfont_autotrace(target_binary, deps): 247 valac_command = config.VALAC + """\ 248 -C \ 249 --enable-experimental \ 250 --basedir build/birdfont-autotrace/ \ 251 """ + config.NON_NULL + """ \ 252 """ + config.VALACFLAGS.get("birdfont-autotrace", "") + """ \ 253 birdfont-autotrace/*.vala \ 254 --vapidir=./ \ 255 --pkg """ + config.GEE + """ \ 256 --pkg gio-2.0 \ 257 --pkg cairo \ 258 --pkg xmlbird \ 259 --pkg libbirdfont \ 260 --pkg libsvgbird \ 261 """ 262 263 cc_command = config.CC + " " + config.CFLAGS.get("birdfont-autotrace", "") + """ \ 264 -c C_SOURCE \ 265 -D 'GETTEXT_PACKAGE="birdfont"' \ 266 -I./build/libbirdfont \ 267 -I./build/libsvgbird \ 268 $(pkg-config --cflags sqlite3) \ 269 $(pkg-config --cflags """ + config.GEE + """) \ 270 $(pkg-config --cflags gio-2.0) \ 271 $(pkg-config --cflags cairo) \ 272 $(pkg-config --cflags glib-2.0) \ 273 -o OBJECT_FILE""" 274 275 linker_command = config.CC + " " + config.LDFLAGS.get("birdfont-autotrace", "") + """ \ 276 build/birdfont-autotrace/*.o \ 277 -I./build/libbirdfont \ 278 -I./build/libsvgbird \ 279 -Lbuild/bin/ -lbirdfont \ 280 -lm \ 281 $(pkg-config --libs sqlite3) \ 282 $(pkg-config --libs """ + config.GEE + """) \ 283 $(pkg-config --libs gio-2.0) \ 284 $(pkg-config --libs cairo) \ 285 $(pkg-config --libs glib-2.0) \ 286 $(pkg-config --libs xmlbird) \ 287 -L./build -L./build/bin -l birdgems -l svgbird\ 288 -o ./build/bin/""" + target_binary 289 290 birdfont_autotrace = Builder('birdfont-autotrace', 291 valac_command, 292 cc_command, 293 linker_command, 294 target_binary, 295 None, 296 deps) 297 298 yield birdfont_autotrace.build() 299 300 def task_birdfont_autotrace(): 301 yield make_birdfont_autotrace('birdfont-autotrace', ['libbirdgems.so', 'libbirdfont.so', 'libsvgbird.so']) 302 303 def make_libbirdfont(target_binary, deps): 304 valac_command = config.VALAC + """\ 305 -C \ 306 --vapidir=./ \ 307 --basedir build/libbirdfont/ \ 308 """ + config.NON_NULL + """ \ 309 """ + config.VALACFLAGS.get("libbirdfont", "") + """ \ 310 --enable-experimental \ 311 --library libbirdfont \ 312 -H build/libbirdfont/birdfont.h \ 313 libbirdfont/*.vala \ 314 libbirdfont/OpenFontFormat/*.vala \ 315 libbirdfont/TextRendering/*.vala \ 316 --pkg posix \ 317 --pkg """ + config.GEE + """ \ 318 --pkg gio-2.0 \ 319 --pkg cairo \ 320 --pkg xmlbird \ 321 --pkg libbirdgems \ 322 --pkg libsvgbird \ 323 --pkg sqlite3 \ 324 --pkg gdk-pixbuf-2.0 \ 325 """ 326 327 cc_command = config.CC + " " + config.CFLAGS.get("libbirdfont", "") + """ \ 328 -c C_SOURCE \ 329 -fPIC \ 330 -D 'GETTEXT_PACKAGE="birdfont"' \ 331 -I ./build/libbirdfont \ 332 -I ./build/libbirdgems \ 333 -I ./build/libsvgbird \ 334 $(pkg-config --cflags sqlite3) \ 335 $(pkg-config --cflags fontconfig) \ 336 $(pkg-config --cflags """ + config.GEE + """) \ 337 $(pkg-config --cflags gio-2.0) \ 338 $(pkg-config --cflags cairo) \ 339 $(pkg-config --cflags glib-2.0) \ 340 $(pkg-config --cflags xmlbird) \ 341 -o OBJECT_FILE""" 342 343 linker_command = config.CC + " " + config.LDFLAGS.get("libbirdfont", "") + """ \ 344 -shared \ 345 """ + soname(target_binary) + """ \ 346 build/libbirdfont/*.o \ 347 $(pkg-config --libs sqlite3) \ 348 $(freetype-config --libs) \ 349 $(pkg-config --libs """ + config.GEE + """) \ 350 $(pkg-config --libs gio-2.0) \ 351 $(pkg-config --libs fontconfig) \ 352 $(pkg-config --libs cairo) \ 353 $(pkg-config --libs glib-2.0) \ 354 $(pkg-config --libs xmlbird) \ 355 -L./build -L./build/bin -l birdgems -l svgbird \ 356 -o ./build/bin/""" + target_binary 357 358 libbirdfont = Builder('libbirdfont', 359 valac_command, 360 cc_command, 361 linker_command, 362 target_binary, 363 'libbirdfont.so', 364 deps) 365 366 yield libbirdfont.build() 367 368 def task_libbirdfont(): 369 yield make_libbirdfont('libbirdfont.so.' + SO_VERSION, ['libbirdgems.so', 'libsvgbird.so']) 370 371 def make_libsvgbird(target_binary, deps): 372 valac_command = config.VALAC + """\ 373 -C \ 374 --vapidir=./ \ 375 --basedir build/libsvgbird/ \ 376 """ + config.NON_NULL + """ \ 377 """ + config.VALACFLAGS.get("libsvgbird", "") + """ \ 378 --enable-experimental \ 379 --library libsvgbird \ 380 -H build/libsvgbird/svgbird.h \ 381 libsvgbird/*.vala \ 382 --pkg posix \ 383 --pkg """ + config.GEE + """ \ 384 --pkg gio-2.0 \ 385 --pkg cairo \ 386 --pkg xmlbird \ 387 """ 388 389 cc_command = config.CC + " " + config.CFLAGS.get("libsvgbird", "") + """ \ 390 -c C_SOURCE \ 391 -fPIC \ 392 -I ./build/libsvgbird \ 393 $(pkg-config --cflags """ + config.GEE + """) \ 394 $(pkg-config --cflags gio-2.0) \ 395 $(pkg-config --cflags cairo) \ 396 $(pkg-config --cflags glib-2.0) \ 397 $(pkg-config --cflags xmlbird) \ 398 -o OBJECT_FILE""" 399 400 linker_command = config.CC + " " + config.LDFLAGS.get("libsvgbird", "") + """ \ 401 -shared \ 402 """ + soname(target_binary) + """ \ 403 build/libsvgbird/*.o \ 404 $(pkg-config --libs """ + config.GEE + """) \ 405 $(pkg-config --libs gio-2.0) \ 406 $(pkg-config --libs cairo) \ 407 $(pkg-config --libs glib-2.0) \ 408 $(pkg-config --libs xmlbird) \ 409 -L./build -L./build/bin \ 410 -o ./build/bin/""" + target_binary 411 412 link_name = 'libsvgbird.so' 413 source_directory = 'libsvgbird' 414 415 libsvgbird = Builder(source_directory, 416 valac_command, 417 cc_command, 418 linker_command, 419 target_binary, 420 link_name, 421 deps) 422 423 yield libsvgbird.build() 424 425 def task_libsvgbird(): 426 yield make_libsvgbird('libsvgbird.so.' + LIBSVGBIRD_SO_VERSION, []) 427 428 def make_libbirdgems(target_binary, deps): 429 valac_command = config.VALAC + """\ 430 -C \ 431 -H build/libbirdgems/birdgems.h \ 432 --pkg posix \ 433 --vapidir=./ \ 434 --basedir=build/libbirdgems/ \ 435 """ + config.NON_NULL + """ \ 436 """ + config.VALACFLAGS.get("libbirdgems", "") + """ \ 437 --enable-experimental \ 438 --library libbirdgems \ 439 libbirdgems/*.vala \ 440 """ 441 442 cc_command = config.CC + " " + config.CFLAGS.get("libbirdgems", "") + """ \ 443 -fPIC \ 444 $(pkg-config --cflags glib-2.0) \ 445 -c C_SOURCE \ 446 -o OBJECT_FILE \ 447 """ 448 449 linker_command = config.CC + " " + config.LDFLAGS.get("libbirdgems", "") + """ \ 450 -shared \ 451 """ + soname(target_binary) + """ \ 452 -fPIC \ 453 build/libbirdgems/*.o \ 454 $(pkg-config --libs glib-2.0) \ 455 $(pkg-config --libs gobject-2.0) \ 456 -o build/bin/""" + target_binary 457 458 libbirdgems = Builder('libbirdgems', 459 valac_command, 460 cc_command, 461 linker_command, 462 target_binary, 463 'libbirdgems.so', 464 deps) 465 466 yield libbirdgems.build() 467 468 def task_libbirdgems(): 469 yield make_libbirdgems('libbirdgems.so.' + LIBBIRDGEMS_SO_VERSION, []) 470 471 def task_compile_translations (): 472 """translate po files""" 473 return { 474 'actions': [compile_translations] 475 } 476 477 def task_man(): 478 """gzip linux man pages""" 479 for name in ("birdfont.1", "birdfont-export.1", 480 "birdfont-import.1", "birdfont-autotrace.1"): 481 yield { 482 'name': name, 483 'file_dep': ['resources/linux/' + name], 484 'targets': ['build/' + name + '.gz'], 485 'actions': ['gzip -9 -c resources/linux/' + name + ' > ' + 'build/' + name + '.gz'], 486 } 487 488 def task_distclean (): 489 return { 490 'actions': ['rm -rf .doit.db build scripts/config.py' 491 + ' libbirdfont/Config.vala' 492 + ' __pycache__ scripts/__pycache__'] 493 } 494 495 def task_build (): 496 if not os.path.exists ("build/configured"): 497 print ("Project is not configured") 498 exit (1) 499 500 subprocess.check_output ('mkdir -p build', shell=True) 501 subprocess.check_output ('touch build/installed', shell=True) 502 503 return { 504 'actions': ['echo "Build"'], 505 } 506 507 def make_birdfont_test(target_binary, deps): 508 valac_command = config.VALAC + """\ 509 -C \ 510 --vapidir=./ \ 511 --basedir build/birdfont-test/ \ 512 """ + config.NON_NULL + """ \ 513 """ + config.VALACFLAGS.get("birdfont-test", "") + """ \ 514 --enable-experimental \ 515 birdfont-test/*.vala \ 516 --vapidir=./ \ 517 --pkg """ + config.GEE + """ \ 518 --pkg gio-2.0 \ 519 --pkg cairo \ 520 --pkg xmlbird \ 521 --pkg libbirdfont \ 522 --pkg libsvgbird \ 523 """ 524 525 cc_command = config.CC + " " + config.CFLAGS.get("birdfont-test", "") + """ \ 526 -c C_SOURCE \ 527 -D 'GETTEXT_PACKAGE="birdfont"' \ 528 -I./build/libbirdfont \ 529 -I./build/libsvgbird \ 530 $(pkg-config --cflags sqlite3) \ 531 $(pkg-config --cflags """ + config.GEE + """) \ 532 $(pkg-config --cflags gio-2.0) \ 533 $(pkg-config --cflags cairo) \ 534 $(pkg-config --cflags glib-2.0) \ 535 -o OBJECT_FILE""" 536 537 linker_command = config.CC + " " + config.LDFLAGS.get("birdfont-test", "") + """ \ 538 build/birdfont-test/*.o \ 539 -L./build/bin -lbirdfont \ 540 $(pkg-config --libs sqlite3) \ 541 $(pkg-config --libs """ + config.GEE + """) \ 542 $(pkg-config --libs gio-2.0) \ 543 $(pkg-config --libs cairo) \ 544 $(pkg-config --libs glib-2.0) \ 545 $(pkg-config --libs xmlbird) \ 546 -L./build -L./build/bin -l birdgems -l svgbird\ 547 -o build/bin/""" + target_binary 548 549 test = Builder('birdfont-test', 550 valac_command, 551 cc_command, 552 linker_command, 553 target_binary, 554 None, 555 deps) 556 557 yield test.build() 558 559 def task_birdfont_test(): 560 yield make_birdfont_test('birdfont-test', ['libbirdgems.so', 'libbirdfont.so']) 561 562 def make_birdui(target_binary, deps): 563 valac_command = config.VALAC + """\ 564 -C \ 565 --pkg posix \ 566 --pkg """ + config.GEE + """ \ 567 --pkg gtk+-3.0 \ 568 --pkg libsvgbird \ 569 --pkg xmlbird \ 570 --vapidir=./ \ 571 --basedir=build/birdui/ \ 572 """ + config.NON_NULL + """ \ 573 --enable-experimental \ 574 birdui/*.vala \ 575 """ 576 577 cc_command = config.CC + """ \ 578 -fPIC \ 579 $(pkg-config --cflags gtk+-3.0) \ 580 $(pkg-config --cflags glib-2.0) \ 581 $(pkg-config --cflags xmlbird) \ 582 $(pkg-config --cflags """ + config.GEE + """) \ 583 -g \ 584 -I ./build/libsvgbird \ 585 -c C_SOURCE \ 586 -o OBJECT_FILE \ 587 """ 588 589 linker_command = config.CC + """ \ 590 """ + soname(target_binary) + """ \ 591 -fPIC \ 592 -g \ 593 build/birdui/*.o \ 594 $(pkg-config --libs gtk+-3.0) \ 595 $(pkg-config --libs glib-2.0) \ 596 $(pkg-config --libs gobject-2.0) \ 597 $(pkg-config --libs xmlbird) \ 598 $(pkg-config --libs """ + config.GEE + """) \ 599 -L ./build/bin -l m -l svgbird \ 600 -o build/bin/""" + target_binary 601 602 libbirdgems = Builder('birdui', 603 valac_command, 604 cc_command, 605 linker_command, 606 target_binary, 607 None, 608 deps) 609 610 yield libbirdgems.build() 611 612 def task_birdui(): 613 yield make_birdui('birdui', []) 614