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