Qt fixes. (Christoph Wiedemann)
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sat, 7 Aug 2004 06:07:04 +0000 (06:07 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sat, 7 Aug 2004 06:07:04 +0000 (06:07 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@1024 fdb21ef1-2011-0410-befe-b5e4ea1792b1

etc/TestCommon.py
src/engine/SCons/Tool/qt.py
test/QT.py
test/QTFLAGS.py

index ff8a3f33dd5ae7cf6127a56757e2ad89eb495528..c7ee6f981c6a2539340e9a00ad84b5cb8a85222e 100644 (file)
@@ -76,8 +76,8 @@ The TestCommon module also provides the following variables
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 
 __author__ = "Steven Knight <knight at baldmt dot com>"
-__revision__ = "TestCommon.py 0.8.D001 2004/07/15 06:24:14 knight"
-__version__ = "0.8"
+__revision__ = "TestCommon.py 0.9.D001 2004/08/06 08:19:26 knight"
+__version__ = "0.9"
 
 import os
 import os.path
@@ -204,7 +204,7 @@ class TestCommon(TestCmd):
         pathname will be constructed by concatenating them.  Exits FAILED
         if any of the files does not exist.
         """
-        files = map(lambda x: is_List(x) and os.path.join(x) or x, files)
+        files = map(lambda x: is_List(x) and apply(os.path.join, x) or x, files)
         missing = filter(lambda x: not os.path.exists(x), files)
         if missing:
             print "Missing files: `%s'" % string.join(missing, "', `")
@@ -233,7 +233,7 @@ class TestCommon(TestCmd):
         which case the pathname will be constructed by concatenating them.
         Exits FAILED if any of the files exists.
         """
-        files = map(lambda x: is_List(x) and os.path.join(x) or x, files)
+        files = map(lambda x: is_List(x) and apply(os.path.join, x) or x, files)
         existing = filter(os.path.exists, files)
         if existing:
             print "Unexpected files exist: `%s'" % string.join(existing, "', `")
index 0a45e55160b616566af0a8691fce4344776b81c2..ee55051bac8468420167d1599e2d1f4be428b8b5 100644 (file)
@@ -62,13 +62,23 @@ 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)
+    # not really sure about the path transformations (moc.cwd? cpp.cwd?) :-/
+    path = SCons.Defaults.CScan.path_function(env, moc.cwd)
+    includes = SCons.Defaults.CScan(cpp, env, path)
     if not moc in includes:
         SCons.Warnings.warn(
             GeneratedMocFileNotIncluded,
             "Generated moc file '%s' is not included by '%s'" %
             (str(moc), str(cpp)))
 
+def find_file(filename, paths, node_factory):
+    retval = None
+    for dir in paths:
+        node = node_factory(filename, dir)
+        if node.rexists():
+            return node
+    return None
+
 class _Automoc:
     """
     Callable class, which works as an emitter for Programs, SharedLibraries and
@@ -98,18 +108,14 @@ class _Automoc:
         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)
-
         # 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'(//.*)|(/\*(([^*])|(\*[^/]))*\*/)')
-
+        #comment = re.compile(r'(//.*)|(/\*(([^*])|(\*[^/]))*\*/)')
+        # CW: something must be wrong with the regexp. See also bug #998222
+        #     CURRENTLY THERE IS NO TEST CASE FOR THAT
+        
         # The following is kind of hacky to get builders working properly (FIXME)
         objBuilderEnv = objBuilder.env
         objBuilder.env = env
@@ -131,19 +137,21 @@ class _Automoc:
                     print "scons: qt: '%s' is no cxx file. Discarded." % str(cpp) 
                 # c or fortran source
                 continue
-            cpp_contents = comment.sub('', cpp.get_contents())
+            #cpp_contents = comment.sub('', cpp.get_contents())
+            cpp_contents = cpp.get_contents()
             h=None
             for h_ext in header_extensions:
                 # 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)
+                h = 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())
+                    #h_contents = comment.sub('', h.get_contents())
+                    h_contents = h.get_contents()
                     break
             if not h and debug:
                 print "scons: qt: no header for '%s'." % (str(cpp))
@@ -167,9 +175,6 @@ class _Automoc:
         objBuilder.env = objBuilderEnv
         env.Moc.env = mocBuilderEnv
 
-        #os.chdir(old_os_cwd)
-        #FS.chdir(old_fs_cwd)
-
         return (target, out_sources)
 
 AutomocShared = _Automoc('SharedObject')
@@ -233,7 +238,8 @@ def generate(env):
 
     def uicEmitter(target, source, env):
         adjustixes = SCons.Util.adjustixes
-        bs = SCons.Util.splitext(str(source[0]))[0]
+        bs = SCons.Util.splitext(str(source[0].name))[0]
+        bs = os.path.join(str(target[0].get_dir()),bs)
         # first target (header) is automatically added by builder
         if len(target) < 2:
             # second target is implementation
index 0f9e2baa74dd4920e1239b429b78b30f5541747b..48148a92462d2159153e2e6855efaab255ca61c1 100644 (file)
@@ -147,16 +147,24 @@ env = Environment(QTDIR = QTDIR,
                   QT_MOC = r'%s',
                   QT_UIC = r'%s',
                   tools=['default','qt'])
+dup = 1
 if ARGUMENTS.get('build_dir', 0):
     if ARGUMENTS.get('chdir', 0):
         SConscriptChdir(1)
     else:
         SConscriptChdir(0)
-    BuildDir('build', '.', duplicate=1)
-    sconscript = Dir('build').File('SConscript')
+    dup=int(ARGUMENTS.get('dup', 1))
+    if dup == 0:
+        builddir = 'build_dup0'
+        env['QT_DEBUG'] = 1
+    else:
+        builddir = 'build'
+    BuildDir(builddir, '.', duplicate=dup)
+    print builddir, dup
+    sconscript = Dir(builddir).File('SConscript')
 else:
     sconscript = File('SConscript')
-Export("env")
+Export("env dup")
 SConscript( sconscript )
 """ % (QT, QT_LIB, QT_MOC, QT_UIC))
 
@@ -210,6 +218,12 @@ test.run(chdir='work1',
 
 test.fail_test( not os.path.exists(test.workpath('work1', 'build', moc)) )
 
+test.run(chdir='work1',
+         arguments = "build_dir=1 chdir=1 dup=0 " +
+                     test.workpath('work1', 'build_dup0', aaa_exe) )
+test.must_exist(['work1', 'build_dup0', moc],
+                ['work1', 'build_dup0', aaa_exe])
+
 ##############################################################################
 # 2. create .cpp, .h, moc_....cpp from .ui file
 
@@ -221,7 +235,8 @@ h = 'aaa.h'
 
 createSConstruct(test, ['work2', 'SConstruct'])
 test.write(['work2', 'SConscript'], """
-Import("env")
+Import("env dup")
+if dup == 0: env.Append(CPPPATH=['#', '.'])
 env.SharedLibrary(target = 'aaa', source = ['aaa.ui', 'useit.cpp'])
 """)
 
@@ -271,17 +286,39 @@ test.not_up_to_date(chdir='work2', options = '-n', arguments = obj)
 test.up_to_date(chdir='work2', options = '-n', arguments = cpp)
 test.up_to_date(chdir='work2', options = '-n', arguments = h)
 test.up_to_date(chdir='work2', options = '-n', arguments = moc)
+# clean up
+test.run(chdir='work2', arguments = '-c ' + aaa_dll)
 
 test.run(chdir='work2',
          arguments = "build_dir=1 " +
                      test.workpath('work2', 'build', aaa_dll) )
+test.fail_test(not os.path.exists(test.workpath('work2','build',moc)) or
+               not os.path.exists(test.workpath('work2','build',cpp)) or
+               not os.path.exists(test.workpath('work2','build',h)) or
+               os.path.exists(test.workpath('work2', moc)) or
+               os.path.exists(test.workpath('work2', cpp)) or
+               os.path.exists(test.workpath('work2', h)))
 test.run(chdir='work2',
          arguments = "build_dir=1 chdir=1 " +
                      test.workpath('work2', 'build', aaa_dll) )
-
 test.fail_test(not os.path.exists(test.workpath('work2','build',moc)) or
                not os.path.exists(test.workpath('work2','build',cpp)) or
-               not os.path.exists(test.workpath('work2','build',h)))
+               not os.path.exists(test.workpath('work2','build',h)) or
+               os.path.exists(test.workpath('work2', moc)) or
+               os.path.exists(test.workpath('work2', cpp)) or
+               os.path.exists(test.workpath('work2', h)))
+
+test.run(chdir='work2',
+         arguments = "build_dir=1 chdir=1 dup=0 " +
+                     test.workpath('work2', 'build_dup0', aaa_dll) )
+
+test.must_exist(['work2','build_dup0',moc], 
+                ['work2','build_dup0',cpp],
+                ['work2','build_dup0',h])
+test.must_not_exist(['work2', moc],
+                    ['work2', cpp],
+                    ['work2', h])
+
 
 ##############################################################################
 # 3. create a moc file from a cpp file
@@ -291,7 +328,8 @@ moc = 'aaa.moc'
 
 createSConstruct(test, ['work3', 'SConstruct'])
 test.write(['work3', 'SConscript'], """
-Import("env")
+Import("env dup")
+if dup == 0: env.Append(CPPPATH=['.'])
 env.StaticLibrary(target = '%s', source = ['aaa.cpp','useit.cpp'])
 """ % lib_aaa)
 
@@ -323,6 +361,7 @@ void aaa(void) Q_OBJECT
 #include "%s"
 """ % moc)
 test.not_up_to_date(chdir='work3', options = '-n', arguments = moc)
+test.run(chdir='work3', options = '-c', arguments = lib_aaa)
 
 test.run(chdir='work3',
          arguments = "build_dir=1 " +
@@ -335,6 +374,11 @@ test.run(chdir='work3',
 
 test.fail_test(not os.path.exists(test.workpath('work3', 'build', moc)))
 
+test.run(chdir='work3',
+         arguments = "build_dir=1 dup=0 " +
+                     test.workpath('work3', 'build_dup0', lib_aaa) )
+test.must_exist(['work3', 'build_dup0', moc])
+
 ##############################################################################
 # 4. Test with a copied environment.
 
@@ -565,7 +609,7 @@ int main() {
     os.environ['PATH']='.'
 
     test.run(chdir='work7', stderr=None, arguments="-c test_realqt" + _exe)
-    test.fail_test(not test.match_re(test.stderr(), r"""
+    test.fail_test(not test.match_re_dotall(test.stderr(), r""".*
 scons: warning: Could not detect qt, using empty QTDIR
 File "[^\"]*", line \d+, in .+
 """))
index a503fad1a0fcee635c70ff30c4915ac8fa79e988..46c54dfd162fa7ba9939447a68a5fc93f575b202 100644 (file)
@@ -214,34 +214,15 @@ int main() {
 """)
 
 test.run( arguments = "mytest" + _exe )
-
-def _existAll( test, files ):
-    return reduce(lambda x,y: x and y,
-                  map(os.path.exists,map(test.workpath, files)))
                        
-createSConstruct(test, ['SConstruct'],
-                 """QT_UICIMPLFLAGS='-x',
-                    QT_UICDECLFLAGS='-y',
-                    QT_MOCFROMHFLAGS='-z',
-                    QT_MOCFROMCXXFLAGS='-i -w',
-                    QT_UICDECLPREFIX='uic-',
-                    QT_UICDECLSUFFIX='.hpp',
-                    QT_UICIMPLPREFIX='',
-                    QT_UICIMPLSUFFIX='.cxx',
-                    QT_MOCHPREFIX='mmm',
-                    QT_MOCHSUFFIX='.cxx',
-                    QT_MOCCXXPREFIX='moc',
-                    QT_MOCCXXSUFFIX=`.inl',
-                    QT_UISUFFIX='.myui',""")
-
-test.fail_test(not _existAll(test, ['mmmmocFromH.cxx',
-                                    'mocmocFromCpp.inl',
-                                    'an_ui_file.cxx',
-                                    'uic-an_ui_file.hpp',
-                                    'mmman_ui_file.cxx',
-                                    'another_ui_file.cxx',
-                                    'uic-another_ui_file.hpp',
-                                    'mmmanother_ui_file.cxx']))
+test.must_exist('mmmmocFromH.cxx',
+                'mocmocFromCpp.inl',
+                'an_ui_file.cxx',
+                'uic-an_ui_file.hpp',
+                'mmman_ui_file.cxx',
+                'another_ui_file.cxx',
+                'uic-another_ui_file.hpp',
+                'mmmanother_ui_file.cxx')
 
 def _flagTest(test,fileToContentsStart):
     import string