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