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 1.9
1 """ 2 Copyright (C) 2012, 2013, 2014 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 22 from optparse import OptionParser 23 from doit.tools import run_once 24 from doit.action import CmdAction 25 from scripts.bavala import Vala 26 from scripts import version 27 from scripts.translations import compile_translations 28 from scripts import config 29 30 DOIT_CONFIG = { 31 'default_tasks': [ 32 'build', 33 'libbirdxml', 34 'libbirdfont', 35 'birdfont', 36 'birdfont_autotrace', 37 'birdfont_export', 38 'birdfont_import', 39 'compile_translations', 40 'man' 41 ], 42 } 43 44 # external Vala libs 45 LIBS = [ 46 'glib-2.0', 47 'gio-2.0', 48 'cairo', 49 'gdk-pixbuf-2.0', 50 'webkitgtk-3.0', 51 config.GEE, 52 'libnotify' 53 ] 54 55 if not config.POSIXVALA: 56 LIBBIRD_XML_LIBS = [ 57 'glib-2.0', 58 'posix' 59 ] 60 else: 61 LIBBIRD_XML_LIBS = [ 62 'posix', 63 'posixtypes' 64 ] 65 66 def task_build (): 67 if not os.path.exists ("build/configured"): 68 print ("Project is not configured") 69 exit (1) 70 71 subprocess.check_output ('mkdir -p build', shell=True) 72 subprocess.check_output ('touch build/installed', shell=True) 73 74 return { 75 'actions': ['echo "Build"'], 76 } 77 78 def task_pkg_flags(): 79 """get compiler flags for libs/pkgs """ 80 for pkg in LIBS: 81 cmd = 'pkg-config --cflags --libs {pkg}' 82 83 yield { 84 'name': pkg, 85 'actions': [CmdAction(cmd.format(pkg=pkg), save_out='out')], 86 'uptodate': [run_once], 87 } 88 89 90 valac_options = [ 91 '--enable-experimental-non-null', 92 '--enable-experimental', 93 '--target-glib=2.34', # see bug 0000004 94 '--define=LINUX' 95 ] 96 97 libbirdxml = Vala(src='libbirdxml', build='build', library='birdxml', so_version=version.LIBBIRDXML_SO_VERSION, pkg_libs=LIBBIRD_XML_LIBS) 98 def task_libbirdxml(): 99 100 if config.POSIXVALA: 101 yield libbirdxml.gen_c(valac_options + ['--profile posix']) 102 else: 103 yield libbirdxml.gen_c(valac_options) 104 105 yield libbirdxml.gen_o(['-fPIC']) 106 yield libbirdxml.gen_so() 107 yield libbirdxml.gen_ln() 108 109 110 libbird = Vala(src='libbirdfont', build='build', library='birdfont', so_version=version.SO_VERSION, pkg_libs=LIBS, vala_deps=[libbirdxml]) 111 def task_libbirdfont(): 112 yield libbird.gen_c(valac_options) 113 yield libbird.gen_o(['-fPIC -I./build/', """-D 'GETTEXT_PACKAGE="birdfont"'"""]) 114 yield libbird.gen_so('-l birdxml') 115 yield libbird.gen_ln() 116 117 118 def task_birdfont(): 119 bird = Vala(src='birdfont', build='build', pkg_libs=LIBS, vala_deps=[libbird, libbirdxml]) 120 yield bird.gen_c(valac_options) 121 yield bird.gen_bin(["""-D 'GETTEXT_PACKAGE="birdfont"' """]) 122 123 124 def task_birdfont_autotrace(): 125 exp = Vala(src='birdfont-autotrace', build='build', pkg_libs=LIBS, vala_deps=[libbird, libbirdxml]) 126 yield exp.gen_c(valac_options) 127 yield exp.gen_bin(["""-D 'GETTEXT_PACKAGE="birdfont"' """]) 128 129 130 def task_birdfont_export(): 131 exp = Vala(src='birdfont-export', build='build', pkg_libs=LIBS, vala_deps=[libbird, libbirdxml]) 132 yield exp.gen_c(valac_options) 133 yield exp.gen_bin(["""-D 'GETTEXT_PACKAGE="birdfont"' """]) 134 135 136 def task_birdfont_import(): 137 exp = Vala(src='birdfont-import', build='build', pkg_libs=LIBS, vala_deps=[libbird, libbirdxml]) 138 yield exp.gen_c(valac_options) 139 yield exp.gen_bin(["""-D 'GETTEXT_PACKAGE="birdfont"' """]) 140 141 142 143 144 145 def task_compile_translations (): 146 """translate po files""" 147 return { 148 'actions': [compile_translations] 149 } 150 151 def task_man(): 152 """gzip linux man pages""" 153 for name in ("birdfont.1", "birdfont-export.1", 154 "birdfont-import.1", "birdfont-autotrace.1"): 155 yield { 156 'name': name, 157 'file_dep': ['resources/linux/%s' % name], 158 'targets': ['build/%s.gz' % name], 159 'actions': ["gzip -9 -c %(dependencies)s > %(targets)s"], 160 } 161 162 163 def task_distclean (): 164 return { 165 'actions': ['rm -rf .doit.db build scripts/config.py scripts/*.pyc dodo.pyc libbirdfont/Config.vala'], 166 } 167 168