From: Stefan Bund Date: Mon, 4 Oct 2010 14:32:34 +0000 (+0200) Subject: Add Qt4DirectoryAsResource builder X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=2a9a97f319b1a62dcf729d868efde5abe894fbeb;p=qtscons.git Add Qt4DirectoryAsResource builder --- diff --git a/qt4.py b/qt4.py index 2363875..2e02775 100644 --- a/qt4.py +++ b/qt4.py @@ -36,6 +36,7 @@ __revision__ = "/home/scons/scons/branch.0/branch.96/baseline/src/engine/SCons/T import os.path import re +import fnmatch import SCons.Action import SCons.Builder @@ -397,6 +398,11 @@ def generate(env): # TODO: Does dbusxml2cpp need an adapter env.AddMethod(enable_modules, "EnableQt4Modules") + resourceDirectoryBuilder = Builder( + action = Action(resourceDirectory), + source_factory = env.Dir) + env.Append( BUILDERS = { 'Qt4ResourceFromDirectory' : resourceDirectoryBuilder } ) + # Utilities env.AddMethod(qt4glob, "Qt4Glob") @@ -538,8 +544,26 @@ def enable_modules(self, modules, debug=False, crosscompiling=False) : def qt4glob(env): resources = env.Glob("*.qrc") sources = [ f for f in env.Glob("*.cc") - if not f.name.startswith("qrc_") ] + if not f.name.startswith("qrc_") and not f.name.startswith("moc_") ] return sources + resources +def scanResourceDirectory(directory, prefix="", exclude=[]): + rv = [ + '', + # '', + '' ] + for base, subdirs, files in os.walk(str(directory)): + rv.append('' % os.path.join(prefix, base[len(str(directory)):])) + for f in files: + if not [True for pattern in exclude if fnmatch.fnmatch(f,pattern)]: + rv.append('%s' % (f, os.path.join(base, f))) + rv.append("''") + rv.append('\n') + return '\n'.join(rv) + +def resourceDirectory(env, target, source): + file(str(target[0]), 'w').write(scanResourceDirectory( + source[0], prefix=env.get('RESOURCE_PREFIX', ''), exclude=env.get('EXCLUDE', []))) + def exists(env): return _detect(env)