jack2 codebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 lines
2.7KB

  1. #!/usr/bin/env python
  2. # encoding: utf-8
  3. # Thomas Nagy, 2006-2010 (ita)
  4. """
  5. Support for the KDE4 libraries and msgfmt
  6. """
  7. import os, sys, re
  8. from waflib import Options, TaskGen, Task, Utils
  9. from waflib.TaskGen import feature, after_method
  10. @feature('msgfmt')
  11. def apply_msgfmt(self):
  12. """
  13. Process all languages to create .mo files and to install them::
  14. def build(bld):
  15. bld(features='msgfmt', langs='es de fr', appname='myapp', install_path='${KDE4_LOCALE_INSTALL_DIR}')
  16. """
  17. for lang in self.to_list(self.langs):
  18. node = self.path.find_resource(lang+'.po')
  19. task = self.create_task('msgfmt', node, node.change_ext('.mo'))
  20. langname = lang.split('/')
  21. langname = langname[-1]
  22. inst = getattr(self, 'install_path', '${KDE4_LOCALE_INSTALL_DIR}')
  23. self.bld.install_as(
  24. inst + os.sep + langname + os.sep + 'LC_MESSAGES' + os.sep + getattr(self, 'appname', 'set_your_appname') + '.mo',
  25. task.outputs[0],
  26. chmod = getattr(self, 'chmod', Utils.O644))
  27. class msgfmt(Task.Task):
  28. """
  29. Transform .po files into .mo files
  30. """
  31. color = 'BLUE'
  32. run_str = '${MSGFMT} ${SRC} -o ${TGT}'
  33. def configure(self):
  34. """
  35. Detect kde4-config and set various variables for the *use* system::
  36. def options(opt):
  37. opt.load('compiler_cxx kde4')
  38. def configure(conf):
  39. conf.load('compiler_cxx kde4')
  40. def build(bld):
  41. bld.program(source='main.c', target='app', use='KDECORE KIO KHTML')
  42. """
  43. kdeconfig = self.find_program('kde4-config')
  44. prefix = self.cmd_and_log(kdeconfig + ['--prefix']).strip()
  45. fname = '%s/share/apps/cmake/modules/KDELibsDependencies.cmake' % prefix
  46. try: os.stat(fname)
  47. except OSError:
  48. fname = '%s/share/kde4/apps/cmake/modules/KDELibsDependencies.cmake' % prefix
  49. try: os.stat(fname)
  50. except OSError: self.fatal('could not open %s' % fname)
  51. try:
  52. txt = Utils.readf(fname)
  53. except EnvironmentError:
  54. self.fatal('could not read %s' % fname)
  55. txt = txt.replace('\\\n', '\n')
  56. fu = re.compile('#(.*)\n')
  57. txt = fu.sub('', txt)
  58. setregexp = re.compile('([sS][eE][tT]\s*\()\s*([^\s]+)\s+\"([^"]+)\"\)')
  59. found = setregexp.findall(txt)
  60. for (_, key, val) in found:
  61. #print key, val
  62. self.env[key] = val
  63. # well well, i could just write an interpreter for cmake files
  64. self.env['LIB_KDECORE']= ['kdecore']
  65. self.env['LIB_KDEUI'] = ['kdeui']
  66. self.env['LIB_KIO'] = ['kio']
  67. self.env['LIB_KHTML'] = ['khtml']
  68. self.env['LIB_KPARTS'] = ['kparts']
  69. self.env['LIBPATH_KDECORE'] = [os.path.join(self.env.KDE4_LIB_INSTALL_DIR, 'kde4', 'devel'), self.env.KDE4_LIB_INSTALL_DIR]
  70. self.env['INCLUDES_KDECORE'] = [self.env['KDE4_INCLUDE_INSTALL_DIR']]
  71. self.env.append_value('INCLUDES_KDECORE', [self.env['KDE4_INCLUDE_INSTALL_DIR']+ os.sep + 'KDE'])
  72. self.find_program('msgfmt', var='MSGFMT')