Do not translate 'name' field for filetype None because it is used
[geany-mirror.git] / wscript
blob7422c5578e4612806ffb4cf8ca6f76a91a007349
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-2010 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
7 # Copyright 2008-2010 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 The code of this file itself loosely follows PEP 8 with some exceptions
39 (line width 100 characters and some other minor things).
41 Requires WAF 1.5.7 and Python 2.4 (or later).
42 """
45 import Build
46 import Configure
47 import Options
48 import Utils
49 import sys
50 import os
51 import shutil
52 import tempfile
53 from distutils import version
54 from TaskGen import taskgen, feature
57 APPNAME = 'geany'
58 VERSION = '0.20'
60 srcdir = '.'
61 blddir = '_build_'
64 tagmanager_sources = [
65 'tagmanager/args.c', 'tagmanager/abc.c', 'tagmanager/actionscript.c', 'tagmanager/asm.c',
66 'tagmanager/basic.c', 'tagmanager/c.c',
67 'tagmanager/conf.c', 'tagmanager/css.c', 'tagmanager/ctags.c', 'tagmanager/diff.c',
68 'tagmanager/docbook.c', 'tagmanager/entry.c', 'tagmanager/fortran.c', 'tagmanager/get.c',
69 'tagmanager/haskell.c', 'tagmanager/haxe.c', 'tagmanager/html.c', 'tagmanager/js.c',
70 'tagmanager/keyword.c', 'tagmanager/latex.c', 'tagmanager/lregex.c', 'tagmanager/lua.c',
71 'tagmanager/make.c', 'tagmanager/markdown.c', 'tagmanager/matlab.c', 'tagmanager/nsis.c',
72 'tagmanager/nestlevel.c', 'tagmanager/options.c',
73 'tagmanager/parse.c', 'tagmanager/pascal.c', 'tagmanager/r.c',
74 'tagmanager/perl.c', 'tagmanager/php.c', 'tagmanager/python.c', 'tagmanager/read.c',
75 'tagmanager/rest.c', 'tagmanager/ruby.c', 'tagmanager/sh.c', 'tagmanager/sort.c',
76 'tagmanager/sql.c', 'tagmanager/strlist.c', 'tagmanager/txt2tags.c', 'tagmanager/tcl.c',
77 'tagmanager/tm_file_entry.c',
78 'tagmanager/tm_project.c', 'tagmanager/tm_source_file.c', 'tagmanager/tm_symbol.c',
79 'tagmanager/tm_tag.c', 'tagmanager/tm_tagmanager.c', 'tagmanager/tm_work_object.c',
80 'tagmanager/tm_workspace.c', 'tagmanager/vhdl.c', 'tagmanager/verilog.c', 'tagmanager/vstring.c' ]
82 scintilla_sources = [
83 'scintilla/AutoComplete.cxx', 'scintilla/CallTip.cxx', 'scintilla/CellBuffer.cxx',
84 'scintilla/CharClassify.cxx', 'scintilla/ContractionState.cxx', 'scintilla/Decoration.cxx',
85 'scintilla/DocumentAccessor.cxx', 'scintilla/Document.cxx', 'scintilla/Editor.cxx',
86 'scintilla/ExternalLexer.cxx', 'scintilla/Indicator.cxx', 'scintilla/KeyMap.cxx',
87 'scintilla/KeyWords.cxx',
88 'scintilla/LexAda.cxx', 'scintilla/LexAsm.cxx', 'scintilla/LexBash.cxx',
89 'scintilla/LexBasic.cxx', 'scintilla/LexCaml.cxx', 'scintilla/LexCmake.cxx', 'scintilla/LexCPP.cxx',
90 'scintilla/LexCSS.cxx', 'scintilla/LexD.cxx', 'scintilla/LexErlang.cxx', 'scintilla/LexForth.cxx',
91 'scintilla/LexFortran.cxx', 'scintilla/LexHaskell.cxx', 'scintilla/LexHTML.cxx', 'scintilla/LexLisp.cxx',
92 'scintilla/LexLua.cxx', 'scintilla/LexMarkdown.cxx', 'scintilla/LexMatlab.cxx',
93 'scintilla/LexNsis.cxx', 'scintilla/LexOthers.cxx',
94 'scintilla/LexPascal.cxx', 'scintilla/LexPerl.cxx', 'scintilla/LexPython.cxx',
95 'scintilla/LexR.cxx', 'scintilla/LexRuby.cxx', 'scintilla/LexSQL.cxx',
96 'scintilla/LexTCL.cxx', 'scintilla/LexTxt2tags.cxx',
97 'scintilla/LexVHDL.cxx', 'scintilla/LexVerilog.cxx', 'scintilla/LexYAML.cxx',
98 'scintilla/LineMarker.cxx', 'scintilla/PerLine.cxx',
99 'scintilla/PlatGTK.cxx',
100 'scintilla/PositionCache.cxx', 'scintilla/PropSet.cxx', 'scintilla/RESearch.cxx',
101 'scintilla/RunStyles.cxx', 'scintilla/ScintillaBase.cxx', 'scintilla/ScintillaGTK.cxx',
102 'scintilla/scintilla-marshal.c', 'scintilla/Selection.cxx', 'scintilla/StyleContext.cxx', 'scintilla/Style.cxx',
103 'scintilla/UniConversion.cxx', 'scintilla/ViewStyle.cxx', 'scintilla/WindowAccessor.cxx',
104 'scintilla/XPM.cxx' ]
106 geany_sources = [
107 'src/about.c', 'src/build.c', 'src/callbacks.c', 'src/dialogs.c', 'src/document.c',
108 'src/editor.c', 'src/encodings.c', 'src/filetypes.c', 'src/geanyentryaction.c',
109 'src/geanymenubuttonaction.c', 'src/geanyobject.c', 'src/geanywraplabel.c',
110 'src/highlighting.c', 'src/interface.c', 'src/keybindings.c',
111 'src/keyfile.c', 'src/log.c', 'src/main.c', 'src/msgwindow.c', 'src/navqueue.c', 'src/notebook.c',
112 'src/plugins.c', 'src/pluginutils.c', 'src/prefix.c', 'src/prefs.c', 'src/printing.c', 'src/project.c',
113 'src/sciwrappers.c', 'src/search.c', 'src/socket.c', 'src/stash.c',
114 'src/symbols.c',
115 'src/templates.c', 'src/toolbar.c', 'src/tools.c', 'src/sidebar.c',
116 'src/ui_utils.c', 'src/utils.c' ]
120 def configure(conf):
121 def in_git():
122 cmd = 'git ls-files >/dev/null 2>&1'
123 return (Utils.exec_command(cmd) == 0)
125 def in_svn():
126 return os.path.exists('.svn')
128 def conf_get_svn_rev():
129 # try GIT
130 if in_git():
131 cmds = [ 'git svn find-rev HEAD 2>/dev/null',
132 'git svn find-rev origin/trunk 2>/dev/null',
133 'git svn find-rev trunk 2>/dev/null',
134 'git svn find-rev master 2>/dev/null'
136 for c in cmds:
137 try:
138 stdout = Utils.cmd_output(c)
139 if stdout:
140 return stdout.strip()
141 except:
142 pass
143 # try SVN
144 elif in_svn():
145 try:
146 _env = None if is_win32 else {'LANG' : 'C'}
147 stdout = Utils.cmd_output(cmd='svn info --non-interactive', silent=True, env=_env)
148 lines = stdout.splitlines(True)
149 for line in lines:
150 if line.startswith('Last Changed Rev'):
151 key, value = line.split(': ', 1)
152 return value.strip()
153 except:
154 pass
155 else:
156 pass
157 return '-1'
159 def conf_define_from_opt(define_name, opt_name, default_value, quote=1):
160 if opt_name:
161 if isinstance(opt_name, bool):
162 opt_name = 1
163 conf.define(define_name, opt_name, quote)
164 elif default_value:
165 conf.define(define_name, default_value, quote)
168 conf.check_tool('compiler_cc')
169 is_win32 = target_is_win32(conf.env)
171 conf.check(header_name='fcntl.h')
172 conf.check(header_name='fnmatch.h')
173 conf.check(header_name='glob.h')
174 conf.check(header_name='sys/time.h')
175 conf.check(header_name='sys/types.h')
176 conf.check(header_name='sys/stat.h')
177 conf.define('HAVE_STDLIB_H', 1) # are there systems without stdlib.h?
178 conf.define('STDC_HEADERS', 1) # an optimistic guess ;-)
180 if Options.options.gnu_regex:
181 conf.define('HAVE_REGCOMP', 1, 0)
182 conf.define('USE_INCLUDED_REGEX', 1, 0)
183 else:
184 conf.check(header_name='regex.h')
185 if conf.env['HAVE_REGEX_H'] == 1:
186 conf.check(function_name='regcomp', header_name='regex.h')
187 # fallback to included regex lib
188 if conf.env['HAVE_REGCOMP'] != 1 or conf.env['HAVE_REGEX_H'] != 1:
189 conf.define('HAVE_REGCOMP', 1, 0)
190 conf.define('USE_INCLUDED_REGEX', 1, 0)
191 Utils.pprint('YELLOW', 'Using included GNU regex library.')
193 conf.check(function_name='fgetpos', header_name='stdio.h')
194 conf.check(function_name='ftruncate', header_name='unistd.h')
195 conf.check(function_name='gethostname', header_name='unistd.h')
196 conf.check(function_name='mkstemp', header_name='stdlib.h')
197 conf.check(function_name='strstr', header_name='string.h', mandatory=True)
199 # check sunOS socket support
200 if Options.platform == 'sunos':
201 conf.check(function_name='socket', lib='socket',
202 header_name='sys/socket.h', uselib_store='SUNOS_SOCKET', mandatory=True)
204 # check for cxx after the header and function checks have been done to ensure they are
205 # checked with cc not cxx
206 conf.check_tool('compiler_cxx misc')
207 if is_win32:
208 conf.check_tool('winres')
209 # we don't require intltool on Windows (it would require Perl) though it works well
210 try:
211 conf.check_tool('intltool')
212 if 'LINGUAS' in os.environ:
213 conf.env['LINGUAS'] = os.environ['LINGUAS']
214 except Configure.ConfigurationError:
215 if not is_win32:
216 raise
218 # GTK / GIO version check
219 conf.check_cfg(package='gtk+-2.0', atleast_version='2.8.0', uselib_store='GTK',
220 mandatory=True, args='--cflags --libs')
221 have_gtk_210 = False
222 gtk_version = conf.check_cfg(modversion='gtk+-2.0', uselib_store='GTK')
223 if gtk_version:
224 if version.LooseVersion(gtk_version) >= version.LooseVersion('2.10.0'):
225 have_gtk_210 = True
226 else:
227 gtk_version = 'Unknown'
228 conf.check_cfg(package='gio-2.0', uselib_store='GIO', args='--cflags --libs', mandatory=False)
230 # Windows specials
231 if is_win32:
232 if conf.env['PREFIX'] == tempfile.gettempdir():
233 # overwrite default prefix on Windows (tempfile.gettempdir() is the Waf default)
234 conf.define('PREFIX', os.path.join(conf.srcdir, '%s-%s' % (APPNAME, VERSION)), 1)
235 conf.define('DOCDIR', os.path.join(conf.env['PREFIX'], 'doc'), 1)
236 conf.define('LOCALEDIR', os.path.join(conf.env['PREFIX'], 'share\locale'), 1)
237 conf.define('LIBDIR', conf.env['PREFIX'], 1)
238 # DATADIR is defined in objidl.h, so we remove it from config.h but keep it in env
239 conf.undefine('DATADIR')
240 conf.env['DATADIR'] = os.path.join(conf.env['PREFIX'], 'data')
241 # hack: we add the parent directory of the first include directory as this is missing in
242 # list returned from pkg-config
243 conf.env['CPPPATH_GTK'].insert(0, os.path.dirname(conf.env['CPPPATH_GTK'][0]))
244 # we don't need -fPIC when compiling on or for Windows
245 if '-fPIC' in conf.env['shlib_CCFLAGS']:
246 conf.env['shlib_CCFLAGS'].remove('-fPIC')
247 if '-fPIC' in conf.env['CXXFLAGS']:
248 conf.env['CXXFLAGS'].remove('-fPIC')
249 conf.env.append_value('program_LINKFLAGS', '-mwindows')
250 conf.env.append_value('LIB_WIN32', [ 'wsock32', 'uuid', 'ole32', 'iberty' ])
251 conf.env['shlib_PATTERN'] = '%s.dll'
252 conf.env['program_PATTERN'] = '%s.exe'
253 else:
254 conf.env['shlib_PATTERN'] = '%s.so'
255 conf_define_from_opt('DOCDIR', Options.options.docdir,
256 os.path.join(conf.env['DATADIR'], 'doc/geany'))
257 conf_define_from_opt('LIBDIR', Options.options.libdir,
258 os.path.join(conf.env['PREFIX'], 'lib'))
259 conf_define_from_opt('MANDIR', Options.options.mandir,
260 os.path.join(conf.env['DATADIR'], 'man'))
262 svn_rev = conf_get_svn_rev()
263 conf.define('ENABLE_NLS', 1)
264 conf.define('GEANY_LOCALEDIR', '' if is_win32 else conf.env['LOCALEDIR'], 1)
265 conf.define('GEANY_DATADIR', 'data' if is_win32 else conf.env['DATADIR'], 1)
266 conf.define('GEANY_DOCDIR', conf.env['DOCDIR'], 1)
267 conf.define('GEANY_LIBDIR', '' if is_win32 else conf.env['LIBDIR'], 1)
268 conf.define('GEANY_PREFIX', '' if is_win32 else conf.env['PREFIX'], 1)
269 conf.define('PACKAGE', APPNAME, 1)
270 conf.define('VERSION', VERSION, 1)
271 conf.define('REVISION', svn_rev, 1)
273 conf.define('GETTEXT_PACKAGE', APPNAME, 1)
275 conf_define_from_opt('HAVE_PLUGINS', not Options.options.no_plugins, None, 0)
276 conf_define_from_opt('HAVE_SOCKET', not Options.options.no_socket, None, 0)
277 conf_define_from_opt('HAVE_VTE', not Options.options.no_vte, None, 0)
279 conf.write_config_header('config.h')
281 Utils.pprint('BLUE', 'Summary:')
282 print_message(conf, 'Install Geany ' + VERSION + ' in', conf.env['PREFIX'])
283 print_message(conf, 'Using GTK version', gtk_version)
284 print_message(conf, 'Build with GTK printing support', have_gtk_210 and 'yes' or 'no')
285 print_message(conf, 'Build with plugin support', Options.options.no_plugins and 'no' or 'yes')
286 print_message(conf, 'Use virtual terminal support', Options.options.no_vte and 'no' or 'yes')
287 if svn_rev != '-1':
288 print_message(conf, 'Compiling Subversion revision', svn_rev)
289 conf.env.append_value('CCFLAGS', '-g -DGEANY_DEBUG'.split())
291 conf.env.append_value('CCFLAGS', '-DHAVE_CONFIG_H')
292 conf.env.append_value('CCFLAGS', '-DGTK') # Scintilla needs this
293 # for now define GEANY_PRIVATE for all files, even though it should just be for src/*.
294 conf.env.append_value('CCFLAGS', '-DGEANY_PRIVATE')
295 # Scintilla flags
296 conf.env.append_value('CXXFLAGS',
297 '-DNDEBUG -DGTK -DGTK2 -DSCI_LEXER -DG_THREADS_IMPL_NONE'.split())
300 def set_options(opt):
301 opt.tool_options('compiler_cc')
302 opt.tool_options('compiler_cxx')
303 opt.tool_options('intltool')
305 if 'configure' in sys.argv:
306 # Features
307 opt.add_option('--disable-plugins', action='store_true', default=False,
308 help='compile without plugin support [default: No]', dest='no_plugins')
309 opt.add_option('--disable-socket', action='store_true', default=False,
310 help='compile without support to detect a running instance [[default: No]',
311 dest='no_socket')
312 opt.add_option('--disable-vte', action='store_true', default=target_is_win32(os.environ),
313 help='compile without support for an embedded virtual terminal [[default: No]',
314 dest='no_vte')
315 opt.add_option('--enable-gnu-regex', action='store_true', default=False,
316 help='compile with included GNU regex library [default: No]', dest='gnu_regex')
317 # Paths
318 opt.add_option('--mandir', type='string', default='',
319 help='man documentation', dest='mandir')
320 opt.add_option('--docdir', type='string', default='',
321 help='documentation root', dest='docdir')
322 opt.add_option('--libdir', type='string', default='',
323 help='object code libraries', dest='libdir')
324 # Actions
325 opt.add_option('--htmldoc', action='store_true', default=False,
326 help='generate HTML documentation', dest='htmldoc')
327 opt.add_option('--hackingdoc', action='store_true', default=False,
328 help='generate HTML documentation from HACKING file', dest='hackingdoc')
329 opt.add_option('--apidoc', action='store_true', default=False,
330 help='generate API reference documentation', dest='apidoc')
331 opt.add_option('--update-po', action='store_true', default=False,
332 help='update the message catalogs for translation', dest='update_po')
335 def build(bld):
336 is_win32 = target_is_win32(bld.env)
338 def build_plugin(plugin_name, install = True):
339 if install:
340 instpath = '${PREFIX}/lib' if is_win32 else '${LIBDIR}/geany/'
341 else:
342 instpath = None
344 bld.new_task_gen(
345 features = 'cc cshlib',
346 source = 'plugins/' + plugin_name + '.c',
347 includes = '. plugins/ src/ scintilla/include tagmanager/include',
348 defines = 'G_LOG_DOMAIN="%s"' % plugin_name,
349 target = plugin_name,
350 uselib = 'GTK',
351 install_path = instpath
355 # Tagmanager
356 if bld.env['USE_INCLUDED_REGEX'] == 1:
357 tagmanager_sources.append('tagmanager/regex.c')
358 bld.new_task_gen(
359 features = 'cc cstaticlib',
360 source = tagmanager_sources,
361 name = 'tagmanager',
362 target = 'tagmanager',
363 includes = '. tagmanager/ tagmanager/include/',
364 defines = 'G_LOG_DOMAIN="Tagmanager"',
365 uselib = 'GTK',
366 install_path = None # do not install this library
369 # Scintilla
370 bld.new_task_gen(
371 features = 'cc cxx cstaticlib',
372 name = 'scintilla',
373 target = 'scintilla',
374 source = scintilla_sources,
375 includes = 'scintilla/ scintilla/include/',
376 uselib = 'GTK',
377 install_path = None, # do not install this library
380 # Geany
381 if bld.env['HAVE_VTE'] == 1:
382 geany_sources.append('src/vte.c')
383 if is_win32:
384 geany_sources.append('src/win32.c')
386 bld.new_task_gen(
387 features = 'cc cxx cprogram',
388 name = 'geany',
389 target = 'geany',
390 source = geany_sources,
391 includes = '. src/ scintilla/include/ tagmanager/include/',
392 defines = 'G_LOG_DOMAIN="Geany"',
393 uselib = 'GTK GIO WIN32 SUNOS_SOCKET',
394 uselib_local = 'scintilla tagmanager',
395 add_objects = 'geany-rc' if is_win32 else None
398 # geanyfunctions.h
399 bld.new_task_gen(
400 source = 'plugins/genapi.py src/plugins.c',
401 name = 'geanyfunctions.h',
402 before = 'cc cxx',
403 cwd = '%s/plugins' % bld.path.abspath(),
404 rule = 'python genapi.py -q'
407 # Plugins
408 if bld.env['HAVE_PLUGINS'] == 1:
409 build_plugin('classbuilder')
410 build_plugin('demoplugin', False)
411 build_plugin('export')
412 build_plugin('filebrowser')
413 build_plugin('htmlchars')
414 build_plugin('saveactions')
415 build_plugin('splitwindow', not is_win32)
417 # Translations
418 if bld.env['INTLTOOL']:
419 bld.new_task_gen(
420 features = 'intltool_po',
421 podir = 'po',
422 install_path = '${LOCALEDIR}',
423 appname = 'geany'
426 # geany.pc
427 bld.new_task_gen(
428 features = 'subst',
429 source = 'geany.pc.in',
430 target = 'geany.pc',
431 dict = { 'VERSION' : VERSION,
432 'prefix': bld.env['PREFIX'],
433 'exec_prefix': '${prefix}',
434 'libdir': '${exec_prefix}/lib',
435 'includedir': '${prefix}/include',
436 'datarootdir': '${prefix}/share',
437 'datadir': '${datarootdir}',
438 'localedir': '${datarootdir}/locale' },
439 install_path = None if is_win32 else '${LIBDIR}/pkgconfig'
442 if not is_win32:
443 # geany.desktop
444 if bld.env['INTLTOOL']:
445 bld.new_task_gen(
446 features = 'intltool_in',
447 source = 'geany.desktop.in',
448 flags = [ '-d', '-q', '-u', '-c' ],
449 install_path = '${DATADIR}/applications'
452 # geany.1
453 bld.new_task_gen(
454 features = 'subst',
455 source = 'doc/geany.1.in',
456 target = 'geany.1',
457 dict = { 'VERSION' : VERSION,
458 'GEANY_DATA_DIR': bld.env['DATADIR'] + '/geany' },
459 install_path = '${MANDIR}/man1'
462 # geany.spec
463 bld.new_task_gen(
464 features = 'subst',
465 source = 'geany.spec.in',
466 target = 'geany.spec',
467 install_path = None,
468 dict = { 'VERSION' : VERSION }
471 # Doxyfile
472 bld.new_task_gen(
473 features = 'subst',
474 source = 'doc/Doxyfile.in',
475 target = 'doc/Doxyfile',
476 install_path = None,
477 dict = { 'VERSION' : VERSION }
479 else:
480 bld.new_task_gen(
481 features = 'cc',
482 name = 'geany-rc',
483 source = 'geany_private.rc'
487 # Install files
489 if not is_win32:
490 # Headers
491 bld.install_files('${PREFIX}/include/geany', '''
492 src/document.h src/editor.h src/encodings.h src/filetypes.h src/geany.h
493 src/highlighting.h src/keybindings.h src/msgwindow.h src/plugindata.h
494 src/prefs.h src/project.h src/search.h src/stash.h src/support.h
495 src/templates.h src/toolbar.h src/ui_utils.h src/utils.h
496 plugins/geanyplugin.h plugins/geanyfunctions.h''')
497 bld.install_files('${PREFIX}/include/geany/scintilla', '''
498 scintilla/include/SciLexer.h scintilla/include/Scintilla.h
499 scintilla/include/Scintilla.iface scintilla/include/ScintillaWidget.h ''')
500 bld.install_files('${PREFIX}/include/geany/tagmanager', '''
501 tagmanager/include/tm_file_entry.h tagmanager/include/tm_project.h
502 tagmanager/include/tm_source_file.h
503 tagmanager/include/tm_symbol.h tagmanager/include/tm_tag.h
504 tagmanager/include/tm_tagmanager.h tagmanager/include/tm_work_object.h
505 tagmanager/include/tm_workspace.h ''')
506 # Docs
507 base_dir = '${PREFIX}' if is_win32 else '${DOCDIR}'
508 ext = '.txt' if is_win32 else ''
509 html_dir = '' if is_win32 else 'html/'
510 html_name = 'Manual.html' if is_win32 else 'index.html'
511 for f in 'AUTHORS ChangeLog COPYING README NEWS THANKS TODO'.split():
512 bld.install_as("%s/%s%s" % (base_dir, uc_first(f, is_win32), ext), f)
513 bld.install_files('${DOCDIR}/%simages' % html_dir, 'doc/images/*.png')
514 bld.install_as('${DOCDIR}/%s' % uc_first('manual.txt', is_win32), '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')
517 if is_win32:
518 bld.install_as('${DOCDIR}/ReadMe.I18n.txt', 'README.I18N')
519 bld.install_as('${DOCDIR}/Hacking.txt', 'HACKING')
520 # Data
521 dir = '' if is_win32 else 'geany'
522 bld.install_files('${DATADIR}/%s' % dir, 'data/filetype*')
523 bld.install_files('${DATADIR}/%s' % dir, 'data/*.tags')
524 bld.install_files('${DATADIR}/%s' % dir, 'data/snippets.conf')
525 bld.install_files('${DATADIR}/%s' % dir, 'data/ui_toolbar.xml')
526 bld.install_files('${DATADIR}/%s/templates' % dir, 'data/templates/*.*')
527 bld.install_files('${DATADIR}/%s/templates/files' % dir, 'data/templates/files/*.*')
528 bld.install_files('${DATADIR}/%s/colorschemes' % dir, 'data/colorschemes/*.*')
529 bld.install_as('${DATADIR}/%s/GPL-2' % dir, 'COPYING')
530 # Icons
531 bld.install_files('${PREFIX}/share/icons'
532 if is_win32 else '${DATADIR}/icons/hicolor/16x16/apps', 'icons/16x16/*.png')
533 if not is_win32:
534 bld.install_files('${DATADIR}/icons/hicolor/48x48/apps', 'icons/48x48/*.png')
535 bld.install_files('${DATADIR}/icons/hicolor/scalable/apps', 'icons/scalable/*.svg')
538 @taskgen
539 @feature('intltool_po')
540 def write_linguas_file(self):
541 linguas = ''
542 if 'LINGUAS' in Build.bld.env:
543 files = Build.bld.env['LINGUAS']
544 for po_filename in files.split(' '):
545 if os.path.exists('po/%s.po' % po_filename):
546 linguas += '%s ' % po_filename
547 else:
548 files = os.listdir('%s/po' % self.path.abspath())
549 files.sort()
550 for f in files:
551 if f.endswith('.po'):
552 linguas += '%s ' % f[:-3]
553 f = open("po/LINGUAS", "w")
554 f.write('# This file is autogenerated. Do not edit.\n%s\n' % linguas)
555 f.close()
558 def shutdown():
559 is_win32 = False if not Build.bld else target_is_win32(Build.bld.env)
560 # the following code was taken from midori's WAF script, thanks
561 if not is_win32 and not Options.options.destdir and (Options.commands['install'] or \
562 Options.commands['uninstall']):
563 dir = Build.bld.get_install_path('${DATADIR}/icons/hicolor')
564 icon_cache_updated = False
565 try:
566 Utils.exec_command('gtk-update-icon-cache -q -f -t %s' % dir)
567 Utils.pprint('GREEN', 'GTK icon cache updated.')
568 icon_cache_updated = True
569 except:
570 Utils.pprint('YELLOW', 'Failed to update icon cache for %s.' % dir)
571 if not icon_cache_updated:
572 print 'Icon cache not updated. After install, run this:'
573 print 'gtk-update-icon-cache -q -f -t %s' % dir
575 if Options.options.apidoc:
576 doxyfile = os.path.join(Build.bld.srcnode.abspath(Build.bld.env), 'doc', 'Doxyfile')
577 cmd = Configure.find_program_impl(Build.bld.env, 'doxygen')
578 if cmd:
579 os.chdir('doc')
580 ret = launch('%s %s' % (cmd, doxyfile), 'Generating API reference documentation')
581 else:
582 Utils.pprint('RED',
583 'doxygen could not be found. Please install the doxygen package.')
584 sys.exit(1)
586 if Options.options.htmldoc or Options.options.hackingdoc:
587 # first try rst2html.py as it is the upstream default, fall back to rst2html
588 cmd = Configure.find_program_impl(Build.bld.env, 'rst2html.py')
589 if not cmd:
590 cmd = Configure.find_program_impl(Build.bld.env, 'rst2html')
591 if cmd:
592 if Options.options.hackingdoc:
593 file_in = '../HACKING'
594 file_out = 'hacking.html'
595 msg = 'HACKING HTML'
596 else:
597 file_in = 'geany.txt'
598 file_out = 'geany.html'
599 msg = 'HTML'
600 os.chdir('doc')
601 ret = launch(cmd + ' -stg --stylesheet=geany.css %s %s' % (file_in, file_out),
602 'Generating %s documentation' % msg)
603 else:
604 Utils.pprint('RED',
605 'rst2html.py could not be found. Please install the Python docutils package.')
606 sys.exit(1)
608 if Options.options.update_po:
609 # the following code was taken from midori's WAF script, thanks
610 os.chdir('%s/po' % srcdir)
611 try:
612 try:
613 size_old = os.stat('geany.pot').st_size
614 except:
615 size_old = 0
616 Utils.exec_command('intltool-update --pot -g %s' % APPNAME)
617 size_new = os.stat('geany.pot').st_size
618 if size_new != size_old:
619 Utils.pprint('CYAN', 'Updated POT file.')
620 launch('intltool-update -r -g %s' % APPNAME, 'Updating translations', 'CYAN')
621 else:
622 Utils.pprint('CYAN', 'POT file is up to date.')
623 except:
624 Utils.pprint('RED', 'Failed to generate pot file.')
625 os.chdir('..')
628 # Simple function to execute a command and print its exit status
629 def launch(command, status, success_color='GREEN'):
630 ret = 0
631 Utils.pprint(success_color, status)
632 try:
633 ret = Utils.exec_command(command)
634 except OSError, e:
635 ret = 1
636 print str(e), ":", command
637 except:
638 ret = 1
640 if ret != 0:
641 Utils.pprint('RED', status + ' failed')
643 return ret
646 def print_message(conf, msg, result, color = 'GREEN'):
647 conf.check_message_1(msg)
648 conf.check_message_2(result, color)
651 def uc_first(s, is_win32):
652 if is_win32:
653 return s.title()
654 return s
657 def target_is_win32(env):
658 if sys.platform == 'win32':
659 return True
660 if env and 'CC' in env:
661 cc = env['CC']
662 if not isinstance(cc, str):
663 cc = ''.join(cc)
664 return cc.find('mingw') != -1
665 return False