Add missing header include.
[geany-mirror.git] / wscript
blob1fa20ed30f5ace1a0e0a4c51d3d2d4cda32463cd
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
4 # WAF build script - this file is part of Geany, a fast and lightweight IDE
6 # Copyright 2008-2009 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
7 # Copyright 2008-2009 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 # $Id$
25 """
26 This is a WAF build script (http://code.google.com/p/waf/).
27 It can be used as an alternative build system to autotools
28 for Geany. It does not (yet) cover all of the autotools tests and
29 configure options but all important things are working.
30 "make dist" should be done with autotools, most other targets and
31 functions should work better (regarding performance and flexibility)
32 or at least equally.
34 Missing features: --enable-binreloc, make targets: dist, pdf (in doc/)
35 Known issues: Dependency handling is buggy, e.g. if src/document.h is
36 changed, depending source files are not rebuilt (maybe Waf bug).
38 Requires WAF 1.5.7 and Python 2.4 (or later).
39 """
42 import Build, Configure, Options, Utils
43 import sys, os, shutil, tempfile
44 from distutils import version
47 APPNAME = 'geany'
48 VERSION = '0.18'
50 srcdir = '.'
51 blddir = '_build_'
54 tagmanager_sources = [
55 'tagmanager/args.c', 'tagmanager/actionscript.c', 'tagmanager/asm.c',
56 'tagmanager/basic.c', 'tagmanager/c.c',
57 'tagmanager/conf.c', 'tagmanager/css.c', 'tagmanager/ctags.c', 'tagmanager/diff.c',
58 'tagmanager/docbook.c', 'tagmanager/entry.c', 'tagmanager/fortran.c', 'tagmanager/get.c',
59 'tagmanager/haskell.c', 'tagmanager/haxe.c', 'tagmanager/html.c', 'tagmanager/js.c',
60 'tagmanager/keyword.c', 'tagmanager/latex.c', 'tagmanager/lregex.c', 'tagmanager/lua.c',
61 'tagmanager/make.c', 'tagmanager/matlab.c', 'tagmanager/nsis.c',
62 'tagmanager/nestlevel.c', 'tagmanager/options.c',
63 'tagmanager/parse.c', 'tagmanager/pascal.c',
64 'tagmanager/perl.c', 'tagmanager/php.c', 'tagmanager/python.c', 'tagmanager/read.c',
65 'tagmanager/rest.c', 'tagmanager/ruby.c', 'tagmanager/sh.c', 'tagmanager/sort.c',
66 'tagmanager/sql.c', 'tagmanager/strlist.c', 'tagmanager/tcl.c', 'tagmanager/tm_file_entry.c',
67 'tagmanager/tm_project.c', 'tagmanager/tm_source_file.c', 'tagmanager/tm_symbol.c',
68 'tagmanager/tm_tag.c', 'tagmanager/tm_tagmanager.c', 'tagmanager/tm_work_object.c',
69 'tagmanager/tm_workspace.c', 'tagmanager/vhdl.c', 'tagmanager/vstring.c' ]
71 scintilla_sources = [
72 'scintilla/AutoComplete.cxx', 'scintilla/CallTip.cxx', 'scintilla/CellBuffer.cxx',
73 'scintilla/CharClassify.cxx', 'scintilla/ContractionState.cxx', 'scintilla/Decoration.cxx',
74 'scintilla/DocumentAccessor.cxx', 'scintilla/Document.cxx', 'scintilla/Editor.cxx',
75 'scintilla/ExternalLexer.cxx', 'scintilla/Indicator.cxx', 'scintilla/KeyMap.cxx',
76 'scintilla/KeyWords.cxx', 'scintilla/LexAda.cxx', 'scintilla/LexAsm.cxx', 'scintilla/LexBash.cxx',
77 'scintilla/LexBasic.cxx', 'scintilla/LexCaml.cxx', 'scintilla/LexCmake.cxx', 'scintilla/LexCPP.cxx',
78 'scintilla/LexCrontab.cxx', 'scintilla/LexCSS.cxx', 'scintilla/LexD.cxx',
79 'scintilla/LexFortran.cxx', 'scintilla/LexHaskell.cxx', 'scintilla/LexHTML.cxx',
80 'scintilla/LexLua.cxx', 'scintilla/LexNsis.cxx', 'scintilla/LexOthers.cxx',
81 'scintilla/LexPascal.cxx', 'scintilla/LexPerl.cxx', 'scintilla/LexPython.cxx',
82 'scintilla/LexR.cxx', 'scintilla/LexMatlab.cxx', 'scintilla/LexYAML.cxx',
83 'scintilla/LexRuby.cxx', 'scintilla/LexSQL.cxx', 'scintilla/LexTCL.cxx',
84 'scintilla/LexVHDL.cxx', 'scintilla/LineMarker.cxx', 'scintilla/PerLine.cxx',
85 'scintilla/PlatGTK.cxx',
86 'scintilla/PositionCache.cxx', 'scintilla/PropSet.cxx', 'scintilla/RESearch.cxx',
87 'scintilla/RunStyles.cxx', 'scintilla/ScintillaBase.cxx', 'scintilla/ScintillaGTK.cxx',
88 'scintilla/scintilla-marshal.c', 'scintilla/StyleContext.cxx', 'scintilla/Style.cxx',
89 'scintilla/UniConversion.cxx', 'scintilla/ViewStyle.cxx', 'scintilla/WindowAccessor.cxx',
90 'scintilla/XPM.cxx' ]
92 geany_sources = [
93 'src/about.c', 'src/build.c', 'src/callbacks.c', 'src/dialogs.c', 'src/document.c',
94 'src/editor.c', 'src/encodings.c', 'src/filetypes.c', 'src/geanyentryaction.c',
95 'src/geanymenubuttonaction.c', 'src/geanyobject.c', 'src/geanywraplabel.c',
96 'src/highlighting.c', 'src/interface.c', 'src/keybindings.c',
97 'src/keyfile.c', 'src/log.c', 'src/main.c', 'src/msgwindow.c', 'src/navqueue.c', 'src/notebook.c',
98 'src/plugins.c', 'src/prefix.c', 'src/prefs.c', 'src/printing.c', 'src/project.c',
99 'src/queue.c', 'src/sciwrappers.c', 'src/search.c', 'src/socket.c', 'src/stash.c',
100 'src/symbols.c',
101 'src/templates.c', 'src/toolbar.c', 'src/tools.c', 'src/treeviews.c',
102 'src/ui_utils.c', 'src/utils.c' ]
106 def configure(conf):
107 def conf_get_svn_rev():
108 # try GIT
109 if os.path.exists('.git'):
110 cmds = [ 'git svn find-rev HEAD 2>/dev/null',
111 'git svn find-rev origin/trunk 2>/dev/null',
112 'git svn find-rev trunk 2>/dev/null',
113 'git svn find-rev master 2>/dev/null' ]
114 for c in cmds:
115 try:
116 stdout = Utils.cmd_output(c)
117 if stdout:
118 return stdout.strip()
119 except:
120 pass
121 # try SVN
122 elif os.path.exists('.svn'):
123 try:
124 _env = None if is_win32 else {'LANG' : 'C'}
125 stdout = Utils.cmd_output(cmd='svn info --non-interactive', silent=True, env=_env)
126 lines = stdout.splitlines(True)
127 for line in lines:
128 if line.startswith('Last Changed Rev'):
129 key, value = line.split(': ', 1)
130 return value.strip()
131 except:
132 pass
133 else:
134 pass
135 return '-1'
137 def conf_define_from_opt(define_name, opt_name, default_value, quote=1):
138 if opt_name:
139 if isinstance(opt_name, bool):
140 opt_name = 1
141 conf.define(define_name, opt_name, quote)
142 elif default_value:
143 conf.define(define_name, default_value, quote)
146 conf.check_tool('compiler_cc')
147 is_win32 = target_is_win32(conf.env)
149 conf.check(header_name='fcntl.h')
150 conf.check(header_name='fnmatch.h')
151 conf.check(header_name='glob.h')
152 conf.check(header_name='sys/time.h')
153 conf.check(header_name='sys/types.h')
154 conf.check(header_name='sys/stat.h')
155 conf.define('HAVE_STDLIB_H', 1) # are there systems without stdlib.h?
156 conf.define('STDC_HEADERS', 1) # an optimistic guess ;-)
158 if Options.options.gnu_regex:
159 conf.define('HAVE_REGCOMP', 1, 0)
160 conf.define('USE_INCLUDED_REGEX', 1, 0)
161 else:
162 conf.check(header_name='regex.h')
163 if conf.env['HAVE_REGEX_H'] == 1:
164 conf.check(function_name='regcomp', header_name='regex.h')
165 # fallback to included regex lib
166 if conf.env['HAVE_REGCOMP'] != 1 or conf.env['HAVE_REGEX_H'] != 1:
167 conf.define('HAVE_REGCOMP', 1, 0)
168 conf.define('USE_INCLUDED_REGEX', 1, 0)
169 Utils.pprint('YELLOW', 'Using included GNU regex library.')
171 conf.check(function_name='fgetpos', header_name='stdio.h')
172 conf.check(function_name='ftruncate', header_name='unistd.h')
173 conf.check(function_name='gethostname', header_name='unistd.h')
174 conf.check(function_name='mkstemp', header_name='stdlib.h')
175 conf.check(function_name='strstr', header_name='string.h', mandatory=True)
177 # check for cxx after the header and function checks have been done to ensure they are
178 # checked with cc not cxx
179 conf.check_tool('compiler_cxx misc')
180 if is_win32:
181 conf.check_tool('winres')
182 # we don't require intltool on Windows (it would require Perl) though it works well
183 try:
184 conf.check_tool('intltool')
185 except:
186 pass
189 # GTK / GIO version check
190 conf.check_cfg(package='gtk+-2.0', atleast_version='2.8.0', uselib_store='GTK',
191 mandatory=True, args='--cflags --libs')
192 have_gtk_210 = False
193 gtk_version = conf.check_cfg(modversion='gtk+-2.0', uselib_store='GTK')
194 if gtk_version:
195 if version.LooseVersion(gtk_version) >= version.LooseVersion('2.10.0'):
196 have_gtk_210 = True
197 else:
198 gtk_version = 'Unknown'
199 conf.check_cfg(package='gio-2.0', uselib_store='GIO', args='--cflags --libs', mandatory=False)
201 # Windows specials
202 if is_win32:
203 if conf.env['PREFIX'] == tempfile.gettempdir():
204 # overwrite default prefix on Windows (tempfile.gettempdir() is the Waf default)
205 conf.define('PREFIX', os.path.join(conf.srcdir, '%s-%s' % (APPNAME, VERSION)), 1)
206 conf.define('DOCDIR', os.path.join(conf.env['PREFIX'], 'doc'), 1)
207 conf.define('LOCALEDIR', os.path.join(conf.env['PREFIX'], 'share\locale'), 1)
208 conf.define('LIBDIR', conf.env['PREFIX'], 1)
209 # DATADIR is defined in objidl.h, so we remove it from config.h but keep it in env
210 conf.undefine('DATADIR')
211 conf.env['DATADIR'] = os.path.join(conf.env['PREFIX'], 'data')
212 # hack: we add the parent directory of the first include directory as this is missing in
213 # list returned from pkg-config
214 conf.env['CPPPATH_GTK'].insert(0, os.path.dirname(conf.env['CPPPATH_GTK'][0]))
215 # we don't need -fPIC when compiling on or for Windows
216 if '-fPIC' in conf.env['shlib_CCFLAGS']:
217 conf.env['shlib_CCFLAGS'].remove('-fPIC')
218 if '-fPIC' in conf.env['CXXFLAGS']:
219 conf.env['CXXFLAGS'].remove('-fPIC')
220 conf.env.append_value('program_LINKFLAGS', '-mwindows')
221 conf.env.append_value('LIB_WIN32', [ 'wsock32', 'uuid', 'ole32', 'iberty' ])
222 conf.env['shlib_PATTERN'] = '%s.dll'
223 conf.env['program_PATTERN'] = '%s.exe'
224 else:
225 conf.env['shlib_PATTERN'] = '%s.so'
226 conf_define_from_opt('DOCDIR', Options.options.docdir,
227 os.path.join(conf.env['DATADIR'], 'doc/geany'))
228 conf_define_from_opt('LIBDIR', Options.options.libdir,
229 os.path.join(conf.env['PREFIX'], 'lib'))
230 conf_define_from_opt('MANDIR', Options.options.mandir,
231 os.path.join(conf.env['DATADIR'], 'man'))
233 svn_rev = conf_get_svn_rev()
234 conf.define('ENABLE_NLS', 1)
235 conf.define('GEANY_LOCALEDIR', '' if is_win32 else conf.env['LOCALEDIR'], 1)
236 conf.define('GEANY_DATADIR', 'data' if is_win32 else conf.env['DATADIR'], 1)
237 conf.define('GEANY_DOCDIR', conf.env['DOCDIR'], 1)
238 conf.define('GEANY_LIBDIR', '' if is_win32 else conf.env['LIBDIR'], 1)
239 conf.define('GEANY_PREFIX', '' if is_win32 else conf.env['PREFIX'], 1)
240 conf.define('PACKAGE', APPNAME, 1)
241 conf.define('VERSION', VERSION, 1)
242 conf.define('REVISION', svn_rev, 1)
244 conf.define('GETTEXT_PACKAGE', APPNAME, 1)
246 conf_define_from_opt('HAVE_PLUGINS', not Options.options.no_plugins, None, 0)
247 conf_define_from_opt('HAVE_SOCKET', not Options.options.no_socket, None, 0)
248 conf_define_from_opt('HAVE_VTE', not Options.options.no_vte, None, 0)
250 conf.write_config_header('config.h')
252 Utils.pprint('BLUE', 'Summary:')
253 print_message(conf, 'Install Geany ' + VERSION + ' in', conf.env['PREFIX'])
254 print_message(conf, 'Using GTK version', gtk_version)
255 print_message(conf, 'Build with GTK printing support', have_gtk_210 and 'yes' or 'no')
256 print_message(conf, 'Build with plugin support', Options.options.no_plugins and 'no' or 'yes')
257 print_message(conf, 'Use virtual terminal support', Options.options.no_vte and 'no' or 'yes')
258 if svn_rev != '-1':
259 print_message(conf, 'Compiling Subversion revision', svn_rev)
260 conf.env.append_value('CCFLAGS', '-g -DGEANY_DEBUG'.split())
262 conf.env.append_value('CCFLAGS', '-DHAVE_CONFIG_H')
263 # Scintilla flags
264 conf.env.append_value('CXXFLAGS', '-DNDEBUG -DGTK -DGTK2 -DSCI_LEXER -DG_THREADS_IMPL_NONE'.split())
267 def set_options(opt):
268 opt.tool_options('compiler_cc')
269 opt.tool_options('compiler_cxx')
270 opt.tool_options('intltool')
272 if 'configure' in sys.argv:
273 # Features
274 opt.add_option('--disable-plugins', action='store_true', default=False,
275 help='compile without plugin support [default: No]', dest='no_plugins')
276 opt.add_option('--disable-socket', action='store_true', default=False,
277 help='compile without support to detect a running instance [[default: No]', dest='no_socket')
278 opt.add_option('--disable-vte', action='store_true', default=target_is_win32(os.environ),
279 help='compile without support for an embedded virtual terminal [[default: No]', dest='no_vte')
280 opt.add_option('--enable-gnu-regex', action='store_true', default=False,
281 help='compile with included GNU regex library [default: No]', dest='gnu_regex')
282 # Paths
283 opt.add_option('--mandir', type='string', default='',
284 help='man documentation', dest='mandir')
285 opt.add_option('--docdir', type='string', default='',
286 help='documentation root', dest='docdir')
287 opt.add_option('--libdir', type='string', default='',
288 help='object code libraries', dest='libdir')
289 # Actions
290 opt.add_option('--htmldoc', action='store_true', default=False,
291 help='generate HTML documentation', dest='htmldoc')
292 opt.add_option('--apidoc', action='store_true', default=False,
293 help='generate API reference documentation', dest='apidoc')
294 opt.add_option('--update-po', action='store_true', default=False,
295 help='update the message catalogs for translation', dest='update_po')
298 def build(bld):
299 is_win32 = target_is_win32(bld.env)
301 def build_plugin(plugin_name, install = True):
302 if install:
303 instpath = '${PREFIX}/lib' if is_win32 else '${LIBDIR}/geany/'
304 else:
305 instpath = None
307 bld.new_task_gen(
308 features = 'cc cshlib',
309 source = 'plugins/' + plugin_name + '.c',
310 includes = '. plugins/ src/ scintilla/include tagmanager/include',
311 target = plugin_name,
312 uselib = 'GTK',
313 install_path = instpath
317 # Tagmanager
318 if bld.env['USE_INCLUDED_REGEX'] == 1:
319 tagmanager_sources.append('tagmanager/regex.c')
320 bld.new_task_gen(
321 features = 'cc cstaticlib',
322 source = tagmanager_sources,
323 name = 'tagmanager',
324 target = 'tagmanager',
325 includes = '. tagmanager/ tagmanager/include/',
326 uselib = 'GTK',
327 install_path = None # do not install this library
330 # Scintilla
331 bld.new_task_gen(
332 features = 'cc cxx cstaticlib',
333 name = 'scintilla',
334 target = 'scintilla',
335 source = scintilla_sources,
336 includes = 'scintilla/ scintilla/include/',
337 uselib = 'GTK',
338 install_path = None, # do not install this library
341 # Geany
342 if bld.env['HAVE_VTE'] == 1:
343 geany_sources.append('src/vte.c')
344 if is_win32:
345 geany_sources.append('src/win32.c')
347 bld.new_task_gen(
348 features = 'cc cxx cprogram',
349 name = 'geany',
350 target = 'geany',
351 source = geany_sources,
352 includes = '. src/ scintilla/include/ tagmanager/include/',
353 uselib = 'GTK GIO WIN32',
354 uselib_local = 'scintilla tagmanager',
355 add_objects = 'geany-rc' if is_win32 else None
358 # geanyfunctions.h
359 bld.new_task_gen(
360 source = 'plugins/genapi.py src/plugins.c',
361 name = 'geanyfunctions.h',
362 before = 'cc cxx',
363 cwd = '%s/plugins' % bld.path.abspath(),
364 rule = 'python genapi.py -q'
367 # Plugins
368 if bld.env['HAVE_PLUGINS'] == 1:
369 build_plugin('classbuilder')
370 build_plugin('demoplugin', False)
371 build_plugin('export')
372 build_plugin('filebrowser')
373 build_plugin('htmlchars')
374 build_plugin('saveactions')
375 build_plugin('splitwindow', not is_win32)
377 # Translations
378 if bld.env['INTLTOOL']:
379 bld.new_task_gen(
380 features = 'intltool_po',
381 podir = 'po',
382 install_path = '${LOCALEDIR}',
383 appname = 'geany'
386 # geany.pc
387 bld.new_task_gen(
388 features = 'subst',
389 source = 'geany.pc.in',
390 target = 'geany.pc',
391 dict = { 'VERSION' : VERSION,
392 'prefix': bld.env['PREFIX'],
393 'exec_prefix': '${prefix}',
394 'libdir': '${exec_prefix}/lib',
395 'includedir': '${prefix}/include',
396 'datarootdir': '${prefix}/share',
397 'datadir': '${datarootdir}',
398 'localedir': '${datarootdir}/locale' },
399 install_path = None if is_win32 else '${LIBDIR}/pkgconfig'
402 if not is_win32:
403 # geany.desktop
404 if bld.env['INTLTOOL']:
405 bld.new_task_gen(
406 features = 'intltool_in',
407 source = 'geany.desktop.in',
408 flags = [ '-d', '-q', '-u', '-c' ],
409 install_path = '${DATADIR}/applications'
412 # geany.1
413 bld.new_task_gen(
414 features = 'subst',
415 source = 'doc/geany.1.in',
416 target = 'geany.1',
417 dict = { 'VERSION' : VERSION,
418 'GEANY_DATA_DIR': bld.env['DATADIR'] + '/geany' },
419 install_path = '${MANDIR}/man1'
422 # geany.spec
423 bld.new_task_gen(
424 features = 'subst',
425 source = 'geany.spec.in',
426 target = 'geany.spec',
427 install_path = None,
428 dict = { 'VERSION' : VERSION }
431 # Doxyfile
432 bld.new_task_gen(
433 features = 'subst',
434 source = 'doc/Doxyfile.in',
435 target = 'doc/Doxyfile',
436 install_path = None,
437 dict = { 'VERSION' : VERSION }
439 else:
440 bld.new_task_gen(
441 features = 'cc',
442 name = 'geany-rc',
443 source = 'geany_private.rc'
447 # Install files
449 if not is_win32:
450 # Headers
451 bld.install_files('${PREFIX}/include/geany', '''
452 src/dialogs.h src/document.h src/editor.h src/encodings.h src/filetypes.h src/geany.h
453 src/highlighting.h src/keybindings.h src/main.h src/msgwindow.h src/plugindata.h
454 src/plugins.h src/prefs.h src/project.h src/sciwrappers.h src/search.h src/support.h
455 src/templates.h src/toolbar.h src/ui_utils.h src/utils.h plugins/pluginmacros.h
456 plugins/geanyfunctions.h ''')
457 bld.install_files('${PREFIX}/include/geany/scintilla', '''
458 scintilla/include/SciLexer.h scintilla/include/Scintilla.h
459 scintilla/include/Scintilla.iface scintilla/include/ScintillaWidget.h ''')
460 bld.install_files('${PREFIX}/include/geany/tagmanager', '''
461 tagmanager/include/tm_file_entry.h tagmanager/include/tm_project.h
462 tagmanager/include/tm_source_file.h
463 tagmanager/include/tm_symbol.h tagmanager/include/tm_tag.h
464 tagmanager/include/tm_tagmanager.h tagmanager/include/tm_work_object.h
465 tagmanager/include/tm_workspace.h ''')
466 # Docs
467 base_dir = '${PREFIX}' if is_win32 else '${DOCDIR}'
468 ext = '.txt' if is_win32 else ''
469 html_dir = '' if is_win32 else 'html/'
470 html_name = 'Manual.html' if is_win32 else 'index.html'
471 for f in 'AUTHORS ChangeLog COPYING README NEWS THANKS TODO'.split():
472 bld.install_as("%s/%s%s" % (base_dir, ucFirst(f, is_win32), ext), f)
473 bld.install_files('${DOCDIR}/%simages' % html_dir, 'doc/images/*.png')
474 bld.install_as('${DOCDIR}/%s' % ucFirst('manual.txt', is_win32), 'doc/geany.txt')
475 bld.install_as('${DOCDIR}/%s%s' % (html_dir, html_name), 'doc/geany.html')
476 bld.install_as('${DOCDIR}/ScintillaLicense.txt', 'scintilla/License.txt')
477 if is_win32:
478 bld.install_as('${DOCDIR}/ReadMe.I18n.txt', 'README.I18N')
479 bld.install_as('${DOCDIR}/Hacking.txt', 'HACKING')
480 # Data
481 dir = '' if is_win32 else 'geany'
482 bld.install_files('${DATADIR}/%s' % dir, 'data/filetype*')
483 bld.install_files('${DATADIR}/%s' % dir, 'data/*.tags')
484 bld.install_files('${DATADIR}/%s' % dir, 'data/snippets.conf')
485 bld.install_files('${DATADIR}/%s' % dir, 'data/ui_toolbar.xml')
486 bld.install_as('${DATADIR}/%s/GPL-2' % dir, 'COPYING')
487 # Icons
488 bld.install_files('${PREFIX}/share/icons'
489 if is_win32 else '${DATADIR}/icons/hicolor/16x16/apps', 'icons/16x16/*.png')
490 if not is_win32:
491 bld.install_files('${DATADIR}/icons/hicolor/48x48/apps', 'icons/48x48/*.png')
492 bld.install_files('${DATADIR}/icons/hicolor/scalable/apps', 'icons/scalable/*.svg')
495 def shutdown():
496 is_win32 = False if not Build.bld else target_is_win32(Build.bld.env)
497 # the following code was taken from midori's WAF script, thanks
498 if not is_win32 and not Options.options.destdir and (Options.commands['install'] or Options.commands['uninstall']):
499 dir = Build.bld.get_install_path('${DATADIR}/icons/hicolor')
500 icon_cache_updated = False
501 try:
502 Utils.exec_command('gtk-update-icon-cache -q -f -t %s' % dir)
503 Utils.pprint('GREEN', 'GTK icon cache updated.')
504 icon_cache_updated = True
505 except:
506 Utils.pprint('YELLOW', 'Failed to update icon cache for %s.' % dir)
507 if not icon_cache_updated:
508 print 'Icon cache not updated. After install, run this:'
509 print 'gtk-update-icon-cache -q -f -t %s' % dir
511 if Options.options.apidoc:
512 doxyfile = os.path.join(Build.bld.srcnode.abspath(Build.bld.env), 'doc', 'Doxyfile')
513 cmd = Configure.find_program_impl(Build.bld.env, 'doxygen')
514 if cmd:
515 os.chdir('doc')
516 ret = launch('%s %s' % (cmd, doxyfile), 'Generating API reference documentation')
517 else:
518 Utils.pprint('RED',
519 'doxygen could not be found. Please install the doxygen package.')
520 sys.exit(1)
522 if Options.options.htmldoc:
523 # first try rst2html.py as it is the upstream default, fall back to rst2html
524 cmd = Configure.find_program_impl(Build.bld.env, 'rst2html.py')
525 if not cmd:
526 cmd = Configure.find_program_impl(Build.bld.env, 'rst2html')
527 if cmd:
528 os.chdir('doc')
529 ret = launch(cmd + ' -stg --stylesheet=geany.css geany.txt geany.html',
530 'Generating HTML documentation')
531 else:
532 Utils.pprint('RED',
533 'rst2html.py could not be found. Please install the Python docutils package.')
534 sys.exit(1)
536 if Options.options.update_po:
537 # the following code was taken from midori's WAF script, thanks
538 os.chdir('%s/po' % srcdir)
539 try:
540 try:
541 size_old = os.stat('geany.pot').st_size
542 except:
543 size_old = 0
544 Utils.exec_command('intltool-update --pot -g %s' % APPNAME)
545 size_new = os.stat('geany.pot').st_size
546 if size_new != size_old:
547 Utils.pprint('CYAN', 'Updated POT file.')
548 launch('intltool-update -r -g %s' % APPNAME, 'Updating translations', 'CYAN')
549 else:
550 Utils.pprint('CYAN', 'POT file is up to date.')
551 except:
552 Utils.pprint('RED', 'Failed to generate pot file.')
553 os.chdir('..')
556 # Simple function to execute a command and print its exit status
557 def launch(command, status, success_color='GREEN'):
558 ret = 0
559 Utils.pprint(success_color, status)
560 try:
561 ret = Utils.exec_command(command)
562 except OSError, e:
563 ret = 1
564 print str(e), ":", command
565 except:
566 ret = 1
568 if ret != 0:
569 Utils.pprint('RED', status + ' failed')
571 return ret
574 def print_message(conf, msg, result, color = 'GREEN'):
575 conf.check_message_1(msg)
576 conf.check_message_2(result, color)
579 def ucFirst(s, is_win32):
580 if is_win32:
581 return s.title()
582 return s
585 def target_is_win32(env):
586 if sys.platform == 'win32':
587 return True
588 if env and 'CC' in env:
589 cc = env['CC']
590 if not isinstance(cc, str):
591 cc = ''.join(cc)
592 return cc.find('mingw') != -1
593 return False