1. dirkbaechle
  2. SCons_Qt4

Commits

dirkbaechle  committed 8bd1edd

- added "How-to install" instructions for the Tool to the manual (as proposed by Bastian Gorholt, bug #684655)
- fixed the sorting of Moc targets in the Automoc class to prevent spurious rebuilds, is now correctly based on the file/entry names instead of their references (reported by Danny Valente, bug #684933)
- added a testcase for the latter bug

  • Participants
  • Parent commits fbf7684
  • Branches default

Comments (0)

Files changed (9)

File __init__.py

View file
         env.Moc4.env = mocBuilderEnv
         env.XMoc4.env = xMocBuilderEnv
 
-        return (target, sorted(set(out_sources)))
+        # We return the set of source entries as sorted sequence, else
+        # the order might accidentally change from one build to another
+        # and trigger unwanted rebuilds. For proper sorting, a key function
+        # has to be specified...FS.Entry (and Base nodes in general) do not
+        # provide a __cmp__, for performance reasons. 
+        return (target, sorted(set(out_sources), key=lambda entry : str(entry)))
 
 AutomocShared = _Automoc('SharedObject')
 AutomocStatic = _Automoc('StaticObject')

File docs/SConstruct

View file
-#
-# A simple SConstruct for creating PDF files from Docbook XML
-# sources. It's plain and ugly...but does its job ;).
-#
-
 #
 # Copyright (c) 2001-2010 The SCons Foundation
 #
 
 import os
 
-bld_fo = Builder(action = 'xsltproc ./pdf.xsl $SOURCE > $TARGET',
-                 suffix = '.fo',
-                 src_suffix = '.xml',
-                 single_source = True)
+env = Environment(ENV = os.environ,
+                  tools = ['docbook'])
 
-bld_html = Builder(action = 'xsltproc ./html.xsl $SOURCE > $TARGET',
-                 suffix = '.html',
-                 src_suffix = '.xml',
-                 single_source = True)
+env.DocbookPdf('manual', DOCBOOK_XSL='pdf.xsl')
+env.DocbookPdf('reference', DOCBOOK_XSL='pdf.xsl')
 
-bld_pdf = Builder(action = 'fop $SOURCE $TARGET',
-                 suffix = '.pdf',
-                 src_suffix = '.fo',
-                 single_source = True)
+env.DocbookHtml('manual', DOCBOOK_XSL='html.xsl')
+env.DocbookHtml('reference', DOCBOOK_XSL='html.xsl')
 
-env = Environment(ENV = os.environ,
-                  BUILDERS = {'Fo' : bld_fo,
-                              'Html' : bld_html,
-                              'Pdf' : bld_pdf})
-
-env.Pdf('manual', env.Fo('manual'))
-env.Pdf('reference', env.Fo('reference'))
-
-env.Html('manual','manual')
-env.Html('reference','reference')
-

File docs/manual.xml

View file
       <surname>Dirk Baechle</surname>
     </author>
 
-    <pubdate>2010-11-18</pubdate>
+    <pubdate>2010-12-06</pubdate>
   </articleinfo>
 
   <section id="basics">
     of the helper tools (<literal>moc</literal>, <literal>uic</literal>)
     behave different.</para>
 
-    <para>For activating the tool "qt4", you have to add its name to the
-    Environment constructor, like this</para>
+    <section id="install">
+      <title>Install</title>
 
-    <screen>env = Environment(tools=['default','qt4'])
+      <para>Installing it, requires you to copy (or, even better: checkout)
+      the contents of the package's <literal>qt4</literal> folder to</para>
+
+      <orderedlist>
+        <listitem>
+          <para><quote><literal>/path_to_your_project/site_scons/site_tools/qt4</literal></quote>,
+          if you need the Qt4 Tool in one project only, or</para>
+        </listitem>
+
+        <listitem>
+          <para><quote><literal>~/.scons/site_scons/site_tools/qt4</literal></quote>,
+          for a system-wide installation under your current login.</para>
+        </listitem>
+      </orderedlist>
+
+      <para>For more infos about this, please refer to</para>
+
+      <itemizedlist>
+        <listitem>
+          <para>the SCons User's Guide, chap. 17.7 "Where to put your custom
+          Builders and Tools" and</para>
+        </listitem>
+
+        <listitem>
+          <para>the SCons Tools Wiki page at <ulink
+          url="http://scons.org/wiki/ToolsIndex">http://scons.org/wiki/ToolsIndex</ulink>.</para>
+        </listitem>
+      </itemizedlist>
+    </section>
+
+    <section id="activation">
+      <title>How to activate</title>
+
+      <para>For activating the tool "qt4", you have to add its name to the
+      Environment constructor, like this</para>
+
+      <screen>env = Environment(tools=['default','qt4'])
 </screen>
 
-    <para>On its startup, the Qt4 tool tries to read the variable
-    <literal>QT4DIR</literal> from the current Environment and
-    <literal>os.environ</literal>. If it is not set, the value of
-    <literal>QTDIR</literal> (in Environment/<literal>os.environ</literal>) is
-    used as a fallback.</para>
+      <para>On its startup, the Qt4 tool tries to read the variable
+      <literal>QT4DIR</literal> from the current Environment and
+      <literal>os.environ</literal>. If it is not set, the value of
+      <literal>QTDIR</literal> (in Environment/<literal>os.environ</literal>)
+      is used as a fallback.</para>
 
-    <para>So, you either have to explicitly give the path of your Qt4
-    installation to the Environment with</para>
+      <para>So, you either have to explicitly give the path of your Qt4
+      installation to the Environment with</para>
 
-    <screen>env['QT4DIR'] = '/usr/local/Trolltech/Qt-4.2.3'
+      <screen>env['QT4DIR'] = '/usr/local/Trolltech/Qt-4.2.3'
 </screen>
 
-    <para>or set the <literal>QT4DIR</literal> as environment variable in your
-    shell.</para>
+      <para>or set the <literal>QT4DIR</literal> as environment variable in
+      your shell.</para>
+    </section>
 
-    <para>Under Linux, "qt4" uses the system tool
-    <literal>pkg-config</literal> for automatically setting the required
-    compile and link flags of the single Qt4 modules (like QtCore, QtGui,...).
-    This means that</para>
+    <section id="requirements">
+      <title>Requirements</title>
 
-    <orderedlist>
-      <listitem>
-        <para>you should have <literal>pkg-config</literal> installed,
-        and</para>
-      </listitem>
+      <para>Under Linux, "qt4" uses the system tool
+      <literal>pkg-config</literal> for automatically setting the required
+      compile and link flags of the single Qt4 modules (like QtCore,
+      QtGui,...). This means that</para>
 
-      <listitem>
-        <para>you additionally have to set <literal>PKG_CONFIG_PATH</literal>
-        in your shell environment, such that it points to
-        $<literal>QT4DIR/lib/pkgconfig</literal> (or
-        $<literal>QT4DIR/lib</literal> for some older versions).</para>
-      </listitem>
-    </orderedlist>
+      <orderedlist>
+        <listitem>
+          <para>you should have <literal>pkg-config</literal> installed,
+          and</para>
+        </listitem>
 
-    <para>Based on these two environment variables (<literal>QT4DIR</literal>
-    and <literal>PKG_CONFIG_PATH</literal>), the "qt4" tool initializes all
-    <literal>QT4_*</literal> construction variables listed in the Reference
-    manual. This happens when the tool is "detected" during Environment
-    construction. As a consequence, the setup of the tool gets a two-stage
-    process, if you want to override the values provided by your current shell
-    settings:</para>
+        <listitem>
+          <para>you additionally have to set
+          <literal>PKG_CONFIG_PATH</literal> in your shell environment, such
+          that it points to $<literal>QT4DIR/lib/pkgconfig</literal> (or
+          $<literal>QT4DIR/lib</literal> for some older versions).</para>
+        </listitem>
+      </orderedlist>
 
-    <screen># Stage 1: create plain environment
+      <para>Based on these two environment variables
+      (<literal>QT4DIR</literal> and <literal>PKG_CONFIG_PATH</literal>), the
+      "qt4" tool initializes all <literal>QT4_*</literal> construction
+      variables listed in the Reference manual. This happens when the tool is
+      "detected" during Environment construction. As a consequence, the setup
+      of the tool gets a two-stage process, if you want to override the values
+      provided by your current shell settings:</para>
+
+      <screen># Stage 1: create plain environment
 qtEnv = Environment()
 # Set new vars
 qtEnv['QT4DIR'] = '/usr/local/Trolltech/Qt-4.2.3
 # Stage 2: add qt4 tool
 qtEnv.Tool('qt4')
 </screen>
+    </section>
   </section>
 
-  <section id="suggested_boilerplate">
+  <section id="boilerplate">
     <title>Suggested boilerplate</title>
 
     <para>Based on the requirements above, we suggest a simple ready-to-go
 </screen>
   </section>
 
-  <section id="a_first_project">
+  <section id="firstproject">
     <title>A first project</title>
 
     <para>The following SConscript is for a simple project with some cxx
 </screen>
   </section>
 
-  <section id="moc_it_up">
+  <section id="mocup">
     <title>MOC it up</title>
 
     <para>For the basic support of automocing, nothing needs to be done by the
     <para>which outputs a lot of messages during automocing.</para>
   </section>
 
-  <section id="forms_(.ui)">
+  <section id="forms">
     <title>Forms (.ui)</title>
 
     <para>The header files with setup code for your GUI classes, are not
 </screen>
   </section>
 
-  <section id="resource_files_(.qrc)">
+  <section id="resources">
     <title>Resource files (.qrc)</title>
 
     <para>Resource files are not built automatically, you always have to add
 </screen>
   </section>
 
-  <section id="translation_files">
+  <section id="translation">
     <title>Translation files</title>
 
     <para>The update of the <literal>.ts</literal> files and the conversion to
     then have to store the .ts and .qm files outside of the current folder, or
     use <literal>Glob('*.cpp'))</literal> instead.</para>
   </section>
-</article>
+</article>

File test/moc/order_independent/image/SConscript

View file
+Import("qtEnv dup reverted")
+
+qtEnv.EnableQt4Modules(['QtCore','QtGui'])
+
+if dup == 0: 
+  qtEnv.Append(CPPPATH=['.'])
+
+if reverted == 0:
+  qtEnv.Program('aaa',['aaa.cpp','bbb.cpp'])
+else:
+  qtEnv.Program('aaa',['bbb.cpp','aaa.cpp'])
+

File test/moc/order_independent/image/SConstruct

View file
+import qtenv
+
+qtEnv = qtenv.createQtEnvironment()
+
+reverted=int(ARGUMENTS.get('reverted', 0))
+dup = 1
+if ARGUMENTS.get('variant_dir', 0):
+    if ARGUMENTS.get('chdir', 0):
+        SConscriptChdir(1)
+    else:
+        SConscriptChdir(0)
+    dup=int(ARGUMENTS.get('dup', 1))
+    if dup == 0:
+        builddir = 'build_dup0'
+        qtEnv['QT4_DEBUG'] = 1
+    else:
+        builddir = 'build'
+    VariantDir(builddir, '.', duplicate=dup)
+    print builddir, dup
+    sconscript = Dir(builddir).File('SConscript')
+else:
+    sconscript = File('SConscript')
+
+Export("qtEnv dup reverted")
+SConscript( sconscript )

File test/moc/order_independent/image/aaa.cpp

View file
+#include "aaa.h"
+
+int main() 
+{ 
+  aaa a; 
+  return 0; 
+}

File test/moc/order_independent/image/aaa.h

View file
+#include <QObject>
+
+class aaa : public QObject
+{
+  Q_OBJECT
+
+public:
+  aaa() {};
+};

File test/moc/order_independent/image/bbb.cpp

View file
+int bbb() 
+{ 
+  return 0; 
+}

File test/moc/order_independent/sconstest-order-independent.py

View file
+#!/usr/bin/env python
+#
+# Copyright (c) 2001-2010 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+"""
+Ensures that no rebuilds get triggered when the order of the source
+list changes in the Automoc routine(s).
+"""
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+test.dir_fixture('image')
+test.file_fixture('../../qtenv.py')
+test.file_fixture('../../../__init__.py','site_scons/site_tools/qt4/__init__.py')
+
+test.run()
+test.up_to_date(options="-n", arguments=".")
+test.up_to_date(options="-n reverted=1", arguments=".")
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4: