File: kde4.py

package info (click to toggle)
lv2fil 2.0%2B20100312.git18130f5a%2Bdfsg0-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 888 kB
  • sloc: python: 10,590; ansic: 1,180; makefile: 27; sh: 11
file content (77 lines) | stat: -rw-r--r-- 2,316 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#! /usr/bin/env python
# encoding: utf-8

#! /usr/bin/env python
# encoding: utf-8
# Thomas Nagy, 2006 (ita)

import os, sys, re, Object, Action, Utils, Common

class msgfmt_taskgen(Object.task_gen):
	def __init__(self, appname='set_your_app_name'):
		Object.task_gen.__init__(self)
		self.langs = '' # for example "foo/fr foo/br"
		self.chmod = 0644
		self.inst_var = 'KDE4_LOCALE_INSTALL_DIR'
		self.appname = appname

	def apply(self):

		for lang in self.to_list(self.langs):
			node = self.path.find_source_lst(Utils.split_path(lang+'.po'))
			task = self.create_task('msgfmt', self.env)
			task.set_inputs(node)
			task.set_outputs(node.change_ext('.mo'))

			if not Params.g_install: continue
			langname = lang.split('/')
			langname = langname[-1]
			inst_dir = langname+os.sep+'LC_MESSAGES'
			task.install = {'var':self.inst_var,'dir':inst_dir+'/','as':self.appname+'.mo','chmod':self.chmod}

def detect(conf):
	kdeconfig = conf.find_program('kde4-config')
	if not kdeconfig:
		conf.fatal('we need kde4-config')
	prefix = os.popen('%s --prefix' % kdeconfig).read().strip()
	file = '%s/share/apps/cmake/modules/KDELibsDependencies.cmake' % prefix
	try: os.stat(file)
	except OSError:
		file = '%s/share/apps/cmake/modules/KDELibsDependencies.cmake' % prefix
		try: os.stat(file)
		except: conf.fatal('could not open %s' % file)

	try:
		f = open(file, 'r')
		txt = f.read()
		f.close()
	except (OSError, IOError):
		conf.fatal('could not read %s' % file)

	txt = txt.replace('\\\n', '\n')
	fu = re.compile('#(.*)\n')
	txt = fu.sub('', txt)

	setregexp = re.compile('([sS][eE][tT]\s*\()\s*([^\s]+)\s+\"([^"]+)\"\)')
	found = setregexp.findall(txt)

	for (_, key, val) in found:
		#print key, val
		conf.env[key] = val

	# well well, i could just write an interpreter for cmake files
	conf.env['LIB_KDECORE']='kdecore'
	conf.env['LIB_KDEUI']  ='kdeui'
	conf.env['LIB_KIO']    ='kio'
	conf.env['LIB_KHTML']  ='khtml'
	conf.env['LIB_KPARTS'] ='kparts'

	conf.env['LIBPATH_KDECORE'] = conf.env['KDE4_LIB_INSTALL_DIR']
	conf.env['CPPPATH_KDECORE'] = conf.env['KDE4_INCLUDE_INSTALL_DIR']
	conf.env.append_value('CPPPATH_KDECORE', conf.env['KDE4_INCLUDE_INSTALL_DIR']+"/KDE")

	conf.env['MSGFMT'] = conf.find_program('msgfmt')

Action.simple_action('msgfmt', '${MSGFMT} ${SRC} -o ${TGT}', color='BLUE', prio=10)