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