3 # Thomas Nagy, 2006-2010 (ita)
6 Support for the KDE4 libraries and msgfmt
10 from waflib
import Task
, Utils
11 from waflib
.TaskGen
import feature
14 def apply_msgfmt(self
):
16 Process all languages to create .mo files and to install them::
19 bld(features='msgfmt', langs='es de fr', appname='myapp', install_path='${KDE4_LOCALE_INSTALL_DIR}')
21 for lang
in self
.to_list(self
.langs
):
22 node
= self
.path
.find_resource(lang
+'.po')
23 task
= self
.create_task('msgfmt', node
, node
.change_ext('.mo'))
25 langname
= lang
.split('/')
26 langname
= langname
[-1]
28 inst
= getattr(self
, 'install_path', '${KDE4_LOCALE_INSTALL_DIR}')
31 inst_to
= inst
+ os
.sep
+ langname
+ os
.sep
+ 'LC_MESSAGES' + os
.sep
+ getattr(self
, 'appname', 'set_your_appname') + '.mo',
32 inst_from
= task
.outputs
[0],
33 chmod
= getattr(self
, 'chmod', Utils
.O644
))
35 class msgfmt(Task
.Task
):
37 Transform .po files into .mo files
40 run_str
= '${MSGFMT} ${SRC} -o ${TGT}'
44 Detect kde4-config and set various variables for the *use* system::
47 opt.load('compiler_cxx kde4')
49 conf.load('compiler_cxx kde4')
51 bld.program(source='main.c', target='app', use='KDECORE KIO KHTML')
53 kdeconfig
= self
.find_program('kde4-config')
54 prefix
= self
.cmd_and_log(kdeconfig
+ ['--prefix']).strip()
55 fname
= '%s/share/apps/cmake/modules/KDELibsDependencies.cmake' % prefix
59 fname
= '%s/share/kde4/apps/cmake/modules/KDELibsDependencies.cmake' % prefix
63 self
.fatal('could not open %s' % fname
)
66 txt
= Utils
.readf(fname
)
67 except EnvironmentError:
68 self
.fatal('could not read %s' % fname
)
70 txt
= txt
.replace('\\\n', '\n')
71 fu
= re
.compile('#(.*)\n')
74 setregexp
= re
.compile(r
'([sS][eE][tT]\s*\()\s*([^\s]+)\s+\"([^"]+)\"\)')
75 found
= setregexp
.findall(txt
)
77 for (_
, key
, val
) in found
:
81 # well well, i could just write an interpreter for cmake files
82 self
.env
['LIB_KDECORE']= ['kdecore']
83 self
.env
['LIB_KDEUI'] = ['kdeui']
84 self
.env
['LIB_KIO'] = ['kio']
85 self
.env
['LIB_KHTML'] = ['khtml']
86 self
.env
['LIB_KPARTS'] = ['kparts']
88 self
.env
['LIBPATH_KDECORE'] = [os
.path
.join(self
.env
.KDE4_LIB_INSTALL_DIR
, 'kde4', 'devel'), self
.env
.KDE4_LIB_INSTALL_DIR
]
89 self
.env
['INCLUDES_KDECORE'] = [self
.env
['KDE4_INCLUDE_INSTALL_DIR']]
90 self
.env
.append_value('INCLUDES_KDECORE', [self
.env
['KDE4_INCLUDE_INSTALL_DIR']+ os
.sep
+ 'KDE'])
92 self
.find_program('msgfmt', var
='MSGFMT')