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