summaryrefslogtreecommitdiff
path: root/waffles
diff options
context:
space:
mode:
authorDmitrijs Ledkovs <dmitrij.ledkov@ubuntu.com>2010-03-20 20:16:37 +0000
committerDmitrijs Ledkovs <dmitrij.ledkov@ubuntu.com>2010-03-20 20:16:37 +0000
commit028ba3824ce426c30c972ddfb36c17c88e04ba8f (patch)
tree12a7479ee4deb38ef9e081d680464fe0f1b7431d /waffles
parentc9ff2037e34f6c1560b5db7b32cd6f78341f510d (diff)
Import upstream version 3.1.3~pre2
Diffstat (limited to 'waffles')
-rw-r--r--waffles/cross_linux_win32.py100
-rw-r--r--waffles/dbus.py40
-rw-r--r--waffles/documentation.py220
-rw-r--r--waffles/editor.py17
-rw-r--r--waffles/gecko.py239
-rw-r--r--waffles/gnome.py223
-rw-r--r--waffles/gtkhtml.py85
-rw-r--r--waffles/misc.py68
-rw-r--r--waffles/winres.py52
9 files changed, 669 insertions, 375 deletions
diff --git a/waffles/cross_linux_win32.py b/waffles/cross_linux_win32.py
new file mode 100644
index 0000000..73db9b9
--- /dev/null
+++ b/waffles/cross_linux_win32.py
@@ -0,0 +1,100 @@
+#!/usr/bin/env python
+# encoding: utf-8
+# Thomas Nagy, 2008 (ita)
+
+import os
+import Utils
+import ccroot
+from Configure import conftest
+
+@conftest
+def find_mingw_cc(conf):
+ v = conf.env
+ v['CC'] = None
+ cc = conf.find_program('i686-mingw32-gcc', var='CC')
+ if not cc: cc = conf.find_program('mingw32-cc', var='CC')
+ if not cc: cc = conf.find_program('i586-mingw32msvc-gcc', var='CC')
+ if not cc: cc = conf.find_program('i586-mingw32msvc-cc', var='CC')
+ if not cc: conf.fatal('mingw32-gcc was not found')
+ try:
+ if Utils.cmd_output('%s --version' % cc).find('mingw') < 0:
+ conf.fatal('mingw32-gcc was not found, see the result of gcc --version')
+ except ValueError:
+ conf.fatal('gcc --version could not be executed')
+ v['CC'] = v['LINK_CC'] = cc
+ v['CC_NAME'] = 'gcc'
+ ccroot.get_cc_version(conf, [cc], 'CC_VERSION')
+
+@conftest
+def find_mingw_ar(conf):
+ v = conf.env
+ v['AR'] = None
+ ar = conf.find_program('i686-mingw32-ar', var='AR')
+ if not ar: ar = conf.find_program('i586-mingw32msvc-ar', var='AR')
+ if not ar: conf.fatal('mingw32-ar was not found')
+ try:
+ if Utils.cmd_output('%s --version' % ar).find('ar') < 0:
+ conf.fatal('mingw32-ar was not found, see the result of %s --version' % ar)
+ except ValueError:
+ conf.fatal('ar --version could not be executed')
+ v['AR_NAME'] = 'ar'
+
+@conftest
+def find_mingw_ranlib(conf):
+ v = conf.env
+ v['RANLIB'] = None
+ ranlib = conf.find_program('i686-mingw32-ranlib', var='RANLIB')
+ if not ranlib: ranlib = conf.find_program('i586-mingw32msvc-ranlib', var='RANLIB')
+ if not ranlib: conf.fatal('mingw32-ranlib was not found')
+ try:
+ if Utils.cmd_output('%s --version' % ranlib).find('ranlib') < 0:
+ conf.fatal('mingw32-ranlib was not found, see the result of mingw32-ranlib --version')
+ except ValueError:
+ conf.fatal('ranlib --version could not be executed')
+ v['RANLIB_NAME'] = 'ranlib'
+
+
+@conftest
+def find_mingw_cxx_cpp(conf):
+ v = conf.env
+ v['CXX'] = None
+ cxx = conf.find_program('i686-mingw32-g++', var='CXX')
+ if not cxx: cxx = conf.find_program('mingw32-c++', var='CXX')
+ if not cxx: cxx = conf.find_program('i586-mingw32msvc-g++', var='CXX')
+ if not cxx: cxx = conf.find_program('i586-mingw32msvc-c++', var='CXX')
+ if not cxx: conf.fatal('mingw32-g++ was not found')
+ try:
+ if Utils.cmd_output('%s --version' % cxx).find('mingw') < 0:
+ conf.fatal('mingw32-g++ was not found, see the result of g++ --version')
+ except ValueError:
+ conf.fatal('g++ --version could not be executed')
+ v['CXX'] = v['LINK_CXX'] = v['COMPILER_CXX'] = v['CPP'] = v['LINK_CPP'] = cxx
+ v['CXX_NAME'] = 'gcc'
+
+@conftest
+def mingw_flags(conf):
+ # As we have to change target platform after the tools
+ # have been loaded there are a few variables that needs
+ # to be initiated if building for win32.
+ # Make sure we don't have -fPIC and/or -DPIC in our CCFLAGS
+ conf.env['shlib_CXXFLAGS'] = []
+
+ # Setup various target file patterns
+ conf.env['staticlib_PATTERN'] = '%s.lib'
+ conf.env['shlib_PATTERN'] = '%s.dll'
+ conf.env['program_PATTERN'] = '%s.exe'
+
+@conftest
+def mingw_libpath(conf):
+ # We must add the library and includes paths of Windows libs
+ msvc_path = conf.env['MSVC_LIBPATH'] or os.environ.get('MSVC_LIBPATH', '')
+ if not os.path.isdir(msvc_path): msvc_path = '/usr/i686-mingw32'
+ if not os.path.isdir(msvc_path): msvc_path = '/usr/mingw32'
+ if not os.path.isdir(msvc_path): msvc_path = '/usr/i586-mingw32msvc'
+ if not os.path.isdir(msvc_path):
+ conf.fatal('Could not find the msvc root dir - set it through MSVC_LIBPATH in the environment')
+ conf.env.prepend_value("LIBPATH", os.path.join(msvc_path, "lib"))
+ conf.env.prepend_value("CPPPATH", os.path.join(msvc_path, "include"))
+
+detect = 'find_mingw_ar find_mingw_ranlib find_mingw_cc find_mingw_cxx_cpp mingw_flags mingw_libpath'
+
diff --git a/waffles/dbus.py b/waffles/dbus.py
new file mode 100644
index 0000000..6fdf523
--- /dev/null
+++ b/waffles/dbus.py
@@ -0,0 +1,40 @@
+#!/usr/bin/env python
+# encoding: utf-8
+# Ali Sabil, 2007
+
+# modified for Xiphos compiling on Windows, 2009
+
+import Task, Utils
+from TaskGen import taskgen, before, after, feature
+
+@taskgen
+def add_dbus_file(self, filename, prefix, mode):
+ if not hasattr(self, 'dbus_lst'):
+ self.dbus_lst = []
+ self.meths.append('process_dbus')
+ self.dbus_lst.append([filename, prefix, mode])
+
+@before('apply_core')
+def process_dbus(self):
+ for filename, prefix, mode in getattr(self, 'dbus_lst', []):
+ env = self.env.copy()
+ node = self.path.find_resource(filename)
+
+ if not node:
+ raise Utils.WafError('file not found ' + filename)
+
+ env['DBUS_BINDING_TOOL_PREFIX'] = prefix
+ env['DBUS_BINDING_TOOL_MODE'] = mode
+
+ task = self.create_task('dbus_binding_tool', env)
+ task.set_inputs(node)
+ task.set_outputs(node.change_ext('.h'))
+
+# run command for Xiphos in windows shell
+Task.simple_task_type('dbus_binding_tool',
+ '${DBUS_BINDING_TOOL} --prefix=${DBUS_BINDING_TOOL_PREFIX} --mode=${DBUS_BINDING_TOOL_MODE} --output=${TGT} ${SRC}',
+ color='BLUE', before='cc', shell=True)
+
+def detect(conf):
+ dbus_binding_tool = conf.find_program('dbus-binding-tool', var='DBUS_BINDING_TOOL')
+
diff --git a/waffles/documentation.py b/waffles/documentation.py
new file mode 100644
index 0000000..19c0174
--- /dev/null
+++ b/waffles/documentation.py
@@ -0,0 +1,220 @@
+#!/usr/bin/env python
+# encoding: utf-8
+
+"Create help files"
+
+import os, re, shutil
+import Configure, TaskGen, Utils, Runner, Task, Build, Options, Logs
+import cc
+from Logs import error
+from TaskGen import taskgen, before, after, feature
+
+
+class xml_doc_taskgen(TaskGen.task_gen):
+ def __init__(self, *k, **kw):
+ TaskGen.task_gen.__init__(self, *k, **kw)
+
+
+@feature('xml_doc')
+def init_xml_doc(self):
+ self.env['XML2PO_FLAGS'] = getattr(self, 'flags', ['-e', '-p'])
+
+ if self.env['IS_WIN32']:
+ self.default_install_path = '${PREFIX}/share/help'
+ self.env['HTMLHELP_XSL'] = os.path.normpath(os.path.join(
+ self.env['ROOTDIR'], 'share/docbook/htmlhelp/htmlhelp.xsl'))
+ else:
+ self.default_install_path = '${PREFIX}/share/gnome/help/xiphos'
+
+
+@feature('xml_doc')
+@after('init_xml_doc')
+def apply_xml_doc(self):
+
+ def replace_backslash(node):
+ return node.abspath().replace('\\', '/')
+
+ def create_xml2po_task(lang):
+ node = self.path.find_resource(lang + os.sep + lang+'.po')
+ src = self.path.find_resource('C' + os.sep + self.doc_module+'.xml')
+ out = self.path.find_or_declare(lang + os.sep + self.doc_module+'.xml')
+
+ if self.env['IS_WIN32']:
+ # FIXME - xml2po on win32 fails with flags containing backslashes '\'
+ # failing example: python xml2po -e -p fr\fr.po C\xiphos.xml
+ node_str = replace_backslash(node)
+ src_str = replace_backslash(src)
+
+ # it is necessary pas to xml2po only paths with '/'
+ Task.simple_task_type('xml2po',
+ '${XML2PO} -e -p %s %s > ${TGT}' % (node_str, src_str),
+ color='BLUE')
+
+ tsk = self.create_task('xml2po')
+ tsk.set_inputs([node, src])
+ # waf will control output file if it exists, when task is done
+ tsk.set_outputs(out)
+ return tsk, out
+
+ def create_xsltproc_task(lang, src, after=[]):
+ out = self.path.find_or_declare(lang + os.sep + 'htmlhelp.hhp')
+ tsk = self.create_task('xsltproc')
+ tsk.set_inputs(src)
+ tsk.set_outputs(out)
+ if after:
+ tsk.run_after.append(after)
+ return tsk, out
+
+ def create_htmlhelpc_task(lang, src, after=[]):
+ out = self.path.find_or_declare(lang + os.sep + 'htmlhelp.chm')
+ tsk = self.create_task('htmlhelpc')
+ tsk.set_inputs(src)
+ tsk.set_outputs(out)
+ tsk.run_after.append(after)
+ return tsk, out
+
+ def copy_figures(lang, figures, out):
+ fig1 = self.path.find_resource(os.path.join(lang, figures[0]))
+ srcdir = os.path.dirname(os.path.dirname(fig1.abspath(self.env)))
+ destdir = os.path.dirname(out.abspath(self.env))
+ for fig in figures:
+ shutil.copyfile(os.path.join(srcdir, fig), os.path.join(destdir, fig))
+
+ def install_help(lang, self):
+ if self.env['IS_WIN32']:
+ chm_help = self.path.find_or_declare(lang + os.sep + 'htmlhelp.chm')
+ path = self.install_path
+ help_file = self.doc_module + '_' + lang + '.chm'
+ self.bld.install_as(os.path.join(path, help_file), chm_help.abspath(self.env))
+ else:
+ xml_help = self.path.find_or_declare(os.path.join(lang, self.doc_module+'.xml'))
+ path = os.path.join(self.install_path, lang)
+ bld = self.bld
+ # install xiphos.xml
+ bld.install_as(os.path.join(path, xml_help.file()), xml_help.abspath(self.env))
+ install_figures(lang, self)
+
+ def install_help_C(self):
+ if self.env['IS_WIN32']:
+ chm_help = self.path.find_or_declare('C' + os.sep + 'htmlhelp.chm')
+ path = self.install_path
+ self.bld.install_as(os.path.join(path, self.doc_module + '.chm'), chm_help.abspath(self.env))
+ else:
+ xml_help = self.path.find_resource('C' + os.sep + self.doc_module+'.xml')
+ path = self.install_path + os.sep + 'C'
+ bld = self.bld
+ # lang C needs all xml files
+ lst = self.to_list(self.doc_includes)
+ for item in lst:
+ bld.install_as(os.path.join(path, item),
+ os.path.join(self.path.abspath(), 'C', item))
+ bld.install_as(os.path.join(path, self.doc_entities),
+ os.path.join(self.path.abspath(), 'C', self.doc_entities))
+ bld.install_as(os.path.join(path, xml_help.file()), xml_help.abspath(self.env))
+ install_figures('C', self)
+
+ def install_figures(lang, self):
+ figures = self.to_list(self.doc_figures)
+ for fig in figures:
+ self.bld.install_as(os.path.join(self.install_path, lang, fig),
+ os.path.join(self.path.abspath(), lang, fig))
+
+
+ figures = self.to_list(self.doc_figures)
+ languages = self.to_list(self.doc_linguas)
+ # C help - doesn't need xml2po phase
+ # on win32 just xsltproc and htmlhelpc
+ if self.env['IS_WIN32']:
+ C_src = self.path.find_resource('C' + os.sep + self.doc_module+'.xml')
+ C_tsk, C_out = create_xsltproc_task('C', C_src)
+ copy_figures('C', figures, C_out)
+ create_htmlhelpc_task('C', C_out, C_tsk)
+
+ # translated help
+ for lang in languages:
+ # xml2po - localized help
+ tsk, out = create_xml2po_task(lang)
+
+ if self.env['IS_WIN32']:
+ # xsltproc - create html files
+ tsk2, out2 = create_xsltproc_task(lang, out, tsk)
+ # copy figures - hhc needs figures in the build dir
+ copy_figures(lang, figures, out2)
+ # CHM help - windows help format
+ tsk3, out3 = create_htmlhelpc_task(lang, out2, tsk2)
+
+ if self.bld.is_install:
+ install_help(lang, self)
+
+ # install C help
+ install_help_C(self)
+
+
+def exec_xsltproc(self):
+ '''
+ xsltproc save files to cwd (current working directory).
+ CWD in this case is folder where is translated documentation.
+ '''
+ env = self.env
+ input = self.inputs[0].abspath(env)
+ cwd = os.path.dirname(self.outputs[0].abspath(env))
+
+ # cmd='xsltproc htmlhelp.xsl xiphos.xml'
+ lst = []
+ lst.append(env['XSLTPROC'])
+ lst.append(env['HTMLHELP_XSL'])
+ lst.append(input)
+
+ lst = [lst]
+ ret = self.exec_command(*lst, cwd=cwd)
+
+ return ret
+
+def exec_htmlhelpc(self):
+ '''
+ hhc also saves files to cwd (current working directory).
+ '''
+ env = self.env
+ input = self.inputs[0].abspath(env)
+ cwd = os.path.dirname(input)
+
+ lst = []
+ lst.append(env['HTMLHELPC'])
+ lst.append(input)
+
+ lst = [lst]
+ ret = self.exec_command(*lst, cwd=cwd)
+
+ return not ret
+
+
+Task.simple_task_type('xml2po', '${XML2PO} -o ${TGT} ${XML2PO_FLAGS} ${SRC}', color='BLUE')
+Task.task_type_from_func('xsltproc', vars=['XSLTPROC', 'HTMLHELP_XSL'], color='BLUE', func=exec_xsltproc)
+Task.task_type_from_func('htmlhelpc', vars=['HTMLHELPC'], color='BLUE', func=exec_htmlhelpc)
+
+
+def detect(conf):
+ # xml2po
+ xml2po = conf.find_program('xml2po', var='XML2PO')
+ if not xml2po:
+ # xml2po: on win32 'xml2po' is not executable thus this hook
+ if conf.env['IS_WIN32']:
+ python = conf.find_program('python', var='PYTHON')
+ if not python:
+ conf.fatal('The program python (required by xml2po) could not be found')
+
+ xml2podir = Configure.find_file('xml2po', os.environ['PATH'].split(os.pathsep))
+ if not xml2podir:
+ conf.fatal('The program xml2po is mandatory!')
+
+ conf.env['XML2PO'] = Utils.to_list(conf.env['PYTHON']) + [xml2podir + os.sep + 'xml2po']
+ conf.check_message('xml2po', '', True, ' '.join(conf.env['XML2PO']))
+
+ else:
+ conf.fatal('The program xml2po is mandatory!')
+
+
+ if conf.env['IS_WIN32']:
+ xsltproc = conf.find_program('xsltproc', var='XSLTPROC')
+ htmlhelpc = conf.find_program('hhc', var='HTMLHELPC')
+
diff --git a/waffles/editor.py b/waffles/editor.py
deleted file mode 100644
index 0a4e5cb..0000000
--- a/waffles/editor.py
+++ /dev/null
@@ -1,17 +0,0 @@
-"""
-Stuff to detect libs and generate Editor-* sources for editor
-"""
-
-class ComponentEditor(object):
- '''
- Editor is a part of Xiphos
- '''
-
- def detect(self):
- pass
-
- def generate_srcfiles(self):
- pass
-
- def clean(self):
- pass
diff --git a/waffles/gecko.py b/waffles/gecko.py
deleted file mode 100644
index 5861bf2..0000000
--- a/waffles/gecko.py
+++ /dev/null
@@ -1,239 +0,0 @@
-"""
-Stuff to detect GECKO
-"""
-
-from os.path import join
-
-from Configure import conf
-
-from waffles.misc import *
-
-# needed for gecko 1.8
-# in libxul 1.9 all headers are in 2 folders
-# ${gecko_incldir}/stable ${gecko_incldir}/unstable
-gecko18_subdirs = '''
- commandhandler
- content
- docshell
- browser
- dom
- fastfind
- find
- gtkembedmoz
- gfx
- layout
- necko
- nspr
- pref
- string
- uriloader
- webbrwsr
- webshell
- widget
- xpcom
- '''.split()
-
-"""
- # TODO: implement gecko detecting (rewrite gecko.m4 in python)
-
- ## Gecko
-
- # other HARDCODED
- # TODO: When should be this define defined?
- # Define if mozilla is of the toolkit flavour */
- #dfn('HAVE_MOZILLA_TOOLKIT', 1)
-
-
-"""
-
-
-#dfn = conf.define
-#env = conf.env
-
-GECKOS = [
- 'libxul-embedding', # xul 1.9
- 'xulrunner-gtkmozembed', # xul 1.8
- 'xulrunner-windows', #windows
- ]
-
-
-class Gecko(object):
- """
- Stuff related to gecko detection
- """
- #DISTROS = [
- #_try_ubuntu804_xul19,
- #_try_gentoo_xul18,
- #]
-
- def __init__(self, conf, incldir='', libdir=''):
- self.incldir = incldir
- self.libdir = libdir
- self.conf = conf
- self.dfn = conf.define
- self.env = conf.env
-
-
- def detect(self):
- """
- Detect gecko in system
- TODO: ignore pkgconfig when supplied custom
- gecko incldir and libdir
- """
- #self.conf.check_cxx(cxxflags='-fshort-wchar',
- # errmsg='fail flag is needed for libxul 1.9')
- #self.env['GECKO_CCFLAGS'] = '-fshort-wchar'
-
- success = False
-
- # try xulwin
- if self.env['IS_WIN32']:
- success = self.try_libxulwin()
-
- else:
- # try first the latest xulrunner version
- success = self.try_libxul19()
-
- if not success:
- success = self.try_xulrunner18()
-
- return success
-
-
- def check_version(self, name):
-
- cfg = self.conf
- check_pkgver(cfg, name, '1.7', var='GECKO_1_7')
- check_pkgver(cfg, name, '1.8', var='GECKO_1_8')
- check_pkgver(cfg, name, '1.8.1', var='GECKO_1_8_1')
- check_pkgver(cfg, name, '1.9', var='GECKO_1_9')
-
-
- def get_gecko_includes(self, incldir):
- # put gecko subdirs in string with absolute paths
- gecko_include = ''
- for i in gecko18_subdirs:
- gecko_include += join(incldir, i) + ' '
- return gecko_include
-
-
-
- # Various configurations to try
-
-
-
- def try_libxul19(self):
- """
- Should work for:
- Ubuntu 8.04
- Ubuntu 8.10
- Gentoo with xulrunner-1.9
- """
- cfg = self.conf
- ret = False
- gecko = 'libxul-embedding'
- gecko_unstable = 'libxul-embedding-unstable'
- lib = 'GTKMOZEMBED'
- lib_unstable = 'GTKMOZEMBED_UNSTABLE'
-
- check_pkg(cfg, gecko, var=lib)
- check_pkg(cfg, gecko_unstable, var=lib_unstable)
-
- if self.env['HAVE_GTKMOZEMBED'] and self.env['HAVE_GTKMOZEMBED_UNSTABLE']:
- #incldir = self.get_pkgvar(gecko, 'includedir')
- self.check_version(gecko)
- libdir = get_pkgvar(self.conf, gecko, 'sdkdir')
- self.dfn('GECKO_HOME', libdir)
- self.env['GECKO_INCLUDE'] = '' # header files aren't in subdirs
-
- # NSS & NSPR
- # TODO: are NSS and NSPR really needed both?
- check_pkg(cfg, 'nss', var='GECKONSS')
- check_pkg(cfg, 'nspr', var='GECKONSPR')
-
- ret = True
-
- return ret
-
-
- def try_xulrunner18(self):
- """
- Should work for:
- Gentoo with xulrunner-1.8
- """
- cfg = self.conf
- ret = False
- gecko = 'xulrunner-gtkmozembed'
- lib = 'GTKMOZEMBED'
-
- check_pkg(cfg, gecko, var=lib)
-
- if self.env['HAVE_GTKMOZEMBED']:
- self.check_version(gecko)
- incldir = get_pkgvar(cfg, gecko, 'includedir')
- libdir = get_pkgvar(cfg, gecko, 'libdir')
- gecko_include = self.get_gecko_includes(incldir)
- self.dfn('GECKO_HOME', libdir)
- self.env['GECKO_INCLUDE'] = gecko_include
-
- check_pkg(cfg, 'xulrunner-nss', var='GECKONSS')
- check_pkg(cfg, 'xulrunner-nspr', var='GECKONSPR')
-
- ret = True
-
- return ret
-
- def try_libxulwin(self):
- v = self.env
- df = self.conf.define
-
- # FIXME hardcoded values
- #if v['IS_CROSS_WIN32']:
- d = v['MOZILLA_DISTDIR']
- df('HAVE_GTKMOZEMBED', 1)
- df('USE_GTKMOZEMBED', 1)
- df('HAVE_GECKO_1_7', 1)
- df('HAVE_GECKO_1_8', 1)
- df('HAVE_GECKO_1_8_1', 1)
- df('HAVE_GECKO_1_9', 1)
- v['ALL_LIBS'].append('GTKMOZEMBED')
- v['CPPPATH_GTKMOZEMBED'] = ['%s/sdk/include' % d,
- '%s/include' % d,
- '%s/include/widget' % d,
- '%s/include/xpcom' % d,
- '%s/include/dom' % d,
- '%s/include/content' % d,
- '%s/include/layout' % d,
- '%s/include/gfx' % d]
- v['LIBPATH_GTKMOZEMBED'] = ['%s/sdk/lib' % d]
- v['LIB_GTKMOZEMBED'] = ['xpcomglue_s', 'xpcom', 'xul', 'nspr4']
- ret = True
-
- #else:
- #ret = False
- #gecko = 'libxul'
- #lib = 'GTKMOZEMBED'
-
- #check_pkg(cfg, gecko, var=lib)
-
- #if self.env['HAVE_GTKMOZEMBED']:
- #self.check_version(gecko)
- #ret = True
-
- return ret
-
-
- def try_custom_conf(self):
- """
- Try values for gecko includedir and libdir
- supplied by user.
- """
- pass
-
- def try_custom_conf_xul19(self):
- """
- Try values for gecko includedir and libdir
- supplied by user.
- """
- pass
-
diff --git a/waffles/gnome.py b/waffles/gnome.py
new file mode 100644
index 0000000..4ef2892
--- /dev/null
+++ b/waffles/gnome.py
@@ -0,0 +1,223 @@
+#!/usr/bin/env python
+# encoding: utf-8
+# Thomas Nagy, 2006-2008 (ita)
+
+"Gnome support"
+
+import os, re
+import TaskGen, Utils, Runner, Task, Build, Options, Logs
+import cc
+from Logs import error
+from TaskGen import taskgen, before, after, feature
+
+n1_regexp = re.compile('<refentrytitle>(.*)</refentrytitle>', re.M)
+n2_regexp = re.compile('<manvolnum>(.*)</manvolnum>', re.M)
+
+def postinstall_schemas(prog_name):
+ if Build.bld.is_install:
+ dir = Build.bld.get_install_path('${PREFIX}/etc/gconf/schemas/%s.schemas' % prog_name)
+ if not Options.options.destdir:
+ # add the gconf schema
+ Utils.pprint('YELLOW', 'Installing GConf schema')
+ command = 'gconftool-2 --install-schema-file=%s 1> /dev/null' % dir
+ ret = Utils.exec_command(command)
+ else:
+ Utils.pprint('YELLOW', 'GConf schema not installed. After install, run this:')
+ Utils.pprint('YELLOW', 'gconftool-2 --install-schema-file=%s' % dir)
+
+def postinstall_icons():
+ dir = Build.bld.get_install_path('${DATAROOTDIR}/icons/hicolor')
+ if Build.bld.is_install:
+ if not Options.options.destdir:
+ # update the pixmap cache directory
+ Utils.pprint('YELLOW', "Updating Gtk icon cache.")
+ command = 'gtk-update-icon-cache -q -f -t %s' % dir
+ ret = Utils.exec_command(command)
+ else:
+ Utils.pprint('YELLOW', 'Icon cache not updated. After install, run this:')
+ Utils.pprint('YELLOW', 'gtk-update-icon-cache -q -f -t %s' % dir)
+
+def postinstall_scrollkeeper(prog_name):
+ if Build.bld.is_install:
+ # now the scrollkeeper update if we can write to the log file
+ if os.access('/var/log/scrollkeeper.log', os.W_OK):
+ dir1 = Build.bld.get_install_path('${PREFIX}/var/scrollkeeper')
+ dir2 = Build.bld.get_install_path('${DATAROOTDIR}/omf/%s' % prog_name)
+ command = 'scrollkeeper-update -q -p %s -o %s' % (dir1, dir2)
+ ret = Utils.exec_command(command)
+
+def postinstall(prog_name='myapp', schemas=1, icons=1, scrollkeeper=1):
+ if schemas: postinstall_schemas(prog_name)
+ if icons: postinstall_icons()
+ if scrollkeeper: postinstall_scrollkeeper(prog_name)
+
+# OBSOLETE
+class gnome_doc_taskgen(TaskGen.task_gen):
+ def __init__(self, *k, **kw):
+ TaskGen.task_gen.__init__(self, *k, **kw)
+
+@feature('gnome_doc')
+def init_gnome_doc(self):
+ self.default_install_path = '${PREFIX}/share'
+
+@feature('gnome_doc')
+@after('init_gnome_doc')
+def apply_gnome_doc(self):
+ self.env['APPNAME'] = self.doc_module
+ lst = self.to_list(self.doc_linguas)
+ bld = self.bld
+ lst.append('C')
+
+ for x in lst:
+ if not x == 'C':
+ tsk = self.create_task('xml2po')
+ node = self.path.find_resource(x+'/'+x+'.po')
+ src = self.path.find_resource('C/%s.xml' % self.doc_module)
+ out = self.path.find_or_declare('%s/%s.xml' % (x, self.doc_module))
+ tsk.set_inputs([node, src])
+ tsk.set_outputs(out)
+ else:
+ out = self.path.find_resource('%s/%s.xml' % (x, self.doc_module))
+
+ tsk2 = self.create_task('xsltproc2po')
+ out2 = self.path.find_or_declare('%s/%s-%s.omf' % (x, self.doc_module, x))
+ tsk2.set_outputs(out2)
+ node = self.path.find_resource(self.doc_module+".omf.in")
+ tsk2.inputs = [node, out]
+
+ tsk2.run_after.append(tsk)
+
+ if bld.is_install:
+ path = self.install_path + '/gnome/help/%s/%s' % (self.doc_module, x)
+ bld.install_files(self.install_path + '/omf', out2, env=self.env)
+ for y in self.to_list(self.doc_figures):
+ try:
+ os.stat(self.path.abspath() + '/' + x + '/' + y)
+ bld.install_as(path + '/' + y, self.path.abspath() + '/' + x + '/' + y)
+ except:
+ bld.install_as(path + '/' + y, self.path.abspath() + '/C/' + y)
+ bld.install_as(path + '/%s.xml' % self.doc_module, out.abspath(self.env))
+ if x == 'C':
+ xmls = self.to_list(self.doc_includes)
+ xmls.append(self.doc_entities)
+ for z in xmls:
+ out = self.path.find_resource('%s/%s' % (x, z))
+ bld.install_as(path + '/%s' % z, out.abspath(self.env))
+
+# OBSOLETE
+class xml_to_taskgen(TaskGen.task_gen):
+ def __init__(self, *k, **kw):
+ TaskGen.task_gen.__init__(self, *k, **kw)
+
+@feature('xml_to')
+def init_xml_to(self):
+ Utils.def_attrs(self,
+ source = 'xmlfile',
+ xslt = 'xlsltfile',
+ target = 'hey',
+ default_install_path = '${PREFIX}',
+ task_created = None)
+
+@feature('xml_to')
+@after('init_xml_to')
+def apply_xml_to(self):
+ xmlfile = self.path.find_resource(self.source)
+ xsltfile = self.path.find_resource(self.xslt)
+ tsk = self.create_task('xmlto', [xmlfile, xsltfile], xmlfile.change_ext('html'))
+ tsk.install_path = self.install_path
+
+def sgml_scan(self):
+ node = self.inputs[0]
+
+ env = self.env
+ variant = node.variant(env)
+
+ fi = open(node.abspath(env), 'r')
+ content = fi.read()
+ fi.close()
+
+ # we should use a sgml parser :-/
+ name = n1_regexp.findall(content)[0]
+ num = n2_regexp.findall(content)[0]
+
+ doc_name = name+'.'+num
+
+ if not self.outputs:
+ self.outputs = [self.generator.path.find_or_declare(doc_name)]
+
+ return ([], [doc_name])
+
+class gnome_sgml2man_taskgen(TaskGen.task_gen):
+ def __init__(self, *k, **kw):
+ TaskGen.task_gen.__init__(self, *k, **kw)
+
+@feature('gnome_sgml2man')
+def apply_gnome_sgml2man(self):
+ """
+ we could make it more complicated, but for now we just scan the document each time
+ """
+ assert(getattr(self, 'appname', None))
+
+ def install_result(task):
+ out = task.outputs[0]
+ name = out.name
+ ext = name[-1]
+ env = task.env
+ self.bld.install_files('${DATAROOTDIR}/man/man%s/' % ext, out, env)
+
+ self.bld.rescan(self.path)
+ for name in self.bld.cache_dir_contents[self.path.id]:
+ base, ext = os.path.splitext(name)
+ if ext != '.sgml': continue
+
+ task = self.create_task('sgml2man')
+ task.set_inputs(self.path.find_resource(name))
+ task.task_generator = self
+ if self.bld.is_install: task.install = install_result
+ # no outputs, the scanner does it
+ # no caching for now, this is not a time-critical feature
+ # in the future the scanner can be used to do more things (find dependencies, etc)
+ task.scan()
+
+cls = Task.simple_task_type('sgml2man', '${SGML2MAN} -o ${TGT[0].bld_dir(env)} ${SRC} > /dev/null', color='BLUE')
+cls.scan = sgml_scan
+cls.quiet = 1
+
+Task.simple_task_type('xmlto', '${XMLTO} html -m ${SRC[1].abspath(env)} ${SRC[0].abspath(env)}')
+
+Task.simple_task_type('xml2po', '${XML2PO} ${XML2POFLAGS} ${SRC} > ${TGT}', color='BLUE')
+
+# how do you expect someone to understand this?!
+xslt_magic = """${XSLTPROC2PO} -o ${TGT[0].abspath(env)} \
+--stringparam db2omf.basename ${APPNAME} \
+--stringparam db2omf.format docbook \
+--stringparam db2omf.lang ${TGT[0].abspath(env)[:-4].split('-')[-1]} \
+--stringparam db2omf.dtd '-//OASIS//DTD DocBook XML V4.1.2//EN' \
+--stringparam db2omf.omf_dir ${PREFIX}/share/omf \
+--stringparam db2omf.help_dir ${PREFIX}/share/gnome/help \
+--stringparam db2omf.omf_in ${SRC[0].abspath(env)} \
+--stringparam db2omf.scrollkeeper_cl ${SCROLLKEEPER_DATADIR}/Templates/C/scrollkeeper_cl.xml \
+${DB2OMF} ${SRC[1].abspath(env)}"""
+
+#--stringparam db2omf.dtd '-//OASIS//DTD DocBook XML V4.3//EN' \
+Task.simple_task_type('xsltproc2po', xslt_magic, color='BLUE')
+
+def detect(conf):
+ conf.check_tool('gnu_dirs glib2 dbus')
+ sgml2man = conf.find_program('docbook2man', var='SGML2MAN')
+
+ def getstr(varname):
+ return getattr(Options.options, varname, '')
+
+ # addefine also sets the variable to the env
+ conf.define('GNOMELOCALEDIR', os.path.join(conf.env['DATAROOTDIR'], 'locale'))
+
+ xml2po = conf.find_program('xml2po', var='XML2PO')
+ xsltproc2po = conf.find_program('xsltproc', var='XSLTPROC2PO')
+ conf.env['XML2POFLAGS'] = '-e -p'
+ conf.env['SCROLLKEEPER_DATADIR'] = Utils.cmd_output("scrollkeeper-config --pkgdatadir", silent=1).strip()
+ conf.env['DB2OMF'] = Utils.cmd_output("/usr/bin/pkg-config --variable db2omf gnome-doc-utils", silent=1).strip()
+
+def set_options(opt):
+ opt.add_option('--want-rpath', type='int', default=1, dest='want_rpath', help='set rpath to 1 or 0 [Default 1]')
+
diff --git a/waffles/gtkhtml.py b/waffles/gtkhtml.py
deleted file mode 100644
index 27be847..0000000
--- a/waffles/gtkhtml.py
+++ /dev/null
@@ -1,85 +0,0 @@
-"""
-Stuff to detect GTKHTML
-and generate Editor-* sources for
-component editor
-"""
-
-from waffles.misc import *
-
-# TODO: adjust for compilation with GTKHTML backend
-class Gtkhtml(object):
-
- def __init__(self, conf):
- self.conf = conf
- self.env = conf.env
-
- def detect(self):
- pass
- """
- Detect gtkhtml in system
- """
- #success = False
- success = self.try_api314()
-
- #if not success:
- #success = self.try_38()
-
- return success
-
-
-
- def try_api314(self):
-
- ret = False
- dfn = self.conf.define
-
- check_pkg(self.conf, 'libgtkhtml-3.14', var='GTKHTML')
-
- if self.env['HAVE_GTKHTML']:
- #dfn('USE_GTKHTML38', 1)
- dfn('USE_GTKHTML3_14', 1)
- self.set_vars('3.14')
- self.check_version323()
- ret = True
-
- return ret
-
-
- #def try_api38(self):
-
- #ret = False
-#
- #check_pkg(self.conf, 'libgtkhtml-3.8', mandatory=True, var='GTKHTML')
-
- #if self.env['GTKHTML']:
- #self.conf.define('USE_GTKHTML38', 1)
- #self.set_vars('3.8')
- #ret = True
-
- #return ret
-
-
- def set_vars(self, api_ver):
-
- dfn = self.conf.define
- api = get_pkgvar(self.conf, 'libgtkhtml-%s' % api_ver,
- 'gtkhtml_apiversion')
- data_dir = get_pkgvar(self.conf, 'libgtkhtml-%s' % api_ver,
- 'gtkhtml_datadir')
-
- self.env['GTKHTML_DATA'] = data_dir
- dfn('GTKHTML_API_VERSION', api)
- dfn('GTKHTML_DATA_DIR', data_dir)
-
-
- def check_version323(self):
- """
- gtkhtml >=3.23 don't need generating sources form Editor.idl
- """
- check_pkgver(self.conf, 'libgtkhtml-3.14', '3.23', var='EDITOR_IDL')
-
- if self.conf.env['HAVE_EDITOR_IDL']:
- check_pkg(self.conf, 'gtkhtml-editor', mandatory=True, var='GTKHTML_EDITOR')
- self.conf.define('USE_GTKHTML3_14_23', 1)
-
-
diff --git a/waffles/misc.py b/waffles/misc.py
index 2c227d4..6734027 100644
--- a/waffles/misc.py
+++ b/waffles/misc.py
@@ -1,7 +1,8 @@
+from Configure import conf
+
"""
General useful functions
"""
-
def myokmsg(kw):
"""
some customization for displaying pkg-config values on the line with ok msg
@@ -13,24 +14,8 @@ def myokmsg(kw):
# pkgconfig utils
-
-def get_pkgvar(conf, pkg, var):
- """
- Read a variable from package using pkg-config
- """
-
- # for cross-compilation it is necessary to prepend custom
- # prefix for include paths
- if conf.env['IS_CROSS_WIN32']:
- ret = conf.check_cfg(package=pkg, args='--variable=%s --define-variable=prefix=%s'%(var, conf.env['PKG_CONFIG_PREFIX'] ), okmsg=myokmsg,
- msg='Checking for var %s in %s' % (var, pkg)).strip()
- else:
- ret = conf.check_cfg(package=pkg, args='--variable=%s' % var, okmsg=myokmsg,
- msg='Checking for var %s in %s' % (var, pkg)).strip()
- return ret
-
-
-def check_pkg(conf, name, version='', mandatory=False, var=None):
+@conf
+def check_pkg(self, name, version='', mandatory=False, var=None):
"""
Check package version and its cflags/libs
"""
@@ -39,51 +24,65 @@ def check_pkg(conf, name, version='', mandatory=False, var=None):
# for cross-compilation it is necessary to prepend custom
# prefix for include paths
- if conf.env['IS_CROSS_WIN32']:
- conf.check_cfg (package=name, uselib_store=var, args='--cflags --libs --define-variable=prefix=%s'%conf.env['PKG_CONFIG_PREFIX'],
+ if self.env['IS_CROSS_WIN32']:
+ self.check_cfg (package=name, uselib_store=var, args='--cflags --libs --define-variable=prefix=%s'%self.env['PKG_CONFIG_PREFIX'],
atleast_version=version, mandatory=mandatory)
else:
- conf.check_cfg (package=name, uselib_store=var, args='--cflags --libs',
+ self.check_cfg (package=name, uselib_store=var, args='--cflags --libs',
atleast_version=version, mandatory=mandatory)
# make available libs to all source files
#(compile code with cflags from pkgconf e.g. -fshort-wchar, -mms-bitfields)
- conf.env.append_value('ALL_LIBS', var)
-
+ self.env.append_value('ALL_LIBS', var)
-def check_pkg_msg(conf, name, version='', mandatory=False, var=None, msg=''):
+@conf
+def check_pkg_msg(self, name, version='', mandatory=False, var=None, msg=''):
"""
Check package version and its cflags/libs
"""
if not var:
var = name.split ('-')[0].upper ()
- conf.check_cfg (package=name, uselib_store=var, args='--cflags --libs',
+ self.check_cfg (package=name, uselib_store=var, args='--cflags --libs',
atleast_version=version, mandatory=mandatory, msg=msg)
# make available libs to all source files
#(compile code with cflags from pkgconf e.g. -fshort-wchar, -mms-bitfields)
- conf.env.append_value('ALL_LIBS', var)
-
+ self.env.append_value('ALL_LIBS', var)
+@conf
+def get_pkgvar(self, pkg, var):
+ """
+ Read a variable from package using pkg-config
+ """
+ # for cross-compilation it is necessary to prepend custom
+ # prefix for include paths
+ if self.env['IS_CROSS_WIN32']:
+ ret = self.check_cfg(package=pkg, args='--variable=%s --define-variable=prefix=%s'%(var, self.env['PKG_CONFIG_PREFIX'] ), okmsg=myokmsg,
+ msg='Checking for var %s in %s' % (var, pkg)).strip()
+ else:
+ ret = self.check_cfg(package=pkg, args='--variable=%s' % var, okmsg=myokmsg,
+ msg='Checking for var %s in %s' % (var, pkg)).strip()
+ return ret
-def check_pkgver(conf, name, version='', mandatory=False, var=None):
+@conf
+def check_pkgver(self, name, version='', mandatory=False, var=None):
"""
Check package version without cflags/libs
"""
if not var:
var = name.split ('-')[0].upper ()
- conf.check_cfg (package=name, uselib_store=var,
+ self.check_cfg (package=name, uselib_store=var,
atleast_version=version, mandatory=mandatory)
-
-def check_pkgver_msg(conf, name, version='', mandatory=False, var=None, msg=''):
+@conf
+def check_pkgver_msg(self, name, version='', mandatory=False, var=None, msg=''):
"""
Check package version without cflags/libs
"""
if not var:
var = name.split ('-')[0].upper ()
- conf.check_cfg (package=name, uselib_store=var,
+ self.check_cfg (package=name, uselib_store=var,
atleast_version=version, mandatory=mandatory, msg=msg)
@@ -94,7 +93,8 @@ def escape(string):
"""
return string.decode('string-escape')
-def escpath(path):
+@conf
+def escpath(self, path):
"""
Escape path - useful in win32
"""
diff --git a/waffles/winres.py b/waffles/winres.py
new file mode 100644
index 0000000..656e4b5
--- /dev/null
+++ b/waffles/winres.py
@@ -0,0 +1,52 @@
+#!/usr/bin/env python
+# encoding: utf-8
+# Brant Young, 2007
+
+"This hook is called when the class cpp/cc task generator encounters a '.rc' file: X{.rc -> [.res|.rc.o]}"
+
+import os, sys, re
+import TaskGen, Task
+from Utils import quote_whitespace
+from TaskGen import extension
+
+EXT_WINRC = ['.rc']
+
+winrc_str = '${WINRC} ${_CPPDEFFLAGS} ${_CCDEFFLAGS} ${WINRCFLAGS} ${_CPPINCFLAGS} ${_CCINCFLAGS} ${WINRC_TGT_F} ${TGT} ${WINRC_SRC_F} ${SRC}'
+
+@extension(EXT_WINRC)
+def rc_file(self, node):
+ obj_ext = '.rc.o'
+ if self.env['WINRC_TGT_F'] == '/fo': obj_ext = '.res'
+
+ rctask = self.create_task('winrc')
+ rctask.set_inputs(node)
+ rctask.set_outputs(node.change_ext(obj_ext))
+
+ # make linker can find compiled resource files
+ self.compiled_tasks.append(rctask)
+
+# create our action, for use with rc file
+Task.simple_task_type('winrc', winrc_str, color='BLUE', before='cc cxx', shell=False)
+
+def detect(conf):
+ v = conf.env
+
+ winrc = v['WINRC']
+ v['WINRC_TGT_F'] = '-o'
+ v['WINRC_SRC_F'] = '-i'
+ # find rc.exe
+ if not winrc:
+ if v['CC_NAME'] in ['gcc', 'cc', 'g++', 'c++']:
+ winrc = conf.find_program('windres', var='WINRC', path_list = v['PATH'])
+ # cross-compilation
+ if not winrc:
+ winrc = conf.find_program('i686-mingw32-windres', var='WINRC', path_list = v['PATH'])
+ elif v['CC_NAME'] == 'msvc':
+ winrc = conf.find_program('RC', var='WINRC', path_list = v['PATH'])
+ v['WINRC_TGT_F'] = '/fo'
+ v['WINRC_SRC_F'] = ''
+ if not winrc:
+ conf.fatal('winrc was not found!')
+
+ v['WINRCFLAGS'] = ''
+