diff options
-rw-r--r-- | bin/import-test.py | 98 | ||||
-rw-r--r-- | src/CHANGES.txt | 3 | ||||
-rw-r--r-- | src/engine/SCons/Tool/qt.py | 18 | ||||
-rw-r--r-- | test/QT/generated-ui.py | 122 |
4 files changed, 231 insertions, 10 deletions
diff --git a/bin/import-test.py b/bin/import-test.py new file mode 100644 index 0000000..1399557 --- /dev/null +++ b/bin/import-test.py @@ -0,0 +1,98 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# tree2test.py - turn a directory tree into TestSCons code +# +# A quick script for importing directory hierarchies containing test +# cases that people supply (typically in a .zip or .tar.gz file) into a +# TestSCons.py script. No error checking or options yet, it just walks +# the first command-line argument (assumed to be the directory containing +# the test case) and spits out code looking like the following: +# +# test.subdir(['sub1'], +# ['sub1', 'sub2']) +# +# test.write(['sub1', 'file1'], """\ +# contents of file1 +# """) +# +# test.write(['sub1', 'sub2', 'file2'], """\ +# contents of file2 +# """) +# +# There's no massaging of contents, so any files that themselves contain +# """ triple-quotes will need to have their contents edited by hand. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import os.path +import sys + +directory = sys.argv[1] + +Top = None +TopPath = None + +class Dir: + def __init__(self, path): + self.path = path + self.entries = {} + def call_for_each_entry(self, func): + entries = self.entries + names = entries.keys() + names.sort() + for name in names: + func(name, entries[name]) + +def lookup(dirname): + global Top, TopPath + if not Top: + Top = Dir([]) + TopPath = dirname + os.sep + return Top + dirname = dirname.replace(TopPath, '') + dirs = dirname.split(os.sep) + t = Top + for d in dirs[:-1]: + t = t.entries[d] + node = t.entries[dirs[-1]] = Dir(dirs) + return node + +def make_nodes(arg, dirname, fnames): + dir = lookup(dirname) + for f in fnames: + dir.entries[f] = None + +def collect_dirs(l, dir): + if dir.path: + l.append(dir.path) + def recurse(n, d): + if d: + collect_dirs(l, d) + dir.call_for_each_entry(recurse) + +def print_files(dir): + def print_a_file(n, d): + if not d: + l = dir.path + [n] + sys.stdout.write('\ntest.write(%s, """\\\n' % l) + p = os.path.join(*([directory] + l)) + sys.stdout.write(open(p, 'r').read()) + sys.stdout.write('""")\n') + dir.call_for_each_entry(print_a_file) + + def recurse(n, d): + if d: + print_files(d) + dir.call_for_each_entry(recurse) + +os.path.walk(directory, make_nodes, None) + +subdir_list = [] +collect_dirs(subdir_list, Top) +subdir_list = [ str(l) for l in subdir_list ] +sys.stdout.write('test.subdir(' + ',\n '.join(subdir_list) + ')\n') + +print_files(Top) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 39c0c8a..e49d391 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -431,6 +431,9 @@ RELEASE 0.97 - XXX - Fix the Java parser's handling of backslashes in strings. + - Fix the Qt UIC scanner to work with generated .ui files (by using + the FindFile() function instead of checking by-hand for the file). + From Christian Neeb: - Fix the Java parser's handling of string definitions to avoid ignoring diff --git a/src/engine/SCons/Tool/qt.py b/src/engine/SCons/Tool/qt.py index 04b6215..5077901 100644 --- a/src/engine/SCons/Tool/qt.py +++ b/src/engine/SCons/Tool/qt.py @@ -219,19 +219,17 @@ def uicEmitter(target, source, env): return target, source def uicScannerFunc(node, env, path): - #print "uicScannerFunc" dir = node.dir + lookout = [] + lookout.extend(env['CPPPATH']) + lookout.append(str(node.rfile().dir)) includes = re.findall("<include.*?>(.*?)</include>", node.get_contents()) - res = [] + result = [] for incFile in includes: - incNode = dir.File(incFile) - if incNode.rexists(): - #print "uicdep: ", incNode - res.append(dir.File(incFile)) - else: - #print "uicdep: ", incNode, "not found" - pass - return res + dep = env.FindFile(incFile,lookout) + if dep: + result.append(dep) + return result uicScanner = SCons.Scanner.Scanner(uicScannerFunc, name = "UicScanner", diff --git a/test/QT/generated-ui.py b/test/QT/generated-ui.py new file mode 100644 index 0000000..1674487 --- /dev/null +++ b/test/QT/generated-ui.py @@ -0,0 +1,122 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# 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. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Test that the UI scanning logic correctly picks up scansG +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir(['layer'], + ['layer', 'aclock'], + ['layer', 'aclock', 'qt_bug']) + +test.write(['SConstruct'], """\ +import os +aa=os.getcwd() + +env=Environment(tools=['default','expheaders','qt'],toolpath=[aa]) +env['ENV']['HOME'] = os.environ['HOME'] +env["EXP_HEADER_ABS"]=os.path.join(os.getcwd(),'include') +if not os.access(env["EXP_HEADER_ABS"],os.F_OK): + os.mkdir (env["EXP_HEADER_ABS"]) +Export('env') +env.SConscript('layer/aclock/qt_bug/SConscript') +""") + +test.write(['expheaders.py'], """\ +import SCons.Defaults +def ExpHeaderScanner(node, env, path): + return [] +def generate(env): + HeaderAction=SCons.Action.Action([SCons.Defaults.Copy('$TARGET','$SOURCE'),SCons.Defaults.Chmod('$TARGET',0755)]) + HeaderBuilder= SCons.Builder.Builder(action=HeaderAction) + env['BUILDERS']['ExportHeaders'] = HeaderBuilder +def exists(env): + return 0 +""") + +test.write(['layer', 'aclock', 'qt_bug', 'SConscript'], """\ +import os + +Import ("env") +#src=os.path.join(env.Dir('.').srcnode().abspath, 'testfile.h') +env.ExportHeaders(os.path.join(env["EXP_HEADER_ABS"],'main.h'), 'main.h') +env.ExportHeaders(os.path.join(env["EXP_HEADER_ABS"],'migraform.h'), 'migraform.h') +env.Append(CPPPATH=env["EXP_HEADER_ABS"]) +env.StaticLibrary('all',['main.ui','migraform.ui']) +""") + +test.write(['layer', 'aclock', 'qt_bug', 'main.ui'], """\ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>Main</class> +<widget class="QWizard"> + <property name="name"> + <cstring>Main</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>600</width> + <height>385</height> + </rect> + </property> +</widget> +<includes> + <include location="local" impldecl="in implementation">migraform.h</include> +</includes> +</UI> +""") + +test.write(['layer', 'aclock', 'qt_bug', 'migraform.ui'], """\ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>MigrateForm</class> +<widget class="QWizard"> + <property name="name"> + <cstring>MigrateForm</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>%s</width> + <height>385</height> + </rect> + </property> +</widget> +</UI> +""") + +test.run(arguments = '.', + stderr = TestSCons.noisy_ar, + match = TestSCons.match_re_dotall) + +test.up_to_date(arguments = '.') + +test.pass_test() |