.
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 'libbirdfont',
36 'birdfont',
37 'birdfont_autotrace',
38 'birdfont_export',
39 'birdfont_import',
40 'compile_translations',
41 'man'
42 ],
43 }
44
45 # external Vala libs
46 LIBS = [
47 'sqlite3',
48 'glib-2.0',
49 'gio-2.0',
50 'fontconfig',
51 'cairo',
52 'gdk-pixbuf-2.0',
53 'webkitgtk-3.0',
54 config.GEE,
55 'libnotify',
56 'xmlbird'
57 ]
58
59 LIBBIRD_LIBS = [
60 'glib-2.0'
61 ]
62
63 def task_build ():
64 if not os.path.exists ("build/configured"):
65 print ("Project is not configured")
66 exit (1)
67
68 subprocess.check_output ('mkdir -p build', shell=True)
69 subprocess.check_output ('touch build/installed', shell=True)
70
71 return {
72 'actions': ['echo "Build"'],
73 }
74
75 def task_pkg_flags():
76 """get compiler flags for libs/pkgs """
77 for pkg in LIBS:
78 cmd = 'pkg-config --cflags --libs {pkg}'
79
80 yield {
81 'name': pkg,
82 'actions': [CmdAction(cmd.format(pkg=pkg), save_out='out')],
83 'uptodate': [run_once],
84 }
85
86
87 valac_options = [
88 '--thread',
89 '--enable-experimental-non-null',
90 '--enable-experimental',
91 '--target-glib=2.34', # see bug 0000004
92 '--define=LINUX'
93 ]
94
95
96 if "bsd" in sys.platform:
97 LIBBIRDGEMS_SO_VERSION='${LIBbirdgems_VERSION}'
98 else:
99 LIBBIRDGEMS_SO_VERSION=version.LIBBIRDGEMS_SO_VERSION
100
101 libbirdgems = Vala(src='libbirdgems', build='build', library='birdgems', so_version=LIBBIRDGEMS_SO_VERSION, pkg_libs=LIBBIRD_LIBS, vala_deps=[])
102 def task_libbirdgems():
103 yield libbirdgems.gen_c(valac_options)
104 yield libbirdgems.gen_o(['-fPIC'])
105 yield libbirdgems.gen_so('-shared -L ./build -l m')
106 yield libbirdgems.gen_ln()
107
108 if "bsd" in sys.platform:
109 SO_VERSION='${LIBbirdfont_VERSION}'
110 else:
111 SO_VERSION=version.SO_VERSION
112
113 libbird = Vala(src='libbirdfont', build='build', library='birdfont', so_version=SO_VERSION, pkg_libs=LIBS, vala_deps=[libbirdgems])
114 def task_libbirdfont():
115 yield libbird.gen_c(valac_options)
116 yield libbird.gen_o(['-fPIC -I./build/', """-D 'GETTEXT_PACKAGE="birdfont"'"""])
117 yield libbird.gen_so('-L ./build -l birdxml -L ./build -l birdgems')
118 yield libbird.gen_ln()
119
120
121 def task_birdfont():
122 bird = Vala(src='birdfont', build='build', pkg_libs=LIBS, vala_deps=[libbird, libbirdgems])
123 yield bird.gen_c(valac_options)
124 yield bird.gen_bin(["""-D 'GETTEXT_PACKAGE="birdfont"' """])
125
126
127 def task_birdfont_autotrace():
128 exp = Vala(src='birdfont-autotrace', build='build', pkg_libs=LIBS, vala_deps=[libbird, libbirdgems])
129 yield exp.gen_c(valac_options)
130 yield exp.gen_bin(["""-D 'GETTEXT_PACKAGE="birdfont"' """])
131
132
133 def task_birdfont_export():
134 exp = Vala(src='birdfont-export', build='build', pkg_libs=LIBS, vala_deps=[libbird, libbirdgems])
135 yield exp.gen_c(valac_options)
136 yield exp.gen_bin(["""-D 'GETTEXT_PACKAGE="birdfont"' """])
137
138
139 def task_birdfont_import():
140 exp = Vala(src='birdfont-import', build='build', pkg_libs=LIBS, vala_deps=[libbird, libbirdgems])
141 yield exp.gen_c(valac_options)
142 yield exp.gen_bin(["""-D 'GETTEXT_PACKAGE="birdfont"' """])
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