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