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