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