summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2004-07-12 20:33:44 (GMT)
committerSteven Knight <knight@baldmt.com>2004-07-12 20:33:44 (GMT)
commitbb10501c96110a8f9a9068344c7f89e79e97fef2 (patch)
tree5a136a3e8fc5e26951471930ae036f53d88254e0 /src
parent1c1b7792121a066fc3cb9537879c71e86b676102 (diff)
downloadSCons-bb10501c96110a8f9a9068344c7f89e79e97fef2.zip
SCons-bb10501c96110a8f9a9068344c7f89e79e97fef2.tar.gz
SCons-bb10501c96110a8f9a9068344c7f89e79e97fef2.tar.bz2
QT fixes and enhancements: Moc() and Uic() builders, a lot of new variables. (Christoph Wiedemann)
Diffstat (limited to 'src')
-rw-r--r--src/CHANGES.txt9
-rw-r--r--src/engine/SCons/Builder.py28
-rw-r--r--src/engine/SCons/BuilderTests.py45
-rw-r--r--src/engine/SCons/Node/FS.py7
-rw-r--r--src/engine/SCons/Script/__init__.py2
-rw-r--r--src/engine/SCons/Tool/__init__.py4
-rw-r--r--src/engine/SCons/Tool/link.py4
-rw-r--r--src/engine/SCons/Tool/qt.py299
8 files changed, 275 insertions, 123 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index 0ecb526..72748d9 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -16,9 +16,6 @@ RELEASE 0.96 - XXX
- Allow construction variable substitutions in $LIBS specifications.
- - Add a $QT_AUTOBUILD_MOC_SOURCES construction variable that controls
- whether moc-generated .cpp files get compiled.
-
- Allow the emitter argument to a Builder() to be or expand to a list
of emitter functions, which will be called in sequence.
@@ -420,6 +417,12 @@ RELEASE 0.95 - Mon, 08 Mar 2004 06:43:20 -0600
the flags from the environment used to specify the target, not
the environment that first has the Qt Builders attached.
+ - Add new Moc() and Uic() Builders for Qt, and a slew of $QT_*
+ construction variables to control them.
+
+ - Add a new single_source keyword argument for Builders that enforces
+ a single source file on calls to the Builder.
+
RELEASE 0.94 - Fri, 07 Nov 2003 05:29:48 -0600
diff --git a/src/engine/SCons/Builder.py b/src/engine/SCons/Builder.py
index 1dcf84c..57f50c9 100644
--- a/src/engine/SCons/Builder.py
+++ b/src/engine/SCons/Builder.py
@@ -311,6 +311,10 @@ def _init_nodes(builder, env, overrides, tlist, slist):
elif t.sources != slist:
raise UserError, "Multiple ways to build the same target were specified for: %s" % str(t)
+ if builder.single_source:
+ if len(slist) > 1:
+ raise UserError, "More than one source given for single-source builder: targets=%s sources=%s" % (map(str,tlist), map(str,slist))
+
# The targets are fine, so find or make the appropriate Executor to
# build this particular list of targets from this particular list of
# sources.
@@ -400,6 +404,7 @@ class BuilderBase:
emitter = None,
multi = 0,
env = None,
+ single_source = 0,
**overrides):
if __debug__: logInstanceCreation(self, 'BuilderBase')
self.action = SCons.Action.Action(action)
@@ -411,6 +416,7 @@ class BuilderBase:
suffix = CallableSelector(suffix)
self.suffix = suffix
self.env = env
+ self.single_source = single_source
if overrides.has_key('overrides'):
SCons.Warnings.warn(SCons.Warnings.DeprecatedWarning,
"The \"overrides\" keyword to Builder() creation has been deprecated;\n" +\
@@ -522,6 +528,21 @@ class BuilderBase:
if source is _null:
source = target
target = None
+
+ if(self.single_source and
+ SCons.Util.is_List(source) and
+ len(source) > 1 and
+ target is None):
+ result = []
+ if target is None: target = [None]*len(source)
+ for k in range(len(source)):
+ t = self._execute(env, target[k], source[k], overwarn)
+ if SCons.Util.is_List(t):
+ result.extend(t)
+ else:
+ result.append(t)
+ return result
+
tlist, slist = self._create_nodes(env, overwarn, target, source)
if len(tlist) == 1:
@@ -605,6 +626,7 @@ class ListBuilder(SCons.Util.Proxy):
self.env = env
self.tlist = tlist
self.multi = builder.multi
+ self.single_source = builder.single_source
def targets(self, node):
"""Return the list of targets for this builder instance.
@@ -639,11 +661,13 @@ class MultiStepBuilder(BuilderBase):
source_factory = SCons.Node.FS.default_fs.File,
target_scanner = None,
source_scanner = None,
- emitter=None):
+ emitter=None,
+ single_source=0):
if __debug__: logInstanceCreation(self)
BuilderBase.__init__(self, action, prefix, suffix, src_suffix,
target_factory, source_factory,
- target_scanner, source_scanner, emitter)
+ target_scanner, source_scanner, emitter,
+ single_source = single_source)
if not SCons.Util.is_List(src_builder):
src_builder = [ src_builder ]
self.src_builder = src_builder
diff --git a/src/engine/SCons/BuilderTests.py b/src/engine/SCons/BuilderTests.py
index e592250..57e9f28 100644
--- a/src/engine/SCons/BuilderTests.py
+++ b/src/engine/SCons/BuilderTests.py
@@ -524,6 +524,51 @@ class BuilderTestCase(unittest.TestCase):
tgt = builder(my_env, source = 'f6.zzz')
assert tgt.path == 'f6.emit', tgt.path
+ def test_single_source(self):
+ """Test Builder with single_source flag set"""
+ def func(target, source, env):
+ open(str(target[0]), "w")
+ if (len(source) == 1 and len(target) == 1):
+ env['CNT'][0] = env['CNT'][0] + 1
+
+ env = Environment()
+ infiles = []
+ outfiles = []
+ for i in range(10):
+ infiles.append(test.workpath('%d.in' % i))
+ outfiles.append(test.workpath('%d.out' % i))
+ test.write(infiles[-1], "\n")
+ builder = SCons.Builder.Builder(action=SCons.Action.Action(func,None),
+ single_source = 1, suffix='.out')
+ env['CNT'] = [0]
+ tgt = builder(env, target=outfiles[0], source=infiles[0])
+ tgt.prepare()
+ tgt.build()
+ assert env['CNT'][0] == 1, env['CNT'][0]
+ tgt = builder(env, outfiles[1], infiles[1])
+ tgt.prepare()
+ tgt.build()
+ assert env['CNT'][0] == 2
+ tgts = builder(env, infiles[2:4])
+ for t in tgts: t.prepare()
+ tgts[0].build()
+ tgts[1].build()
+ assert env['CNT'][0] == 4
+ try:
+ tgt = builder(env, outfiles[4], infiles[4:6])
+ except SCons.Errors.UserError:
+ pass
+ else:
+ assert 0
+ try:
+ # The builder may output more than one target per input file.
+ tgt = builder(env, outfiles[4:6], infiles[4:6])
+ except SCons.Errors.UserError:
+ pass
+ else:
+ assert 0
+
+
def test_ListBuilder(self):
"""Testing ListBuilder class."""
def function2(target, source, env, tlist = [outfile, outfile2], **kw):
diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py
index e61878b..72ed154 100644
--- a/src/engine/SCons/Node/FS.py
+++ b/src/engine/SCons/Node/FS.py
@@ -169,15 +169,16 @@ LocalCopy = SCons.Action.Action(LinkFunc, LocalString)
def UnlinkFunc(target, source, env):
t = target[0]
- t.fs.unlink(t.path)
+ t.fs.unlink(t.abspath)
return 0
Unlink = SCons.Action.Action(UnlinkFunc, None)
def MkdirFunc(target, source, env):
t = target[0]
- if not t.fs.exists(t.path):
- t.fs.mkdir(t.path)
+ p = t.abspath
+ if not t.fs.exists(p):
+ t.fs.mkdir(p)
return 0
Mkdir = SCons.Action.Action(MkdirFunc, None, presub=None)
diff --git a/src/engine/SCons/Script/__init__.py b/src/engine/SCons/Script/__init__.py
index 835409e..853a944 100644
--- a/src/engine/SCons/Script/__init__.py
+++ b/src/engine/SCons/Script/__init__.py
@@ -96,7 +96,7 @@ class BuildTask(SCons.Taskmaster.Task):
target = self.targets[0]
if target.get_state() == SCons.Node.up_to_date:
if self.top and target.has_builder():
- display("scons: `%s' is up to date." % str(target))
+ display("scons: `%s' is up to date." % str(self.node))
elif target.has_builder() and not hasattr(target.builder, 'status'):
if print_time:
start_time = time.time()
diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py
index 4364cf3..5753bb9 100644
--- a/src/engine/SCons/Tool/__init__.py
+++ b/src/engine/SCons/Tool/__init__.py
@@ -174,7 +174,7 @@ def createObjBuilders(env):
prefix = '$OBJPREFIX',
suffix = '$OBJSUFFIX',
src_builder = ['CFile', 'CXXFile'],
- source_scanner = SCons.Defaults.ObjSourceScan)
+ source_scanner = SCons.Defaults.ObjSourceScan, single_source=1)
env['BUILDERS']['StaticObject'] = static_obj
env['BUILDERS']['Object'] = static_obj
env['OBJEMITTER'] = SCons.Defaults.StaticObjectEmitter
@@ -187,7 +187,7 @@ def createObjBuilders(env):
prefix = '$SHOBJPREFIX',
suffix = '$SHOBJSUFFIX',
src_builder = ['CFile', 'CXXFile'],
- source_scanner = SCons.Defaults.ObjSourceScan)
+ source_scanner = SCons.Defaults.ObjSourceScan, single_source=1)
env['BUILDERS']['SharedObject'] = shared_obj
env['SHOBJEMITTER'] = SCons.Defaults.SharedObjectEmitter
diff --git a/src/engine/SCons/Tool/link.py b/src/engine/SCons/Tool/link.py
index cc0d4f4..8248be9 100644
--- a/src/engine/SCons/Tool/link.py
+++ b/src/engine/SCons/Tool/link.py
@@ -52,7 +52,9 @@ def generate(env):
env['SHLINK'] = '$LINK'
env['SHLINKFLAGS'] = SCons.Util.CLVar('$LINKFLAGS -shared')
env['SHLINKCOM'] = '$SHLINK $SHLINKFLAGS -o $TARGET $SOURCES $_LIBDIRFLAGS $_LIBFLAGS'
- env['SHLIBEMITTER']= None
+ # don't set up the emitter, cause AppendUnique will generate a list
+ # starting with None :-(
+ #env['SHLIBEMITTER']= None
env['SMARTLINK'] = smart_link
env['LINK'] = "$SMARTLINK"
env['LINKFLAGS'] = SCons.Util.CLVar('')
diff --git a/src/engine/SCons/Tool/qt.py b/src/engine/SCons/Tool/qt.py
index 01a5cf6..0a45e55 100644
--- a/src/engine/SCons/Tool/qt.py
+++ b/src/engine/SCons/Tool/qt.py
@@ -41,10 +41,33 @@ import SCons.Defaults
import SCons.Tool
import SCons.Util
-header_extensions = [".h", ".hxx", ".hpp", ".hh"]
+class ToolQtWarning(SCons.Warnings.Warning):
+ pass
+
+class GeneratedMocFileNotIncluded(ToolQtWarning):
+ pass
+
+class QtdirNotFound(ToolQtWarning):
+ pass
+SCons.Warnings.enableWarningClass(ToolQtWarning)
+
+header_extensions = [".h", ".hxx", ".hpp", ".hh"]
if SCons.Util.case_sensitive_suffixes('.h', '.H'):
header_extensions.append('.H')
+cplusplus = __import__('c++', globals(), locals(), [])
+cxx_suffixes = cplusplus.CXXSuffixes
+
+def checkMocIncluded(target, source, env):
+ moc = target[0]
+ cpp = source[0]
+ # looks like cpp.includes is cleared before the build stage :-(
+ includes = SCons.Defaults.CScan(cpp, env)
+ if not moc in includes:
+ SCons.Warnings.warn(
+ GeneratedMocFileNotIncluded,
+ "Generated moc file '%s' is not included by '%s'" %
+ (str(moc), str(cpp)))
class _Automoc:
"""
@@ -52,87 +75,105 @@ class _Automoc:
StaticLibraries.
"""
- def __init__(self, objBuilderName,uicDeclBuild,mocFromHBld,mocFromCppBld):
+ def __init__(self, objBuilderName):
self.objBuilderName = objBuilderName
- self.uicDeclBld = uicDeclBuild
- self.mocFromHBld = mocFromHBld
- self.mocFromCppBld = mocFromCppBld
def __call__(self, target, source, env):
"""
Smart autoscan function. Gets the list of objects for the Program
or Lib. Adds objects and builders for the special qt files.
"""
+ try:
+ if int(env.subst('$QT_AUTOSCAN')) == 0:
+ return target, source
+ except ValueError:
+ pass
+ try:
+ debug = int(env.subst('$QT_DEBUG'))
+ except ValueError:
+ debug = 0
+
+ # some shortcuts used in the scanner
FS = SCons.Node.FS.default_fs
splitext = SCons.Util.splitext
-
+ objBuilder = getattr(env, self.objBuilderName)
+
# To make the following work, we assume that we stay in the
# root directory
- old_os_cwd = os.getcwd()
- old_fs_cwd = FS.getcwd()
- FS.chdir(FS.Dir('#'), change_os_dir=1)
-
- # a regular expression for the Q_OBJECT macro
- # currently fails, when Q_OBJECT is in comment (e.g. /* Q_OBJECT */)
- q_object_search = re.compile(r'\sQ_OBJECT[\s;]')
- # out_sources contains at least all sources for the Library or Prog
+ #old_os_cwd = os.getcwd()
+ #old_fs_cwd = FS.getcwd()
+ #FS.chdir(FS.Dir('#'), change_os_dir=1)
+
+ # some regular expressions:
+ # Q_OBJECT detection
+ q_object_search = re.compile(r'[^A-Za-z0-9]Q_OBJECT[^A-Za-z0-9]')
+ # cxx and c comment 'eater'
+ comment = re.compile(r'(//.*)|(/\*(([^*])|(\*[^/]))*\*/)')
+
+ # The following is kind of hacky to get builders working properly (FIXME)
+ objBuilderEnv = objBuilder.env
+ objBuilder.env = env
+ mocBuilderEnv = env.Moc.env
+ env.Moc.env = env
+
+ # make a deep copy for the result; MocH objects will be appended
out_sources = source[:]
- for s in source:
- prefix, suffix = splitext(str(s))
- # Nodes for header (h) / moc file (moc_cpp) / cpp file (cpp)
- # and ui.h file (ui_h)
- cpp = s.sources[0]
- ui = None
- if cpp.sources != None and len(cpp.sources) > 0:
- src_src_suffix = splitext(str(cpp.sources[0]))[1]
- if src_src_suffix == env.subst('$QT_UISUFFIX'):
- ui = cpp.sources[0]
-
- src_prefix, src_suffix = splitext(str(cpp.srcnode()))
+
+ for obj in source:
+ if not obj.has_builder():
+ # binary obj file provided
+ if debug:
+ print "scons: qt: '%s' seems to be a binary. Discarded." % str(obj)
+ continue
+ cpp = obj.sources[0]
+ if not splitext(str(cpp))[1] in cxx_suffixes:
+ if debug:
+ print "scons: qt: '%s' is no cxx file. Discarded." % str(cpp)
+ # c or fortran source
+ continue
+ cpp_contents = comment.sub('', cpp.get_contents())
h=None
for h_ext in header_extensions:
- if os.path.exists(src_prefix + h_ext):
- h = FS.File(src_prefix + h_ext)
-
- if ui:
- # file built from .ui file -> build also header from .ui
- h = self.uicDeclBld(env, prefix, ui)
- env.Depends(cpp, h)
- ui_h_suff = env.subst('$QT_UIHSUFFIX')
- if os.path.exists(src_prefix + ui_h_suff):
- # if a .ui.h file exists, we need to specify the dependecy ...
- ui_h = FS.File(src_prefix + ui_h_suff)
- env.Depends(cpp, ui_h)
- if (h and q_object_search.search(h.get_contents())) or ui:
+ # try to find the header file in the corresponding source
+ # directory
+ hname = splitext(cpp.name)[0] + h_ext
+ h = SCons.Node.FS.find_file(hname,
+ (cpp.get_dir(),),
+ FS.File)
+ if h:
+ if debug:
+ print "scons: qt: Scanning '%s' (header of '%s')" % (str(h), str(cpp))
+ h_contents = comment.sub('', h.get_contents())
+ break
+ if not h and debug:
+ print "scons: qt: no header for '%s'." % (str(cpp))
+ if h and q_object_search.search(h_contents):
# h file with the Q_OBJECT macro found -> add moc_cpp
- d,base = os.path.split(prefix)
- src_ext = splitext(str(h))[1]
- moc_cpp = FS.File(os.path.join(d,
- env['QT_MOCNAMEGENERATOR'](base, src_ext, env)))
- objBuilder = getattr(env, self.objBuilderName)
- if env.get('QT_AUTOBUILD_MOC_SOURCES'):
- moc_o = objBuilder(source=moc_cpp)
- out_sources.append(moc_o)
- objBuilder(moc_o, moc_cpp)
- self.mocFromHBld(env, moc_cpp, h)
+ moc_cpp = env.Moc(h)
+ moc_o = objBuilder(moc_cpp)
+ out_sources.append(moc_o)
#moc_cpp.target_scanner = SCons.Defaults.CScan
- if cpp and q_object_search.search(cpp.get_contents()):
+ if debug:
+ print "scons: qt: found Q_OBJECT macro in '%s', moc'ing to '%s'" % (str(h), str(moc_cpp))
+ if cpp and q_object_search.search(cpp_contents):
# cpp file with Q_OBJECT macro found -> add moc
# (to be included in cpp)
- d,base = os.path.split(prefix)
- src_ext = splitext(str(cpp))[1]
- moc = FS.File(os.path.join(d,
- env['QT_MOCNAMEGENERATOR'](base, src_ext, env)))
- self.mocFromCppBld(env, moc, cpp)
+ moc = env.Moc(cpp)
env.Ignore(moc, moc)
+ if debug:
+ print "scons: qt: found Q_OBJECT macro in '%s', moc'ing to '%s'" % (str(cpp), str(moc))
#moc.source_scanner = SCons.Defaults.CScan
+ # restore the original env attributes (FIXME)
+ objBuilder.env = objBuilderEnv
+ env.Moc.env = mocBuilderEnv
- os.chdir(old_os_cwd)
- FS.chdir(old_fs_cwd)
- if env.get('QT_AUTOBUILD_MOC_SOURCES'):
- return (target, out_sources)
- else:
- return (target, source)
+ #os.chdir(old_os_cwd)
+ #FS.chdir(old_fs_cwd)
+
+ return (target, out_sources)
+
+AutomocShared = _Automoc('SharedObject')
+AutomocStatic = _Automoc('StaticObject')
def _detect(env):
"""Not really safe, but fast method to detect the QT library"""
@@ -142,85 +183,121 @@ def _detect(env):
if not QTDIR:
QTDIR = os.environ.get('QTDIR',None)
if not QTDIR:
- moc = env.Detect('moc')
+ moc = env.WhereIs('moc')
if moc:
QTDIR = os.path.dirname(os.path.dirname(moc))
+ SCons.Warnings.warn(
+ QtdirNotFound,
+ "Could not detect qt, using moc executable as a hint (QTDIR=%s)" % QTDIR)
else:
QTDIR = None
+ SCons.Warnings.warn(
+ QtdirNotFound,
+ "Could not detect qt, using empty QTDIR")
return QTDIR
+
def generate(env):
"""Add Builders and construction variables for qt to an Environment."""
+ CLVar = SCons.Util.CLVar
+ Action = SCons.Action.Action
+ Builder = SCons.Builder.Builder
+ splitext = SCons.Util.splitext
+ # the basics
env['QTDIR'] = _detect(env)
env['QT_MOC'] = os.path.join('$QTDIR','bin','moc')
env['QT_UIC'] = os.path.join('$QTDIR','bin','uic')
- env['QT_LIB'] = 'qt'
+ env['QT_LIB'] = 'qt' # may be set to qt-mt
- # Should moc-generated sources be automatically compiled?
- env['QT_AUTOBUILD_MOC_SOURCES'] = 1
+ # Should the qt tool try to figure out, which sources are to be moc'ed ?
+ env['QT_AUTOSCAN'] = 1
# Some QT specific flags. I don't expect someone wants to
# manipulate those ...
- env['QT_UICIMPLFLAGS'] = SCons.Util.CLVar('')
- env['QT_UICDECLFLAGS'] = SCons.Util.CLVar('')
- env['QT_MOCFROMHFLAGS'] = SCons.Util.CLVar('')
- env['QT_MOCFROMCXXFLAGS'] = SCons.Util.CLVar('-i')
+ env['QT_UICIMPLFLAGS'] = CLVar('')
+ env['QT_UICDECLFLAGS'] = CLVar('')
+ env['QT_MOCFROMHFLAGS'] = CLVar('')
+ env['QT_MOCFROMCXXFLAGS'] = CLVar('-i')
- # Suffixes for the headers / sources to generate
- env['QT_HSUFFIX'] = '.h'
+ # suffixes/prefixes for the headers / sources to generate
+ env['QT_UICDECLPREFIX'] = ''
+ env['QT_UICDECLSUFFIX'] = '.h'
+ env['QT_UICIMPLPREFIX'] = 'uic_'
+ env['QT_UICIMPLSUFFIX'] = '$CXXFILESUFFIX'
+ env['QT_MOCHPREFIX'] = 'moc_'
+ env['QT_MOCHSUFFIX'] = '$CXXFILESUFFIX'
+ env['QT_MOCCXXPREFIX'] = ''
+ env['QT_MOCCXXSUFFIX'] = '.moc'
env['QT_UISUFFIX'] = '.ui'
- env['QT_UIHSUFFIX'] = '.ui.h'
- env['QT_MOCNAMEGENERATOR'] = \
- lambda x, src_suffix, env: 'moc_' + x + env.get('CXXFILESUFFIX','.cc')
+
+ def uicEmitter(target, source, env):
+ adjustixes = SCons.Util.adjustixes
+ bs = SCons.Util.splitext(str(source[0]))[0]
+ # first target (header) is automatically added by builder
+ if len(target) < 2:
+ # second target is implementation
+ target.append(adjustixes(bs,
+ env.subst('$QT_UICIMPLPREFIX'),
+ env.subst('$QT_UICIMPLSUFFIX')))
+ if len(target) < 3:
+ # third target is moc file
+ target.append(adjustixes(bs,
+ env.subst('$QT_MOCHPREFIX'),
+ env.subst('$QT_MOCHSUFFIX')))
+ return target, source
# Commands for the qt support ...
- # command to generate implementation (cpp) file from a .ui file
- env['QT_UICIMPLCOM'] = ('$QT_UIC $QT_UICIMPLFLAGS -impl '
- '${TARGETS[0].filebase}$QT_HSUFFIX '
- '-o $TARGET $SOURCES')
- # command to generate declaration (h) file from a .ui file
- env['QT_UICDECLCOM'] = ('$QT_UIC $QT_UICDECLFLAGS '
- '-o ${TARGETS[0].base}$QT_HSUFFIX $SOURCES')
+ # command to generate header, implementation and moc-file from a .ui file
+ env['QT_UICCOM'] = [
+ CLVar('$QT_UIC $QT_UICDECLFLAGS -o ${TARGETS[0]} $SOURCE'),
+ CLVar('$QT_UIC $QT_UICIMPLFLAGS -impl ${TARGETS[0].file} '
+ '-o ${TARGETS[1]} $SOURCE'),
+ CLVar('$QT_MOC $QT_MOCFROMHFLAGS -o ${TARGETS[2]} ${TARGETS[0]}')]
# command to generate meta object information for a class declarated
# in a header
- env['QT_MOCFROMHCOM'] = '$QT_MOC $QT_MOCFROMHFLAGS -o $TARGET $SOURCE'
- # command to generate meta object information for a class declatazed
+ env['QT_MOCFROMHCOM'] = (
+ '$QT_MOC $QT_MOCFROMHFLAGS -o ${TARGETS[0]} $SOURCE')
+ # command to generate meta object information for a class declarated
# in a cpp file
- env['QT_MOCFROMCXXCOM'] = '$QT_MOC $QT_MOCFROMCXXFLAGS -o $TARGET $SOURCE'
-
+ env['QT_MOCFROMCXXCOM'] = [
+ CLVar('$QT_MOC $QT_MOCFROMCXXFLAGS -o ${TARGETS[0]} $SOURCE'),
+ Action(checkMocIncluded,None)]
# ... and the corresponding builders
- uicDeclBld = SCons.Builder.Builder(action='$QT_UICDECLCOM',
- src_suffix='$QT_UISUFFIX',
- suffix='$QT_HSUFFIX')
- mocFromHBld = SCons.Builder.Builder(action='$QT_MOCFROMHCOM',
- src_suffix='$QT_HSUFFIX',
- suffix='$QT_MOCSUFFIX')
- mocFromCppBld = SCons.Builder.Builder(action='$QT_MOCFROMCXXCOM',
- src_suffix='$QT_CXXSUFFIX',
- suffix='$QT_MOCSUFFIX')
-
- # we use CXXFile to generate .cpp files from .ui files
- c_file, cxx_file = SCons.Tool.createCFileBuilders(env)
- cxx_file.add_action('$QT_UISUFFIX', '$QT_UICIMPLCOM')
+ uicBld = Builder(action='$QT_UICCOM',
+ emitter=uicEmitter,
+ src_suffix='$QT_UISUFFIX',
+ suffix='$QT_UICDECLSUFFIX',
+ prefix='$QT_UICDECLPREFIX')
+ mocBld = Builder(action={}, prefix={}, suffix={})
+ for h in header_extensions:
+ mocBld.add_action(h, '$QT_MOCFROMHCOM')
+ mocBld.prefix[h] = '$QT_MOCHPREFIX'
+ mocBld.suffix[h] = '$QT_MOCHSUFFIX'
+ for cxx in cxx_suffixes:
+ mocBld.add_action(cxx, '$QT_MOCFROMCXXCOM')
+ mocBld.prefix[cxx] = '$QT_MOCCXXPREFIX'
+ mocBld.suffix[cxx] = '$QT_MOCCXXSUFFIX'
+
+ # register the builders
+ env['BUILDERS']['Uic'] = uicBld
+ env['BUILDERS']['Moc'] = mocBld
+ static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
+ static_obj.src_builder.append('Uic')
+ shared_obj.src_builder.append('Uic')
# We use the emitters of Program / StaticLibrary / SharedLibrary
- # to produce almost all builders except .cpp from .ui
- # First, make sure the Environment has Object builders.
- SCons.Tool.createObjBuilders(env)
+ # to scan for moc'able files
# We can't refer to the builders directly, we have to fetch them
# as Environment attributes because that sets them up to be called
# correctly later by our emitter.
- env.Append(PROGEMITTER = [_Automoc('StaticObject',
- uicDeclBld,mocFromHBld,mocFromCppBld)],
- SHLIBEMITTER = [_Automoc('SharedObject',
- uicDeclBld,mocFromHBld,mocFromCppBld)],
- LIBEMITTER = [_Automoc('StaticObject',
- uicDeclBld,mocFromHBld,mocFromCppBld)])
- # Of course, we need to link against the qt libraries
- env.AppendUnique(CPPPATH=[os.path.join('$QTDIR', 'include')])
- env.AppendUnique(LIBPATH=[os.path.join('$QTDIR', 'lib')])
- env.AppendUnique(LIBS=['$QT_LIB'])
+ env.AppendUnique(PROGEMITTER =[AutomocStatic],
+ SHLIBEMITTER=[AutomocShared],
+ LIBEMITTER =[AutomocStatic],
+ # Of course, we need to link against the qt libraries
+ CPPPATH=[os.path.join('$QTDIR', 'include')],
+ LIBPATH=[os.path.join('$QTDIR', 'lib')],
+ LIBS=['$QT_LIB'])
def exists(env):
return _detect(env)