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.
Linear gradients and matrix tranform on gradients
1 """ 2 Copyright (C) 2012 2013 2014 2015 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 SO_VERSION=version.SO_VERSION 52 elif "openbsd" in sys.platform: 53 SO_VERSION='${LIBbirdfont_VERSION}' 54 else: 55 SO_VERSION=version.SO_VERSION 56 57 def soname(target_binary): 58 if "darwin" in sys.platform or "msys" in sys.platform: 59 return '' 60 61 return '-Wl,-soname,' + target_binary 62 63 def make_birdfont(target_binary, deps): 64 valac_command = config.VALAC + """\ 65 -C \ 66 --vapidir=./ \ 67 --basedir build/birdfont/ \ 68 """ + config.NON_NULL + """ \ 69 """ + config.VALACFLAGS.get("birdfont", "") + """ \ 70 --enable-experimental \ 71 birdfont/*.vala \ 72 --vapidir=./ \ 73 --pkg """ + config.GEE + """ \ 74 --pkg gio-2.0 \ 75 --pkg cairo \ 76 --pkg libsoup-2.4 \ 77 --pkg gdk-pixbuf-2.0 \ 78 --pkg webkitgtk-3.0 \ 79 --pkg libnotify \ 80 --pkg xmlbird \ 81 --pkg librsvg-2.0 \ 82 --pkg libbirdfont 83 """ 84 85 cc_command = config.CC + " " + config.CFLAGS.get("birdfont", "") + """ \ 86 -c C_SOURCE \ 87 -D 'GETTEXT_PACKAGE="birdfont"' \ 88 -I./build/libbirdfont \ 89 $(pkg-config --cflags sqlite3) \ 90 $(pkg-config --cflags """ + config.GEE + """) \ 91 $(pkg-config --cflags gio-2.0) \ 92 $(pkg-config --cflags cairo) \ 93 $(pkg-config --cflags glib-2.0) \ 94 $(pkg-config --cflags gdk-pixbuf-2.0) \ 95 $(pkg-config --cflags webkitgtk-3.0) \ 96 $(pkg-config --cflags libnotify) \ 97 $(pkg-config --cflags librsvg-2.0) \ 98 -o OBJECT_FILE""" 99 100 linker_command = config.CC + " " + config.LDFLAGS.get("birdfont", "") + """ \ 101 build/birdfont/*.o \ 102 -L./build/bin -lbirdfont \ 103 $(pkg-config --libs sqlite3) \ 104 $(pkg-config --libs """ + config.GEE + """) \ 105 $(pkg-config --libs gio-2.0) \ 106 $(pkg-config --libs cairo) \ 107 $(pkg-config --libs glib-2.0) \ 108 $(pkg-config --libs gdk-pixbuf-2.0) \ 109 $(pkg-config --libs webkitgtk-3.0) \ 110 $(pkg-config --libs xmlbird) \ 111 $(pkg-config --libs libnotify) \ 112 $(pkg-config --libs librsvg-2.0) \ 113 -L./build -L./build/bin -l birdgems\ 114 -o build/bin/""" + target_binary 115 116 birdfont = Builder('birdfont', 117 valac_command, 118 cc_command, 119 linker_command, 120 target_binary, 121 None, 122 deps) 123 124 yield birdfont.build() 125 126 def task_birdfont(): 127 yield make_birdfont('birdfont', ['libbirdgems.so', 'libbirdfont.so']) 128 129 def make_birdfont_export(target_binary, deps): 130 valac_command = config.VALAC + """ \ 131 -C \ 132 --enable-experimental \ 133 --basedir build/birdfont-export/ \ 134 """ + config.NON_NULL + """ \ 135 """ + config.VALACFLAGS.get("birdfont-export", "") + """ \ 136 birdfont-export/*.vala \ 137 --vapidir=./ \ 138 --pkg """ + config.GEE + """ \ 139 --pkg gio-2.0 \ 140 --pkg cairo \ 141 --pkg xmlbird \ 142 --pkg libbirdfont 143 """ 144 145 cc_command = config.CC + " " + config.CFLAGS.get("birdfont-export", "") + """ \ 146 -c C_SOURCE \ 147 -D 'GETTEXT_PACKAGE="birdfont"' \ 148 -I./build/libbirdfont \ 149 $(pkg-config --cflags sqlite3) \ 150 $(pkg-config --cflags """ + config.GEE + """) \ 151 $(pkg-config --cflags gio-2.0) \ 152 $(pkg-config --cflags cairo) \ 153 $(pkg-config --cflags glib-2.0) \ 154 -o OBJECT_FILE""" 155 156 linker_command = config.CC + " " + config.LDFLAGS.get("birdfont-export", "") + """ \ 157 build/birdfont-export/*.o \ 158 -Lbuild/bin/ -lbirdfont \ 159 -lm \ 160 $(pkg-config --libs sqlite3) \ 161 $(pkg-config --libs """ + config.GEE + """) \ 162 $(pkg-config --libs gio-2.0) \ 163 $(pkg-config --libs cairo) \ 164 $(pkg-config --libs glib-2.0) \ 165 $(pkg-config --libs xmlbird) \ 166 $(pkg-config --libs librsvg-2.0) \ 167 -L./build -L./build/bin -l birdgems\ 168 -o ./build/bin/""" + target_binary 169 170 birdfont_export = Builder('birdfont-export', 171 valac_command, 172 cc_command, 173 linker_command, 174 target_binary, 175 None, 176 deps) 177 178 yield birdfont_export.build() 179 180 def task_birdfont_export(): 181 yield make_birdfont_export('birdfont-export', ['libbirdgems.so', 'libbirdfont.so']) 182 183 def make_birdfont_import(target_binary, deps): 184 valac_command = config.VALAC + """\ 185 -C \ 186 --enable-experimental \ 187 --basedir build/birdfont-import/ \ 188 """ + config.NON_NULL + """ \ 189 """ + config.VALACFLAGS.get("birdfont-import", "") + """ \ 190 birdfont-import/*.vala \ 191 --vapidir=./ \ 192 --pkg """ + config.GEE + """ \ 193 --pkg gio-2.0 \ 194 --pkg cairo \ 195 --pkg xmlbird \ 196 --pkg libbirdfont \ 197 """ 198 199 cc_command = config.CC + " " + config.CFLAGS.get("birdfont-import", "") + """ \ 200 -c C_SOURCE \ 201 -D 'GETTEXT_PACKAGE="birdfont"' \ 202 -I./build/libbirdfont \ 203 $(pkg-config --cflags sqlite3) \ 204 $(pkg-config --cflags """ + config.GEE + """) \ 205 $(pkg-config --cflags gio-2.0) \ 206 $(pkg-config --cflags cairo) \ 207 $(pkg-config --cflags glib-2.0) \ 208 -o OBJECT_FILE""" 209 210 linker_command = config.CC + " " + config.LDFLAGS.get("birdfont-import", "") + """ \ 211 build/birdfont-import/*.o \ 212 -Lbuild/bin/ -lbirdfont \ 213 -lm \ 214 $(pkg-config --libs sqlite3) \ 215 $(pkg-config --libs """ + config.GEE + """) \ 216 $(pkg-config --libs gio-2.0) \ 217 $(pkg-config --libs cairo) \ 218 $(pkg-config --libs glib-2.0) \ 219 $(pkg-config --libs xmlbird) \ 220 $(pkg-config --libs librsvg-2.0) \ 221 -L./build -L./build/bin -l birdgems\ 222 -o ./build/bin/""" + target_binary 223 224 birdfont_import = Builder('birdfont-import', 225 valac_command, 226 cc_command, 227 linker_command, 228 target_binary, 229 None, 230 deps) 231 232 yield birdfont_import.build() 233 234 def task_birdfont_import(): 235 yield make_birdfont_import('birdfont-import', ['libbirdgems.so', 'libbirdfont.so']) 236 237 def make_birdfont_autotrace(target_binary, deps): 238 valac_command = config.VALAC + """\ 239 -C \ 240 --enable-experimental \ 241 --basedir build/birdfont-autotrace/ \ 242 """ + config.NON_NULL + """ \ 243 """ + config.VALACFLAGS.get("birdfont-autotrace", "") + """ \ 244 birdfont-autotrace/*.vala \ 245 --vapidir=./ \ 246 --pkg """ + config.GEE + """ \ 247 --pkg gio-2.0 \ 248 --pkg cairo \ 249 --pkg xmlbird \ 250 --pkg libbirdfont \ 251 """ 252 253 cc_command = config.CC + " " + config.CFLAGS.get("birdfont-autotrace", "") + """ \ 254 -c C_SOURCE \ 255 -D 'GETTEXT_PACKAGE="birdfont"' \ 256 -I./build/libbirdfont \ 257 $(pkg-config --cflags sqlite3) \ 258 $(pkg-config --cflags """ + config.GEE + """) \ 259 $(pkg-config --cflags gio-2.0) \ 260 $(pkg-config --cflags cairo) \ 261 $(pkg-config --cflags glib-2.0) \ 262 -o OBJECT_FILE""" 263 264 linker_command = config.CC + " " + config.LDFLAGS.get("birdfont-autotrace", "") + """ \ 265 build/birdfont-autotrace/*.o \ 266 -I./build/libbirdfont \ 267 -Lbuild/bin/ -lbirdfont \ 268 -lm \ 269 $(pkg-config --libs sqlite3) \ 270 $(pkg-config --libs """ + config.GEE + """) \ 271 $(pkg-config --libs gio-2.0) \ 272 $(pkg-config --libs cairo) \ 273 $(pkg-config --libs glib-2.0) \ 274 $(pkg-config --libs xmlbird) \ 275 $(pkg-config --libs librsvg-2.0) \ 276 -L./build -L./build/bin -l birdgems\ 277 -o ./build/bin/""" + target_binary 278 279 birdfont_autotrace = Builder('birdfont-autotrace', 280 valac_command, 281 cc_command, 282 linker_command, 283 target_binary, 284 None, 285 deps) 286 287 yield birdfont_autotrace.build() 288 289 def task_birdfont_autotrace(): 290 yield make_birdfont_autotrace('birdfont-autotrace', ['libbirdgems.so', 'libbirdfont.so']) 291 292 def make_libbirdfont(target_binary, deps): 293 valac_command = config.VALAC + """\ 294 -C \ 295 --vapidir=./ \ 296 --basedir build/libbirdfont/ \ 297 """ + config.NON_NULL + """ \ 298 """ + config.VALACFLAGS.get("libbirdfont", "") + """ \ 299 --enable-experimental \ 300 --library libbirdfont \ 301 -H build/libbirdfont/birdfont.h \ 302 libbirdfont/*.vala \ 303 libbirdfont/OpenFontFormat/*.vala \ 304 libbirdfont/TextRendering/*.vala \ 305 libbirdfont/Svg/*.vala \ 306 --pkg posix \ 307 --pkg """ + config.GEE + """ \ 308 --pkg gio-2.0 \ 309 --pkg cairo \ 310 --pkg xmlbird \ 311 --pkg libbirdgems \ 312 --pkg sqlite3 \ 313 --pkg gdk-pixbuf-2.0 \ 314 --pkg librsvg-2.0 \ 315 """ 316 317 cc_command = config.CC + " " + config.CFLAGS.get("libbirdfont", "") + """ \ 318 -c C_SOURCE \ 319 -fPIC \ 320 -D 'GETTEXT_PACKAGE="birdfont"' \ 321 -I ./build/libbirdfont \ 322 -I ./build/libbirdgems \ 323 $(pkg-config --cflags sqlite3) \ 324 $(pkg-config --cflags fontconfig) \ 325 $(pkg-config --cflags """ + config.GEE + """) \ 326 $(pkg-config --cflags gio-2.0) \ 327 $(pkg-config --cflags cairo) \ 328 $(pkg-config --cflags glib-2.0) \ 329 $(pkg-config --cflags xmlbird) \ 330 $(pkg-config --cflags librsvg-2.0) \ 331 -o OBJECT_FILE""" 332 333 linker_command = config.CC + " " + config.LDFLAGS.get("libbirdfont", "") + """ \ 334 -shared \ 335 """ + soname(target_binary) + """ \ 336 build/libbirdfont/*.o \ 337 $(pkg-config --libs sqlite3) \ 338 $(freetype-config --libs) \ 339 $(pkg-config --libs """ + config.GEE + """) \ 340 $(pkg-config --libs gio-2.0) \ 341 $(pkg-config --libs fontconfig) \ 342 $(pkg-config --libs cairo) \ 343 $(pkg-config --libs glib-2.0) \ 344 $(pkg-config --libs xmlbird) \ 345 -L./build -L./build/bin -l birdgems\ 346 -o ./build/bin/""" + target_binary 347 348 libbirdfont = Builder('libbirdfont', 349 valac_command, 350 cc_command, 351 linker_command, 352 target_binary, 353 'libbirdfont.so', 354 deps) 355 356 yield libbirdfont.build() 357 358 def task_libbirdfont(): 359 yield make_libbirdfont('libbirdfont.so.' + SO_VERSION, ['libbirdgems.so']) 360 361 def make_libbirdgems(target_binary, deps): 362 valac_command = config.VALAC + """\ 363 -C \ 364 -H build/libbirdgems/birdgems.h \ 365 --pkg posix \ 366 --vapidir=./ \ 367 --basedir=build/libbirdgems/ \ 368 """ + config.NON_NULL + """ \ 369 """ + config.VALACFLAGS.get("libbirdgems", "") + """ \ 370 --enable-experimental \ 371 --library libbirdgems \ 372 libbirdgems/*.vala \ 373 """ 374 375 cc_command = config.CC + " " + config.CFLAGS.get("libbirdgems", "") + """ \ 376 -fPIC \ 377 $(pkg-config --cflags glib-2.0) \ 378 -c C_SOURCE \ 379 -o OBJECT_FILE \ 380 """ 381 382 linker_command = config.CC + " " + config.LDFLAGS.get("libbirdgems", "") + """ \ 383 -shared \ 384 """ + soname(target_binary) + """ \ 385 -fPIC \ 386 build/libbirdgems/*.o \ 387 $(pkg-config --libs glib-2.0) \ 388 $(pkg-config --libs gobject-2.0) \ 389 -o build/bin/""" + target_binary 390 391 libbirdgems = Builder('libbirdgems', 392 valac_command, 393 cc_command, 394 linker_command, 395 target_binary, 396 'libbirdgems.so', 397 deps) 398 399 yield libbirdgems.build() 400 401 def task_libbirdgems(): 402 yield make_libbirdgems('libbirdgems.so.' + LIBBIRDGEMS_SO_VERSION, []) 403 404 def task_compile_translations (): 405 """translate po files""" 406 return { 407 'actions': [compile_translations] 408 } 409 410 def task_man(): 411 """gzip linux man pages""" 412 for name in ("birdfont.1", "birdfont-export.1", 413 "birdfont-import.1", "birdfont-autotrace.1"): 414 yield { 415 'name': name, 416 'file_dep': ['resources/linux/' + name], 417 'targets': ['build/' + name + '.gz'], 418 'actions': ['gzip -9 -c resources/linux/' + name + ' > ' + 'build/' + name + '.gz'], 419 } 420 421 def task_distclean (): 422 return { 423 'actions': ['rm -rf .doit.db build scripts/config.py' 424 + ' libbirdfont/Config.vala' 425 + ' __pycache__ scripts/__pycache__'] 426 } 427 428 def task_build (): 429 if not os.path.exists ("build/configured"): 430 print ("Project is not configured") 431 exit (1) 432 433 subprocess.check_output ('mkdir -p build', shell=True) 434 subprocess.check_output ('touch build/installed', shell=True) 435 436 return { 437 'actions': ['echo "Build"'], 438 } 439 440 def make_birdfont_test(target_binary, deps): 441 valac_command = config.VALAC + """\ 442 -C \ 443 --vapidir=./ \ 444 --basedir build/birdfont-test/ \ 445 """ + config.NON_NULL + """ \ 446 """ + config.VALACFLAGS.get("birdfont-test", "") + """ \ 447 --enable-experimental \ 448 birdfont-test/*.vala \ 449 --vapidir=./ \ 450 --pkg """ + config.GEE + """ \ 451 --pkg gio-2.0 \ 452 --pkg cairo \ 453 --pkg xmlbird \ 454 --pkg libbirdfont \ 455 """ 456 457 cc_command = config.CC + " " + config.CFLAGS.get("birdfont-test", "") + """ \ 458 -c C_SOURCE \ 459 -D 'GETTEXT_PACKAGE="birdfont"' \ 460 -I./build/libbirdfont \ 461 $(pkg-config --cflags sqlite3) \ 462 $(pkg-config --cflags """ + config.GEE + """) \ 463 $(pkg-config --cflags gio-2.0) \ 464 $(pkg-config --cflags cairo) \ 465 $(pkg-config --cflags glib-2.0) \ 466 -o OBJECT_FILE""" 467 468 linker_command = config.CC + " " + config.LDFLAGS.get("birdfont-test", "") + """ \ 469 build/birdfont-test/*.o \ 470 -L./build/bin -lbirdfont \ 471 $(pkg-config --libs sqlite3) \ 472 $(pkg-config --libs """ + config.GEE + """) \ 473 $(pkg-config --libs gio-2.0) \ 474 $(pkg-config --libs cairo) \ 475 $(pkg-config --libs glib-2.0) \ 476 $(pkg-config --libs xmlbird) \ 477 $(pkg-config --libs librsvg-2.0) \ 478 -L./build -L./build/bin -l birdgems\ 479 -o build/bin/""" + target_binary 480 481 test = Builder('birdfont-test', 482 valac_command, 483 cc_command, 484 linker_command, 485 target_binary, 486 None, 487 deps) 488 489 yield test.build() 490 491 def task_birdfont_test(): 492 yield make_birdfont_test('birdfont-test', ['libbirdgems.so', 'libbirdfont.so']) 493 494 495