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.
Build configuration
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 'libbirdgems', 32 'libbirdfont', 33 'birdfont', 34 'birdfont-autotrace', 35 'birdfont-export', 36 'birdfont-import', 37 'compile_translations', 38 'man' 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 make_birdfont(target_binary): 57 valac_command = config.VALAC + """\ 58 -C \ 59 --vapidir=./ \ 60 --basedir build/birdfont/ \ 61 """ + config.NON_NULL + """ \ 62 --enable-experimental \ 63 birdfont/*.vala \ 64 --vapidir=./ \ 65 --pkg """ + config.GEE + """ \ 66 --pkg gio-2.0 \ 67 --pkg cairo \ 68 --pkg libsoup-2.4 \ 69 --pkg gdk-pixbuf-2.0 \ 70 --pkg webkitgtk-3.0 \ 71 --pkg libnotify \ 72 --pkg xmlbird \ 73 --pkg libbirdfont 74 """ 75 76 cflags = '' 77 cc_command = config.CC + " " + cflags + """ \ 78 -c C_SOURCE \ 79 -D 'GETTEXT_PACKAGE="birdfont"' \ 80 -I./build/libbirdfont \ 81 $(pkg-config --cflags sqlite3) \ 82 $(pkg-config --cflags """ + config.GEE + """) \ 83 $(pkg-config --cflags gio-2.0) \ 84 $(pkg-config --cflags cairo) \ 85 $(pkg-config --cflags glib-2.0) \ 86 $(pkg-config --cflags gdk-pixbuf-2.0) \ 87 $(pkg-config --cflags webkitgtk-3.0) \ 88 $(pkg-config --cflags libnotify) \ 89 -o OBJECT_FILE""" 90 91 soname_parameters = "-Wl,-soname," + target_binary 92 93 ldflags = '' 94 linker_command = config.CC + " " + ldflags + """ \ 95 build/birdfont/*.o \ 96 -L./build/bin -lbirdfont \ 97 $(pkg-config --libs sqlite3) \ 98 $(pkg-config --libs """ + config.GEE + """) \ 99 $(pkg-config --libs gio-2.0) \ 100 $(pkg-config --libs cairo) \ 101 $(pkg-config --libs glib-2.0) \ 102 $(pkg-config --libs gdk-pixbuf-2.0) \ 103 $(pkg-config --libs webkitgtk-3.0) \ 104 $(pkg-config --libs gtk+-2.0) \ 105 $(pkg-config --libs xmlbird) \ 106 $(pkg-config --libs libnotify) \ 107 -L./build -L./build/bin -l birdgems\ 108 -o build/bin/""" + target_binary 109 110 birdfont = Builder('birdfont', 111 valac_command, 112 cc_command, 113 linker_command, 114 target_binary, 115 None, 116 ['libbirdgems.so', 'libbirdfont.so']) 117 118 yield birdfont.build() 119 120 def task_birdfont(): 121 yield make_birdfont('birdfont') 122 123 def make_birdfont_export(target_binary): 124 valac_command = config.VALAC + """ \ 125 -C \ 126 --enable-experimental \ 127 --define=MAC \ 128 --basedir build/birdfont-export/ \ 129 """ + config.NON_NULL + """ \ 130 birdfont-export/*.vala \ 131 --vapidir=./ \ 132 --pkg """ + config.GEE + """ \ 133 --pkg gio-2.0 \ 134 --pkg cairo \ 135 --pkg xmlbird \ 136 --pkg libbirdfont 137 """ 138 139 cflags = '' 140 cc_command = config.CC + " " + cflags + """ \ 141 -c C_SOURCE \ 142 -D 'GETTEXT_PACKAGE="birdfont"' \ 143 -I./build/libbirdfont \ 144 $(pkg-config --cflags sqlite3) \ 145 $(pkg-config --cflags """ + config.GEE + """) \ 146 $(pkg-config --cflags gio-2.0) \ 147 $(pkg-config --cflags cairo) \ 148 $(pkg-config --cflags glib-2.0) \ 149 -o OBJECT_FILE""" 150 151 soname_parameters = "-Wl,-soname," + target_binary 152 153 ldflags = '' 154 linker_command = config.CC + " " + ldflags + """ \ 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 ['libbirdgems.so', 'libbirdfont.so']) 174 175 yield birdfont_export.build() 176 177 def task_birdfont_export(): 178 yield make_birdfont_export('birdfont-export') 179 180 def make_birdfont_import(target_binary): 181 valac_command = config.VALAC + """\ 182 -C \ 183 --enable-experimental \ 184 --define=MAC \ 185 --basedir build/birdfont-import/ \ 186 """ + config.NON_NULL + """ \ 187 birdfont-import/*.vala \ 188 --vapidir=./ \ 189 --pkg """ + config.GEE + """ \ 190 --pkg gio-2.0 \ 191 --pkg cairo \ 192 --pkg xmlbird \ 193 --pkg libbirdfont 194 """ 195 196 cflags = '' 197 cc_command = config.CC + " " + cflags + """ \ 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 soname_parameters = "-Wl,-soname," + target_binary 209 210 ldflags = '' 211 linker_command = config.CC + " " + ldflags + """ \ 212 build/birdfont-import/*.o \ 213 -Lbuild/bin/ -lbirdfont \ 214 -lm \ 215 $(pkg-config --libs sqlite3) \ 216 $(pkg-config --libs """ + config.GEE + """) \ 217 $(pkg-config --libs gio-2.0) \ 218 $(pkg-config --libs cairo) \ 219 $(pkg-config --libs glib-2.0) \ 220 $(pkg-config --libs xmlbird) \ 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 ['libbirdgems.so', 'libbirdfont.so']) 231 232 yield birdfont_import.build() 233 234 def task_birdfont_import(): 235 yield make_birdfont_import('birdfont-import') 236 237 def make_birdfont_autotrace(target_binary): 238 valac_command = config.VALAC + """\ 239 -C \ 240 --enable-experimental \ 241 --define=MAC \ 242 --basedir build/birdfont-autotrace/ \ 243 """ + config.NON_NULL + """ \ 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 cflags = '' 254 cc_command = config.CC + " " + cflags + """ \ 255 -c C_SOURCE \ 256 -D 'GETTEXT_PACKAGE="birdfont"' \ 257 -I./build/libbirdfont \ 258 $(pkg-config --cflags sqlite3) \ 259 $(pkg-config --cflags """ + config.GEE + """) \ 260 $(pkg-config --cflags gio-2.0) \ 261 $(pkg-config --cflags cairo) \ 262 $(pkg-config --cflags glib-2.0) \ 263 -o OBJECT_FILE""" 264 265 soname_parameters = "-Wl,-soname," + target_binary 266 267 ldflags = '' 268 linker_command = config.CC + " " + ldflags + """ \ 269 build/birdfont-autotrace/*.o \ 270 -I./build/libbirdfont \ 271 -Lbuild/bin/ -lbirdfont \ 272 -lm \ 273 $(pkg-config --libs sqlite3) \ 274 $(pkg-config --libs """ + config.GEE + """) \ 275 $(pkg-config --libs gio-2.0) \ 276 $(pkg-config --libs cairo) \ 277 $(pkg-config --libs glib-2.0) \ 278 $(pkg-config --libs xmlbird) \ 279 -L./build -L./build/bin -l birdgems\ 280 -o ./build/bin/""" + target_binary 281 282 birdfont_autotrace = Builder('birdfont-autotrace', 283 valac_command, 284 cc_command, 285 linker_command, 286 target_binary, 287 None, 288 ['libbirdgems.so', 'libbirdfont.so']) 289 290 yield birdfont_autotrace.build() 291 292 def task_birdfont_autotrace(): 293 yield make_birdfont_autotrace('birdfont-autotrace') 294 295 def make_libbirdfont(target_binary): 296 valac_command = config.VALAC + """\ 297 -C \ 298 --vapidir=./ \ 299 --basedir build/libbirdfont/ \ 300 """ + config.NON_NULL + """ \ 301 --enable-experimental \ 302 --library libbirdfont \ 303 -H build/libbirdfont/birdfont.h \ 304 libbirdfont/*.vala \ 305 libbirdfont/OpenFontFormat/*.vala \ 306 libbirdfont/Renderer/*.vala \ 307 --pkg """ + config.GEE + """ \ 308 --pkg gio-2.0 \ 309 --pkg cairo \ 310 --pkg xmlbird \ 311 --pkg libbirdgems \ 312 --pkg sqlite3 \ 313 """ 314 315 cflags = '' 316 cc_command = config.CC + " " + cflags + """ \ 317 -c C_SOURCE \ 318 -fPIC \ 319 -D 'GETTEXT_PACKAGE="birdfont"' \ 320 -I ./build/libbirdfont \ 321 -I ./build/libbirdgems \ 322 $(pkg-config --cflags sqlite3) \ 323 $(pkg-config --cflags fontconfig) \ 324 $(pkg-config --cflags """ + config.GEE + """) \ 325 $(pkg-config --cflags gio-2.0) \ 326 $(pkg-config --cflags cairo) \ 327 $(pkg-config --cflags glib-2.0) \ 328 $(pkg-config --cflags xmlbird) \ 329 -o OBJECT_FILE""" 330 331 soname_parameters = "-Wl,-soname," + target_binary 332 333 ldflags = '' 334 linker_command = config.CC + " " + ldflags + """ \ 335 -shared \ 336 """ + soname_parameters + """ \ 337 build/libbirdfont/*.o \ 338 $(pkg-config --libs sqlite3) \ 339 $(freetype-config --libs) \ 340 $(pkg-config --libs """ + config.GEE + """) \ 341 $(pkg-config --libs gio-2.0) \ 342 $(pkg-config --libs fontconfig) \ 343 $(pkg-config --libs cairo) \ 344 $(pkg-config --libs glib-2.0) \ 345 $(pkg-config --libs xmlbird) \ 346 -L./build -L./build/bin -l birdgems\ 347 -o ./build/bin/""" + target_binary 348 349 libbirdfont = Builder('libbirdfont', 350 valac_command, 351 cc_command, 352 linker_command, 353 target_binary, 354 'libbirdfont.so', 355 ['libbirdgems.so']) 356 357 yield libbirdfont.build() 358 359 def task_libbirdfont(): 360 yield make_libbirdfont('libbirdfont.so.' + version.SO_VERSION_MAJOR) 361 362 def make_libbirdgems(target_binary): 363 valac_command = config.VALAC + """\ 364 -C \ 365 -H build/libbirdgems/birdgems.h \ 366 --pkg posix \ 367 --vapidir=./ \ 368 --basedir build/libbirdgems/ \ 369 """ + config.NON_NULL + """ \ 370 --enable-experimental \ 371 --library libbirdgems \ 372 libbirdgems/*.vala \ 373 """ 374 375 cc = 'gcc' 376 cflags = '' 377 cc_command = config.CC + " " + cflags + """ \ 378 -fPIC \ 379 $(pkg-config --cflags glib-2.0) \ 380 -c C_SOURCE \ 381 -o OBJECT_FILE \ 382 """ 383 384 soname_parameters = "-Wl,-soname," + target_binary 385 386 ldflags = '' 387 linker_command = config.CC + " " + ldflags + """ \ 388 -shared \ 389 """ + soname_parameters + """ \ 390 -fPIC \ 391 build/libbirdgems/*.o \ 392 $(pkg-config --libs glib-2.0) \ 393 $(pkg-config --libs gobject-2.0) \ 394 -o build/bin/""" + target_binary 395 396 libbirdgems = Builder('libbirdgems', 397 valac_command, 398 cc_command, 399 linker_command, 400 target_binary, 401 'libbirdgems.so') 402 403 yield libbirdgems.build() 404 405 def task_libbirdgems(): 406 yield make_libbirdgems('libbirdgems.so.' + version.LIBBIRDGEMS_SO_VERSION_MAJOR) 407 408 def task_compile_translations (): 409 """translate po files""" 410 return { 411 'actions': [compile_translations] 412 } 413 414 def task_man(): 415 """gzip linux man pages""" 416 for name in ("birdfont.1", "birdfont-export.1", 417 "birdfont-import.1", "birdfont-autotrace.1"): 418 yield { 419 'name': name, 420 'file_dep': ['resources/linux/%s' % name], 421 'targets': ['build/%s.gz' % name], 422 'actions': ["gzip -9 -c %(dependencies)s > %(targets)s"], 423 } 424 425 def task_distclean (): 426 return { 427 'actions': ['rm -rf .doit.db build scripts/config.py scripts/*.pyc dodo.pyc libbirdfont/Config.vala'], 428 } 429 430 def task_build (): 431 if not os.path.exists ("build/configured"): 432 print ("Project is not configured") 433 exit (1) 434 435 subprocess.check_output ('mkdir -p build', shell=True) 436 subprocess.check_output ('touch build/installed', shell=True) 437 438 return { 439 'actions': ['echo "Build"'], 440 } 441