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 windows build
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 "bsd" 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 "bsd" 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=./ \g 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 gtk+-2.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 --define=MAC \ 131 --basedir build/birdfont-export/ \ 132 """ + config.NON_NULL + """ \ 133 """ + config.VALACFLAGS.get("birdfont-export", "") + """ \ 134 birdfont-export/*.vala \ 135 --vapidir=./ \ 136 --pkg """ + config.GEE + """ \ 137 --pkg gio-2.0 \ 138 --pkg cairo \ 139 --pkg xmlbird \ 140 --pkg libbirdfont 141 """ 142 143 cc_command = config.CC + " " + config.CFLAGS.get("birdfont-export", "") + """ \ 144 -c C_SOURCE \ 145 -D 'GETTEXT_PACKAGE="birdfont"' \ 146 -I./build/libbirdfont \ 147 $(pkg-config --cflags sqlite3) \ 148 $(pkg-config --cflags """ + config.GEE + """) \ 149 $(pkg-config --cflags gio-2.0) \ 150 $(pkg-config --cflags cairo) \ 151 $(pkg-config --cflags glib-2.0) \ 152 -o OBJECT_FILE""" 153 154 linker_command = config.CC + " " + config.LDFLAGS.get("birdfont-export", "") + """ \ 155 build/birdfont-export/*.o \ 156 -Lbuild/bin/ -lbirdfont \ 157 -lm \ 158 $(pkg-config --libs sqlite3) \ 159 $(pkg-config --libs """ + config.GEE + """) \ 160 $(pkg-config --libs gio-2.0) \ 161 $(pkg-config --libs cairo) \ 162 $(pkg-config --libs glib-2.0) \ 163 $(pkg-config --libs xmlbird) \ 164 -L./build -L./build/bin -l birdgems\ 165 -o ./build/bin/""" + target_binary 166 167 birdfont_export = Builder('birdfont-export', 168 valac_command, 169 cc_command, 170 linker_command, 171 target_binary, 172 None, 173 deps) 174 175 yield birdfont_export.build() 176 177 def task_birdfont_export(): 178 yield make_birdfont_export('birdfont-export', ['libbirdgems.so', 'libbirdfont.so']) 179 180 def make_birdfont_import(target_binary, deps): 181 valac_command = config.VALAC + """\ 182 -C \ 183 --enable-experimental \ 184 --define=MAC \ 185 --basedir build/birdfont-import/ \ 186 """ + config.NON_NULL + """ \ 187 """ + config.VALACFLAGS.get("birdfont-import", "") + """ \ 188 birdfont-import/*.vala \ 189 --vapidir=./ \ 190 --pkg """ + config.GEE + """ \ 191 --pkg gio-2.0 \ 192 --pkg cairo \ 193 --pkg xmlbird \ 194 --pkg libbirdfont 195 """ 196 197 cc_command = config.CC + " " + config.CFLAGS.get("birdfont-import", "") + """ \ 198 -c C_SOURCE \ 199 -D 'GETTEXT_PACKAGE="birdfont"' \ 200 -I./build/libbirdfont \ 201 $(pkg-config --cflags sqlite3) \ 202 $(pkg-config --cflags """ + config.GEE + """) \ 203 $(pkg-config --cflags gio-2.0) \ 204 $(pkg-config --cflags cairo) \ 205 $(pkg-config --cflags glib-2.0) \ 206 -o OBJECT_FILE""" 207 208 linker_command = config.CC + " " + config.LDFLAGS.get("birdfont-import", "") + """ \ 209 build/birdfont-import/*.o \ 210 -Lbuild/bin/ -lbirdfont \ 211 -lm \ 212 $(pkg-config --libs sqlite3) \ 213 $(pkg-config --libs """ + config.GEE + """) \ 214 $(pkg-config --libs gio-2.0) \ 215 $(pkg-config --libs cairo) \ 216 $(pkg-config --libs glib-2.0) \ 217 $(pkg-config --libs xmlbird) \ 218 -L./build -L./build/bin -l birdgems\ 219 -o ./build/bin/""" + target_binary 220 221 birdfont_import = Builder('birdfont-import', 222 valac_command, 223 cc_command, 224 linker_command, 225 target_binary, 226 None, 227 deps) 228 229 yield birdfont_import.build() 230 231 def task_birdfont_import(): 232 yield make_birdfont_import('birdfont-import', ['libbirdgems.so', 'libbirdfont.so']) 233 234 def make_birdfont_autotrace(target_binary, deps): 235 valac_command = config.VALAC + """\ 236 -C \ 237 --enable-experimental \ 238 --define=MAC \ 239 --basedir build/birdfont-autotrace/ \ 240 """ + config.NON_NULL + """ \ 241 """ + config.VALACFLAGS.get("birdfont-autotrace", "") + """ \ 242 birdfont-autotrace/*.vala \ 243 --vapidir=./ \ 244 --pkg """ + config.GEE + """ \ 245 --pkg gio-2.0 \ 246 --pkg cairo \ 247 --pkg xmlbird \ 248 --pkg libbirdfont \ 249 """ 250 251 cc_command = config.CC + " " + config.CFLAGS.get("birdfont-autotrace", "") + """ \ 252 -c C_SOURCE \ 253 -D 'GETTEXT_PACKAGE="birdfont"' \ 254 -I./build/libbirdfont \ 255 $(pkg-config --cflags sqlite3) \ 256 $(pkg-config --cflags """ + config.GEE + """) \ 257 $(pkg-config --cflags gio-2.0) \ 258 $(pkg-config --cflags cairo) \ 259 $(pkg-config --cflags glib-2.0) \ 260 -o OBJECT_FILE""" 261 262 linker_command = config.CC + " " + config.LDFLAGS.get("birdfont-autotrace", "") + """ \ 263 build/birdfont-autotrace/*.o \ 264 -I./build/libbirdfont \ 265 -Lbuild/bin/ -lbirdfont \ 266 -lm \ 267 $(pkg-config --libs sqlite3) \ 268 $(pkg-config --libs """ + config.GEE + """) \ 269 $(pkg-config --libs gio-2.0) \ 270 $(pkg-config --libs cairo) \ 271 $(pkg-config --libs glib-2.0) \ 272 $(pkg-config --libs xmlbird) \ 273 -L./build -L./build/bin -l birdgems\ 274 -o ./build/bin/""" + target_binary 275 276 birdfont_autotrace = Builder('birdfont-autotrace', 277 valac_command, 278 cc_command, 279 linker_command, 280 target_binary, 281 None, 282 deps) 283 284 yield birdfont_autotrace.build() 285 286 def task_birdfont_autotrace(): 287 yield make_birdfont_autotrace('birdfont-autotrace') 288 289 def make_libbirdfont(target_binary, deps): 290 valac_command = config.VALAC + """\ 291 -C \ 292 --vapidir=./ \ 293 --basedir build/libbirdfont/ \ 294 """ + config.NON_NULL + """ \ 295 """ + config.VALACFLAGS.get("libbirdfont", "") + """ \ 296 --enable-experimental \ 297 --library libbirdfont \ 298 -H build/libbirdfont/birdfont.h \ 299 libbirdfont/*.vala \ 300 libbirdfont/OpenFontFormat/*.vala \ 301 libbirdfont/Renderer/*.vala \ 302 --pkg """ + config.GEE + """ \ 303 --pkg gio-2.0 \ 304 --pkg cairo \ 305 --pkg xmlbird \ 306 --pkg libbirdgems \ 307 --pkg sqlite3 \ 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.' + version.SO_VERSION_MAJOR, ['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 None, 389 deps) 390 391 yield libbirdgems.build() 392 393 def task_libbirdgems(): 394 yield make_libbirdgems('libbirdgems.so.' + version.LIBBIRDGEMS_SO_VERSION_MAJOR, []) 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/%s' % name], 409 'targets': ['build/%s.gz' % name], 410 'actions': ["gzip -9 -c %(dependencies)s > %(targets)s"], 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