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