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.
Fix compile error
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 webkit2gtk-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 webkit2gtk-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 webkit2gtk-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 global version 373 374 valac_command = config.VALAC + """\ 375 -C \ 376 --vapidir=./ \ 377 --basedir build/libsvgbird/ \ 378 """ + config.NON_NULL + """ \ 379 """ + config.VALACFLAGS.get("libsvgbird", "") + """ \ 380 --enable-experimental \ 381 --library libsvgbird \ 382 -H build/libsvgbird/svgbird.h \ 383 libsvgbird/*.vala \ 384 --pkg posix \ 385 --pkg """ + config.GEE + """ \ 386 --pkg gio-2.0 \ 387 --pkg cairo \ 388 --pkg xmlbird \ 389 --vapi=./svgbird.vapi \ 390 """ 391 392 cc_command = config.CC + " " + config.CFLAGS.get("libsvgbird", "") + """ \ 393 -c C_SOURCE \ 394 -fPIC \ 395 -I ./build/libsvgbird \ 396 $(pkg-config --cflags """ + config.GEE + """) \ 397 $(pkg-config --cflags gio-2.0) \ 398 $(pkg-config --cflags cairo) \ 399 $(pkg-config --cflags glib-2.0) \ 400 $(pkg-config --cflags xmlbird) \ 401 -o OBJECT_FILE""" 402 403 linker_command = config.CC + " " + config.LDFLAGS.get("libsvgbird", "") + """ \ 404 -shared \ 405 """ + soname(target_binary) + """ \ 406 build/libsvgbird/*.o \ 407 $(pkg-config --libs """ + config.GEE + """) \ 408 $(pkg-config --libs gio-2.0) \ 409 $(pkg-config --libs cairo) \ 410 $(pkg-config --libs glib-2.0) \ 411 $(pkg-config --libs xmlbird) \ 412 -L./build -L./build/bin \ 413 -o ./build/bin/""" + target_binary 414 415 link_name = 'libsvgbird.so' 416 source_directory = 'libsvgbird' 417 418 libsvgbird = Builder(source_directory, 419 valac_command, 420 cc_command, 421 linker_command, 422 target_binary, 423 link_name, 424 deps) 425 426 f = open('./build/svgbird.pc', 'w+') 427 f.write("""prefix=""" + config.PREFIX + """ 428 exec_prefix=${prefix} 429 includedir=${prefix}/include 430 libdir=${exec_prefix}/lib 431 432 Name: svgbird 433 Description: SVG library 434 Version: """ + version.LIBSVGBIRD_VERSION + """ 435 Cflags: -I${includedir} 436 Libs: -L${libdir} -lsvgbird 437 Requires: cairo, gobject-2.0, glib-2.0 438 """) 439 440 yield libsvgbird.build() 441 442 443 def task_libsvgbird(): 444 yield make_libsvgbird('libsvgbird.so.' + LIBSVGBIRD_SO_VERSION, []) 445 446 def make_libbirdgems(target_binary, deps): 447 valac_command = config.VALAC + """\ 448 -C \ 449 -H build/libbirdgems/birdgems.h \ 450 --pkg posix \ 451 --vapidir=./ \ 452 --basedir=build/libbirdgems/ \ 453 """ + config.NON_NULL + """ \ 454 """ + config.VALACFLAGS.get("libbirdgems", "") + """ \ 455 --enable-experimental \ 456 --library libbirdgems \ 457 libbirdgems/*.vala \ 458 """ 459 460 cc_command = config.CC + " " + config.CFLAGS.get("libbirdgems", "") + """ \ 461 -fPIC \ 462 $(pkg-config --cflags glib-2.0) \ 463 -c C_SOURCE \ 464 -o OBJECT_FILE \ 465 """ 466 467 linker_command = config.CC + " " + config.LDFLAGS.get("libbirdgems", "") + """ \ 468 -shared \ 469 """ + soname(target_binary) + """ \ 470 -fPIC \ 471 build/libbirdgems/*.o \ 472 $(pkg-config --libs glib-2.0) \ 473 $(pkg-config --libs gobject-2.0) \ 474 -o build/bin/""" + target_binary 475 476 libbirdgems = Builder('libbirdgems', 477 valac_command, 478 cc_command, 479 linker_command, 480 target_binary, 481 'libbirdgems.so', 482 deps) 483 484 yield libbirdgems.build() 485 486 def task_libbirdgems(): 487 yield make_libbirdgems('libbirdgems.so.' + LIBBIRDGEMS_SO_VERSION, []) 488 489 def task_compile_translations (): 490 """translate po files""" 491 return { 492 'actions': [compile_translations] 493 } 494 495 def task_man(): 496 """gzip linux man pages""" 497 for name in ("birdfont.1", "birdfont-export.1", 498 "birdfont-import.1", "birdfont-autotrace.1"): 499 yield { 500 'name': name, 501 'file_dep': ['resources/linux/' + name], 502 'targets': ['build/' + name + '.gz'], 503 'actions': ['gzip -9 -c resources/linux/' + name + ' > ' + 'build/' + name + '.gz'], 504 } 505 506 def task_distclean (): 507 return { 508 'actions': ['rm -rf .doit.db build scripts/config.py' 509 + ' libbirdfont/Config.vala' 510 + ' __pycache__ scripts/__pycache__'] 511 } 512 513 def task_build (): 514 if not os.path.exists ("build/configured"): 515 print ("Project is not configured") 516 exit (1) 517 518 subprocess.check_output ('mkdir -p build', shell=True) 519 subprocess.check_output ('touch build/installed', shell=True) 520 521 return { 522 'actions': ['echo "Build"'], 523 } 524 525 def make_birdfont_test(target_binary, deps): 526 valac_command = config.VALAC + """\ 527 -C \ 528 --vapidir=./ \ 529 --basedir build/birdfont-test/ \ 530 """ + config.NON_NULL + """ \ 531 """ + config.VALACFLAGS.get("birdfont-test", "") + """ \ 532 --enable-experimental \ 533 birdfont-test/*.vala \ 534 --vapidir=./ \ 535 --pkg """ + config.GEE + """ \ 536 --pkg gio-2.0 \ 537 --pkg cairo \ 538 --pkg xmlbird \ 539 --pkg libbirdfont \ 540 --pkg libsvgbird \ 541 """ 542 543 cc_command = config.CC + " " + config.CFLAGS.get("birdfont-test", "") + """ \ 544 -c C_SOURCE \ 545 -D 'GETTEXT_PACKAGE="birdfont"' \ 546 -I./build/libbirdfont \ 547 -I./build/libsvgbird \ 548 $(pkg-config --cflags sqlite3) \ 549 $(pkg-config --cflags """ + config.GEE + """) \ 550 $(pkg-config --cflags gio-2.0) \ 551 $(pkg-config --cflags cairo) \ 552 $(pkg-config --cflags glib-2.0) \ 553 -o OBJECT_FILE""" 554 555 linker_command = config.CC + " " + config.LDFLAGS.get("birdfont-test", "") + """ \ 556 build/birdfont-test/*.o \ 557 -L./build/bin -lbirdfont \ 558 $(pkg-config --libs sqlite3) \ 559 $(pkg-config --libs """ + config.GEE + """) \ 560 $(pkg-config --libs gio-2.0) \ 561 $(pkg-config --libs cairo) \ 562 $(pkg-config --libs glib-2.0) \ 563 $(pkg-config --libs xmlbird) \ 564 -L./build -L./build/bin -l birdgems -l svgbird \ 565 -o build/bin/""" + target_binary 566 567 test = Builder('birdfont-test', 568 valac_command, 569 cc_command, 570 linker_command, 571 target_binary, 572 None, 573 deps) 574 575 yield test.build() 576 577 def task_birdfont_test(): 578 yield make_birdfont_test('birdfont-test', ['libbirdgems.so', 'libbirdfont.so']) 579 580