3
# Thomas Nagy, 2006 (ita)
6
import Options, TaskGen, Task, Utils
7
from TaskGen import taskgen, feature, after
9
class msgfmt_taskgen(TaskGen.task_gen):
10
def __init__(self, *k, **kw):
11
TaskGen.task_gen.__init__(self, *k, **kw)
14
def init_msgfmt(self):
15
#langs = '' # for example "foo/fr foo/br"
16
self.default_install_path = '${KDE4_LOCALE_INSTALL_DIR}'
20
def apply_msgfmt(self):
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
if not self.bld.is_install: continue
26
langname = lang.split('/')
27
langname = langname[-1]
28
task.install_path = self.install_path + os.sep + langname + os.sep + 'LC_MESSAGES'
29
task.filename = getattr(self, 'appname', 'set_your_appname') + '.mo'
30
task.chmod = self.chmod
33
kdeconfig = conf.find_program('kde4-config')
35
conf.fatal('we need kde4-config')
36
prefix = Utils.cmd_output('%s --prefix' % kdeconfig, silent=True).strip()
37
file = '%s/share/apps/cmake/modules/KDELibsDependencies.cmake' % prefix
40
file = '%s/share/kde4/apps/cmake/modules/KDELibsDependencies.cmake' % prefix
42
except OSError: conf.fatal('could not open %s' % file)
45
txt = Utils.readf(file)
46
except (OSError, IOError):
47
conf.fatal('could not read %s' % file)
49
txt = txt.replace('\\\n', '\n')
50
fu = re.compile('#(.*)\n')
53
setregexp = re.compile('([sS][eE][tT]\s*\()\s*([^\s]+)\s+\"([^"]+)\"\)')
54
found = setregexp.findall(txt)
56
for (_, key, val) in found:
60
# well well, i could just write an interpreter for cmake files
61
conf.env['LIB_KDECORE']='kdecore'
62
conf.env['LIB_KDEUI'] ='kdeui'
63
conf.env['LIB_KIO'] ='kio'
64
conf.env['LIB_KHTML'] ='khtml'
65
conf.env['LIB_KPARTS'] ='kparts'
67
conf.env['LIBPATH_KDECORE'] = conf.env['KDE4_LIB_INSTALL_DIR']
68
conf.env['CPPPATH_KDECORE'] = conf.env['KDE4_INCLUDE_INSTALL_DIR']
69
conf.env.append_value('CPPPATH_KDECORE', conf.env['KDE4_INCLUDE_INSTALL_DIR']+"/KDE")
71
conf.env['MSGFMT'] = conf.find_program('msgfmt')
73
Task.simple_task_type('msgfmt', '${MSGFMT} ${SRC} -o ${TGT}', color='BLUE', shell=False)