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.
Editable .notdef character
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/Renderer/*.vala \ 305 --pkg """ + config.GEE + """ \ 306 --pkg gio-2.0 \ 307 --pkg cairo \ 308 --pkg xmlbird \ 309 --pkg libbirdgems \ 310 --pkg sqlite3 \ 311 --pkg gdk-pixbuf-2.0 \ 312 --pkg librsvg-2.0 \ 313 """ 314 315 cc_command = config.CC + " " + config.CFLAGS.get("libbirdfont", "") + """ \ 316 -c C_SOURCE \ 317 -fPIC \ 318 -D 'GETTEXT_PACKAGE="birdfont"' \ 319 -I ./build/libbirdfont \ 320 -I ./build/libbirdgems \ 321 $(pkg-config --cflags sqlite3) \ 322 $(pkg-config --cflags fontconfig) \ 323 $(pkg-config --cflags """ + config.GEE + """) \ 324 $(pkg-config --cflags gio-2.0) \ 325 $(pkg-config --cflags cairo) \ 326 $(pkg-config --cflags glib-2.0) \ 327 $(pkg-config --cflags xmlbird) \ 328 $(pkg-config --cflags librsvg-2.0) \ 329 -o OBJECT_FILE""" 330 331 linker_command = config.CC + " " + config.LDFLAGS.get("libbirdfont", "") + """ \ 332 -shared \ 333 """ + soname(target_binary) + """ \ 334 build/libbirdfont/*.o \ 335 $(pkg-config --libs sqlite3) \ 336 $(freetype-config --libs) \ 337 $(pkg-config --libs """ + config.GEE + """) \ 338 $(pkg-config --libs gio-2.0) \ 339 $(pkg-config --libs fontconfig) \ 340 $(pkg-config --libs cairo) \ 341 $(pkg-config --libs glib-2.0) \ 342 $(pkg-config --libs xmlbird) \ 343 -L./build -L./build/bin -l birdgems\ 344 -o ./build/bin/""" + target_binary 345 346 libbirdfont = Builder('libbirdfont', 347 valac_command, 348 cc_command, 349 linker_command, 350 target_binary, 351 'libbirdfont.so', 352 deps) 353 354 yield libbirdfont.build() 355 356 def task_libbirdfont(): 357 yield make_libbirdfont('libbirdfont.so.' + SO_VERSION, ['libbirdgems.so']) 358 359 def make_libbirdgems(target_binary, deps): 360 valac_command = config.VALAC + """\ 361 -C \ 362 -H build/libbirdgems/birdgems.h \ 363 --pkg posix \ 364 --vapidir=./ \ 365 --basedir=build/libbirdgems/ \ 366 """ + config.NON_NULL + """ \ 367 """ + config.VALACFLAGS.get("libbirdgems", "") + """ \ 368 --enable-experimental \ 369 --library libbirdgems \ 370 libbirdgems/*.vala \ 371 """ 372 373 cc_command = config.CC + " " + config.CFLAGS.get("libbirdgems", "") + """ \ 374 -fPIC \ 375 $(pkg-config --cflags glib-2.0) \ 376 -c C_SOURCE \ 377 -o OBJECT_FILE \ 378 """ 379 380 linker_command = config.CC + " " + config.LDFLAGS.get("libbirdgems", "") + """ \ 381 -shared \ 382 """ + soname(target_binary) + """ \ 383 -fPIC \ 384 build/libbirdgems/*.o \ 385 $(pkg-config --libs glib-2.0) \ 386 $(pkg-config --libs gobject-2.0) \ 387 -o build/bin/""" + target_binary 388 389 libbirdgems = Builder('libbirdgems', 390 valac_command, 391 cc_command, 392 linker_command, 393 target_binary, 394 'libbirdgems.so', 395 deps) 396 397 yield libbirdgems.build() 398 399 def task_libbirdgems(): 400 yield make_libbirdgems('libbirdgems.so.' + LIBBIRDGEMS_SO_VERSION, []) 401 402 def task_compile_translations (): 403 """translate po files""" 404 return { 405 'actions': [compile_translations] 406 } 407 408 def task_man(): 409 """gzip linux man pages""" 410 for name in ("birdfont.1", "birdfont-export.1", 411 "birdfont-import.1", "birdfont-autotrace.1"): 412 yield { 413 'name': name, 414 'file_dep': ['resources/linux/' + name], 415 'targets': ['build/' + name + '.gz'], 416 'actions': ['gzip -9 -c resources/linux/' + name + ' > ' + 'build/' + name + '.gz'], 417 } 418 419 def task_distclean (): 420 return { 421 'actions': ['rm -rf .doit.db build scripts/config.py' 422 + ' libbirdfont/Config.vala' 423 + ' __pycache__ scripts/__pycache__'] 424 } 425 426 def task_build (): 427 if not os.path.exists ("build/configured"): 428 print ("Project is not configured") 429 exit (1) 430 431 subprocess.check_output ('mkdir -p build', shell=True) 432 subprocess.check_output ('touch build/installed', shell=True) 433 434 return { 435 'actions': ['echo "Build"'], 436 } 437 438 def make_birdfont_test(target_binary, deps): 439 valac_command = config.VALAC + """\ 440 -C \ 441 --vapidir=./ \ 442 --basedir build/birdfont-test/ \ 443 """ + config.NON_NULL + """ \ 444 """ + config.VALACFLAGS.get("birdfont-test", "") + """ \ 445 --enable-experimental \ 446 birdfont-test/*.vala \ 447 --vapidir=./ \ 448 --pkg """ + config.GEE + """ \ 449 --pkg gio-2.0 \ 450 --pkg cairo \ 451 --pkg xmlbird \ 452 --pkg libbirdfont \ 453 """ 454 455 cc_command = config.CC + " " + config.CFLAGS.get("birdfont-test", "") + """ \ 456 -c C_SOURCE \ 457 -D 'GETTEXT_PACKAGE="birdfont"' \ 458 -I./build/libbirdfont \ 459 $(pkg-config --cflags sqlite3) \ 460 $(pkg-config --cflags """ + config.GEE + """) \ 461 $(pkg-config --cflags gio-2.0) \ 462 $(pkg-config --cflags cairo) \ 463 $(pkg-config --cflags glib-2.0) \ 464 -o OBJECT_FILE""" 465 466 linker_command = config.CC + " " + config.LDFLAGS.get("birdfont-test", "") + """ \ 467 build/birdfont-test/*.o \ 468 -L./build/bin -lbirdfont \ 469 $(pkg-config --libs sqlite3) \ 470 $(pkg-config --libs """ + config.GEE + """) \ 471 $(pkg-config --libs gio-2.0) \ 472 $(pkg-config --libs cairo) \ 473 $(pkg-config --libs glib-2.0) \ 474 $(pkg-config --libs xmlbird) \ 475 $(pkg-config --libs librsvg-2.0) \ 476 -L./build -L./build/bin -l birdgems\ 477 -o build/bin/""" + target_binary 478 479 test = Builder('birdfont-test', 480 valac_command, 481 cc_command, 482 linker_command, 483 target_binary, 484 None, 485 deps) 486 487 yield test.build() 488 489 def task_birdfont_test(): 490 yield make_birdfont_test('birdfont-test', ['libbirdgems.so', 'libbirdfont.so']) 491 492 493