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.
Merge ../birdfont-2.x
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 'libsvgbird', 36 'svgbird_vapi', 37 'birdfont', 38 'birdfont-autotrace', 39 'birdfont-export', 40 'birdfont-import', 41 'birdfont-test' 42 ], 43 } 44 45 if "kfreebsd" in sys.platform: 46 LIBBIRDGEMS_SO_VERSION=version.LIBBIRDGEMS_SO_VERSION 47 elif "openbsd" in sys.platform: 48 LIBBIRDGEMS_SO_VERSION='${LIBbirdgems_VERSION}' 49 else: 50 LIBBIRDGEMS_SO_VERSION=version.LIBBIRDGEMS_SO_VERSION 51 52 if "kfreebsd" in sys.platform: 53 LIBSVGBIRD_SO_VERSION=version.LIBSVGBIRD_SO_VERSION 54 elif "openbsd" in sys.platform: 55 LIBSVGBIRD_SO_VERSION='${LIBbirdgems_VERSION}' 56 else: 57 LIBSVGBIRD_SO_VERSION=version.LIBSVGBIRD_SO_VERSION 58 59 if "kfreebsd" in sys.platform: 60 SO_VERSION=version.SO_VERSION 61 elif "openbsd" in sys.platform: 62 SO_VERSION='${LIBbirdfont_VERSION}' 63 else: 64 SO_VERSION=version.SO_VERSION 65 66 def soname(target_binary): 67 if "darwin" in sys.platform or "msys" in sys.platform: 68 return '' 69 70 return '-Wl,-soname,' + target_binary 71 72 def make_birdfont(target_binary, deps): 73 valac_command = config.VALAC + """\ 74 -C \ 75 --vapidir=./ \ 76 --basedir build/birdfont/ \ 77 """ + config.NON_NULL + """ \ 78 """ + config.VALACFLAGS.get("birdfont", "") + """ \ 79 --enable-experimental \ 80 birdfont/*.vala \ 81 --vapidir=./ \ 82 --pkg """ + config.GEE + """ \ 83 --pkg gio-2.0 \ 84 --pkg cairo \ 85 --pkg libsoup-2.4 \ 86 --pkg gdk-pixbuf-2.0 \ 87 --pkg webkit2gtk-4.0 \ 88 --pkg libnotify \ 89 --pkg xmlbird \ 90 --pkg libbirdfont \ 91 --pkg svgbird \ 92 """ 93 94 cc_command = config.CC + " " + config.CFLAGS.get("birdfont", "") + """ \ 95 -c C_SOURCE \ 96 -D 'GETTEXT_PACKAGE="birdfont"' \ 97 -I./build/libbirdfont \ 98 -I./build/libsvgbird \ 99 $(pkg-config --cflags sqlite3) \ 100 $(pkg-config --cflags """ + config.GEE + """) \ 101 $(pkg-config --cflags gio-2.0) \ 102 $(pkg-config --cflags cairo) \ 103 $(pkg-config --cflags glib-2.0) \ 104 $(pkg-config --cflags gdk-pixbuf-2.0) \ 105 $(pkg-config --cflags webkit2gtk-4.0) \ 106 $(pkg-config --cflags libnotify) \ 107 -o OBJECT_FILE""" 108 109 linker_command = config.CC + " " + config.LDFLAGS.get("birdfont", "") + """ \ 110 build/birdfont/*.o \ 111 -L./build/bin -lbirdfont \ 112 $(pkg-config --libs sqlite3) \ 113 $(pkg-config --libs """ + config.GEE + """) \ 114 $(pkg-config --libs gio-2.0) \ 115 $(pkg-config --libs cairo) \ 116 $(pkg-config --libs glib-2.0) \ 117 $(pkg-config --libs gdk-pixbuf-2.0) \ 118 $(pkg-config --libs webkit2gtk-4.0) \ 119 $(pkg-config --libs xmlbird) \ 120 $(pkg-config --libs libnotify) \ 121 -L./build -L./build/bin -l birdgems -l svgbird \ 122 -o build/bin/""" + target_binary 123 124 birdfont = Builder('birdfont', 125 valac_command, 126 cc_command, 127 linker_command, 128 target_binary, 129 None, 130 deps) 131 132 yield birdfont.build() 133 134 def task_birdfont(): 135 yield make_birdfont('birdfont', ['libbirdgems.so', 'libbirdfont.so', 'libsvgbird.so']) 136 137 def make_birdfont_export(target_binary, deps): 138 valac_command = config.VALAC + """ \ 139 -C \ 140 --enable-experimental \ 141 --basedir build/birdfont-export/ \ 142 """ + config.NON_NULL + """ \ 143 """ + config.VALACFLAGS.get("birdfont-export", "") + """ \ 144 birdfont-export/*.vala \ 145 --vapidir=./ \ 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 """ + config.GEE + """ \ 203 --pkg gio-2.0 \ 204 --pkg cairo \ 205 --pkg xmlbird \ 206 --pkg libbirdfont \ 207 --pkg svgbird \ 208 """ 209 210 cc_command = config.CC + " " + config.CFLAGS.get("birdfont-import", "") + """ \ 211 -c C_SOURCE \ 212 -D 'GETTEXT_PACKAGE="birdfont"' \ 213 -I./build/libbirdfont \ 214 -I./build/libsvgbird \ 215 $(pkg-config --cflags sqlite3) \ 216 $(pkg-config --cflags """ + config.GEE + """) \ 217 $(pkg-config --cflags gio-2.0) \ 218 $(pkg-config --cflags cairo) \ 219 $(pkg-config --cflags glib-2.0) \ 220 -o OBJECT_FILE""" 221 222 linker_command = config.CC + " " + config.LDFLAGS.get("birdfont-import", "") + """ \ 223 build/birdfont-import/*.o \ 224 -Lbuild/bin/ -lbirdfont \ 225 -lm \ 226 $(pkg-config --libs sqlite3) \ 227 $(pkg-config --libs """ + config.GEE + """) \ 228 $(pkg-config --libs gio-2.0) \ 229 $(pkg-config --libs cairo) \ 230 $(pkg-config --libs glib-2.0) \ 231 $(pkg-config --libs xmlbird) \ 232 -L./build -L./build/bin -l birdgems -l svgbird \ 233 -o ./build/bin/""" + target_binary 234 235 birdfont_import = Builder('birdfont-import', 236 valac_command, 237 cc_command, 238 linker_command, 239 target_binary, 240 None, 241 deps) 242 243 yield birdfont_import.build() 244 245 def task_birdfont_import(): 246 yield make_birdfont_import('birdfont-import', ['libbirdgems.so', 'libbirdfont.so', 'libsvgbird.so']) 247 248 def make_birdfont_autotrace(target_binary, deps): 249 valac_command = config.VALAC + """\ 250 -C \ 251 --enable-experimental \ 252 --basedir build/birdfont-autotrace/ \ 253 """ + config.NON_NULL + """ \ 254 """ + config.VALACFLAGS.get("birdfont-autotrace", "") + """ \ 255 birdfont-autotrace/*.vala \ 256 --vapidir=./ \ 257 --pkg """ + config.GEE + """ \ 258 --pkg gio-2.0 \ 259 --pkg cairo \ 260 --pkg xmlbird \ 261 --pkg libbirdfont \ 262 --pkg svgbird \ 263 """ 264 265 cc_command = config.CC + " " + config.CFLAGS.get("birdfont-autotrace", "") + """ \ 266 -c C_SOURCE \ 267 -D 'GETTEXT_PACKAGE="birdfont"' \ 268 -I./build/libbirdfont \ 269 -I./build/libsvgbird \ 270 $(pkg-config --cflags sqlite3) \ 271 $(pkg-config --cflags """ + config.GEE + """) \ 272 $(pkg-config --cflags gio-2.0) \ 273 $(pkg-config --cflags cairo) \ 274 $(pkg-config --cflags glib-2.0) \ 275 -o OBJECT_FILE""" 276 277 linker_command = config.CC + " " + config.LDFLAGS.get("birdfont-autotrace", "") + """ \ 278 build/birdfont-autotrace/*.o \ 279 -I./build/libbirdfont \ 280 -I./build/libsvgbird \ 281 -Lbuild/bin/ -lbirdfont \ 282 -lm \ 283 $(pkg-config --libs sqlite3) \ 284 $(pkg-config --libs """ + config.GEE + """) \ 285 $(pkg-config --libs gio-2.0) \ 286 $(pkg-config --libs cairo) \ 287 $(pkg-config --libs glib-2.0) \ 288 $(pkg-config --libs xmlbird) \ 289 -L./build -L./build/bin -l birdgems -l svgbird\ 290 -o ./build/bin/""" + target_binary 291 292 birdfont_autotrace = Builder('birdfont-autotrace', 293 valac_command, 294 cc_command, 295 linker_command, 296 target_binary, 297 None, 298 deps) 299 300 yield birdfont_autotrace.build() 301 302 def task_birdfont_autotrace(): 303 yield make_birdfont_autotrace('birdfont-autotrace', ['libbirdgems.so', 'libbirdfont.so', 'libsvgbird.so']) 304 305 def make_libbirdfont(target_binary, deps): 306 valac_command = config.VALAC + """\ 307 -C \ 308 --vapidir=./ \ 309 --basedir build/libbirdfont/ \ 310 """ + config.NON_NULL + """ \ 311 """ + config.VALACFLAGS.get("libbirdfont", "") + """ \ 312 --enable-experimental \ 313 --library libbirdfont \ 314 -H build/libbirdfont/birdfont.h \ 315 libbirdfont/*.vala \ 316 libbirdfont/OpenFontFormat/*.vala \ 317 libbirdfont/TextRendering/*.vala \ 318 --pkg posix \ 319 --pkg """ + config.GEE + """ \ 320 --pkg gio-2.0 \ 321 --pkg cairo \ 322 --pkg xmlbird \ 323 --pkg libbirdgems \ 324 --pkg svgbird \ 325 --pkg sqlite3 \ 326 --pkg gdk-pixbuf-2.0 \ 327 """ 328 329 cc_command = config.CC + " " + config.CFLAGS.get("libbirdfont", "") + """ \ 330 -c C_SOURCE \ 331 -fPIC \ 332 -D 'GETTEXT_PACKAGE="birdfont"' \ 333 -I ./build/libbirdfont \ 334 -I ./build/libbirdgems \ 335 -I ./build/libsvgbird \ 336 $(pkg-config --cflags sqlite3) \ 337 $(pkg-config --cflags fontconfig) \ 338 $(pkg-config --cflags """ + config.GEE + """) \ 339 $(pkg-config --cflags gio-2.0) \ 340 $(pkg-config --cflags cairo) \ 341 $(pkg-config --cflags glib-2.0) \ 342 $(pkg-config --cflags xmlbird) \ 343 -o OBJECT_FILE""" 344 345 linker_command = config.CC + " " + config.LDFLAGS.get("libbirdfont", "") + """ \ 346 -shared \ 347 """ + soname(target_binary) + """ \ 348 build/libbirdfont/*.o \ 349 $(pkg-config --libs sqlite3) \ 350 $(freetype-config --libs) \ 351 $(pkg-config --libs """ + config.GEE + """) \ 352 $(pkg-config --libs gio-2.0) \ 353 $(pkg-config --libs fontconfig) \ 354 $(pkg-config --libs cairo) \ 355 $(pkg-config --libs glib-2.0) \ 356 $(pkg-config --libs xmlbird) \ 357 -L./build -L./build/bin -l birdgems -l svgbird \ 358 -o ./build/bin/""" + target_binary 359 360 libbirdfont = Builder('libbirdfont', 361 valac_command, 362 cc_command, 363 linker_command, 364 target_binary, 365 'libbirdfont.so', 366 deps) 367 368 yield libbirdfont.build() 369 370 def task_libbirdfont(): 371 yield make_libbirdfont('libbirdfont.so.' + SO_VERSION, ['libbirdgems.so', 'libsvgbird.so']) 372 373 def make_libsvgbird(target_binary, deps): 374 global version 375 376 valac_command = config.VALAC + """\ 377 -C \ 378 --vapidir=./ \ 379 --basedir build/libsvgbird/ \ 380 """ + config.NON_NULL + """ \ 381 """ + config.VALACFLAGS.get("libsvgbird", "") + """ \ 382 --enable-experimental \ 383 --library libsvgbird \ 384 -H build/libsvgbird/svgbird.h \ 385 libsvgbird/*.vala \ 386 --pkg posix \ 387 --pkg svgbirdpoint \ 388 --pkg """ + config.GEE + """ \ 389 --pkg gio-2.0 \ 390 --pkg cairo \ 391 --pkg xmlbird \ 392 --vapi=./svgbird_generated.vapi \ 393 """ 394 395 cc_command = config.CC + " " + config.CFLAGS.get("libsvgbird", "") + """ \ 396 -c C_SOURCE \ 397 -std=c99 \ 398 -fPIC \ 399 -I ./build/libsvgbird \ 400 $(pkg-config --cflags """ + config.GEE + """) \ 401 $(pkg-config --cflags gio-2.0) \ 402 $(pkg-config --cflags cairo) \ 403 $(pkg-config --cflags glib-2.0) \ 404 $(pkg-config --cflags xmlbird) \ 405 $(pkg-config --cflags fontconfig) \ 406 $(pkg-config --cflags harfbuzz) \ 407 $(pkg-config --cflags harfbuzz-icu) \ 408 -o OBJECT_FILE""" 409 410 linker_command = config.CC + " " + config.LDFLAGS.get("libsvgbird", "") + """ \ 411 -shared \ 412 """ + soname(target_binary) + """ \ 413 build/libsvgbird/*.o \ 414 $(pkg-config --libs """ + config.GEE + """) \ 415 $(pkg-config --libs gio-2.0) \ 416 $(pkg-config --libs cairo) \ 417 $(pkg-config --libs glib-2.0) \ 418 $(pkg-config --libs xmlbird) \ 419 $(pkg-config --libs fontconfig) \ 420 $(pkg-config --libs harfbuzz) \ 421 $(pkg-config --libs harfbuzz-icu) \ 422 -L./build -L./build/bin \ 423 -o ./build/bin/""" + target_binary 424 425 link_name = 'libsvgbird.so' 426 source_directory = 'libsvgbird' 427 428 libsvgbird = Builder(source_directory, 429 valac_command, 430 cc_command, 431 linker_command, 432 target_binary, 433 link_name, 434 deps) 435 436 f = open('./build/svgbird.pc', 'w+') 437 f.write("""prefix=""" + config.PREFIX + """ 438 exec_prefix=${prefix} 439 includedir=${prefix}/include 440 libdir=${exec_prefix}/lib 441 442 Name: svgbird 443 Description: SVG library 444 Version: """ + version.LIBSVGBIRD_VERSION + """ 445 Cflags: -I${includedir} 446 Libs: -L${libdir} -lsvgbird 447 Requires: cairo, gobject-2.0, glib-2.0 448 """) 449 450 yield libsvgbird.build() 451 452 453 def task_libsvgbird(): 454 yield make_libsvgbird('libsvgbird.so.' + LIBSVGBIRD_SO_VERSION, []) 455 456 def task_svgbird_vapi(): 457 yield { 458 'name': 'merge svgbird vapi', 459 'file_dep': ['build/libsvgbird/Object.c'], 460 'actions': ['cat svgbirdpoint.vapi > svgbird.vapi && cat svgbird_generated.vapi >> svgbird.vapi'], 461 'targets': ['svgbird vapi'] 462 } 463 def make_libbirdgems(target_binary, deps): 464 valac_command = config.VALAC + """\ 465 -C \ 466 -H build/libbirdgems/birdgems.h \ 467 --pkg posix \ 468 --vapidir=./ \ 469 --basedir=build/libbirdgems/ \ 470 """ + config.NON_NULL + """ \ 471 """ + config.VALACFLAGS.get("libbirdgems", "") + """ \ 472 --enable-experimental \ 473 --library libbirdgems \ 474 libbirdgems/*.vala \ 475 """ 476 477 cc_command = config.CC + " " + config.CFLAGS.get("libbirdgems", "") + """ \ 478 -fPIC \ 479 $(pkg-config --cflags glib-2.0) \ 480 -c C_SOURCE \ 481 -o OBJECT_FILE \ 482 """ 483 484 linker_command = config.CC + " " + config.LDFLAGS.get("libbirdgems", "") + """ \ 485 -shared \ 486 """ + soname(target_binary) + """ \ 487 -fPIC \ 488 build/libbirdgems/*.o \ 489 $(pkg-config --libs glib-2.0) \ 490 $(pkg-config --libs gobject-2.0) \ 491 -o build/bin/""" + target_binary 492 493 libbirdgems = Builder('libbirdgems', 494 valac_command, 495 cc_command, 496 linker_command, 497 target_binary, 498 'libbirdgems.so', 499 deps) 500 501 yield libbirdgems.build() 502 503 def task_libbirdgems(): 504 yield make_libbirdgems('libbirdgems.so.' + LIBBIRDGEMS_SO_VERSION, []) 505 506 def task_compile_translations (): 507 """translate po files""" 508 return { 509 'actions': [compile_translations] 510 } 511 512 def task_man(): 513 """gzip linux man pages""" 514 for name in ("birdfont.1", "birdfont-export.1", 515 "birdfont-import.1", "birdfont-autotrace.1"): 516 yield { 517 'name': name, 518 'file_dep': ['resources/linux/' + name], 519 'targets': ['build/' + name + '.gz'], 520 'actions': ['gzip -9 -c resources/linux/' + name + ' > ' + 'build/' + name + '.gz'], 521 } 522 523 def task_distclean (): 524 return { 525 'actions': ['rm -rf .doit.db build scripts/config.py' 526 + ' libbirdfont/Config.vala' 527 + ' __pycache__ scripts/__pycache__'] 528 } 529 530 def task_build (): 531 if not os.path.exists ("build/configured"): 532 print ("Project is not configured") 533 exit (1) 534 535 subprocess.check_output ('mkdir -p build', shell=True) 536 subprocess.check_output ('touch build/installed', shell=True) 537 538 return { 539 'actions': ['echo "Build"'], 540 } 541 542 def make_birdfont_test(target_binary, deps): 543 valac_command = config.VALAC + """\ 544 -C \ 545 --vapidir=./ \ 546 --basedir build/birdfont-test/ \ 547 """ + config.NON_NULL + """ \ 548 """ + config.VALACFLAGS.get("birdfont-test", "") + """ \ 549 --enable-experimental \ 550 birdfont-test/*.vala \ 551 --vapidir=./ \ 552 --pkg """ + config.GEE + """ \ 553 --pkg gio-2.0 \ 554 --pkg cairo \ 555 --pkg xmlbird \ 556 --pkg libbirdfont \ 557 --pkg svgbird \ 558 """ 559 560 cc_command = config.CC + " " + config.CFLAGS.get("birdfont-test", "") + """ \ 561 -c C_SOURCE \ 562 -D 'GETTEXT_PACKAGE="birdfont"' \ 563 -I./build/libbirdfont \ 564 -I./build/libsvgbird \ 565 $(pkg-config --cflags sqlite3) \ 566 $(pkg-config --cflags """ + config.GEE + """) \ 567 $(pkg-config --cflags gio-2.0) \ 568 $(pkg-config --cflags cairo) \ 569 $(pkg-config --cflags glib-2.0) \ 570 $(pkg-config --cflags xmlbird) \ 571 -o OBJECT_FILE""" 572 573 linker_command = config.CC + " " + config.LDFLAGS.get("birdfont-test", "") + """ \ 574 build/birdfont-test/*.o \ 575 -L./build/bin -lbirdfont \ 576 $(pkg-config --libs sqlite3) \ 577 $(pkg-config --libs """ + config.GEE + """) \ 578 $(pkg-config --libs gio-2.0) \ 579 $(pkg-config --libs cairo) \ 580 $(pkg-config --libs glib-2.0) \ 581 $(pkg-config --libs xmlbird) \ 582 -L./build -L./build/bin -l birdgems -l svgbird \ 583 -o build/bin/""" + target_binary 584 585 test = Builder('birdfont-test', 586 valac_command, 587 cc_command, 588 linker_command, 589 target_binary, 590 None, 591 deps) 592 593 yield test.build() 594 595 def task_birdfont_test(): 596 yield make_birdfont_test('birdfont-test', ['libbirdgems.so', 'libbirdfont.so']) 597 598