1 # -*- coding: utf-8 -*-
3 # WAF build script - this file is part of Geany, a fast and lightweight IDE
5 # Copyright 2008-2012 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
6 # Copyright 2008-2012 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 This is a WAF build script (http://code.google.com/p/waf/).
24 It can be used as an alternative build system to autotools
25 for Geany. It does not (yet) cover all of the autotools tests and
26 configure options but all important things are working.
27 "make dist" should be done with autotools, most other targets and
28 functions should work better (regarding performance and flexibility)
31 Missing features: --enable-binreloc, make targets: dist, pdf (in doc/)
32 Known issues: Dependency handling is buggy, e.g. if src/document.h is
33 changed, depending source files are not rebuilt (maybe Waf bug).
35 The code of this file itself loosely follows PEP 8 with some exceptions
36 (line width 100 characters and some other minor things).
38 Requires WAF 1.6.1 and Python 2.5 (or later).
45 from waflib import Logs, Options, Scripting, Utils
46 from waflib.Configure import ConfigurationContext
47 from waflib.Errors import WafError
48 from waflib.TaskGen import feature
53 LINGUAS_FILE = 'po/LINGUAS'
54 MINIMUM_GTK_VERSION = '2.16.0'
55 MINIMUM_GLIB_VERSION = '2.20.0'
61 mio_sources = set(['tagmanager/mio/mio.c'])
64 'tagmanager/ctags/args.c',
65 'tagmanager/ctags/abc.c',
66 'tagmanager/ctags/actionscript.c',
67 'tagmanager/ctags/asciidoc.c',
68 'tagmanager/ctags/asm.c',
69 'tagmanager/ctags/basic.c',
70 'tagmanager/ctags/c.c',
71 'tagmanager/ctags/cobol.c',
72 'tagmanager/ctags/conf.c',
73 'tagmanager/ctags/css.c',
74 'tagmanager/ctags/ctags.c',
75 'tagmanager/ctags/diff.c',
76 'tagmanager/ctags/docbook.c',
77 'tagmanager/ctags/entry.c',
78 'tagmanager/ctags/fortran.c',
79 'tagmanager/ctags/get.c',
80 'tagmanager/ctags/haskell.c',
81 'tagmanager/ctags/haxe.c',
82 'tagmanager/ctags/html.c',
83 'tagmanager/ctags/js.c',
84 'tagmanager/ctags/keyword.c',
85 'tagmanager/ctags/latex.c',
86 'tagmanager/ctags/lregex.c',
87 'tagmanager/ctags/lua.c',
88 'tagmanager/ctags/make.c',
89 'tagmanager/ctags/markdown.c',
90 'tagmanager/ctags/matlab.c',
91 'tagmanager/ctags/nsis.c',
92 'tagmanager/ctags/nestlevel.c',
93 'tagmanager/ctags/objc.c',
94 'tagmanager/ctags/options.c',
95 'tagmanager/ctags/parse.c',
96 'tagmanager/ctags/pascal.c',
97 'tagmanager/ctags/r.c',
98 'tagmanager/ctags/perl.c',
99 'tagmanager/ctags/php.c',
100 'tagmanager/ctags/python.c',
101 'tagmanager/ctags/read.c',
102 'tagmanager/ctags/rest.c',
103 'tagmanager/ctags/ruby.c',
104 'tagmanager/ctags/sh.c',
105 'tagmanager/ctags/sort.c',
106 'tagmanager/ctags/sql.c',
107 'tagmanager/ctags/strlist.c',
108 'tagmanager/ctags/txt2tags.c',
109 'tagmanager/ctags/tcl.c',
110 'tagmanager/ctags/vhdl.c',
111 'tagmanager/ctags/verilog.c',
112 'tagmanager/ctags/vstring.c'])
114 tagmanager_sources = set([
115 'tagmanager/src/tm_file_entry.c',
116 'tagmanager/src/tm_project.c',
117 'tagmanager/src/tm_source_file.c',
118 'tagmanager/src/tm_symbol.c',
119 'tagmanager/src/tm_tag.c',
120 'tagmanager/src/tm_tagmanager.c',
121 'tagmanager/src/tm_work_object.c',
122 'tagmanager/src/tm_workspace.c'])
124 scintilla_sources = set(['scintilla/gtk/scintilla-marshal.c'])
126 geany_sources = set([
127 'src/about.c', 'src/build.c', 'src/callbacks.c', 'src/dialogs.c', 'src/document.c',
128 'src/editor.c', 'src/encodings.c', 'src/filetypes.c', 'src/geanyentryaction.c',
129 'src/geanymenubuttonaction.c', 'src/geanyobject.c', 'src/geanywraplabel.c',
130 'src/highlighting.c', 'src/keybindings.c',
131 'src/keyfile.c', 'src/log.c', 'src/main.c', 'src/msgwindow.c', 'src/navqueue.c', 'src/notebook.c',
132 'src/plugins.c', 'src/pluginutils.c', 'src/prefix.c', 'src/prefs.c', 'src/printing.c', 'src/project.c',
133 'src/sciwrappers.c', 'src/search.c', 'src/socket.c', 'src/stash.c',
135 'src/templates.c', 'src/toolbar.c', 'src/tools.c', 'src/sidebar.c',
136 'src/ui_utils.c', 'src/utils.c'])
139 'hicolor/16x16/apps': ['16x16/classviewer-class.png',
140 '16x16/classviewer-macro.png',
141 '16x16/classviewer-member.png',
142 '16x16/classviewer-method.png',
143 '16x16/classviewer-namespace.png',
144 '16x16/classviewer-other.png',
145 '16x16/classviewer-struct.png',
146 '16x16/classviewer-var.png',
148 'hicolor/16x16/actions': ['16x16/geany-build.png',
149 '16x16/geany-close-all.png',
150 '16x16/geany-save-all.png'],
151 'hicolor/24x24/actions': ['24x24/geany-build.png',
152 '24x24/geany-close-all.png',
153 '24x24/geany-save-all.png'],
154 'hicolor/32x32/actions': ['32x32/geany-build.png',
155 '32x32/geany-close-all.png',
156 '32x32/geany-save-all.png'],
157 'hicolor/48x48/actions': ['48x48/geany-build.png',
158 '48x48/geany-close-all.png',
159 '48x48/geany-save-all.png'],
160 'hicolor/48x48/apps': ['48x48/geany.png'],
161 'hicolor/scalable/apps': ['scalable/geany.svg'],
162 'hicolor/scalable/actions': ['scalable/geany-build.svg',
163 'scalable/geany-close-all.svg',
164 'scalable/geany-save-all.svg'],
165 'Tango/16x16/actions': ['tango/16x16/geany-save-all.png'],
166 'Tango/24x24/actions': ['tango/24x24/geany-save-all.png'],
167 'Tango/32x32/actions': ['tango/32x32/geany-save-all.png'],
168 'Tango/48x48/actions': ['tango/48x48/geany-save-all.png'],
169 'Tango/scalable/actions': ['tango/scalable/geany-save-all.svg']
171 geany_icons_indexes = {
172 'hicolor': ['index.theme'],
173 'Tango': ['tango/index.theme']
179 conf.check_waf_version(mini='1.6.1')
181 conf.load('compiler_c')
182 is_win32 = _target_is_win32(conf)
184 conf.check_cc(header_name='fcntl.h', mandatory=False)
185 conf.check_cc(header_name='fnmatch.h', mandatory=False)
186 conf.check_cc(header_name='glob.h', mandatory=False)
187 conf.check_cc(header_name='sys/time.h', mandatory=False)
188 conf.check_cc(header_name='sys/types.h', mandatory=False)
189 conf.check_cc(header_name='sys/stat.h', mandatory=False)
190 conf.define('HAVE_STDLIB_H', 1) # are there systems without stdlib.h?
191 conf.define('STDC_HEADERS', 1) # an optimistic guess ;-)
192 _add_to_env_and_define(conf, 'HAVE_REGCOMP', 1) # needed for CTags
194 conf.check_cc(function_name='fgetpos', header_name='stdio.h', mandatory=False)
195 conf.check_cc(function_name='ftruncate', header_name='unistd.h', mandatory=False)
196 conf.check_cc(function_name='gethostname', header_name='unistd.h', mandatory=False)
197 conf.check_cc(function_name='mkstemp', header_name='stdlib.h', mandatory=False)
198 conf.check_cc(function_name='strstr', header_name='string.h')
200 # check sunOS socket support
201 if Options.platform == 'sunos':
202 conf.check_cc(function_name='socket', lib='socket',
203 header_name='sys/socket.h', uselib_store='SUNOS_SOCKET', mandatory=True)
205 # check for cxx after the header and function checks have been done to ensure they are
206 # checked with cc not cxx
207 conf.load('compiler_cxx')
210 _load_intltool_if_available(conf)
212 # GTK / GIO version check
213 conf.check_cfg(package='gtk+-2.0', atleast_version=MINIMUM_GTK_VERSION, uselib_store='GTK',
214 mandatory=True, args='--cflags --libs')
215 conf.check_cfg(package='glib-2.0', atleast_version=MINIMUM_GLIB_VERSION, uselib_store='GLIB',
216 mandatory=True, args='--cflags --libs')
217 conf.check_cfg(package='gmodule-2.0', uselib_store='GMODULE',
218 mandatory=True, args='--cflags --libs')
219 conf.check_cfg(package='gio-2.0', uselib_store='GIO', args='--cflags --libs', mandatory=True)
220 gtk_version = conf.check_cfg(modversion='gtk+-2.0', uselib_store='GTK') or 'Unknown'
221 conf.check_cfg(package='gthread-2.0', uselib_store='GTHREAD', args='--cflags --libs')
225 if conf.env['PREFIX'].lower() == tempfile.gettempdir().lower():
226 # overwrite default prefix on Windows (tempfile.gettempdir() is the Waf default)
227 new_prefix = os.path.join(str(conf.root), '%s-%s' % (APPNAME, VERSION))
228 _add_to_env_and_define(conf, 'PREFIX', new_prefix, quote=True)
229 _add_to_env_and_define(conf, 'BINDIR', os.path.join(new_prefix, 'bin'), quote=True)
230 _add_to_env_and_define(conf, 'DOCDIR', os.path.join(conf.env['PREFIX'], 'doc'), quote=True)
231 _add_to_env_and_define(conf, 'LIBDIR', conf.env['PREFIX'], quote=True)
232 conf.define('LOCALEDIR', os.path.join('share' 'locale'), quote=True)
233 # overwrite LOCALEDIR to install message catalogues properly
234 conf.env['LOCALEDIR'] = os.path.join(conf.env['PREFIX'], 'share/locale')
235 # DATADIR is defined in objidl.h, so we remove it from config.h but keep it in env
236 conf.undefine('DATADIR')
237 conf.env['DATADIR'] = os.path.join(conf.env['PREFIX'], 'data')
238 conf.env.append_value('LINKFLAGS_cprogram', ['-mwindows'])
239 conf.env.append_value('LIB_WIN32', ['wsock32', 'uuid', 'ole32', 'iberty'])
241 conf.env['cshlib_PATTERN'] = '%s.so'
242 # DATADIR and LOCALEDIR are defined by the intltool tool
243 # but they are not added to the environment, so we need to
244 _add_define_to_env(conf, 'DATADIR')
245 _add_define_to_env(conf, 'LOCALEDIR')
246 docdir = os.path.join(conf.env['DATADIR'], 'doc', 'geany')
247 libdir = os.path.join(conf.env['PREFIX'], 'lib')
248 mandir = os.path.join(conf.env['DATADIR'], 'man')
249 _define_from_opt(conf, 'DOCDIR', conf.options.docdir, docdir)
250 _define_from_opt(conf, 'LIBDIR', conf.options.libdir, libdir)
251 _define_from_opt(conf, 'MANDIR', conf.options.mandir, mandir)
253 revision = _get_git_rev(conf)
255 conf.define('ENABLE_NLS', 1)
256 conf.define('GEANY_LOCALEDIR', '' if is_win32 else conf.env['LOCALEDIR'], quote=True)
257 conf.define('GEANY_DATADIR', 'data' if is_win32 else conf.env['DATADIR'], quote=True)
258 conf.define('GEANY_DOCDIR', conf.env['DOCDIR'], quote=True)
259 conf.define('GEANY_LIBDIR', '' if is_win32 else conf.env['LIBDIR'], quote=True)
260 conf.define('GEANY_PREFIX', '' if is_win32 else conf.env['PREFIX'], quote=True)
261 conf.define('PACKAGE', APPNAME, quote=True)
262 conf.define('VERSION', VERSION, quote=True)
263 conf.define('REVISION', revision or '-1', quote=True)
265 conf.define('GETTEXT_PACKAGE', APPNAME, quote=True)
269 conf.options.no_vte = True
271 _define_from_opt(conf, 'HAVE_PLUGINS', not conf.options.no_plugins, None)
272 _define_from_opt(conf, 'HAVE_SOCKET', not conf.options.no_socket, None)
273 _define_from_opt(conf, 'HAVE_VTE', not conf.options.no_vte, None)
275 conf.write_config_header('config.h', remove=False)
277 # some more compiler flags
278 conf.env.append_value('CFLAGS', ['-DHAVE_CONFIG_H'])
279 if revision is not None:
280 conf.env.append_value('CFLAGS', ['-g', '-DGEANY_DEBUG'])
282 conf.env.append_value('CFLAGS', ['-DGTK'])
283 conf.env.append_value('CXXFLAGS',
284 ['-DNDEBUG', '-DGTK', '-DSCI_LEXER', '-DG_THREADS_IMPL_NONE'])
287 Logs.pprint('BLUE', 'Summary:')
288 conf.msg('Install Geany ' + VERSION + ' in', conf.env['PREFIX'])
289 conf.msg('Using GTK version', gtk_version)
290 conf.msg('Build with plugin support', conf.options.no_plugins and 'no' or 'yes')
291 conf.msg('Use virtual terminal support', conf.options.no_vte and 'no' or 'yes')
292 if revision is not None:
293 conf.msg('Compiling Git revision', revision)
297 opt.tool_options('compiler_cc')
298 opt.tool_options('compiler_cxx')
299 opt.tool_options('intltool')
302 opt.add_option('--disable-plugins', action='store_true', default=False,
303 help='compile without plugin support [default: No]', dest='no_plugins')
304 opt.add_option('--disable-socket', action='store_true', default=False,
305 help='compile without support to detect a running instance [[default: No]',
307 opt.add_option('--disable-vte', action='store_true', default=False,
308 help='compile without support for an embedded virtual terminal [[default: No]',
311 opt.add_option('--mandir', type='string', default='',
312 help='man documentation', dest='mandir')
313 opt.add_option('--docdir', type='string', default='',
314 help='documentation root', dest='docdir')
315 opt.add_option('--libdir', type='string', default='',
316 help='object code libraries', dest='libdir')
318 opt.add_option('--hackingdoc', action='store_true', default=False,
319 help='generate HTML documentation from HACKING file', dest='hackingdoc')
323 is_win32 = _target_is_win32(bld)
325 if bld.cmd == 'clean':
326 _remove_linguas_file()
327 if bld.cmd in ('install', 'uninstall'):
328 bld.add_post_fun(_post_install)
330 def build_plugin(plugin_name, install=True):
332 instpath = '${PREFIX}/lib' if is_win32 else '${LIBDIR}/geany'
337 features = ['c', 'cshlib'],
338 source = 'plugins/%s.c' % plugin_name,
339 includes = ['.', 'src/', 'scintilla/include', 'tagmanager/src'],
340 defines = 'G_LOG_DOMAIN="%s"' % plugin_name,
341 target = plugin_name,
342 uselib = ['GTK', 'GLIB', 'GMODULE'],
343 install_path = instpath)
347 features = ['c', 'cstlib'],
348 source = ctags_sources,
351 includes = ['.', 'tagmanager', 'tagmanager/ctags'],
352 defines = 'G_LOG_DOMAIN="CTags"',
354 install_path = None) # do not install this library
358 features = ['c', 'cstlib'],
359 source = tagmanager_sources,
361 target = 'tagmanager',
362 includes = ['.', 'tagmanager', 'tagmanager/ctags'],
363 defines = 'G_LOG_DOMAIN="Tagmanager"',
364 uselib = ['GTK', 'GLIB'],
365 install_path = None) # do not install this library
369 features = ['c', 'cstlib'],
370 source = mio_sources,
373 includes = ['.', 'tagmanager/mio/'],
374 defines = 'G_LOG_DOMAIN="MIO"',
375 uselib = ['GTK', 'GLIB'],
376 install_path = None) # do not install this library
379 files = bld.srcnode.ant_glob('scintilla/**/*.cxx', src=True, dir=False)
380 scintilla_sources.update(files)
382 features = ['c', 'cxx', 'cxxstlib'],
384 target = 'scintilla',
385 source = scintilla_sources,
386 includes = ['.', 'scintilla/include', 'scintilla/src', 'scintilla/lexlib'],
387 uselib = ['GTK', 'GLIB', 'GMODULE'],
388 install_path = None) # do not install this library
391 if bld.env['HAVE_VTE'] == 1:
392 geany_sources.add('src/vte.c')
394 geany_sources.add('src/win32.c')
395 geany_sources.add('geany_private.rc')
398 features = ['c', 'cxx', 'cprogram'],
401 source = geany_sources,
402 includes = ['.', 'scintilla/include', 'tagmanager/src'],
403 defines = ['G_LOG_DOMAIN="Geany"', 'GEANY_PRIVATE'],
404 uselib = ['GTK', 'GLIB', 'GMODULE', 'GIO', 'GTHREAD', 'WIN32', 'SUNOS_SOCKET'],
405 use = ['scintilla', 'ctags', 'tagmanager', 'mio'])
409 source = ['plugins/genapi.py', 'src/plugins.c'],
410 name = 'geanyfunctions.h',
411 before = ['c', 'cxx'],
412 cwd = '%s/plugins' % bld.path.abspath(),
413 rule = '%s genapi.py -q' % sys.executable)
416 if bld.env['HAVE_PLUGINS'] == 1:
417 build_plugin('classbuilder')
418 build_plugin('demoplugin', False)
419 build_plugin('export')
420 build_plugin('filebrowser')
421 build_plugin('htmlchars')
422 build_plugin('saveactions')
423 build_plugin('splitwindow')
426 if bld.env['INTLTOOL']:
428 features = ['linguas', 'intltool_po'],
430 install_path = '${LOCALEDIR}',
435 source = 'geany.pc.in',
436 dct = {'VERSION': VERSION,
437 'DEPENDENCIES': 'gtk+-2.0 >= %s glib-2.0 >= %s' % \
438 (MINIMUM_GTK_VERSION, MINIMUM_GLIB_VERSION),
439 'prefix': bld.env['PREFIX'],
440 'exec_prefix': '${prefix}',
441 'libdir': '${exec_prefix}/lib',
442 'includedir': '${prefix}/include',
443 'datarootdir': '${prefix}/share',
444 'datadir': '${datarootdir}',
445 'localedir': '${datarootdir}/locale'})
449 if bld.env['INTLTOOL']:
451 features = 'intltool_in',
452 source = 'geany.desktop.in',
453 flags = ['-d', '-q', '-u', '-c'],
454 install_path = '${DATADIR}/applications')
459 source = 'doc/geany.1.in',
461 dct = {'VERSION': VERSION,
462 'GEANY_DATA_DIR': bld.env['DATADIR'] + '/geany'},
463 install_path = '${MANDIR}/man1')
468 source = 'geany.spec.in',
469 target = 'geany.spec',
471 dct = {'VERSION': VERSION})
476 source = 'doc/Doxyfile.in',
477 target = 'doc/Doxyfile',
479 dct = {'VERSION': VERSION})
486 bld.install_files('${PREFIX}/include/geany', '''
487 src/document.h src/editor.h src/encodings.h src/filetypes.h src/geany.h
488 src/highlighting.h src/keybindings.h src/msgwindow.h src/plugindata.h
489 src/prefs.h src/project.h src/search.h src/stash.h src/support.h
490 src/templates.h src/toolbar.h src/ui_utils.h src/utils.h src/build.h
491 plugins/geanyplugin.h plugins/geanyfunctions.h''')
492 bld.install_files('${PREFIX}/include/geany/scintilla', '''
493 scintilla/include/SciLexer.h scintilla/include/Scintilla.h
494 scintilla/include/Scintilla.iface scintilla/include/ScintillaWidget.h ''')
495 bld.install_files('${PREFIX}/include/geany/tagmanager', '''
496 tagmanager/src/tm_file_entry.h tagmanager/src/tm_project.h
497 tagmanager/src/tm_source_file.h
498 tagmanager/src/tm_symbol.h tagmanager/src/tm_tag.h
499 tagmanager/src/tm_tagmanager.h tagmanager/src/tm_work_object.h
500 tagmanager/src/tm_workspace.h ''')
502 base_dir = '${PREFIX}' if is_win32 else '${DOCDIR}'
503 ext = '.txt' if is_win32 else ''
504 html_dir = '' if is_win32 else 'html/'
505 html_name = 'Manual.html' if is_win32 else 'index.html'
506 for filename in 'AUTHORS ChangeLog COPYING README NEWS THANKS TODO'.split():
507 basename = _uc_first(filename, bld)
508 destination_filename = '%s%s' % (basename, ext)
509 destination = os.path.join(base_dir, destination_filename)
510 bld.install_as(destination, filename)
512 start_dir = bld.path.find_dir('doc/images')
513 bld.install_files('${DOCDIR}/%simages' % html_dir, start_dir.ant_glob('*.png'), cwd=start_dir)
514 bld.install_as('${DOCDIR}/%s' % _uc_first('manual.txt', bld), 'doc/geany.txt')
515 bld.install_as('${DOCDIR}/%s%s' % (html_dir, html_name), 'doc/geany.html')
516 bld.install_as('${DOCDIR}/ScintillaLicense.txt', 'scintilla/License.txt')
518 bld.install_as('${DOCDIR}/ReadMe.I18n.txt', 'README.I18N')
519 bld.install_as('${DOCDIR}/Hacking.txt', 'HACKING')
521 data_dir = '' if is_win32 else 'geany'
522 start_dir = bld.path.find_dir('data')
523 bld.install_as('${DATADIR}/%s/GPL-2' % data_dir, 'COPYING')
524 bld.install_files('${DATADIR}/%s' % data_dir, start_dir.ant_glob('filetype*'), cwd=start_dir)
525 bld.install_files('${DATADIR}/%s' % data_dir, start_dir.ant_glob('*.tags'), cwd=start_dir)
526 bld.install_files('${DATADIR}/%s' % data_dir, 'data/geany.glade')
527 bld.install_files('${DATADIR}/%s' % data_dir, 'data/geany.gtkrc')
528 bld.install_files('${DATADIR}/%s' % data_dir, 'data/snippets.conf')
529 bld.install_files('${DATADIR}/%s' % data_dir, 'data/ui_toolbar.xml')
530 start_dir = bld.path.find_dir('data/colorschemes')
531 template_dest = '${DATADIR}/%s/colorschemes' % data_dir
532 bld.install_files(template_dest, start_dir.ant_glob('*'), cwd=start_dir)
533 start_dir = bld.path.find_dir('data/templates')
534 template_dest = '${DATADIR}/%s/templates' % data_dir
535 bld.install_files(template_dest, start_dir.ant_glob('**/*'), cwd=start_dir, relative_trick=True)
537 for dest, srcs in geany_icons.items():
538 dest_dir = os.path.join('${PREFIX}/share/icons' if is_win32 else '${DATADIR}/icons', dest)
539 bld.install_files(dest_dir, srcs, cwd=bld.path.find_dir('icons'))
540 # install theme indexes on Windows
542 for dest, srcs in geany_icons_indexes.items():
543 bld.install_files(os.path.join('${PREFIX}/share/icons', dest), srcs, cwd=bld.path.find_dir('icons'))
547 Scripting.distclean(ctx)
548 _remove_linguas_file()
551 def _remove_linguas_file():
552 # remove LINGUAS file as well
554 os.unlink(LINGUAS_FILE)
560 def write_linguas_file(self):
561 if os.path.exists(LINGUAS_FILE):
564 if 'LINGUAS' in self.env:
565 files = self.env['LINGUAS']
566 for po_filename in files.split(' '):
567 if os.path.exists('po/%s.po' % po_filename):
568 linguas += '%s ' % po_filename
570 files = os.listdir('%s/po' % self.path.abspath())
572 for filename in files:
573 if filename.endswith('.po'):
574 linguas += '%s ' % filename[:-3]
575 file_h = open(LINGUAS_FILE, 'w')
576 file_h.write('# This file is autogenerated. Do not edit.\n%s\n' % linguas)
580 def _post_install(ctx):
581 is_win32 = _target_is_win32(ctx)
584 for d in 'hicolor', 'Tango':
585 theme_dir = Utils.subst_vars('${DATADIR}/icons/' + d, ctx.env)
586 icon_cache_updated = False
587 if not ctx.options.destdir:
588 ctx.exec_command('gtk-update-icon-cache -q -f -t %s' % theme_dir)
589 Logs.pprint('GREEN', 'GTK icon cache updated.')
590 icon_cache_updated = True
591 if not icon_cache_updated:
592 Logs.pprint('YELLOW', 'Icon cache not updated. After install, run this:')
593 Logs.pprint('YELLOW', 'gtk-update-icon-cache -q -f -t %s' % theme_dir)
597 """update the message catalogs for internationalization"""
598 potfile = '%s.pot' % APPNAME
599 os.chdir('%s/po' % top)
602 old_size = os.stat(potfile).st_size
605 ctx.exec_command('intltool-update --pot -g %s' % APPNAME)
606 size_new = os.stat(potfile).st_size
607 if size_new != old_size:
608 Logs.pprint('CYAN', 'Updated POT file.')
609 Logs.pprint('CYAN', 'Updating translations')
610 ret = ctx.exec_command('intltool-update -r -g %s' % APPNAME)
612 Logs.pprint('RED', 'Updating translations failed')
614 Logs.pprint('CYAN', 'POT file is up to date.')
616 Logs.pprint('RED', 'Failed to generate pot file.')
620 """generate API reference documentation"""
621 basedir = ctx.path.abspath()
622 doxygen = _find_program(ctx, 'doxygen')
623 doxyfile = '%s/%s/doc/Doxyfile' % (basedir, out)
625 Logs.pprint('CYAN', 'Generating API documentation')
626 ret = ctx.exec_command('%s %s' % (doxygen, doxyfile))
628 raise WafError('Generating API documentation failed')
629 # update hacking.html
630 cmd = _find_rst2html(ctx)
631 ctx.exec_command('%s -stg --stylesheet=geany.css %s %s' % (cmd, '../HACKING', 'hacking.html'))
636 """generate HTML documentation"""
637 # first try rst2html.py as it is the upstream default, fall back to rst2html
638 cmd = _find_rst2html(ctx)
640 Logs.pprint('CYAN', 'Generating HTML documentation')
641 ctx.exec_command('%s -stg --stylesheet=geany.css %s %s' % (cmd, 'geany.txt', 'geany.html'))
645 def _find_program(ctx, cmd, **kw):
649 ctx = ConfigurationContext()
652 return ctx.find_program(cmd, **kw)
655 def _find_rst2html(ctx):
656 cmds = ['rst2html.py', 'rst2html']
658 cmd = _find_program(ctx, command, mandatory=False)
663 'rst2html.py could not be found. Please install the Python docutils package.')
667 def _add_define_to_env(conf, key):
668 value = conf.get_define(key)
670 value = value.replace('"', '')
671 conf.env[key] = value
674 def _add_to_env_and_define(conf, key, value, quote=False):
675 conf.define(key, value, quote)
676 conf.env[key] = value
679 def _define_from_opt(conf, define_name, opt_value, default_value, quote=1):
680 value = default_value
682 if isinstance(opt_value, bool):
686 if value is not None:
687 _add_to_env_and_define(conf, define_name, value, quote)
689 conf.undefine(define_name)
692 def _get_git_rev(conf):
693 if not os.path.isdir('.git'):
697 cmd = 'git rev-parse --short --revs-only HEAD'
698 revision = conf.cmd_and_log(cmd).strip()
705 def _load_intltool_if_available(conf):
707 conf.check_tool('intltool')
708 if 'LINGUAS' in os.environ:
709 conf.env['LINGUAS'] = os.environ['LINGUAS']
711 # on Windows, we don't hard depend on intltool, on all other platforms raise an error
712 if not _target_is_win32(conf):
716 def _target_is_win32(ctx):
717 if 'is_win32' in ctx.env:
719 return ctx.env['is_win32']
721 if sys.platform == 'win32':
724 if ctx.env and 'CC' in ctx.env:
725 env_cc = ctx.env['CC']
726 if not isinstance(env_cc, str):
727 env_cc = ''.join(env_cc)
728 is_win32 = (env_cc.find('mingw') != -1)
731 # cache for future checks
732 ctx.env['is_win32'] = is_win32
736 def _uc_first(string, ctx):
737 if _target_is_win32(ctx):
738 return string.title()