From 4e17c7182977812c7751523ef08f7b221ae6aa61 Mon Sep 17 00:00:00 2001 From: Steven Knight Date: Fri, 7 Jan 2005 00:42:01 +0000 Subject: Finish the display-customization variables: , , , , , and . --- doc/man/scons.1 | 45 +- src/CHANGES.txt | 11 +- src/engine/SCons/Tool/midl.py | 8 +- src/engine/SCons/Tool/mingw.py | 6 +- src/engine/SCons/Tool/mslink.py | 2 +- src/engine/SCons/Tool/msvc.py | 7 +- src/engine/SCons/Tool/qt.py | 12 +- test/GSFLAGS.py | 113 ----- test/Ghostscript/GSFLAGS.py | 113 +++++ test/IDL/IDLSUFFIXES.py | 70 +++ test/IDL/MIDLCOM.py | 63 +++ test/IDL/MIDLCOMSTR.py | 67 +++ test/IDL/midl.py | 446 +++++++++++++++++++ test/IDLSUFFIXES.py | 70 --- test/MSVC/PCHCOM.py | 63 +++ test/MSVC/PCHCOMSTR.py | 67 +++ test/MSVC/RCCOM.py | 64 +++ test/MSVC/RCCOMSTR.py | 67 +++ test/MSVC/msvc.py | 263 ++++++++++++ test/MinGW/RCCOM.py | 64 +++ test/MinGW/RCCOMSTR.py | 67 +++ test/QT.py | 930 ---------------------------------------- test/QT/QT.py | 930 ++++++++++++++++++++++++++++++++++++++++ test/QT/QTFLAGS.py | 279 ++++++++++++ test/QTFLAGS.py | 279 ------------ test/midl.py | 446 ------------------- test/msvc.py | 263 ------------ test/rpcgen.py | 99 ----- 28 files changed, 2694 insertions(+), 2220 deletions(-) delete mode 100644 test/GSFLAGS.py create mode 100644 test/Ghostscript/GSFLAGS.py create mode 100644 test/IDL/IDLSUFFIXES.py create mode 100644 test/IDL/MIDLCOM.py create mode 100644 test/IDL/MIDLCOMSTR.py create mode 100644 test/IDL/midl.py delete mode 100644 test/IDLSUFFIXES.py create mode 100644 test/MSVC/PCHCOM.py create mode 100644 test/MSVC/PCHCOMSTR.py create mode 100644 test/MSVC/RCCOM.py create mode 100644 test/MSVC/RCCOMSTR.py create mode 100644 test/MSVC/msvc.py create mode 100644 test/MinGW/RCCOM.py create mode 100644 test/MinGW/RCCOMSTR.py delete mode 100644 test/QT.py create mode 100644 test/QT/QT.py create mode 100644 test/QT/QTFLAGS.py delete mode 100644 test/QTFLAGS.py delete mode 100644 test/midl.py delete mode 100644 test/msvc.py delete mode 100644 test/rpcgen.py diff --git a/doc/man/scons.1 b/doc/man/scons.1 index f195c62..449eace 100644 --- a/doc/man/scons.1 +++ b/doc/man/scons.1 @@ -6068,6 +6068,15 @@ dependencies for the PCH file. Example: env['PCH'] = 'StdAfx.pch' .EE +.IP PCHCOM +The command line used by the +.B PCH +builder to generated a precompiled header. + +.IP PCHCOMSTR +The string displayed when generating a precompiled header. +If this is not set, then $PCHCOM (the command line) is displayed. + .IP PCHSTOP This variable specifies how much of a source file is precompiled. This variable is ignored by tools other than Microsoft Visual C++, or when @@ -6267,9 +6276,17 @@ cpp file. .IP QT_MOCFROMCXXCOM Command to generate a moc file from a cpp file. +.IP QT_MOCFROMCXXCOMSTR +The string displayed when generating a moc file from a cpp file. +If this is not set, then $QT_MOCFROMCXXCOM (the command line) is displayed. + .IP QT_MOCFROMHCOM Command to generate a moc file from a header. +.IP QT_MOCFROMHCOMSTR +The string displayed when generating a moc file from a cpp file. +If this is not set, then $QT_MOCFROMHCOM (the command line) is displayed. + .IP QT_MOCFROMHFLAGS Default value is ''. These flags are passed to moc, when moccing a header file. @@ -6284,9 +6301,13 @@ a header. .IP QT_UIC Default value is '$QT_BINPATH/uic'. -.IP QT_UICDECLCOM +.IP QT_UICCOM Command to generate header files from .ui files. +.IP QT_UICCOMSTR +The string displayed when generating header files from .ui files. +If this is not set, then $QT_UICCOM (the command line) is displayed. + .IP QT_UICDECLFLAGS Default value is ''. These flags are passed to uic, when creating a a h file from a .ui file. @@ -6297,9 +6318,6 @@ Default value is ''. Prefix for uic generated header files. .IP QT_UICDECLSUFFIX Default value is '.h'. Suffix for uic generated header files. -.IP QT_UICIMPLCOM -Command to generate cxx files from .ui files. - .IP QT_UICIMPLFLAGS Default value is ''. These flags are passed to uic, when creating a cxx file from a .ui file. @@ -6326,6 +6344,10 @@ The resource compiler used by the RES builder. .IP RCCOM The command line used by the RES builder. +.IP RCCOMSTR +The string displayed when invoking the resource compiler. +If this is not set, then $RCCOM (the command line) is displayed. + .IP RCFLAGS The flags passed to the resource compiler by the RES builder. @@ -6354,6 +6376,21 @@ If this is not set, then $RCS_COCOM .IP RCS_COFLAGS Options that are passed to the $RCS_CO command. +.IP REGSVR +The program used to register DLLs on Windows systems. + +.IP REGSVRCOM +The command line used to register a newly-built DLL file +on Windows systems. +Invoked when the "register=1" +keyword argument is passed to the +.B SharedLibrary +Builder. + +.IP REGSVRCOMSTR +The string displayed when registering a newly-built DLL file. +If this is not set, then $REGSVRCOM (the command line) is displayed. + .IP RDirs A function that converts a file name into a list of Dir instances by searching the repositories. diff --git a/src/CHANGES.txt b/src/CHANGES.txt index c2801bd..11c8e62 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -141,11 +141,12 @@ RELEASE 0.97 - XXX $CVSCOMSTR, $CXXCOMSTR, $DCOMSTR, $DVIPDFCOMSTR, $F77COMSTR, $F90COMSTR, $F95COMSTR, $FORTRANCOMSTR, $GSCOMSTR, $JARCOMSTR, $JAVACCOMSTR, $JAVAHCOMSTR, $LATEXCOMSTR, $LEXCOMSTR, $LINKCOMSTR, - $M4COMSTR, $P4COMSTR, $PDFLATEXCOMSTR, $PDFTEXCOMSTR, $PSCOMSTR, - $RCSCOMSTR, $RMICCOMSTR, $SCCSCOMSTR, $SHCCCOMSTR, $SHCXXCOMSTR, - $SHF77COMSTR, $SHF90COMSTR, $SHF95COMSTR, $SHFORTRANCOMSTR, - $SHLINKCOMSTR, $SWIGCOMSTR, $TARCOMSTR, $TEXCOMSTR, $YACCCOMSTR - and $ZIPCOMSTR. + $M4COMSTR, $MIDLCOMSTR, $P4COMSTR, $PCHCOMSTR, $PDFLATEXCOMSTR, + $PDFTEXCOMSTR, $PSCOMSTR, $QT_MOCFROMCXXCOMSTR, $QT_MOCFROMHCOMSTR, + $QT_UICCOMSTR, $RCCOMSTR, $REGSVRCOMSTR, $RCS_COCOMSTR, $RMICCOMSTR, + $SCCSCOMSTR, $SHCCCOMSTR, $SHCXXCOMSTR, $SHF77COMSTR, $SHF90COMSTR, + $SHF95COMSTR, $SHFORTRANCOMSTR, $SHLINKCOMSTR, $SWIGCOMSTR, + $TARCOMSTR, $TEXCOMSTR, $YACCCOMSTR and $ZIPCOMSTR. - Add an optional "map" keyword argument to ListOption() that takes a dictionary to map user-specified values to legal values from the list diff --git a/src/engine/SCons/Tool/midl.py b/src/engine/SCons/Tool/midl.py index 6be91ef..67579e9 100644 --- a/src/engine/SCons/Tool/midl.py +++ b/src/engine/SCons/Tool/midl.py @@ -33,6 +33,8 @@ selection method. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import SCons.Action +import SCons.Builder import SCons.Defaults import SCons.Scanner.IDL import SCons.Util @@ -53,7 +55,9 @@ def midl_emitter(target, source, env): idl_scanner = SCons.Scanner.IDL.IDLScan() -midl_builder = SCons.Builder.Builder(action='$MIDLCOM', +midl_action = SCons.Action.Action('$MIDLCOM', '$MIDLCOMSTR') + +midl_builder = SCons.Builder.Builder(action = midl_action, src_suffix = '.idl', suffix='.tlb', emitter = midl_emitter, @@ -73,5 +77,3 @@ def exists(env): return 1 else: return env.Detect('midl') - - diff --git a/src/engine/SCons/Tool/mingw.py b/src/engine/SCons/Tool/mingw.py index debb873..99a5574 100644 --- a/src/engine/SCons/Tool/mingw.py +++ b/src/engine/SCons/Tool/mingw.py @@ -37,6 +37,8 @@ import os import os.path import string +import SCons.Action +import SCons.Builder import SCons.Tool import SCons.Util @@ -94,7 +96,9 @@ def shlib_emitter(target, source, env): shlib_action = SCons.Action.CommandGenerator(shlib_generator) -res_builder = SCons.Builder.Builder(action='$RCCOM', suffix='.o', +res_action = SCons.Action.Action('$RCCOM', '$RCCOMSTR') + +res_builder = SCons.Builder.Builder(action=res_action, suffix='.o', source_scanner=SCons.Defaults.ObjSourceScan) SCons.Defaults.ObjSourceScan.add_scanner('.rc', SCons.Defaults.CScan) diff --git a/src/engine/SCons/Tool/mslink.py b/src/engine/SCons/Tool/mslink.py index 0c7b7dc..98258c2 100644 --- a/src/engine/SCons/Tool/mslink.py +++ b/src/engine/SCons/Tool/mslink.py @@ -124,7 +124,7 @@ def RegServerFunc(target, source, env): return ret return 0 -regServerAction = SCons.Action.Action("$REGSVRCOM") +regServerAction = SCons.Action.Action("$REGSVRCOM", "$REGSVRCOMSTR") regServerCheck = SCons.Action.Action(RegServerFunc, None) shlibLinkAction = SCons.Action.Action('${TEMPFILE("$SHLINK $SHLINKFLAGS $_SHLINK_TARGETS $( $_LIBDIRFLAGS $) $_LIBFLAGS $_PDB $_SHLINK_SOURCES")}') compositeLinkAction = shlibLinkAction + regServerCheck diff --git a/src/engine/SCons/Tool/msvc.py b/src/engine/SCons/Tool/msvc.py index 34a1b94..e0ed26d 100644 --- a/src/engine/SCons/Tool/msvc.py +++ b/src/engine/SCons/Tool/msvc.py @@ -397,9 +397,12 @@ def shared_object_emitter(target, source, env): return object_emitter(target, source, env, SCons.Defaults.SharedObjectEmitter) -pch_builder = SCons.Builder.Builder(action='$PCHCOM', suffix='.pch', emitter=pch_emitter, +pch_action = SCons.Action.Action('$PCHCOM', '$PCHCOMSTR') +pch_builder = SCons.Builder.Builder(action=pch_action, suffix='.pch', + emitter=pch_emitter, source_scanner=SCons.Defaults.ObjSourceScan) -res_builder = SCons.Builder.Builder(action='$RCCOM', suffix='.res', +res_action = SCons.Action.Action('$RCCOM', '$RCCOMSTR') +res_builder = SCons.Builder.Builder(action=res_action, suffix='.res', source_scanner=SCons.Defaults.ObjSourceScan) SCons.Defaults.ObjSourceScan.add_scanner('.rc', SCons.Defaults.CScan) diff --git a/src/engine/SCons/Tool/qt.py b/src/engine/SCons/Tool/qt.py index 9bb0438..bc2d41b 100644 --- a/src/engine/SCons/Tool/qt.py +++ b/src/engine/SCons/Tool/qt.py @@ -1,7 +1,7 @@ """SCons.Tool.qt -Tool-specific initialization for qt. +Tool-specific initialization for Qt. There normally shouldn't be any need to import this module directly. It will usually be imported through the generic SCons.Tool.Tool() @@ -37,6 +37,8 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os.path import re +import SCons.Action +import SCons.Builder import SCons.Defaults import SCons.Scanner import SCons.Tool @@ -294,7 +296,7 @@ def generate(env): Action(checkMocIncluded,None)]) # ... and the corresponding builders - uicBld = Builder(action='$QT_UICCOM', + uicBld = Builder(action=SCons.Action.Action('$QT_UICCOM', '$QT_UICCOMSTR'), emitter=uicEmitter, src_suffix='$QT_UISUFFIX', suffix='$QT_UICDECLSUFFIX', @@ -302,11 +304,13 @@ def generate(env): source_scanner=uicScanner) mocBld = Builder(action={}, prefix={}, suffix={}) for h in header_extensions: - mocBld.add_action(h, '$QT_MOCFROMHCOM') + act = SCons.Action.Action('$QT_MOCFROMHCOM', '$QT_MOCFROMHCOMSTR') + mocBld.add_action(h, act) mocBld.prefix[h] = '$QT_MOCHPREFIX' mocBld.suffix[h] = '$QT_MOCHSUFFIX' for cxx in cxx_suffixes: - mocBld.add_action(cxx, '$QT_MOCFROMCXXCOM') + act = SCons.Action.Action('$QT_MOCFROMCXXCOM', '$QT_MOCFROMCXXCOMSTR') + mocBld.add_action(cxx, act) mocBld.prefix[cxx] = '$QT_MOCCXXPREFIX' mocBld.suffix[cxx] = '$QT_MOCCXXSUFFIX' diff --git a/test/GSFLAGS.py b/test/GSFLAGS.py deleted file mode 100644 index 14ce769..0000000 --- a/test/GSFLAGS.py +++ /dev/null @@ -1,113 +0,0 @@ -#!/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__" - -import os -import os.path -import string -import sys -import TestSCons - -python = TestSCons.python - -test = TestSCons.TestSCons() - - - -test.write('mygs.py', r""" -import getopt -import os -import sys -cmd_opts, args = getopt.getopt(sys.argv[1:], 's:x', []) -opt_string = '' -for opt, arg in cmd_opts: - if opt == '-s': - if arg[:11] == 'OutputFile=': - out_file = open(arg[11:], 'wb') - else: - opt_string = opt_string + ' ' + opt -infile = open(args[0], 'rb') -out_file.write(opt_string + "\n") -for l in infile.readlines(): - if l[:3] != '#ps': - out_file.write(l) -sys.exit(0) -""") - -test.write('SConstruct', """ -env = Environment(GS = r'%s mygs.py', GSFLAGS = '-x', - tools = ['gs']) -env.PDF(target = 'test1.pdf', source = 'test1.ps') -""" % (python)) - -test.write('test1.ps', """\ -This is a .ps test. -#ps -""") - -test.run(arguments = '.', stderr = None) - -test.fail_test(test.read('test1.pdf') != " -x\nThis is a .ps test.\n") - - - -if sys.platform == 'win32': - gs_executable = 'gswin32c' -elif sys.platform == 'os2': - gs_executable = 'gsos2' -else: - gs_executable = 'gs' -gs = test.where_is(gs_executable) - -if gs: - - test.write("wrapper.py", """import os -import string -import sys -cmd = string.join(sys.argv[1:], " ") -open('%s', 'ab').write("%%s\\n" %% cmd) -os.system(cmd) -""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) - - test.write('SConstruct', """\ -import os -ENV = { 'PATH' : os.environ['PATH'] } -foo = Environment(ENV = ENV) -foo.Append(GSFLAGS = '-q') -foo.PDF(target = 'foo.pdf', source = 'foo.ps') -""") - - input = """\ -%!PS-Adobe -100 100 moveto /Times-Roman findfont 24 scalefont (Hello, world!) show showpage -""" - - test.write('foo.ps', input) - - test.run(arguments = 'foo.pdf', stderr = None) - - test.fail_test(not os.path.exists(test.workpath('foo.pdf'))) - -test.pass_test() diff --git a/test/Ghostscript/GSFLAGS.py b/test/Ghostscript/GSFLAGS.py new file mode 100644 index 0000000..14ce769 --- /dev/null +++ b/test/Ghostscript/GSFLAGS.py @@ -0,0 +1,113 @@ +#!/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__" + +import os +import os.path +import string +import sys +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + + + +test.write('mygs.py', r""" +import getopt +import os +import sys +cmd_opts, args = getopt.getopt(sys.argv[1:], 's:x', []) +opt_string = '' +for opt, arg in cmd_opts: + if opt == '-s': + if arg[:11] == 'OutputFile=': + out_file = open(arg[11:], 'wb') + else: + opt_string = opt_string + ' ' + opt +infile = open(args[0], 'rb') +out_file.write(opt_string + "\n") +for l in infile.readlines(): + if l[:3] != '#ps': + out_file.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(GS = r'%s mygs.py', GSFLAGS = '-x', + tools = ['gs']) +env.PDF(target = 'test1.pdf', source = 'test1.ps') +""" % (python)) + +test.write('test1.ps', """\ +This is a .ps test. +#ps +""") + +test.run(arguments = '.', stderr = None) + +test.fail_test(test.read('test1.pdf') != " -x\nThis is a .ps test.\n") + + + +if sys.platform == 'win32': + gs_executable = 'gswin32c' +elif sys.platform == 'os2': + gs_executable = 'gsos2' +else: + gs_executable = 'gs' +gs = test.where_is(gs_executable) + +if gs: + + test.write("wrapper.py", """import os +import string +import sys +cmd = string.join(sys.argv[1:], " ") +open('%s', 'ab').write("%%s\\n" %% cmd) +os.system(cmd) +""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) + + test.write('SConstruct', """\ +import os +ENV = { 'PATH' : os.environ['PATH'] } +foo = Environment(ENV = ENV) +foo.Append(GSFLAGS = '-q') +foo.PDF(target = 'foo.pdf', source = 'foo.ps') +""") + + input = """\ +%!PS-Adobe +100 100 moveto /Times-Roman findfont 24 scalefont (Hello, world!) show showpage +""" + + test.write('foo.ps', input) + + test.run(arguments = 'foo.pdf', stderr = None) + + test.fail_test(not os.path.exists(test.workpath('foo.pdf'))) + +test.pass_test() diff --git a/test/IDL/IDLSUFFIXES.py b/test/IDL/IDLSUFFIXES.py new file mode 100644 index 0000000..2aaf9fe --- /dev/null +++ b/test/IDL/IDLSUFFIXES.py @@ -0,0 +1,70 @@ +#!/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 we can add filesuffixes to $IDLSUFFIXES. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """ +import SCons.Scanner.IDL +env = Environment(CPPPATH=['.']) +env.Append(SCANNERS = [ SCons.Scanner.IDL.IDLScan() ], + IDLSUFFIXES = ['.x']) +env.InstallAs('foo_idl', 'foo.idl') +env.InstallAs('foo_x', 'foo.x') +""") + +test.write('foo.idl', """\ +import +""") + +test.write('foo.x', """\ +#include +""") + +test.write('foo.h', "foo.h 1\n") + +test.run(arguments='.', stdout=test.wrap_stdout("""\ +Install file: "foo.idl" as "foo_idl" +Install file: "foo.x" as "foo_x" +""")) + +test.up_to_date(arguments='.') + +test.write('foo.h', "foo.h 2\n") + +test.run(arguments='.', stdout=test.wrap_stdout("""\ +Install file: "foo.idl" as "foo_idl" +Install file: "foo.x" as "foo_x" +""")) + +test.up_to_date(arguments='.') + +test.pass_test() diff --git a/test/IDL/MIDLCOM.py b/test/IDL/MIDLCOM.py new file mode 100644 index 0000000..d3f6420 --- /dev/null +++ b/test/IDL/MIDLCOM.py @@ -0,0 +1,63 @@ +#!/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 the ability to configure the $MIDLCOM construction variable. +""" + +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + + + +test.write('mymidl.py', """ +import sys +outfile = open(sys.argv[1], 'wb') +for f in sys.argv[2:]: + infile = open(f, 'rb') + for l in filter(lambda l: l != '/*midl*/\\n', infile.readlines()): + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(tools=['default', 'midl'], + MIDLCOM = r'%s mymidl.py $TARGET $SOURCES') +env.TypeLibrary(target = 'aaa', source = 'aaa.idl') +""" % python) + +test.write('aaa.idl', "aaa.idl\n/*midl*/\n") + +test.run(arguments = '.') + +test.must_match('aaa.tlb', "aaa.idl\n") + + + +test.pass_test() diff --git a/test/IDL/MIDLCOMSTR.py b/test/IDL/MIDLCOMSTR.py new file mode 100644 index 0000000..89a6e25 --- /dev/null +++ b/test/IDL/MIDLCOMSTR.py @@ -0,0 +1,67 @@ +#!/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 $MIDLCOMSTR construction variable allows you to customize +the displayed string when midl is called. +""" + +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + + + +test.write('mymidl.py', """ +import sys +outfile = open(sys.argv[1], 'wb') +for f in sys.argv[2:]: + infile = open(f, 'rb') + for l in filter(lambda l: l != '/*midl*/\\n', infile.readlines()): + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(tools=['default', 'midl'], + MIDLCOM = r'%s mymidl.py $TARGET $SOURCES', + MIDLCOMSTR = 'MIDLing $TARGET from $SOURCE') +env.TypeLibrary(target = 'aaa', source = 'aaa.idl') +""" % python) + +test.write('aaa.idl', "aaa.idl\n/*midl*/\n") + +test.run(stdout = test.wrap_stdout("""\ +MIDLing aaa.tlb from aaa.idl +""")) + +test.must_match('aaa.tlb', "aaa.idl\n") + + + +test.pass_test() diff --git a/test/IDL/midl.py b/test/IDL/midl.py new file mode 100644 index 0000000..a41ac01 --- /dev/null +++ b/test/IDL/midl.py @@ -0,0 +1,446 @@ +#!/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__" + +import TestSCons +import sys +import os.path +import os +import TestCmd +import time + +test = TestSCons.TestSCons(match = TestCmd.match_re) + +if sys.platform != 'win32': + test.pass_test() + +##### +# Test the basics + +test.write('SConstruct',""" +import os.path +import os + +env = Environment(CCFLAGS = ' -nologo ', + CPPPATH = '${TARGET.dir}', + MSVS_USE_MFC_DIRS = 1) +Export('env') + +BuildDir('build', 'src') +SConscript(os.path.join('build','SConscript')) + +BuildDir('build2', 'src', duplicate=0) +SConscript(os.path.join('build2','SConscript')) +""") + +test.subdir('src','build') + +test.write('src/SConscript',""" +import os.path + +Import('env') + +local = env.Copy(WIN32_INSERT_DEF = 1) + +barsrc = [ + 'BarObject.cpp', + 'bar.cpp', + local.RES('bar.rc', RCFLAGS= '/I${SOURCE.srcdir}'), + ] + +local.TypeLibrary('bar.idl') + +local.SharedLibrary(target = 'bar.dll', + source = barsrc, + PCH=local.PCH('BarPCH.cpp')[0], + PCHSTOP = 'BarPCH.h', + register=1) +""") + +test.write('src/BarObject.cpp',''' +#include "BarPCH.h" +#include "Bar.h" +#include "BarObject.h" +''') + +test.write('src/BarObject.h',''' +#ifndef __BAROBJECT_H_ +#define __BAROBJECT_H_ + +#include "resource.h" + +class ATL_NO_VTABLE CBarObject : + public CComObjectRootEx, + public CComCoClass, + public IDispatchImpl +{ +public: + CBarObject() + { + } + +DECLARE_REGISTRY_RESOURCEID(IDR_BAROBJECT) + +DECLARE_PROTECT_FINAL_CONSTRUCT() + +BEGIN_COM_MAP(CBarObject) + COM_INTERFACE_ENTRY(IBarObject) + COM_INTERFACE_ENTRY(IDispatch) +END_COM_MAP() + +public: +}; + +#endif +''') + +test.write('src/BarObject.rgs',""" +HKCR +{ + Bar.BarObject.1 = s 'BarObject Class' + { + CLSID = s '{640BE9EC-B79D-4C9E-BB64-95D24854A303}' + } + Bar.BarObject = s 'BarObject Class' + { + CLSID = s '{640BE9EC-B79D-4C9E-BB64-95D24854A303}' + CurVer = s 'Bar.BarObject.1' + } + NoRemove CLSID + { + ForceRemove {640BE9EC-B79D-4C9E-BB64-95D24854A303} = s 'BarObject Class' + { + ProgID = s 'Bar.BarObject.1' + VersionIndependentProgID = s 'Bar.BarObject' + ForceRemove 'Programmable' + InprocServer32 = s '%MODULE%' + { + val ThreadingModel = s 'Apartment' + } + 'TypeLib' = s '{73E5EA5F-9D45-463F-AA33-9F376AF7B643}' + } + } +} +""") + +test.write('src/BarPCH.cpp',''' +#include "BarPCH.h" + +#ifdef _ATL_STATIC_REGISTRY +#include +#include +#endif + +#include +''') + +test.write('src/BarPCH.h',''' +#ifndef BarPCH_h +#define BarPCH_h + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#define STRICT +#ifndef _WIN32_WINNT +#define _WIN32_WINNT 0x0400 +#endif +#define _ATL_APARTMENT_THREADED + +#include +extern CComModule _Module; +#include + +#endif +''') + +test.write('src/bar.cpp',''' +#include "BarPCH.h" +#include "resource.h" +#include +#include "bar.h" + +#include "bar_i.c" +#include "BarObject.h" + +CComModule _Module; + +BEGIN_OBJECT_MAP(ObjectMap) +OBJECT_ENTRY(CLSID_BarObject, CBarObject) +END_OBJECT_MAP() + +extern "C" +BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) +{ + lpReserved; + if (dwReason == DLL_PROCESS_ATTACH) + { + _Module.Init(ObjectMap, hInstance, &LIBID_BARLib); + DisableThreadLibraryCalls(hInstance); + } + else if (dwReason == DLL_PROCESS_DETACH) + _Module.Term(); + return TRUE; // ok +} + +STDAPI DllCanUnloadNow(void) +{ + return (_Module.GetLockCount()==0) ? S_OK : S_FALSE; +} + +STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv) +{ + return _Module.GetClassObject(rclsid, riid, ppv); +} + +STDAPI DllRegisterServer(void) +{ + return _Module.RegisterServer(TRUE); +} + +STDAPI DllUnregisterServer(void) +{ + return _Module.UnregisterServer(TRUE); +} +''') + +test.write('src/bar.def',''' +; bar.def : Declares the module parameters. + +LIBRARY "bar.DLL" + +EXPORTS + DllCanUnloadNow @1 PRIVATE + DllGetClassObject @2 PRIVATE + DllRegisterServer @3 PRIVATE + DllUnregisterServer @4 PRIVATE +''') + +test.write('src/bar.idl',''' +import "oaidl.idl"; +import "ocidl.idl"; + [ + object, + uuid(22995106-CE26-4561-AF1B-C71C6934B840), + dual, + helpstring("IBarObject Interface"), + pointer_default(unique) + ] + interface IBarObject : IDispatch + { + }; + +[ + uuid(73E5EA5F-9D45-463F-AA33-9F376AF7B643), + version(1.0), + helpstring("bar 1.0 Type Library") +] +library BARLib +{ + importlib("stdole32.tlb"); + importlib("stdole2.tlb"); + + [ + uuid(640BE9EC-B79D-4C9E-BB64-95D24854A303), + helpstring("BarObject Class") + ] + coclass BarObject + { + [default] interface IBarObject; + }; +}; +''') + +test.write('src/bar.rc',''' +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS + +#include "winres.h" + +#undef APSTUDIO_READONLY_SYMBOLS + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""winres.h""\\r\\n" + "\\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "1 TYPELIB ""bar.tlb""\\r\\n" + "\\0" +END + +#endif // APSTUDIO_INVOKED + + +#ifndef _MAC + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904B0" + BEGIN + VALUE "CompanyName", "\\0" + VALUE "FileDescription", "bar Module\\0" + VALUE "FileVersion", "1, 0, 0, 1\\0" + VALUE "InternalName", "bar\\0" + VALUE "LegalCopyright", "Copyright 2003\\0" + VALUE "OriginalFilename", "bar.DLL\\0" + VALUE "ProductName", "bar Module\\0" + VALUE "ProductVersion", "1, 0, 0, 1\\0" + VALUE "OLESelfRegister", "\\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +#endif // !_MAC + +IDR_BAROBJECT REGISTRY DISCARDABLE "BarObject.rgs" + +STRINGTABLE DISCARDABLE +BEGIN + IDS_PROJNAME "bar" +END + +#endif // English (U.S.) resources + +#ifndef APSTUDIO_INVOKED + +1 TYPELIB "bar.tlb" + +#endif // not APSTUDIO_INVOKED +''') + +test.write('src/resource.h',''' +#define IDS_PROJNAME 100 +#define IDR_BAROBJECT 101 + +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 201 +#define _APS_NEXT_COMMAND_VALUE 32768 +#define _APS_NEXT_CONTROL_VALUE 201 +#define _APS_NEXT_SYMED_VALUE 102 +#endif +#endif +''') + +test.run(arguments=os.path.join('build','bar.dll')) + +test.must_exist(['build','BarPCH.pch']) +test.must_exist(['build','BarPCH.obj']) +test.must_exist(['build','bar.tlb']) +test.must_exist(['build','bar.h']) +test.must_exist(['build','bar_i.c']) +test.must_exist(['build','bar_p.c']) +test.must_exist(['build','bar_data.c']) +test.must_exist(['build','BarObject.obj']) +test.must_exist(['build','bar.obj']) +test.must_exist(['build','bar.res']) +test.must_exist(['build','bar.dll']) +test.must_exist(['build','bar.lib']) +test.must_exist(['build','bar.exp']) + +test.run(arguments='-c .') + +test.must_not_exist(['build','BarPCH.pch']) +test.must_not_exist(['build','BarPCH.obj']) +test.must_not_exist(['build','bar.tlb']) +test.must_not_exist(['build','bar.h']) +test.must_not_exist(['build','bar_i.c']) +test.must_not_exist(['build','bar_p.c']) +test.must_not_exist(['build','bar_data.c']) +test.must_not_exist(['build','BarObject.obj']) +test.must_not_exist(['build','bar.obj']) +test.must_not_exist(['build','bar.res']) +test.must_not_exist(['build','bar.dll']) +test.must_not_exist(['build','bar.lib']) +test.must_not_exist(['build','bar.exp']) + +test.run(arguments=os.path.join('build2','bar.dll')) + +test.must_exist(['build2','BarPCH.pch']) +test.must_exist(['build2','BarPCH.obj']) +test.must_exist(['build2','bar.tlb']) +test.must_exist(['build2','bar.h']) +test.must_exist(['build2','bar_i.c']) +test.must_exist(['build2','bar_p.c']) +test.must_exist(['build2','bar_data.c']) +test.must_exist(['build2','BarObject.obj']) +test.must_exist(['build2','bar.obj']) +test.must_exist(['build2','bar.res']) +test.must_exist(['build2','bar.dll']) +test.must_exist(['build2','bar.lib']) +test.must_exist(['build2','bar.exp']) + +test.run(arguments='-c .') + +test.must_not_exist(['build2','BarPCH.pch']) +test.must_not_exist(['build2','BarPCH.obj']) +test.must_not_exist(['build2','bar.tlb']) +test.must_not_exist(['build2','bar.h']) +test.must_not_exist(['build2','bar_i.c']) +test.must_not_exist(['build2','bar_p.c']) +test.must_not_exist(['build2','bar_data.c']) +test.must_not_exist(['build2','BarObject.obj']) +test.must_not_exist(['build2','bar.obj']) +test.must_not_exist(['build2','bar.res']) +test.must_not_exist(['build2','bar.dll']) +test.must_not_exist(['build2','bar.lib']) +test.must_not_exist(['build2','bar.exp']) + +test.pass_test() diff --git a/test/IDLSUFFIXES.py b/test/IDLSUFFIXES.py deleted file mode 100644 index 2aaf9fe..0000000 --- a/test/IDLSUFFIXES.py +++ /dev/null @@ -1,70 +0,0 @@ -#!/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 we can add filesuffixes to $IDLSUFFIXES. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -test.write('SConstruct', """ -import SCons.Scanner.IDL -env = Environment(CPPPATH=['.']) -env.Append(SCANNERS = [ SCons.Scanner.IDL.IDLScan() ], - IDLSUFFIXES = ['.x']) -env.InstallAs('foo_idl', 'foo.idl') -env.InstallAs('foo_x', 'foo.x') -""") - -test.write('foo.idl', """\ -import -""") - -test.write('foo.x', """\ -#include -""") - -test.write('foo.h', "foo.h 1\n") - -test.run(arguments='.', stdout=test.wrap_stdout("""\ -Install file: "foo.idl" as "foo_idl" -Install file: "foo.x" as "foo_x" -""")) - -test.up_to_date(arguments='.') - -test.write('foo.h', "foo.h 2\n") - -test.run(arguments='.', stdout=test.wrap_stdout("""\ -Install file: "foo.idl" as "foo_idl" -Install file: "foo.x" as "foo_x" -""")) - -test.up_to_date(arguments='.') - -test.pass_test() diff --git a/test/MSVC/PCHCOM.py b/test/MSVC/PCHCOM.py new file mode 100644 index 0000000..593a1c1 --- /dev/null +++ b/test/MSVC/PCHCOM.py @@ -0,0 +1,63 @@ +#!/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 the ability to configure the $MIDLCOM construction variable. +""" + +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + + + +test.write('mypch.py', """ +import sys +outfile = open(sys.argv[1], 'wb') +for f in sys.argv[2:]: + infile = open(f, 'rb') + for l in filter(lambda l: l != '/*pch*/\\n', infile.readlines()): + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(tools=['default', 'msvc'], + PCHCOM = r'%s mypch.py $TARGET $SOURCES') +env.PCH(target = 'aaa', source = 'aaa.h') +""" % python) + +test.write('aaa.h', "aaa.h\n/*pch*/\n") + +test.run(arguments = ".") + +test.must_match('aaa.pch', "aaa.h\n") + + + +test.pass_test() diff --git a/test/MSVC/PCHCOMSTR.py b/test/MSVC/PCHCOMSTR.py new file mode 100644 index 0000000..c5ab9f5 --- /dev/null +++ b/test/MSVC/PCHCOMSTR.py @@ -0,0 +1,67 @@ +#!/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 $PCHCOMSTR construction variable allows you to customize +the displayed string when pch is called. +""" + +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + + + +test.write('mypch.py', """ +import sys +outfile = open(sys.argv[1], 'wb') +for f in sys.argv[2:]: + infile = open(f, 'rb') + for l in filter(lambda l: l != '/*pch*/\\n', infile.readlines()): + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(tools=['default', 'msvc'], + PCHCOM = r'%s mypch.py $TARGET $SOURCES', + PCHCOMSTR = 'PCHing $TARGET from $SOURCE') +env.PCH(target = 'aaa', source = 'aaa.h') +""" % python) + +test.write('aaa.h', "aaa.h\n/*pch*/\n") + +test.run(stdout = test.wrap_stdout("""\ +PCHing aaa.pch from aaa.h +""")) + +test.must_match('aaa.pch', "aaa.h\n") + + + +test.pass_test() diff --git a/test/MSVC/RCCOM.py b/test/MSVC/RCCOM.py new file mode 100644 index 0000000..3262f0c --- /dev/null +++ b/test/MSVC/RCCOM.py @@ -0,0 +1,64 @@ +#!/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 the ability to configure the $RCCOM construction variable +when using MSVC. +""" + +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + + + +test.write('myrc.py', """ +import sys +outfile = open(sys.argv[1], 'wb') +for f in sys.argv[2:]: + infile = open(f, 'rb') + for l in filter(lambda l: l != '/*rc*/\\n', infile.readlines()): + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(tools=['default', 'msvc'], + RCCOM = r'%(python)s myrc.py $TARGET $SOURCES') +env.RES(target = 'aaa', source = 'aaa.rc') +""" % locals()) + +test.write('aaa.rc', "aaa.rc\n/*rc*/\n") + +test.run(arguments = ".") + +test.must_match('aaa.res', "aaa.rc\n") + + + +test.pass_test() diff --git a/test/MSVC/RCCOMSTR.py b/test/MSVC/RCCOMSTR.py new file mode 100644 index 0000000..33e192b --- /dev/null +++ b/test/MSVC/RCCOMSTR.py @@ -0,0 +1,67 @@ +#!/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 $RCCOMSTR construction variable allows you to customize +the displayed string when rc is called. +""" + +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + + + +test.write('myrc.py', """ +import sys +outfile = open(sys.argv[1], 'wb') +for f in sys.argv[2:]: + infile = open(f, 'rb') + for l in filter(lambda l: l != '/*rc*/\\n', infile.readlines()): + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(tools=['default', 'msvc'], + RCCOM = r'%(python)s myrc.py $TARGET $SOURCES', + RCCOMSTR = 'RCing $TARGET from $SOURCE') +env.RES(target = 'aaa', source = 'aaa.rc') +""" % locals()) + +test.write('aaa.rc', "aaa.rc\n/*rc*/\n") + +test.run(stdout = test.wrap_stdout("""\ +RCing aaa.res from aaa.rc +""")) + +test.must_match('aaa.res', "aaa.rc\n") + + + +test.pass_test() diff --git a/test/MSVC/msvc.py b/test/MSVC/msvc.py new file mode 100644 index 0000000..fe5bfee --- /dev/null +++ b/test/MSVC/msvc.py @@ -0,0 +1,263 @@ +#!/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__" + +import TestSCons +import sys +import os.path +import os +import TestCmd +import time + +test = TestSCons.TestSCons(match = TestCmd.match_re) + +if sys.platform != 'win32': + test.pass_test() + +##### +# Test the basics + +test.write('SConstruct',""" +env=Environment() +env['PDB'] = File('test.pdb') +env['PCHSTOP'] = 'StdAfx.h' +env['PCH'] = env.PCH('StdAfx.cpp')[0] +env.Program('test', ['test.cpp', env.RES('test.rc')], LIBS=['user32']) + +env.Object('fast', 'foo.cpp') +env.Object('slow', 'foo.cpp', PCH=0) +""") + +test.write('test.cpp', ''' +#include "StdAfx.h" +#include "resource.h" + +int main(void) +{ + char test[1024]; + LoadString(GetModuleHandle(NULL), IDS_TEST, test, sizeof(test)); + printf("%d %s\\n", IDS_TEST, test); + return 0; +} +''') + +test.write('test.rc', ''' +#include "resource.h" + +STRINGTABLE DISCARDABLE +BEGIN + IDS_TEST "test 1" +END +''') + +test.write('resource.h', ''' +#define IDS_TEST 2001 +''') + + +test.write('foo.cpp', ''' +#include "StdAfx.h" +''') + +test.write('StdAfx.h', ''' +#include +#include +#include "resource.h" +''') + +test.write('StdAfx.cpp', ''' +#include "StdAfx.h" +''') + +test.run(arguments='test.exe') + +test.fail_test(not os.path.exists(test.workpath('test.exe'))) +test.fail_test(not os.path.exists(test.workpath('test.res'))) +test.fail_test(not os.path.exists(test.workpath('test.pdb'))) +test.fail_test(not os.path.exists(test.workpath('StdAfx.pch'))) +test.fail_test(not os.path.exists(test.workpath('StdAfx.obj'))) + +test.run(program=test.workpath('test.exe'), stdout='2001 test 1\n') + +test.write('resource.h', ''' +#define IDS_TEST 2002 +''') +test.run(arguments='test.exe') +test.run(program=test.workpath('test.exe'), stdout='2002 test 1\n') + +test.write('test.rc', ''' +#include "resource.h" + +STRINGTABLE DISCARDABLE +BEGIN + IDS_TEST "test 2" +END +''') +test.run(arguments='test.exe') +test.run(program=test.workpath('test.exe'), stdout='2002 test 2\n') + +test.run(arguments='-c .') + +test.fail_test(os.path.exists(test.workpath('test.exe'))) +test.fail_test(os.path.exists(test.workpath('test.pdb'))) +test.fail_test(os.path.exists(test.workpath('test.res'))) +test.fail_test(os.path.exists(test.workpath('StdAfx.pch'))) +test.fail_test(os.path.exists(test.workpath('StdAfx.obj'))) + +test.run(arguments='test.exe') + +test.fail_test(not os.path.exists(test.workpath('test.pdb'))) +test.fail_test(not os.path.exists(test.workpath('StdAfx.pch'))) +test.fail_test(not os.path.exists(test.workpath('StdAfx.obj'))) + +test.run(arguments='-c test.pdb') +test.fail_test(os.path.exists(test.workpath('test.exe'))) +test.fail_test(os.path.exists(test.workpath('test.obj'))) +test.fail_test(os.path.exists(test.workpath('test.pdb'))) +test.fail_test(os.path.exists(test.workpath('StdAfx.pch'))) +test.fail_test(os.path.exists(test.workpath('StdAfx.obj'))) + +test.run(arguments='StdAfx.pch') + +test.fail_test(os.path.exists(test.workpath('test.pdb'))) +test.fail_test(not os.path.exists(test.workpath('StdAfx.pch'))) +test.fail_test(not os.path.exists(test.workpath('StdAfx.obj'))) + +test.run(arguments='-c test.exe') +test.fail_test(os.path.exists(test.workpath('test.exe'))) +test.fail_test(os.path.exists(test.workpath('test.obj'))) +test.fail_test(os.path.exists(test.workpath('test.pdb'))) +test.fail_test(os.path.exists(test.workpath('StdAfx.pch'))) +test.fail_test(os.path.exists(test.workpath('StdAfx.obj'))) + +test.run(arguments='test.obj') +test.fail_test(os.path.exists(test.workpath('test.pdb'))) +test.fail_test(not os.path.exists(test.workpath('test.obj'))) + + +start = time.time() +test.run(arguments='fast.obj') +fast = time.time() - start + +start = time.time() +test.run(arguments='slow.obj') +slow = time.time() - start + +# using precompiled headers should be significantly faster +assert fast < slow*0.8 + +# Modifying resource.h should cause both the resource and precompiled header to be rebuilt: +test.write('resource.h', ''' +#define IDS_TEST 2003 +''') + +test.not_up_to_date(arguments='test.res') +test.not_up_to_date(arguments='StdAfx.pch') +test.not_up_to_date(arguments='test.exe') +test.run(program=test.workpath('test.exe'), stdout='2003 test 2\n') + + +########## +# Test a hierarchical build + +test.subdir('src', 'build', 'out') + +test.write('SConstruct',""" +BuildDir('build', 'src', duplicate=0) +SConscript('build/SConscript') +""") + +test.write('src/SConscript',""" +env=Environment() +env['PCH'] = 'StdAfx.pch' +env['PDB'] = '#out/test.pdb' +env['PCHSTOP'] = 'StdAfx.h' +env.PCH('StdAfx.cpp') +env.Program('#out/test.exe', 'test.cpp') +""") + +test.write('src/test.cpp', ''' +#include "StdAfx.h" + +int main(void) +{ + return 1; +} +''') + +test.write('src/StdAfx.h', ''' +#include +''') + +test.write('src/StdAfx.cpp', ''' +#include "StdAfx.h" +''') + +test.run(arguments='out') + +test.fail_test(not os.path.exists(test.workpath('out/test.pdb'))) +test.fail_test(not os.path.exists(test.workpath('build/StdAfx.pch'))) +test.fail_test(not os.path.exists(test.workpath('build/StdAfx.obj'))) + +test.run(arguments='-c out') + +test.fail_test(os.path.exists(test.workpath('out/test.pdb'))) +test.fail_test(os.path.exists(test.workpath('build/StdAfx.pch'))) +test.fail_test(os.path.exists(test.workpath('build/StdAfx.obj'))) + +##### +# Test error reporting + +test.write('SConstruct',""" +env=Environment() +env['PDB'] = File('test.pdb') +env['PCH'] = env.PCH('StdAfx.cpp')[0] +env.Program('test', 'test.cpp') +""") + +test.run(status=2, stderr=''' +scons: \*\*\* The PCHSTOP construction must be defined if PCH is defined. +File "SConstruct", line 5, in \? +''') + +test.write('SConstruct',""" +env=Environment() +env['PDB'] = File('test.pdb') +env['PCHSTOP'] = File('StdAfx.h') +env['PCH'] = env.PCH('StdAfx.cpp')[0] +env.Program('test', 'test.cpp') +""") + +test.run(status=2, stderr=''' +scons: \*\*\* The PCHSTOP construction variable must be a string: .+ +File "SConstruct", line 6, in \? +''') + +test.pass_test() + + + + + diff --git a/test/MinGW/RCCOM.py b/test/MinGW/RCCOM.py new file mode 100644 index 0000000..4ddcd91 --- /dev/null +++ b/test/MinGW/RCCOM.py @@ -0,0 +1,64 @@ +#!/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 the ability to configure the $RCCOM construction variable +when using MinGW. +""" + +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + + + +test.write('myrc.py', """ +import sys +outfile = open(sys.argv[1], 'wb') +for f in sys.argv[2:]: + infile = open(f, 'rb') + for l in filter(lambda l: l != '/*rc*/\\n', infile.readlines()): + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(tools=['default', 'mingw'], + RCCOM = r'%(python)s myrc.py $TARGET $SOURCES') +env.RES(target = 'aaa', source = 'aaa.rc') +""" % locals()) + +test.write('aaa.rc', "aaa.rc\n/*rc*/\n") + +test.run(arguments = ".") + +test.must_match('aaa.o', "aaa.rc\n") + + + +test.pass_test() diff --git a/test/MinGW/RCCOMSTR.py b/test/MinGW/RCCOMSTR.py new file mode 100644 index 0000000..e095847 --- /dev/null +++ b/test/MinGW/RCCOMSTR.py @@ -0,0 +1,67 @@ +#!/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 $RCCOMSTR construction variable allows you to customize +the displayed string when rc is called. +""" + +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + + + +test.write('myrc.py', """ +import sys +outfile = open(sys.argv[1], 'wb') +for f in sys.argv[2:]: + infile = open(f, 'rb') + for l in filter(lambda l: l != '/*rc*/\\n', infile.readlines()): + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(tools=['default', 'mingw'], + RCCOM = r'%(python)s myrc.py $TARGET $SOURCES', + RCCOMSTR = 'RCing $TARGET from $SOURCE') +env.RES(target = 'aaa', source = 'aaa.rc') +""" % locals()) + +test.write('aaa.rc', "aaa.rc\n/*rc*/\n") + +test.run(stdout = test.wrap_stdout("""\ +RCing aaa.o from aaa.rc +""")) + +test.must_match('aaa.o', "aaa.rc\n") + + + +test.pass_test() diff --git a/test/QT.py b/test/QT.py deleted file mode 100644 index 680784f..0000000 --- a/test/QT.py +++ /dev/null @@ -1,930 +0,0 @@ -#!/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__" - -""" -Testing the 'qt' tool, i.e. support for .ui files and automatic -generation of qt's moc files. -""" - -import os.path -import re -import string - -import TestSCons - -python = TestSCons.python -_exe = TestSCons._exe -lib_ = TestSCons.lib_ -_lib = TestSCons._lib -dll_ = TestSCons.dll_ -_dll = TestSCons._dll -_shobj = TestSCons._shobj - -test = TestSCons.TestSCons() - -test.subdir( 'qt', ['qt', 'bin'], ['qt', 'include'], ['qt', 'lib'] ) - -# create a dummy qt installation - -test.write(['qt', 'bin', 'mymoc.py'], """ -import getopt -import sys -import string -import re -cmd_opts, args = getopt.getopt(sys.argv[1:], 'io:', []) -output = None -impl = 0 -opt_string = '' -for opt, arg in cmd_opts: - if opt == '-o': output = open(arg, 'wb') - elif opt == '-i': impl = 1 - else: opt_string = opt_string + ' ' + opt -for a in args: - contents = open(a, 'rb').read() - subst = r'{ my_qt_symbol( "' + a + '\\\\n" ); }' - if impl: - contents = re.sub( r'#include.*', '', contents ) - output.write(string.replace(contents, 'Q_OBJECT', subst)) -output.close() -sys.exit(0) -""" ) - -test.write(['qt', 'bin', 'myuic.py'], """ -import os.path -import re -import sys -import string -output_arg = 0 -impl_arg = 0 -impl = None -source = None -for arg in sys.argv[1:]: - if output_arg: - output = open(arg, 'wb') - output_arg = 0 - elif impl_arg: - impl = arg - impl_arg = 0 - elif arg == "-o": - output_arg = 1 - elif arg == "-impl": - impl_arg = 1 - else: - if source: - sys.exit(1) - source = open(arg, 'rb') - sourceFile = arg -if impl: - output.write( '#include "' + impl + '"\\n' ) - includes = re.findall('(.*?)', source.read()) - for incFile in includes: - # this is valid for ui.h files, at least - if os.path.exists(incFile): - output.write('#include "' + incFile + '"\\n') -else: - output.write( '#include "my_qobject.h"\\n' + source.read() + " Q_OBJECT \\n" ) -output.close() -sys.exit(0) -""" ) - -test.write(['qt', 'include', 'my_qobject.h'], r""" -#define Q_OBJECT ; -void my_qt_symbol(const char *arg); -""") - -test.write(['qt', 'lib', 'my_qobject.cpp'], r""" -#include "../include/my_qobject.h" -#include -void my_qt_symbol(const char *arg) { - printf( arg ); -} -""") - -test.write(['qt', 'lib', 'SConstruct'], r""" -env = Environment() -env.StaticLibrary( 'myqt', 'my_qobject.cpp' ) -""") - -test.run(chdir=test.workpath('qt','lib'), arguments = '.', - stderr=TestSCons.noisy_ar, - match=TestSCons.match_re_dotall) - -QT = test.workpath('qt') -QT_LIB = 'myqt' -QT_MOC = '%s %s' % (python, test.workpath('qt','bin','mymoc.py')) -QT_UIC = '%s %s' % (python, test.workpath('qt','bin','myuic.py')) - -############################################################################## -# Test cases with different operation modes - -def createSConstruct(test,place): - test.write(place, """ -if ARGUMENTS.get('noqtdir', 0): QTDIR=None -else: QTDIR=r'%s' -env = Environment(QTDIR = QTDIR, - QT_LIB = r'%s', - 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) - 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 dup") -SConscript( sconscript ) -""" % (QT, QT_LIB, QT_MOC, QT_UIC)) - -test.subdir( 'work1', 'work2', 'work3', 'work4', - 'work5', 'work6', 'work7', 'work8', - 'work9', ['work9', 'local_include'], - 'work10', ['work10', 'sub'], ['work10', 'sub', 'local_include'], - 'work11', ['work11', 'include'], ['work11', 'ui'], - 'work12') - -############################################################################## -# 1. create a moc file from a header file. - -aaa_exe = 'aaa' + _exe -moc = 'moc_aaa.cc' - -createSConstruct(test, ['work1', 'SConstruct']) -test.write( ['work1', 'SConscript'], """ -Import("env") -env.Program(target = 'aaa', source = 'aaa.cpp') -""") - -test.write(['work1', 'aaa.cpp'], r""" -#include "aaa.h" -int main() { aaa(); return 0; } -""") - -test.write(['work1', 'aaa.h'], r""" -#include "my_qobject.h" -void aaa(void) Q_OBJECT; -""") - -test.run(chdir='work1', arguments = aaa_exe) -test.up_to_date(chdir='work1', options = '-n', arguments=aaa_exe) - -test.up_to_date(chdir='work1', options = '-n', arguments = aaa_exe) -test.write(['work1', 'aaa.h'], r""" -/* a change */ -#include "my_qobject.h" -void aaa(void) Q_OBJECT; -""") -test.not_up_to_date(chdir='work1', options='-n', arguments = moc) -test.run(program = test.workpath('work1', aaa_exe), stdout = 'aaa.h\n') - -test.run(chdir='work1', - arguments = "build_dir=1 " + - test.workpath('work1', 'build', aaa_exe) ) -test.run(chdir='work1', - arguments = "build_dir=1 chdir=1 " + - test.workpath('work1', 'build', aaa_exe) ) - -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 - -aaa_dll = dll_ + 'aaa' + _dll -moc = 'moc_aaa.cc' -cpp = 'uic_aaa.cc' -obj = os.path.splitext(cpp)[0] + _shobj -h = 'aaa.h' - -createSConstruct(test, ['work2', 'SConstruct']) -test.write(['work2', 'SConscript'], """ -Import("env dup") -if dup == 0: env.Append(CPPPATH=['#', '.']) -env.SharedLibrary(target = 'aaa', source = ['aaa.ui', 'useit.cpp']) -""") - -test.write(['work2', 'aaa.ui'], r""" -#if defined (_WIN32) || defined(__CYGWIN__) -#define DLLEXPORT __declspec(dllexport) -#else -#define DLLEXPORT -#endif -DLLEXPORT void aaa(void) -""") - -test.write(['work2', 'useit.cpp'], r""" -#include "aaa.h" -void useit() { - aaa(); -} -""") - -test.run(chdir='work2', arguments = aaa_dll) -test.up_to_date(chdir='work2', options='-n',arguments = aaa_dll) -test.write(['work2', 'aaa.ui'], r""" -/* a change */ -#if defined (_WIN32) || defined(__CYGWIN__) -#define DLLEXPORT __declspec(dllexport) -#else -#define DLLEXPORT -#endif -DLLEXPORT void aaa(void) -""") -test.not_up_to_date(chdir='work2', options = '-n', arguments = moc) -test.not_up_to_date(chdir='work2', options = '-n', arguments = cpp) -test.not_up_to_date(chdir='work2', options = '-n', arguments = h) -test.run(chdir='work2', arguments = aaa_dll) -test.write(['work2', 'aaa.ui'], r""" -void aaa(void) -//aaa.ui.h -""") -test.run(chdir='work2', arguments = aaa_dll) # test that non-existant ui.h files are ignored (as uic does) -test.write(['work2', 'aaa.ui.h'], r""" -/* test dependency to .ui.h */ -""") -test.run(chdir='work2', arguments = aaa_dll) -test.write(['work2', 'aaa.ui.h'], r""" -/* changed */ -""") -test.not_up_to_date(chdir='work2', options = '-n', arguments = obj) -test.not_up_to_date(chdir='work2', options = '-n', arguments = cpp) -test.not_up_to_date(chdir='work2', options = '-n', arguments = h) -test.not_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))) -cppContents = test.read(test.workpath('work2', 'build', cpp)) -test.fail_test(string.find(cppContents, '#include "aaa.ui.h"') == -1) - -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)) 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 - -lib_aaa = lib_ + 'aaa' + _lib -moc = 'aaa.moc' - -createSConstruct(test, ['work3', 'SConstruct']) -test.write(['work3', 'SConscript'], """ -Import("env dup") -if dup == 0: env.Append(CPPPATH=['.']) -env.StaticLibrary(target = '%s', source = ['aaa.cpp','useit.cpp']) -""" % lib_aaa) - -test.write(['work3', 'aaa.h'], r""" -void aaa(void); -""") - -test.write(['work3', 'aaa.cpp'], r""" -#include "my_qobject.h" -void aaa(void) Q_OBJECT -#include "%s" -""" % moc) - -test.write(['work3', 'useit.cpp'], r""" -#include "aaa.h" -void useit() { - aaa(); -} -""") - -test.run(chdir='work3', arguments = lib_aaa, - stderr=TestSCons.noisy_ar, - match=TestSCons.match_re_dotall) -test.up_to_date(chdir='work3', options = '-n', arguments = lib_aaa) -test.write(['work3', 'aaa.cpp'], r""" -#include "my_qobject.h" -/* a change */ -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 " + - test.workpath('work3', 'build', lib_aaa), - stderr=TestSCons.noisy_ar, - match=TestSCons.match_re_dotall) -test.run(chdir='work3', - arguments = "build_dir=1 chdir=1 " + - test.workpath('work3', 'build', lib_aaa) ) - -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), - stderr=TestSCons.noisy_ar, - match=TestSCons.match_re_dotall) -test.must_exist(['work3', 'build_dup0', moc]) - -############################################################################## -# 4. Test with a copied environment. - -createSConstruct(test, ['work4', 'SConstruct']) -test.write(['work4', 'SConscript'], """\ -Import("env") -env.Append(CPPDEFINES = ['FOOBAZ']) - -copy = env.Copy() -copy.Append(CPPDEFINES = ['MYLIB_IMPL']) - -copy.SharedLibrary( - target = 'MyLib', - source = ['MyFile.cpp','MyForm.ui'] -) -""") - -test.write(['work4', 'MyFile.h'], r""" -void aaa(void); -""") - -test.write(['work4', 'MyFile.cpp'], r""" -#include "MyFile.h" -void useit() { - aaa(); -} -""") - -test.write(['work4', 'MyForm.ui'], r""" -void aaa(void) -""") - -test.run(chdir='work4') -moc_MyForm = filter(lambda x: string.find(x, 'moc_MyForm') != -1, - string.split(test.stdout(), '\n')) -MYLIB_IMPL = filter(lambda x: string.find(x, 'MYLIB_IMPL') != -1, moc_MyForm) -if not MYLIB_IMPL: - print "Did not find MYLIB_IMPL on moc_MyForm compilation line:" - print test.stdout() - test.fail_test() - -############################################################################## -# 5. Test creation from a copied environment that already has QT variables. -# This makes sure the tool initialization is re-entrant. - -createSConstruct(test, ['work5', 'SConstruct']) -test.write( ['work5', 'SConscript'], """ -Import("env") -env = env.Copy(tools=['qt']) -env.Program('main', 'main.cpp', CPPDEFINES=['FOO'], LIBS=[]) -""") - -test.write(['work5', 'main.cpp'], r""" -#include "foo5.h" -int main() { foo5(); return 0; } -""") - -test.write(['qt', 'include', 'foo5.h'], """\ -#include -void -foo5(void) -{ -#ifdef FOO - printf("qt/include/foo5.h\\n"); -#endif -} -""") - -test.run(chdir='work5') - -main_exe = 'main' + _exe -test.run(program = test.workpath('work5', main_exe), - stdout = 'qt/include/foo5.h\n') - -############################################################################## -# 6. Test creation from a copied empty environment. - -test.write(['work6', 'SConstruct'], """\ -orig = Environment() -env = orig.Copy(QTDIR = r'%s', - QT_LIB = r'%s', - QT_MOC = r'%s', - QT_UIC = r'%s', - tools=['qt']) -env.Program('main', 'main.cpp', CPPDEFINES=['FOO'], LIBS=[]) -""" % (QT, QT_LIB, QT_MOC, QT_UIC)) - -test.write(['work6', 'main.cpp'], r""" -#include "foo6.h" -int main() { foo6(); return 0; } -""") - -test.write(['qt', 'include', 'foo6.h'], """\ -#include -void -foo6(void) -{ -#ifdef FOO - printf("qt/include/foo6.h\\n"); -#endif -} -""") - -# we can receive warnings about a non detected qt (empty QTDIR) -# these are not critical, but maybe annoying -test.run(chdir='work6', stderr=None) - -main_exe = 'main' + _exe -test.run(program = test.workpath('work6', main_exe), - stderr = None, - stdout = 'qt/include/foo6.h\n') - -############################################################################## -# 7. look if qt is installed, and try out all builders - -if os.environ.get('QTDIR', None): - - QTDIR=os.environ['QTDIR'] - - - test.write( ['work7', 'SConstruct'],""" -import os -dummy_env = Environment() -ENV = dummy_env['ENV'] -try: - PATH=ARGUMENTS['PATH'] - if ENV.has_key('PATH'): - ENV_PATH = PATH + os.pathsep + ENV['PATH'] - else: - Exit(0) # this is certainly a weird system :-) -except KeyError: - ENV_PATH=ENV.get('PATH', '') - -env = Environment(tools=['default','qt'], - ENV={'PATH':ENV_PATH, - 'PATHEXT':os.environ.get('PATHEXT'), - 'HOME':os.getcwd()}, - # moc / uic want to write stuff in ~/.qt - CXXFILESUFFIX=".cpp") - -conf = env.Configure() -if not conf.CheckLib(env.subst("$QT_LIB"), autoadd=0): - conf.env['QT_LIB'] = 'qt-mt' - if not conf.CheckLib(env.subst("$QT_LIB"), autoadd=0): - Exit(0) -env = conf.Finish() -BuildDir('bld', '.') -env.Program('bld/test_realqt', ['bld/mocFromCpp.cpp', - 'bld/mocFromH.cpp', - 'bld/anUiFile.ui', - 'bld/main.cpp']) -""") - - test.write( ['work7', 'mocFromCpp.h'],""" -void mocFromCpp(); -""") - - test.write( ['work7', 'mocFromCpp.cpp'],""" -#include -#include "mocFromCpp.h" -class MyClass1 : public QObject { - Q_OBJECT - public: - MyClass1() : QObject() {}; - public slots: - void myslot() {}; -}; -void mocFromCpp() { - MyClass1 myclass; -} -#include "mocFromCpp.moc" -""") - - test.write( ['work7', 'mocFromH.h'],""" -#include -class MyClass2 : public QObject { - Q_OBJECT; - public: - MyClass2(); - public slots: - void myslot(); -}; -void mocFromH(); -""") - - test.write( ['work7', 'mocFromH.cpp'],""" -#include "mocFromH.h" - -MyClass2::MyClass2() : QObject() {} -void MyClass2::myslot() {} -void mocFromH() { - MyClass2 myclass; -} -""") - - test.write( ['work7', 'anUiFile.ui'],""" - -MyWidget - - QWidget - - MyWidget - - - MyWidget - - - - anUiFile.ui.h - - - testSlot() - - - -""") - test.write( ['work7', 'anUiFile.ui.h'], r""" -#include -#if QT_VERSION >= 0x030100 -void MyWidget::testSlot() -{ - printf("Hello World\n"); -} -#endif -""") - - test.write( ['work7', 'main.cpp'], r""" -#include -#include "mocFromCpp.h" -#include "mocFromH.h" -#include "anUiFile.h" -#include - -int main(int argc, char **argv) { - QApplication app(argc, argv); - mocFromCpp(); - mocFromH(); - MyWidget mywidget; -#if QT_VERSION >= 0x030100 - mywidget.testSlot(); -#else - printf("Hello World\n"); -#endif - return 0; -} -""") - - test.run(chdir='work7', arguments="bld/test_realqt" + _exe) - test.run(program=test.workpath("work7", "bld", "test_realqt"), - stdout="Hello World\n") - - QTDIR=os.environ['QTDIR'] - del os.environ['QTDIR'] - PATH=os.environ['PATH'] - os.environ['PATH']='.' - - test.run(chdir='work7', stderr=None, arguments="-c bld/test_realqt" + _exe) - test.fail_test(not test.match_re_dotall(test.stderr(), r""".* -scons: warning: Could not detect qt, using empty QTDIR -""" + TestSCons.file_expr)) - - os.environ['PATH'] = PATH - - test.run(chdir='work7', stderr=None, - arguments="PATH=%s%sbin bld%stest_realqt%s"%(QTDIR,os.sep,os.sep,_exe)) - test.fail_test(not test.match_re(test.stderr(), (r""" -scons: warning: Could not detect qt, using moc executable as a hint \(QTDIR=%s\) -""" + TestSCons.file_expr) % re.escape(QTDIR))) - - -else: - print "Could not find QT, skipping test(s)." - -############################################################################## -# 8. test the $QT_AUTOBUILD_MOC_SOURCES variable -# -# This has been removed, but I'm leaving the test here, commented out, -# in case we ever resurrect this functionality again in the future. -# -#aaa_dll = dll_ + 'aaa' + _dll -#moc = 'moc_aaa.cc' -# -#createSConstruct(test, ['work8', 'SConstruct']) -# -#test.write(['work8', 'SConscript'], """ -#Import("env") -#env = env.Copy(QT_AUTOBUILD_MOC_SOURCES = 0) -#env.SharedLibrary(target = 'aaa', source = ['aaa.ui', 'useit.cpp', 'aaa_function.cpp']) -#""") -# -#test.write(['work8', 'aaa.ui'], r""" -##if defined (_WIN32) || defined(__CYGWIN__) -##define DLLEXPORT __declspec(dllexport) -##else -##define DLLEXPORT -##endif -#DLLEXPORT void aaa(void) -#""") -# -#test.write(['work8', 'useit.cpp'], r""" -##include "aaa.h" -#void useit() { -# aaa(); -#} -#""") -# -#test.write(['work8', 'aaa_function.cpp'], r""" -##include "my_qobject.h" -##if defined (_WIN32) || defined(__CYGWIN__) -##define DLLEXPORT __declspec(dllexport) -##else -##define DLLEXPORT -##endif -#DLLEXPORT void aaa(void) -# { my_qt_symbol( "aaa_function.cpp\n" ); } -#""") -# -#test.run(chdir='work8', arguments = aaa_dll) -# -#test.must_not_exist(test.workpath('work8', moc)) -# -#test.write(['work8', 'SConscript'], """ -#Import("env") -#env = env.Copy(QT_AUTOBUILD_MOC_SOURCES = 1) -#env.SharedLibrary(target = 'aaa', source = ['aaa.ui', 'useit.cpp']) -#""") -# -#test.run(chdir='work8', arguments = aaa_dll) -# -#test.must_exist(test.workpath('work8', moc)) - -############################################################################## -# 9. test that an overwritten CPPPATH is working with generated files - -# this is basically test 1, but with an additional include -aaa_exe = 'aaa' + _exe - -createSConstruct(test, ['work9', 'SConstruct']) -test.write( ['work9', 'SConscript'], """ -Import("env") -env.Program(target = 'aaa', source = 'aaa.cpp', CPPPATH=['$CPPPATH', './local_include']) -""") - -test.write(['work9', 'aaa.cpp'], r""" -#include "aaa.h" -int main() { aaa(); return 0; } -""") - -test.write(['work9', 'aaa.h'], r""" -#include "my_qobject.h" -#include "local_include.h" -void aaa(void) Q_OBJECT; -""") - -test.write(['work9', 'local_include', 'local_include.h'], r""" -/* empty; just needs to be found */ -""") - -test.run(chdir='work9', arguments = aaa_exe) - -############################################################################## -# 10. test that an appended relative CPPPATH is working with generated files - -# this is basically test 9, but the include path is env.Append-ed and -# everything goes into sub directory "sub" -aaa_exe = os.path.join('sub', 'aaa' + _exe) - -createSConstruct(test, ['work10', 'SConstruct']) -test.write( ['work10', 'SConscript'], r""" -SConscript('sub/SConscript') -""") - -test.write( ['work10', 'sub', 'SConscript'], r""" -Import("env") -env.Append(CPPPATH=['./local_include']) -env.Program(target = 'aaa', source = 'aaa.cpp') -""") - -test.write(['work10', 'sub', 'aaa.cpp'], r""" -#include "aaa.h" -int main() { aaa(); return 0; } -""") - -test.write(['work10', 'sub', 'aaa.h'], r""" -#include "my_qobject.h" -#include "local_include.h" -void aaa(void) Q_OBJECT; -""") - -test.write(['work10', 'sub', 'local_include', 'local_include.h'], r""" -/* empty; just needs to be found */ -""") - -test.run(chdir='work10', arguments = aaa_exe) - -############################################################################### -# 11. test the manual QT builder calls - -aaa_exe = 'aaa' + _exe - -createSConstruct(test, ['work11', 'SConstruct']) -test.write( ['work11', 'SConscript'], r""" -Import("env") -sources = ['aaa.cpp', 'bbb.cpp', 'ddd.cpp', 'eee.cpp', 'main.cpp'] - -# normal invocation -sources.append(env.Moc('include/aaa.h')) -env.Moc('bbb.cpp') -sources.extend(env.Uic('ui/ccc.ui')[1:]) - -# manual target specification -sources.append(env.Moc('moc-ddd.cpp', 'include/ddd.h', - QT_MOCHPREFIX='')) # Watch out ! -env.Moc('moc_eee.cpp', 'eee.cpp') -sources.extend(env.Uic(['include/uic_fff.hpp', 'fff.cpp', 'fff.moc.cpp'], - 'ui/fff.ui')[1:]) - -print map(str,sources) -env.Program(target='aaa', - source=sources, - CPPPATH=['$CPPPATH', './include'], - QT_AUTOSCAN=0) -""") - -test.write(['work11', 'aaa.cpp'], r""" -#include "aaa.h" -""") - -test.write(['work11', 'include', 'aaa.h'], r""" -#include "my_qobject.h" -void aaa(void) Q_OBJECT; -""") - -test.write(['work11', 'bbb.h'], r""" -void bbb(void); -""") - -test.write(['work11', 'bbb.cpp'], r""" -#include "my_qobject.h" -void bbb(void) Q_OBJECT -#include "bbb.moc" -""") - -test.write(['work11', 'ui', 'ccc.ui'], r""" -void ccc(void) -""") - -test.write(['work11', 'ddd.cpp'], r""" -#include "ddd.h" -""") - -test.write(['work11', 'include', 'ddd.h'], r""" -#include "my_qobject.h" -void ddd(void) Q_OBJECT; -""") - -test.write(['work11', 'eee.h'], r""" -void eee(void); -""") - -test.write(['work11', 'eee.cpp'], r""" -#include "my_qobject.h" -void eee(void) Q_OBJECT -#include "moc_eee.cpp" -""") - -test.write(['work11', 'ui', 'fff.ui'], r""" -void fff(void) -""") - -test.write(['work11', 'main.cpp'], r""" -#include "aaa.h" -#include "bbb.h" -#include "ui/ccc.h" -#include "ddd.h" -#include "eee.h" -#include "uic_fff.hpp" - -int main() { - aaa(); bbb(); ccc(); ddd(); eee(); fff(); return 0; -} -""") - -test.run(chdir='work11', arguments = aaa_exe) - -# normal invocation -test.must_exist(test.workpath('work11', 'include', 'moc_aaa.cc')) -test.must_exist(test.workpath('work11', 'bbb.moc')) -test.must_exist(test.workpath('work11', 'ui', 'ccc.h')) -test.must_exist(test.workpath('work11', 'ui', 'uic_ccc.cc')) -test.must_exist(test.workpath('work11', 'ui', 'moc_ccc.cc')) - -# manual target spec. -test.must_exist(test.workpath('work11', 'moc-ddd.cpp')) -test.must_exist(test.workpath('work11', 'moc_eee.cpp')) -test.must_exist(test.workpath('work11', 'include', 'uic_fff.hpp')) -test.must_exist(test.workpath('work11', 'fff.cpp')) -test.must_exist(test.workpath('work11', 'fff.moc.cpp')) - - -############################################################################## -# 12. test the tool warings -createSConstruct(test, ['work12', 'SConstruct']) - -test.write(['work12', 'aaa.cpp'], r""" -#include "my_qobject.h" -void aaa(void) Q_OBJECT -""") - -test.write(['work12', 'SConscript'], r""" -Import("env") -import os -env.StaticLibrary('aaa.cpp') -""") - -test.run(chdir='work12', stderr=None) - -match12 = r""" -scons: warning: Generated moc file 'aaa.moc' is not included by 'aaa.cpp' -""" + TestSCons.file_expr - -# In case 'ar' gives a warning about creating a library. -test.fail_test(not test.match_re(test.stderr(), match12) and \ - not test.match_re(test.stderr(), match12 + ".+\n")) - -os.environ['QTDIR'] = QT -test.run(chdir='work12', arguments='-n noqtdir=1') - -# We'd like to eliminate $QTDIR from the environment as follows: -# del os.environ['QTDIR'] -# But unfortunately, in at least some versions of Python, the Environment -# class doesn't implement a __delitem__() method to make the library -# call to actually remove the deleted variable from the *external* -# environment, so it only gets removed from the Python dictionary. -# Consequently, we need to just wipe out its value as follows> -os.environ['QTDIR'] = '' -test.run(chdir='work12', stderr=None, arguments='-n noqtdir=1') -test.fail_test(not test.match_re(test.stderr(), r""" -scons: warning: Could not detect qt, using empty QTDIR -""" + TestSCons.file_expr)) - -test.pass_test() diff --git a/test/QT/QT.py b/test/QT/QT.py new file mode 100644 index 0000000..680784f --- /dev/null +++ b/test/QT/QT.py @@ -0,0 +1,930 @@ +#!/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__" + +""" +Testing the 'qt' tool, i.e. support for .ui files and automatic +generation of qt's moc files. +""" + +import os.path +import re +import string + +import TestSCons + +python = TestSCons.python +_exe = TestSCons._exe +lib_ = TestSCons.lib_ +_lib = TestSCons._lib +dll_ = TestSCons.dll_ +_dll = TestSCons._dll +_shobj = TestSCons._shobj + +test = TestSCons.TestSCons() + +test.subdir( 'qt', ['qt', 'bin'], ['qt', 'include'], ['qt', 'lib'] ) + +# create a dummy qt installation + +test.write(['qt', 'bin', 'mymoc.py'], """ +import getopt +import sys +import string +import re +cmd_opts, args = getopt.getopt(sys.argv[1:], 'io:', []) +output = None +impl = 0 +opt_string = '' +for opt, arg in cmd_opts: + if opt == '-o': output = open(arg, 'wb') + elif opt == '-i': impl = 1 + else: opt_string = opt_string + ' ' + opt +for a in args: + contents = open(a, 'rb').read() + subst = r'{ my_qt_symbol( "' + a + '\\\\n" ); }' + if impl: + contents = re.sub( r'#include.*', '', contents ) + output.write(string.replace(contents, 'Q_OBJECT', subst)) +output.close() +sys.exit(0) +""" ) + +test.write(['qt', 'bin', 'myuic.py'], """ +import os.path +import re +import sys +import string +output_arg = 0 +impl_arg = 0 +impl = None +source = None +for arg in sys.argv[1:]: + if output_arg: + output = open(arg, 'wb') + output_arg = 0 + elif impl_arg: + impl = arg + impl_arg = 0 + elif arg == "-o": + output_arg = 1 + elif arg == "-impl": + impl_arg = 1 + else: + if source: + sys.exit(1) + source = open(arg, 'rb') + sourceFile = arg +if impl: + output.write( '#include "' + impl + '"\\n' ) + includes = re.findall('(.*?)', source.read()) + for incFile in includes: + # this is valid for ui.h files, at least + if os.path.exists(incFile): + output.write('#include "' + incFile + '"\\n') +else: + output.write( '#include "my_qobject.h"\\n' + source.read() + " Q_OBJECT \\n" ) +output.close() +sys.exit(0) +""" ) + +test.write(['qt', 'include', 'my_qobject.h'], r""" +#define Q_OBJECT ; +void my_qt_symbol(const char *arg); +""") + +test.write(['qt', 'lib', 'my_qobject.cpp'], r""" +#include "../include/my_qobject.h" +#include +void my_qt_symbol(const char *arg) { + printf( arg ); +} +""") + +test.write(['qt', 'lib', 'SConstruct'], r""" +env = Environment() +env.StaticLibrary( 'myqt', 'my_qobject.cpp' ) +""") + +test.run(chdir=test.workpath('qt','lib'), arguments = '.', + stderr=TestSCons.noisy_ar, + match=TestSCons.match_re_dotall) + +QT = test.workpath('qt') +QT_LIB = 'myqt' +QT_MOC = '%s %s' % (python, test.workpath('qt','bin','mymoc.py')) +QT_UIC = '%s %s' % (python, test.workpath('qt','bin','myuic.py')) + +############################################################################## +# Test cases with different operation modes + +def createSConstruct(test,place): + test.write(place, """ +if ARGUMENTS.get('noqtdir', 0): QTDIR=None +else: QTDIR=r'%s' +env = Environment(QTDIR = QTDIR, + QT_LIB = r'%s', + 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) + 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 dup") +SConscript( sconscript ) +""" % (QT, QT_LIB, QT_MOC, QT_UIC)) + +test.subdir( 'work1', 'work2', 'work3', 'work4', + 'work5', 'work6', 'work7', 'work8', + 'work9', ['work9', 'local_include'], + 'work10', ['work10', 'sub'], ['work10', 'sub', 'local_include'], + 'work11', ['work11', 'include'], ['work11', 'ui'], + 'work12') + +############################################################################## +# 1. create a moc file from a header file. + +aaa_exe = 'aaa' + _exe +moc = 'moc_aaa.cc' + +createSConstruct(test, ['work1', 'SConstruct']) +test.write( ['work1', 'SConscript'], """ +Import("env") +env.Program(target = 'aaa', source = 'aaa.cpp') +""") + +test.write(['work1', 'aaa.cpp'], r""" +#include "aaa.h" +int main() { aaa(); return 0; } +""") + +test.write(['work1', 'aaa.h'], r""" +#include "my_qobject.h" +void aaa(void) Q_OBJECT; +""") + +test.run(chdir='work1', arguments = aaa_exe) +test.up_to_date(chdir='work1', options = '-n', arguments=aaa_exe) + +test.up_to_date(chdir='work1', options = '-n', arguments = aaa_exe) +test.write(['work1', 'aaa.h'], r""" +/* a change */ +#include "my_qobject.h" +void aaa(void) Q_OBJECT; +""") +test.not_up_to_date(chdir='work1', options='-n', arguments = moc) +test.run(program = test.workpath('work1', aaa_exe), stdout = 'aaa.h\n') + +test.run(chdir='work1', + arguments = "build_dir=1 " + + test.workpath('work1', 'build', aaa_exe) ) +test.run(chdir='work1', + arguments = "build_dir=1 chdir=1 " + + test.workpath('work1', 'build', aaa_exe) ) + +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 + +aaa_dll = dll_ + 'aaa' + _dll +moc = 'moc_aaa.cc' +cpp = 'uic_aaa.cc' +obj = os.path.splitext(cpp)[0] + _shobj +h = 'aaa.h' + +createSConstruct(test, ['work2', 'SConstruct']) +test.write(['work2', 'SConscript'], """ +Import("env dup") +if dup == 0: env.Append(CPPPATH=['#', '.']) +env.SharedLibrary(target = 'aaa', source = ['aaa.ui', 'useit.cpp']) +""") + +test.write(['work2', 'aaa.ui'], r""" +#if defined (_WIN32) || defined(__CYGWIN__) +#define DLLEXPORT __declspec(dllexport) +#else +#define DLLEXPORT +#endif +DLLEXPORT void aaa(void) +""") + +test.write(['work2', 'useit.cpp'], r""" +#include "aaa.h" +void useit() { + aaa(); +} +""") + +test.run(chdir='work2', arguments = aaa_dll) +test.up_to_date(chdir='work2', options='-n',arguments = aaa_dll) +test.write(['work2', 'aaa.ui'], r""" +/* a change */ +#if defined (_WIN32) || defined(__CYGWIN__) +#define DLLEXPORT __declspec(dllexport) +#else +#define DLLEXPORT +#endif +DLLEXPORT void aaa(void) +""") +test.not_up_to_date(chdir='work2', options = '-n', arguments = moc) +test.not_up_to_date(chdir='work2', options = '-n', arguments = cpp) +test.not_up_to_date(chdir='work2', options = '-n', arguments = h) +test.run(chdir='work2', arguments = aaa_dll) +test.write(['work2', 'aaa.ui'], r""" +void aaa(void) +//aaa.ui.h +""") +test.run(chdir='work2', arguments = aaa_dll) # test that non-existant ui.h files are ignored (as uic does) +test.write(['work2', 'aaa.ui.h'], r""" +/* test dependency to .ui.h */ +""") +test.run(chdir='work2', arguments = aaa_dll) +test.write(['work2', 'aaa.ui.h'], r""" +/* changed */ +""") +test.not_up_to_date(chdir='work2', options = '-n', arguments = obj) +test.not_up_to_date(chdir='work2', options = '-n', arguments = cpp) +test.not_up_to_date(chdir='work2', options = '-n', arguments = h) +test.not_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))) +cppContents = test.read(test.workpath('work2', 'build', cpp)) +test.fail_test(string.find(cppContents, '#include "aaa.ui.h"') == -1) + +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)) 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 + +lib_aaa = lib_ + 'aaa' + _lib +moc = 'aaa.moc' + +createSConstruct(test, ['work3', 'SConstruct']) +test.write(['work3', 'SConscript'], """ +Import("env dup") +if dup == 0: env.Append(CPPPATH=['.']) +env.StaticLibrary(target = '%s', source = ['aaa.cpp','useit.cpp']) +""" % lib_aaa) + +test.write(['work3', 'aaa.h'], r""" +void aaa(void); +""") + +test.write(['work3', 'aaa.cpp'], r""" +#include "my_qobject.h" +void aaa(void) Q_OBJECT +#include "%s" +""" % moc) + +test.write(['work3', 'useit.cpp'], r""" +#include "aaa.h" +void useit() { + aaa(); +} +""") + +test.run(chdir='work3', arguments = lib_aaa, + stderr=TestSCons.noisy_ar, + match=TestSCons.match_re_dotall) +test.up_to_date(chdir='work3', options = '-n', arguments = lib_aaa) +test.write(['work3', 'aaa.cpp'], r""" +#include "my_qobject.h" +/* a change */ +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 " + + test.workpath('work3', 'build', lib_aaa), + stderr=TestSCons.noisy_ar, + match=TestSCons.match_re_dotall) +test.run(chdir='work3', + arguments = "build_dir=1 chdir=1 " + + test.workpath('work3', 'build', lib_aaa) ) + +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), + stderr=TestSCons.noisy_ar, + match=TestSCons.match_re_dotall) +test.must_exist(['work3', 'build_dup0', moc]) + +############################################################################## +# 4. Test with a copied environment. + +createSConstruct(test, ['work4', 'SConstruct']) +test.write(['work4', 'SConscript'], """\ +Import("env") +env.Append(CPPDEFINES = ['FOOBAZ']) + +copy = env.Copy() +copy.Append(CPPDEFINES = ['MYLIB_IMPL']) + +copy.SharedLibrary( + target = 'MyLib', + source = ['MyFile.cpp','MyForm.ui'] +) +""") + +test.write(['work4', 'MyFile.h'], r""" +void aaa(void); +""") + +test.write(['work4', 'MyFile.cpp'], r""" +#include "MyFile.h" +void useit() { + aaa(); +} +""") + +test.write(['work4', 'MyForm.ui'], r""" +void aaa(void) +""") + +test.run(chdir='work4') +moc_MyForm = filter(lambda x: string.find(x, 'moc_MyForm') != -1, + string.split(test.stdout(), '\n')) +MYLIB_IMPL = filter(lambda x: string.find(x, 'MYLIB_IMPL') != -1, moc_MyForm) +if not MYLIB_IMPL: + print "Did not find MYLIB_IMPL on moc_MyForm compilation line:" + print test.stdout() + test.fail_test() + +############################################################################## +# 5. Test creation from a copied environment that already has QT variables. +# This makes sure the tool initialization is re-entrant. + +createSConstruct(test, ['work5', 'SConstruct']) +test.write( ['work5', 'SConscript'], """ +Import("env") +env = env.Copy(tools=['qt']) +env.Program('main', 'main.cpp', CPPDEFINES=['FOO'], LIBS=[]) +""") + +test.write(['work5', 'main.cpp'], r""" +#include "foo5.h" +int main() { foo5(); return 0; } +""") + +test.write(['qt', 'include', 'foo5.h'], """\ +#include +void +foo5(void) +{ +#ifdef FOO + printf("qt/include/foo5.h\\n"); +#endif +} +""") + +test.run(chdir='work5') + +main_exe = 'main' + _exe +test.run(program = test.workpath('work5', main_exe), + stdout = 'qt/include/foo5.h\n') + +############################################################################## +# 6. Test creation from a copied empty environment. + +test.write(['work6', 'SConstruct'], """\ +orig = Environment() +env = orig.Copy(QTDIR = r'%s', + QT_LIB = r'%s', + QT_MOC = r'%s', + QT_UIC = r'%s', + tools=['qt']) +env.Program('main', 'main.cpp', CPPDEFINES=['FOO'], LIBS=[]) +""" % (QT, QT_LIB, QT_MOC, QT_UIC)) + +test.write(['work6', 'main.cpp'], r""" +#include "foo6.h" +int main() { foo6(); return 0; } +""") + +test.write(['qt', 'include', 'foo6.h'], """\ +#include +void +foo6(void) +{ +#ifdef FOO + printf("qt/include/foo6.h\\n"); +#endif +} +""") + +# we can receive warnings about a non detected qt (empty QTDIR) +# these are not critical, but maybe annoying +test.run(chdir='work6', stderr=None) + +main_exe = 'main' + _exe +test.run(program = test.workpath('work6', main_exe), + stderr = None, + stdout = 'qt/include/foo6.h\n') + +############################################################################## +# 7. look if qt is installed, and try out all builders + +if os.environ.get('QTDIR', None): + + QTDIR=os.environ['QTDIR'] + + + test.write( ['work7', 'SConstruct'],""" +import os +dummy_env = Environment() +ENV = dummy_env['ENV'] +try: + PATH=ARGUMENTS['PATH'] + if ENV.has_key('PATH'): + ENV_PATH = PATH + os.pathsep + ENV['PATH'] + else: + Exit(0) # this is certainly a weird system :-) +except KeyError: + ENV_PATH=ENV.get('PATH', '') + +env = Environment(tools=['default','qt'], + ENV={'PATH':ENV_PATH, + 'PATHEXT':os.environ.get('PATHEXT'), + 'HOME':os.getcwd()}, + # moc / uic want to write stuff in ~/.qt + CXXFILESUFFIX=".cpp") + +conf = env.Configure() +if not conf.CheckLib(env.subst("$QT_LIB"), autoadd=0): + conf.env['QT_LIB'] = 'qt-mt' + if not conf.CheckLib(env.subst("$QT_LIB"), autoadd=0): + Exit(0) +env = conf.Finish() +BuildDir('bld', '.') +env.Program('bld/test_realqt', ['bld/mocFromCpp.cpp', + 'bld/mocFromH.cpp', + 'bld/anUiFile.ui', + 'bld/main.cpp']) +""") + + test.write( ['work7', 'mocFromCpp.h'],""" +void mocFromCpp(); +""") + + test.write( ['work7', 'mocFromCpp.cpp'],""" +#include +#include "mocFromCpp.h" +class MyClass1 : public QObject { + Q_OBJECT + public: + MyClass1() : QObject() {}; + public slots: + void myslot() {}; +}; +void mocFromCpp() { + MyClass1 myclass; +} +#include "mocFromCpp.moc" +""") + + test.write( ['work7', 'mocFromH.h'],""" +#include +class MyClass2 : public QObject { + Q_OBJECT; + public: + MyClass2(); + public slots: + void myslot(); +}; +void mocFromH(); +""") + + test.write( ['work7', 'mocFromH.cpp'],""" +#include "mocFromH.h" + +MyClass2::MyClass2() : QObject() {} +void MyClass2::myslot() {} +void mocFromH() { + MyClass2 myclass; +} +""") + + test.write( ['work7', 'anUiFile.ui'],""" + +MyWidget + + QWidget + + MyWidget + + + MyWidget + + + + anUiFile.ui.h + + + testSlot() + + + +""") + test.write( ['work7', 'anUiFile.ui.h'], r""" +#include +#if QT_VERSION >= 0x030100 +void MyWidget::testSlot() +{ + printf("Hello World\n"); +} +#endif +""") + + test.write( ['work7', 'main.cpp'], r""" +#include +#include "mocFromCpp.h" +#include "mocFromH.h" +#include "anUiFile.h" +#include + +int main(int argc, char **argv) { + QApplication app(argc, argv); + mocFromCpp(); + mocFromH(); + MyWidget mywidget; +#if QT_VERSION >= 0x030100 + mywidget.testSlot(); +#else + printf("Hello World\n"); +#endif + return 0; +} +""") + + test.run(chdir='work7', arguments="bld/test_realqt" + _exe) + test.run(program=test.workpath("work7", "bld", "test_realqt"), + stdout="Hello World\n") + + QTDIR=os.environ['QTDIR'] + del os.environ['QTDIR'] + PATH=os.environ['PATH'] + os.environ['PATH']='.' + + test.run(chdir='work7', stderr=None, arguments="-c bld/test_realqt" + _exe) + test.fail_test(not test.match_re_dotall(test.stderr(), r""".* +scons: warning: Could not detect qt, using empty QTDIR +""" + TestSCons.file_expr)) + + os.environ['PATH'] = PATH + + test.run(chdir='work7', stderr=None, + arguments="PATH=%s%sbin bld%stest_realqt%s"%(QTDIR,os.sep,os.sep,_exe)) + test.fail_test(not test.match_re(test.stderr(), (r""" +scons: warning: Could not detect qt, using moc executable as a hint \(QTDIR=%s\) +""" + TestSCons.file_expr) % re.escape(QTDIR))) + + +else: + print "Could not find QT, skipping test(s)." + +############################################################################## +# 8. test the $QT_AUTOBUILD_MOC_SOURCES variable +# +# This has been removed, but I'm leaving the test here, commented out, +# in case we ever resurrect this functionality again in the future. +# +#aaa_dll = dll_ + 'aaa' + _dll +#moc = 'moc_aaa.cc' +# +#createSConstruct(test, ['work8', 'SConstruct']) +# +#test.write(['work8', 'SConscript'], """ +#Import("env") +#env = env.Copy(QT_AUTOBUILD_MOC_SOURCES = 0) +#env.SharedLibrary(target = 'aaa', source = ['aaa.ui', 'useit.cpp', 'aaa_function.cpp']) +#""") +# +#test.write(['work8', 'aaa.ui'], r""" +##if defined (_WIN32) || defined(__CYGWIN__) +##define DLLEXPORT __declspec(dllexport) +##else +##define DLLEXPORT +##endif +#DLLEXPORT void aaa(void) +#""") +# +#test.write(['work8', 'useit.cpp'], r""" +##include "aaa.h" +#void useit() { +# aaa(); +#} +#""") +# +#test.write(['work8', 'aaa_function.cpp'], r""" +##include "my_qobject.h" +##if defined (_WIN32) || defined(__CYGWIN__) +##define DLLEXPORT __declspec(dllexport) +##else +##define DLLEXPORT +##endif +#DLLEXPORT void aaa(void) +# { my_qt_symbol( "aaa_function.cpp\n" ); } +#""") +# +#test.run(chdir='work8', arguments = aaa_dll) +# +#test.must_not_exist(test.workpath('work8', moc)) +# +#test.write(['work8', 'SConscript'], """ +#Import("env") +#env = env.Copy(QT_AUTOBUILD_MOC_SOURCES = 1) +#env.SharedLibrary(target = 'aaa', source = ['aaa.ui', 'useit.cpp']) +#""") +# +#test.run(chdir='work8', arguments = aaa_dll) +# +#test.must_exist(test.workpath('work8', moc)) + +############################################################################## +# 9. test that an overwritten CPPPATH is working with generated files + +# this is basically test 1, but with an additional include +aaa_exe = 'aaa' + _exe + +createSConstruct(test, ['work9', 'SConstruct']) +test.write( ['work9', 'SConscript'], """ +Import("env") +env.Program(target = 'aaa', source = 'aaa.cpp', CPPPATH=['$CPPPATH', './local_include']) +""") + +test.write(['work9', 'aaa.cpp'], r""" +#include "aaa.h" +int main() { aaa(); return 0; } +""") + +test.write(['work9', 'aaa.h'], r""" +#include "my_qobject.h" +#include "local_include.h" +void aaa(void) Q_OBJECT; +""") + +test.write(['work9', 'local_include', 'local_include.h'], r""" +/* empty; just needs to be found */ +""") + +test.run(chdir='work9', arguments = aaa_exe) + +############################################################################## +# 10. test that an appended relative CPPPATH is working with generated files + +# this is basically test 9, but the include path is env.Append-ed and +# everything goes into sub directory "sub" +aaa_exe = os.path.join('sub', 'aaa' + _exe) + +createSConstruct(test, ['work10', 'SConstruct']) +test.write( ['work10', 'SConscript'], r""" +SConscript('sub/SConscript') +""") + +test.write( ['work10', 'sub', 'SConscript'], r""" +Import("env") +env.Append(CPPPATH=['./local_include']) +env.Program(target = 'aaa', source = 'aaa.cpp') +""") + +test.write(['work10', 'sub', 'aaa.cpp'], r""" +#include "aaa.h" +int main() { aaa(); return 0; } +""") + +test.write(['work10', 'sub', 'aaa.h'], r""" +#include "my_qobject.h" +#include "local_include.h" +void aaa(void) Q_OBJECT; +""") + +test.write(['work10', 'sub', 'local_include', 'local_include.h'], r""" +/* empty; just needs to be found */ +""") + +test.run(chdir='work10', arguments = aaa_exe) + +############################################################################### +# 11. test the manual QT builder calls + +aaa_exe = 'aaa' + _exe + +createSConstruct(test, ['work11', 'SConstruct']) +test.write( ['work11', 'SConscript'], r""" +Import("env") +sources = ['aaa.cpp', 'bbb.cpp', 'ddd.cpp', 'eee.cpp', 'main.cpp'] + +# normal invocation +sources.append(env.Moc('include/aaa.h')) +env.Moc('bbb.cpp') +sources.extend(env.Uic('ui/ccc.ui')[1:]) + +# manual target specification +sources.append(env.Moc('moc-ddd.cpp', 'include/ddd.h', + QT_MOCHPREFIX='')) # Watch out ! +env.Moc('moc_eee.cpp', 'eee.cpp') +sources.extend(env.Uic(['include/uic_fff.hpp', 'fff.cpp', 'fff.moc.cpp'], + 'ui/fff.ui')[1:]) + +print map(str,sources) +env.Program(target='aaa', + source=sources, + CPPPATH=['$CPPPATH', './include'], + QT_AUTOSCAN=0) +""") + +test.write(['work11', 'aaa.cpp'], r""" +#include "aaa.h" +""") + +test.write(['work11', 'include', 'aaa.h'], r""" +#include "my_qobject.h" +void aaa(void) Q_OBJECT; +""") + +test.write(['work11', 'bbb.h'], r""" +void bbb(void); +""") + +test.write(['work11', 'bbb.cpp'], r""" +#include "my_qobject.h" +void bbb(void) Q_OBJECT +#include "bbb.moc" +""") + +test.write(['work11', 'ui', 'ccc.ui'], r""" +void ccc(void) +""") + +test.write(['work11', 'ddd.cpp'], r""" +#include "ddd.h" +""") + +test.write(['work11', 'include', 'ddd.h'], r""" +#include "my_qobject.h" +void ddd(void) Q_OBJECT; +""") + +test.write(['work11', 'eee.h'], r""" +void eee(void); +""") + +test.write(['work11', 'eee.cpp'], r""" +#include "my_qobject.h" +void eee(void) Q_OBJECT +#include "moc_eee.cpp" +""") + +test.write(['work11', 'ui', 'fff.ui'], r""" +void fff(void) +""") + +test.write(['work11', 'main.cpp'], r""" +#include "aaa.h" +#include "bbb.h" +#include "ui/ccc.h" +#include "ddd.h" +#include "eee.h" +#include "uic_fff.hpp" + +int main() { + aaa(); bbb(); ccc(); ddd(); eee(); fff(); return 0; +} +""") + +test.run(chdir='work11', arguments = aaa_exe) + +# normal invocation +test.must_exist(test.workpath('work11', 'include', 'moc_aaa.cc')) +test.must_exist(test.workpath('work11', 'bbb.moc')) +test.must_exist(test.workpath('work11', 'ui', 'ccc.h')) +test.must_exist(test.workpath('work11', 'ui', 'uic_ccc.cc')) +test.must_exist(test.workpath('work11', 'ui', 'moc_ccc.cc')) + +# manual target spec. +test.must_exist(test.workpath('work11', 'moc-ddd.cpp')) +test.must_exist(test.workpath('work11', 'moc_eee.cpp')) +test.must_exist(test.workpath('work11', 'include', 'uic_fff.hpp')) +test.must_exist(test.workpath('work11', 'fff.cpp')) +test.must_exist(test.workpath('work11', 'fff.moc.cpp')) + + +############################################################################## +# 12. test the tool warings +createSConstruct(test, ['work12', 'SConstruct']) + +test.write(['work12', 'aaa.cpp'], r""" +#include "my_qobject.h" +void aaa(void) Q_OBJECT +""") + +test.write(['work12', 'SConscript'], r""" +Import("env") +import os +env.StaticLibrary('aaa.cpp') +""") + +test.run(chdir='work12', stderr=None) + +match12 = r""" +scons: warning: Generated moc file 'aaa.moc' is not included by 'aaa.cpp' +""" + TestSCons.file_expr + +# In case 'ar' gives a warning about creating a library. +test.fail_test(not test.match_re(test.stderr(), match12) and \ + not test.match_re(test.stderr(), match12 + ".+\n")) + +os.environ['QTDIR'] = QT +test.run(chdir='work12', arguments='-n noqtdir=1') + +# We'd like to eliminate $QTDIR from the environment as follows: +# del os.environ['QTDIR'] +# But unfortunately, in at least some versions of Python, the Environment +# class doesn't implement a __delitem__() method to make the library +# call to actually remove the deleted variable from the *external* +# environment, so it only gets removed from the Python dictionary. +# Consequently, we need to just wipe out its value as follows> +os.environ['QTDIR'] = '' +test.run(chdir='work12', stderr=None, arguments='-n noqtdir=1') +test.fail_test(not test.match_re(test.stderr(), r""" +scons: warning: Could not detect qt, using empty QTDIR +""" + TestSCons.file_expr)) + +test.pass_test() diff --git a/test/QT/QTFLAGS.py b/test/QT/QTFLAGS.py new file mode 100644 index 0000000..f9cb917 --- /dev/null +++ b/test/QT/QTFLAGS.py @@ -0,0 +1,279 @@ +#!/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__" + +""" +Testing the configuration mechanisms of the 'qt' tool. +""" + +import TestSCons +import os.path + +python = TestSCons.python +_exe = TestSCons._exe + +test = TestSCons.TestSCons() + +test.subdir( 'qt', ['qt', 'bin'], ['qt', 'include'], ['qt', 'lib'], + 'work1', 'work2') + +# create a dummy qt installation + +test.write(['qt', 'bin', 'mymoc.py'], """ +import getopt +import sys +import string +import re +cmd_opts, args = getopt.getopt(sys.argv[1:], 'wzio:', []) +output = None +impl = 0 +opt_string = '' +for opt, arg in cmd_opts: + if opt == '-o': output = open(arg, 'wb') + elif opt == '-i': impl = 1 + else: opt_string = opt_string + ' ' + opt +output.write( "/* mymoc.py%s */\\n" % opt_string) +for a in args: + contents = open(a, 'rb').read() + subst = r'{ my_qt_symbol( "' + a + '\\\\n" ); }' + if impl: + contents = re.sub( r'#include.*', '', contents ) + output.write(string.replace(contents, 'Q_OBJECT', subst)) +output.close() +sys.exit(0) +""" ) + +test.write(['qt', 'bin', 'myuic.py'], """ +import sys +import string +output_arg = 0 +impl_arg = 0 +impl = None +source = None +opt_string = '' +for arg in sys.argv[1:]: + if output_arg: + output = open(arg, 'wb') + output_arg = 0 + elif impl_arg: + impl = arg + impl_arg = 0 + elif arg == "-o": + output_arg = 1 + elif arg == "-impl": + impl_arg = 1 + elif arg[0:1] == "-": + opt_string = opt_string + ' ' + arg + else: + if source: + sys.exit(1) + source = open(arg, 'rb') +output.write("/* myuic.py%s */\\n" % opt_string) +if impl: + output.write( '#include "' + impl + '"\\n' ) +else: + output.write( '#include "my_qobject.h"\\n' + source.read() + " Q_OBJECT \\n" ) +output.close() +sys.exit(0) +""" ) + +test.write(['qt', 'include', 'my_qobject.h'], r""" +#define Q_OBJECT ; +void my_qt_symbol(const char *arg); +""") + +test.write(['qt', 'lib', 'my_qobject.cpp'], r""" +#include "../include/my_qobject.h" +#include +void my_qt_symbol(const char *arg) { + printf( arg ); +} +""") + +test.write(['qt', 'lib', 'SConstruct'], r""" +env = Environment() +env.StaticLibrary( 'myqt', 'my_qobject.cpp' ) +""") + +test.run(chdir=test.workpath('qt','lib'), arguments = '.', + stderr=TestSCons.noisy_ar, + match=TestSCons.match_re_dotall) + +QT = test.workpath('qt') +QT_LIB = 'myqt' +QT_MOC = '%s %s' % (python, test.workpath('qt','bin','mymoc.py')) +QT_UIC = '%s %s' % (python, test.workpath('qt','bin','myuic.py')) + +def createSConstruct(test,place,overrides): + test.write(place, """ +env = Environment(QTDIR = r'%s', + QT_LIB = r'%s', + QT_MOC = r'%s', + QT_UIC = r'%s', + %s + tools=['default','qt']) +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') +else: + sconscript = File('SConscript') +Export("env") +SConscript( sconscript ) +""" % (QT, QT_LIB, QT_MOC, QT_UIC, overrides)) + + +createSConstruct(test, ['work1', '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.write(['work1', 'SConscript'],""" +Import("env") +env.Program('mytest', ['mocFromH.cpp', + 'mocFromCpp.cpp', + 'an_ui_file.myui', + 'another_ui_file.myui', + 'main.cpp']) +""") + +test.write(['work1', 'mocFromH.hpp'], """ +#include "my_qobject.h" +void mocFromH() Q_OBJECT +""") + +test.write(['work1', 'mocFromH.cpp'], """ +#include "mocFromH.hpp" +""") + +test.write(['work1', 'mocFromCpp.cpp'], """ +#include "my_qobject.h" +void mocFromCpp() Q_OBJECT +#include "mocmocFromCpp.inl" +""") + +test.write(['work1', 'an_ui_file.myui'], """ +void an_ui_file() +""") + +test.write(['work1', 'another_ui_file.myui'], """ +void another_ui_file() +""") + +test.write(['work1', 'another_ui_file.desc.hpp'], """ +/* just a dependency checker */ +""") + +test.write(['work1', 'main.cpp'], """ +#include "mocFromH.hpp" +#include "uic-an_ui_file.hpp" +#include "uic-another_ui_file.hpp" +void mocFromCpp(); + +int main() { + mocFromH(); + mocFromCpp(); + an_ui_file(); + another_ui_file(); +} +""") + +test.run(chdir = 'work1', arguments = "mytest" + _exe) + +test.must_exist(['work1', 'mmmmocFromH.cxx'], + ['work1', 'mocmocFromCpp.inl'], + ['work1', 'an_ui_file.cxx'], + ['work1', 'uic-an_ui_file.hpp'], + ['work1', 'mmman_ui_file.cxx'], + ['work1', 'another_ui_file.cxx'], + ['work1', 'uic-another_ui_file.hpp'], + ['work1', 'mmmanother_ui_file.cxx']) + +def _flagTest(test,fileToContentsStart): + import string + for f,c in fileToContentsStart.items(): + if string.find(test.read(test.workpath('work1', f)), c) != 0: + return 1 + return 0 + +test.fail_test(_flagTest(test, {'mmmmocFromH.cxx':'/* mymoc.py -z */', + 'mocmocFromCpp.inl':'/* mymoc.py -w */', + 'an_ui_file.cxx':'/* myuic.py -x */', + 'uic-an_ui_file.hpp':'/* myuic.py -y */', + 'mmman_ui_file.cxx':'/* mymoc.py -z */'})) + +test.write(['work2', 'SConstruct'], """ +import os.path +env1 = Environment(tools=['qt'], + QTDIR = r'%(QTDIR)s', + QT_BINPATH='$QTDIR/bin64', + QT_LIBPATH='$QTDIR/lib64', + QT_CPPPATH='$QTDIR/h64') + +cpppath = env1.subst('$CPPPATH') +if os.path.normpath(cpppath) != os.path.join(r'%(QTDIR)s', 'h64'): + print cpppath + Exit(1) +libpath = env1.subst('$LIBPATH') +if os.path.normpath(libpath) != os.path.join(r'%(QTDIR)s', 'lib64'): + print libpath + Exit(2) +qt_moc = env1.subst('$QT_MOC') +if os.path.normpath(qt_moc) != os.path.join(r'%(QTDIR)s', 'bin64', 'moc'): + print qt_moc + Exit(3) + +env2 = Environment(tools=['default', 'qt'], + QTDIR = None, + QT_LIB = None, + QT_CPPPATH = None, + QT_LIBPATH = None) + +env2.Program('main.cpp') +""" % {'QTDIR':QT}) + +test.write(['work2', 'main.cpp'], """ +int main() { return 0; } +""") + +# Ignore stderr, because if Qt is not installed, +# there may be a warning about an empty QTDIR on stderr. +test.run(chdir='work2', stderr=None) + +test.must_exist(['work2', 'main' + _exe]) + +test.pass_test() diff --git a/test/QTFLAGS.py b/test/QTFLAGS.py deleted file mode 100644 index f9cb917..0000000 --- a/test/QTFLAGS.py +++ /dev/null @@ -1,279 +0,0 @@ -#!/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__" - -""" -Testing the configuration mechanisms of the 'qt' tool. -""" - -import TestSCons -import os.path - -python = TestSCons.python -_exe = TestSCons._exe - -test = TestSCons.TestSCons() - -test.subdir( 'qt', ['qt', 'bin'], ['qt', 'include'], ['qt', 'lib'], - 'work1', 'work2') - -# create a dummy qt installation - -test.write(['qt', 'bin', 'mymoc.py'], """ -import getopt -import sys -import string -import re -cmd_opts, args = getopt.getopt(sys.argv[1:], 'wzio:', []) -output = None -impl = 0 -opt_string = '' -for opt, arg in cmd_opts: - if opt == '-o': output = open(arg, 'wb') - elif opt == '-i': impl = 1 - else: opt_string = opt_string + ' ' + opt -output.write( "/* mymoc.py%s */\\n" % opt_string) -for a in args: - contents = open(a, 'rb').read() - subst = r'{ my_qt_symbol( "' + a + '\\\\n" ); }' - if impl: - contents = re.sub( r'#include.*', '', contents ) - output.write(string.replace(contents, 'Q_OBJECT', subst)) -output.close() -sys.exit(0) -""" ) - -test.write(['qt', 'bin', 'myuic.py'], """ -import sys -import string -output_arg = 0 -impl_arg = 0 -impl = None -source = None -opt_string = '' -for arg in sys.argv[1:]: - if output_arg: - output = open(arg, 'wb') - output_arg = 0 - elif impl_arg: - impl = arg - impl_arg = 0 - elif arg == "-o": - output_arg = 1 - elif arg == "-impl": - impl_arg = 1 - elif arg[0:1] == "-": - opt_string = opt_string + ' ' + arg - else: - if source: - sys.exit(1) - source = open(arg, 'rb') -output.write("/* myuic.py%s */\\n" % opt_string) -if impl: - output.write( '#include "' + impl + '"\\n' ) -else: - output.write( '#include "my_qobject.h"\\n' + source.read() + " Q_OBJECT \\n" ) -output.close() -sys.exit(0) -""" ) - -test.write(['qt', 'include', 'my_qobject.h'], r""" -#define Q_OBJECT ; -void my_qt_symbol(const char *arg); -""") - -test.write(['qt', 'lib', 'my_qobject.cpp'], r""" -#include "../include/my_qobject.h" -#include -void my_qt_symbol(const char *arg) { - printf( arg ); -} -""") - -test.write(['qt', 'lib', 'SConstruct'], r""" -env = Environment() -env.StaticLibrary( 'myqt', 'my_qobject.cpp' ) -""") - -test.run(chdir=test.workpath('qt','lib'), arguments = '.', - stderr=TestSCons.noisy_ar, - match=TestSCons.match_re_dotall) - -QT = test.workpath('qt') -QT_LIB = 'myqt' -QT_MOC = '%s %s' % (python, test.workpath('qt','bin','mymoc.py')) -QT_UIC = '%s %s' % (python, test.workpath('qt','bin','myuic.py')) - -def createSConstruct(test,place,overrides): - test.write(place, """ -env = Environment(QTDIR = r'%s', - QT_LIB = r'%s', - QT_MOC = r'%s', - QT_UIC = r'%s', - %s - tools=['default','qt']) -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') -else: - sconscript = File('SConscript') -Export("env") -SConscript( sconscript ) -""" % (QT, QT_LIB, QT_MOC, QT_UIC, overrides)) - - -createSConstruct(test, ['work1', '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.write(['work1', 'SConscript'],""" -Import("env") -env.Program('mytest', ['mocFromH.cpp', - 'mocFromCpp.cpp', - 'an_ui_file.myui', - 'another_ui_file.myui', - 'main.cpp']) -""") - -test.write(['work1', 'mocFromH.hpp'], """ -#include "my_qobject.h" -void mocFromH() Q_OBJECT -""") - -test.write(['work1', 'mocFromH.cpp'], """ -#include "mocFromH.hpp" -""") - -test.write(['work1', 'mocFromCpp.cpp'], """ -#include "my_qobject.h" -void mocFromCpp() Q_OBJECT -#include "mocmocFromCpp.inl" -""") - -test.write(['work1', 'an_ui_file.myui'], """ -void an_ui_file() -""") - -test.write(['work1', 'another_ui_file.myui'], """ -void another_ui_file() -""") - -test.write(['work1', 'another_ui_file.desc.hpp'], """ -/* just a dependency checker */ -""") - -test.write(['work1', 'main.cpp'], """ -#include "mocFromH.hpp" -#include "uic-an_ui_file.hpp" -#include "uic-another_ui_file.hpp" -void mocFromCpp(); - -int main() { - mocFromH(); - mocFromCpp(); - an_ui_file(); - another_ui_file(); -} -""") - -test.run(chdir = 'work1', arguments = "mytest" + _exe) - -test.must_exist(['work1', 'mmmmocFromH.cxx'], - ['work1', 'mocmocFromCpp.inl'], - ['work1', 'an_ui_file.cxx'], - ['work1', 'uic-an_ui_file.hpp'], - ['work1', 'mmman_ui_file.cxx'], - ['work1', 'another_ui_file.cxx'], - ['work1', 'uic-another_ui_file.hpp'], - ['work1', 'mmmanother_ui_file.cxx']) - -def _flagTest(test,fileToContentsStart): - import string - for f,c in fileToContentsStart.items(): - if string.find(test.read(test.workpath('work1', f)), c) != 0: - return 1 - return 0 - -test.fail_test(_flagTest(test, {'mmmmocFromH.cxx':'/* mymoc.py -z */', - 'mocmocFromCpp.inl':'/* mymoc.py -w */', - 'an_ui_file.cxx':'/* myuic.py -x */', - 'uic-an_ui_file.hpp':'/* myuic.py -y */', - 'mmman_ui_file.cxx':'/* mymoc.py -z */'})) - -test.write(['work2', 'SConstruct'], """ -import os.path -env1 = Environment(tools=['qt'], - QTDIR = r'%(QTDIR)s', - QT_BINPATH='$QTDIR/bin64', - QT_LIBPATH='$QTDIR/lib64', - QT_CPPPATH='$QTDIR/h64') - -cpppath = env1.subst('$CPPPATH') -if os.path.normpath(cpppath) != os.path.join(r'%(QTDIR)s', 'h64'): - print cpppath - Exit(1) -libpath = env1.subst('$LIBPATH') -if os.path.normpath(libpath) != os.path.join(r'%(QTDIR)s', 'lib64'): - print libpath - Exit(2) -qt_moc = env1.subst('$QT_MOC') -if os.path.normpath(qt_moc) != os.path.join(r'%(QTDIR)s', 'bin64', 'moc'): - print qt_moc - Exit(3) - -env2 = Environment(tools=['default', 'qt'], - QTDIR = None, - QT_LIB = None, - QT_CPPPATH = None, - QT_LIBPATH = None) - -env2.Program('main.cpp') -""" % {'QTDIR':QT}) - -test.write(['work2', 'main.cpp'], """ -int main() { return 0; } -""") - -# Ignore stderr, because if Qt is not installed, -# there may be a warning about an empty QTDIR on stderr. -test.run(chdir='work2', stderr=None) - -test.must_exist(['work2', 'main' + _exe]) - -test.pass_test() diff --git a/test/midl.py b/test/midl.py deleted file mode 100644 index a41ac01..0000000 --- a/test/midl.py +++ /dev/null @@ -1,446 +0,0 @@ -#!/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__" - -import TestSCons -import sys -import os.path -import os -import TestCmd -import time - -test = TestSCons.TestSCons(match = TestCmd.match_re) - -if sys.platform != 'win32': - test.pass_test() - -##### -# Test the basics - -test.write('SConstruct',""" -import os.path -import os - -env = Environment(CCFLAGS = ' -nologo ', - CPPPATH = '${TARGET.dir}', - MSVS_USE_MFC_DIRS = 1) -Export('env') - -BuildDir('build', 'src') -SConscript(os.path.join('build','SConscript')) - -BuildDir('build2', 'src', duplicate=0) -SConscript(os.path.join('build2','SConscript')) -""") - -test.subdir('src','build') - -test.write('src/SConscript',""" -import os.path - -Import('env') - -local = env.Copy(WIN32_INSERT_DEF = 1) - -barsrc = [ - 'BarObject.cpp', - 'bar.cpp', - local.RES('bar.rc', RCFLAGS= '/I${SOURCE.srcdir}'), - ] - -local.TypeLibrary('bar.idl') - -local.SharedLibrary(target = 'bar.dll', - source = barsrc, - PCH=local.PCH('BarPCH.cpp')[0], - PCHSTOP = 'BarPCH.h', - register=1) -""") - -test.write('src/BarObject.cpp',''' -#include "BarPCH.h" -#include "Bar.h" -#include "BarObject.h" -''') - -test.write('src/BarObject.h',''' -#ifndef __BAROBJECT_H_ -#define __BAROBJECT_H_ - -#include "resource.h" - -class ATL_NO_VTABLE CBarObject : - public CComObjectRootEx, - public CComCoClass, - public IDispatchImpl -{ -public: - CBarObject() - { - } - -DECLARE_REGISTRY_RESOURCEID(IDR_BAROBJECT) - -DECLARE_PROTECT_FINAL_CONSTRUCT() - -BEGIN_COM_MAP(CBarObject) - COM_INTERFACE_ENTRY(IBarObject) - COM_INTERFACE_ENTRY(IDispatch) -END_COM_MAP() - -public: -}; - -#endif -''') - -test.write('src/BarObject.rgs',""" -HKCR -{ - Bar.BarObject.1 = s 'BarObject Class' - { - CLSID = s '{640BE9EC-B79D-4C9E-BB64-95D24854A303}' - } - Bar.BarObject = s 'BarObject Class' - { - CLSID = s '{640BE9EC-B79D-4C9E-BB64-95D24854A303}' - CurVer = s 'Bar.BarObject.1' - } - NoRemove CLSID - { - ForceRemove {640BE9EC-B79D-4C9E-BB64-95D24854A303} = s 'BarObject Class' - { - ProgID = s 'Bar.BarObject.1' - VersionIndependentProgID = s 'Bar.BarObject' - ForceRemove 'Programmable' - InprocServer32 = s '%MODULE%' - { - val ThreadingModel = s 'Apartment' - } - 'TypeLib' = s '{73E5EA5F-9D45-463F-AA33-9F376AF7B643}' - } - } -} -""") - -test.write('src/BarPCH.cpp',''' -#include "BarPCH.h" - -#ifdef _ATL_STATIC_REGISTRY -#include -#include -#endif - -#include -''') - -test.write('src/BarPCH.h',''' -#ifndef BarPCH_h -#define BarPCH_h - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#define STRICT -#ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x0400 -#endif -#define _ATL_APARTMENT_THREADED - -#include -extern CComModule _Module; -#include - -#endif -''') - -test.write('src/bar.cpp',''' -#include "BarPCH.h" -#include "resource.h" -#include -#include "bar.h" - -#include "bar_i.c" -#include "BarObject.h" - -CComModule _Module; - -BEGIN_OBJECT_MAP(ObjectMap) -OBJECT_ENTRY(CLSID_BarObject, CBarObject) -END_OBJECT_MAP() - -extern "C" -BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) -{ - lpReserved; - if (dwReason == DLL_PROCESS_ATTACH) - { - _Module.Init(ObjectMap, hInstance, &LIBID_BARLib); - DisableThreadLibraryCalls(hInstance); - } - else if (dwReason == DLL_PROCESS_DETACH) - _Module.Term(); - return TRUE; // ok -} - -STDAPI DllCanUnloadNow(void) -{ - return (_Module.GetLockCount()==0) ? S_OK : S_FALSE; -} - -STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv) -{ - return _Module.GetClassObject(rclsid, riid, ppv); -} - -STDAPI DllRegisterServer(void) -{ - return _Module.RegisterServer(TRUE); -} - -STDAPI DllUnregisterServer(void) -{ - return _Module.UnregisterServer(TRUE); -} -''') - -test.write('src/bar.def',''' -; bar.def : Declares the module parameters. - -LIBRARY "bar.DLL" - -EXPORTS - DllCanUnloadNow @1 PRIVATE - DllGetClassObject @2 PRIVATE - DllRegisterServer @3 PRIVATE - DllUnregisterServer @4 PRIVATE -''') - -test.write('src/bar.idl',''' -import "oaidl.idl"; -import "ocidl.idl"; - [ - object, - uuid(22995106-CE26-4561-AF1B-C71C6934B840), - dual, - helpstring("IBarObject Interface"), - pointer_default(unique) - ] - interface IBarObject : IDispatch - { - }; - -[ - uuid(73E5EA5F-9D45-463F-AA33-9F376AF7B643), - version(1.0), - helpstring("bar 1.0 Type Library") -] -library BARLib -{ - importlib("stdole32.tlb"); - importlib("stdole2.tlb"); - - [ - uuid(640BE9EC-B79D-4C9E-BB64-95D24854A303), - helpstring("BarObject Class") - ] - coclass BarObject - { - [default] interface IBarObject; - }; -}; -''') - -test.write('src/bar.rc',''' -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS - -#include "winres.h" - -#undef APSTUDIO_READONLY_SYMBOLS - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED - -1 TEXTINCLUDE DISCARDABLE -BEGIN - "resource.h\\0" -END - -2 TEXTINCLUDE DISCARDABLE -BEGIN - "#include ""winres.h""\\r\\n" - "\\0" -END - -3 TEXTINCLUDE DISCARDABLE -BEGIN - "1 TYPELIB ""bar.tlb""\\r\\n" - "\\0" -END - -#endif // APSTUDIO_INVOKED - - -#ifndef _MAC - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904B0" - BEGIN - VALUE "CompanyName", "\\0" - VALUE "FileDescription", "bar Module\\0" - VALUE "FileVersion", "1, 0, 0, 1\\0" - VALUE "InternalName", "bar\\0" - VALUE "LegalCopyright", "Copyright 2003\\0" - VALUE "OriginalFilename", "bar.DLL\\0" - VALUE "ProductName", "bar Module\\0" - VALUE "ProductVersion", "1, 0, 0, 1\\0" - VALUE "OLESelfRegister", "\\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - -#endif // !_MAC - -IDR_BAROBJECT REGISTRY DISCARDABLE "BarObject.rgs" - -STRINGTABLE DISCARDABLE -BEGIN - IDS_PROJNAME "bar" -END - -#endif // English (U.S.) resources - -#ifndef APSTUDIO_INVOKED - -1 TYPELIB "bar.tlb" - -#endif // not APSTUDIO_INVOKED -''') - -test.write('src/resource.h',''' -#define IDS_PROJNAME 100 -#define IDR_BAROBJECT 101 - -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 201 -#define _APS_NEXT_COMMAND_VALUE 32768 -#define _APS_NEXT_CONTROL_VALUE 201 -#define _APS_NEXT_SYMED_VALUE 102 -#endif -#endif -''') - -test.run(arguments=os.path.join('build','bar.dll')) - -test.must_exist(['build','BarPCH.pch']) -test.must_exist(['build','BarPCH.obj']) -test.must_exist(['build','bar.tlb']) -test.must_exist(['build','bar.h']) -test.must_exist(['build','bar_i.c']) -test.must_exist(['build','bar_p.c']) -test.must_exist(['build','bar_data.c']) -test.must_exist(['build','BarObject.obj']) -test.must_exist(['build','bar.obj']) -test.must_exist(['build','bar.res']) -test.must_exist(['build','bar.dll']) -test.must_exist(['build','bar.lib']) -test.must_exist(['build','bar.exp']) - -test.run(arguments='-c .') - -test.must_not_exist(['build','BarPCH.pch']) -test.must_not_exist(['build','BarPCH.obj']) -test.must_not_exist(['build','bar.tlb']) -test.must_not_exist(['build','bar.h']) -test.must_not_exist(['build','bar_i.c']) -test.must_not_exist(['build','bar_p.c']) -test.must_not_exist(['build','bar_data.c']) -test.must_not_exist(['build','BarObject.obj']) -test.must_not_exist(['build','bar.obj']) -test.must_not_exist(['build','bar.res']) -test.must_not_exist(['build','bar.dll']) -test.must_not_exist(['build','bar.lib']) -test.must_not_exist(['build','bar.exp']) - -test.run(arguments=os.path.join('build2','bar.dll')) - -test.must_exist(['build2','BarPCH.pch']) -test.must_exist(['build2','BarPCH.obj']) -test.must_exist(['build2','bar.tlb']) -test.must_exist(['build2','bar.h']) -test.must_exist(['build2','bar_i.c']) -test.must_exist(['build2','bar_p.c']) -test.must_exist(['build2','bar_data.c']) -test.must_exist(['build2','BarObject.obj']) -test.must_exist(['build2','bar.obj']) -test.must_exist(['build2','bar.res']) -test.must_exist(['build2','bar.dll']) -test.must_exist(['build2','bar.lib']) -test.must_exist(['build2','bar.exp']) - -test.run(arguments='-c .') - -test.must_not_exist(['build2','BarPCH.pch']) -test.must_not_exist(['build2','BarPCH.obj']) -test.must_not_exist(['build2','bar.tlb']) -test.must_not_exist(['build2','bar.h']) -test.must_not_exist(['build2','bar_i.c']) -test.must_not_exist(['build2','bar_p.c']) -test.must_not_exist(['build2','bar_data.c']) -test.must_not_exist(['build2','BarObject.obj']) -test.must_not_exist(['build2','bar.obj']) -test.must_not_exist(['build2','bar.res']) -test.must_not_exist(['build2','bar.dll']) -test.must_not_exist(['build2','bar.lib']) -test.must_not_exist(['build2','bar.exp']) - -test.pass_test() diff --git a/test/msvc.py b/test/msvc.py deleted file mode 100644 index fe5bfee..0000000 --- a/test/msvc.py +++ /dev/null @@ -1,263 +0,0 @@ -#!/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__" - -import TestSCons -import sys -import os.path -import os -import TestCmd -import time - -test = TestSCons.TestSCons(match = TestCmd.match_re) - -if sys.platform != 'win32': - test.pass_test() - -##### -# Test the basics - -test.write('SConstruct',""" -env=Environment() -env['PDB'] = File('test.pdb') -env['PCHSTOP'] = 'StdAfx.h' -env['PCH'] = env.PCH('StdAfx.cpp')[0] -env.Program('test', ['test.cpp', env.RES('test.rc')], LIBS=['user32']) - -env.Object('fast', 'foo.cpp') -env.Object('slow', 'foo.cpp', PCH=0) -""") - -test.write('test.cpp', ''' -#include "StdAfx.h" -#include "resource.h" - -int main(void) -{ - char test[1024]; - LoadString(GetModuleHandle(NULL), IDS_TEST, test, sizeof(test)); - printf("%d %s\\n", IDS_TEST, test); - return 0; -} -''') - -test.write('test.rc', ''' -#include "resource.h" - -STRINGTABLE DISCARDABLE -BEGIN - IDS_TEST "test 1" -END -''') - -test.write('resource.h', ''' -#define IDS_TEST 2001 -''') - - -test.write('foo.cpp', ''' -#include "StdAfx.h" -''') - -test.write('StdAfx.h', ''' -#include -#include -#include "resource.h" -''') - -test.write('StdAfx.cpp', ''' -#include "StdAfx.h" -''') - -test.run(arguments='test.exe') - -test.fail_test(not os.path.exists(test.workpath('test.exe'))) -test.fail_test(not os.path.exists(test.workpath('test.res'))) -test.fail_test(not os.path.exists(test.workpath('test.pdb'))) -test.fail_test(not os.path.exists(test.workpath('StdAfx.pch'))) -test.fail_test(not os.path.exists(test.workpath('StdAfx.obj'))) - -test.run(program=test.workpath('test.exe'), stdout='2001 test 1\n') - -test.write('resource.h', ''' -#define IDS_TEST 2002 -''') -test.run(arguments='test.exe') -test.run(program=test.workpath('test.exe'), stdout='2002 test 1\n') - -test.write('test.rc', ''' -#include "resource.h" - -STRINGTABLE DISCARDABLE -BEGIN - IDS_TEST "test 2" -END -''') -test.run(arguments='test.exe') -test.run(program=test.workpath('test.exe'), stdout='2002 test 2\n') - -test.run(arguments='-c .') - -test.fail_test(os.path.exists(test.workpath('test.exe'))) -test.fail_test(os.path.exists(test.workpath('test.pdb'))) -test.fail_test(os.path.exists(test.workpath('test.res'))) -test.fail_test(os.path.exists(test.workpath('StdAfx.pch'))) -test.fail_test(os.path.exists(test.workpath('StdAfx.obj'))) - -test.run(arguments='test.exe') - -test.fail_test(not os.path.exists(test.workpath('test.pdb'))) -test.fail_test(not os.path.exists(test.workpath('StdAfx.pch'))) -test.fail_test(not os.path.exists(test.workpath('StdAfx.obj'))) - -test.run(arguments='-c test.pdb') -test.fail_test(os.path.exists(test.workpath('test.exe'))) -test.fail_test(os.path.exists(test.workpath('test.obj'))) -test.fail_test(os.path.exists(test.workpath('test.pdb'))) -test.fail_test(os.path.exists(test.workpath('StdAfx.pch'))) -test.fail_test(os.path.exists(test.workpath('StdAfx.obj'))) - -test.run(arguments='StdAfx.pch') - -test.fail_test(os.path.exists(test.workpath('test.pdb'))) -test.fail_test(not os.path.exists(test.workpath('StdAfx.pch'))) -test.fail_test(not os.path.exists(test.workpath('StdAfx.obj'))) - -test.run(arguments='-c test.exe') -test.fail_test(os.path.exists(test.workpath('test.exe'))) -test.fail_test(os.path.exists(test.workpath('test.obj'))) -test.fail_test(os.path.exists(test.workpath('test.pdb'))) -test.fail_test(os.path.exists(test.workpath('StdAfx.pch'))) -test.fail_test(os.path.exists(test.workpath('StdAfx.obj'))) - -test.run(arguments='test.obj') -test.fail_test(os.path.exists(test.workpath('test.pdb'))) -test.fail_test(not os.path.exists(test.workpath('test.obj'))) - - -start = time.time() -test.run(arguments='fast.obj') -fast = time.time() - start - -start = time.time() -test.run(arguments='slow.obj') -slow = time.time() - start - -# using precompiled headers should be significantly faster -assert fast < slow*0.8 - -# Modifying resource.h should cause both the resource and precompiled header to be rebuilt: -test.write('resource.h', ''' -#define IDS_TEST 2003 -''') - -test.not_up_to_date(arguments='test.res') -test.not_up_to_date(arguments='StdAfx.pch') -test.not_up_to_date(arguments='test.exe') -test.run(program=test.workpath('test.exe'), stdout='2003 test 2\n') - - -########## -# Test a hierarchical build - -test.subdir('src', 'build', 'out') - -test.write('SConstruct',""" -BuildDir('build', 'src', duplicate=0) -SConscript('build/SConscript') -""") - -test.write('src/SConscript',""" -env=Environment() -env['PCH'] = 'StdAfx.pch' -env['PDB'] = '#out/test.pdb' -env['PCHSTOP'] = 'StdAfx.h' -env.PCH('StdAfx.cpp') -env.Program('#out/test.exe', 'test.cpp') -""") - -test.write('src/test.cpp', ''' -#include "StdAfx.h" - -int main(void) -{ - return 1; -} -''') - -test.write('src/StdAfx.h', ''' -#include -''') - -test.write('src/StdAfx.cpp', ''' -#include "StdAfx.h" -''') - -test.run(arguments='out') - -test.fail_test(not os.path.exists(test.workpath('out/test.pdb'))) -test.fail_test(not os.path.exists(test.workpath('build/StdAfx.pch'))) -test.fail_test(not os.path.exists(test.workpath('build/StdAfx.obj'))) - -test.run(arguments='-c out') - -test.fail_test(os.path.exists(test.workpath('out/test.pdb'))) -test.fail_test(os.path.exists(test.workpath('build/StdAfx.pch'))) -test.fail_test(os.path.exists(test.workpath('build/StdAfx.obj'))) - -##### -# Test error reporting - -test.write('SConstruct',""" -env=Environment() -env['PDB'] = File('test.pdb') -env['PCH'] = env.PCH('StdAfx.cpp')[0] -env.Program('test', 'test.cpp') -""") - -test.run(status=2, stderr=''' -scons: \*\*\* The PCHSTOP construction must be defined if PCH is defined. -File "SConstruct", line 5, in \? -''') - -test.write('SConstruct',""" -env=Environment() -env['PDB'] = File('test.pdb') -env['PCHSTOP'] = File('StdAfx.h') -env['PCH'] = env.PCH('StdAfx.cpp')[0] -env.Program('test', 'test.cpp') -""") - -test.run(status=2, stderr=''' -scons: \*\*\* The PCHSTOP construction variable must be a string: .+ -File "SConstruct", line 6, in \? -''') - -test.pass_test() - - - - - diff --git a/test/rpcgen.py b/test/rpcgen.py deleted file mode 100644 index 7c9f8ec..0000000 --- a/test/rpcgen.py +++ /dev/null @@ -1,99 +0,0 @@ -#!/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__" - -import os -import string -import sys -import TestSCons - -_exe = TestSCons._exe -test = TestSCons.TestSCons() - -rpcgen = test.where_is('rpcgen') -if not rpcgen: - print "rpcgen not found, skipping test" - test.pass_test(1) - -test.subdir('do_rpcgen') - -test.write('SConstruct', """\ -import os -env = Environment(ENV=os.environ) -env.Program('rpcclnt', ['rpcclnt.c', 'do_rpcgen/rpcif_clnt.c']) -env.RPCGenHeader('do_rpcgen/rpcif') -env.RPCGenClient('do_rpcgen/rpcif') -env.RPCGenService('do_rpcgen/rpcif') -env.RPCGenXDR('do_rpcgen/rpcif') -""") - -test.write(['do_rpcgen', 'rpcif.x'], """\ -program RPCTEST_IF -{ - version RPCTEST_IF_VERSION - { - int START(unsigned long) = 1; - int STOP(unsigned long) = 2; - int STATUS(unsigned long) = 3; - } = 1; /* version */ -} = 0xfeedf00d; /* portmap program ID */ -""") - -# Following test tries to make sure it can compile and link, but when -# it's run it doesn't actually invoke any rpc operations because that -# would have significant dependencies on network configuration, -# portmapper, etc. that aren't necessarily appropriate for an scons -# test. - -test.write('rpcclnt.c', """\ -#include -#include -#include "do_rpcgen/rpcif.h" - -int main(int argc, char **args) { - const char* const SERVER = "localhost"; - CLIENT *cl; - int *rslt; - unsigned long arg = 0; - if (argc > 2) { - cl = clnt_create( SERVER, RPCTEST_IF, RPCTEST_IF_VERSION, "udp" ); - if (cl == 0 ) { return 1; } - rslt = start_1(&arg, cl); - if (*rslt == 0) { clnt_perror( cl, SERVER ); return 1; } - clnt_destroy(cl); - } else - printf("Hello!\\n"); - return 0; -} -""") - - -test.run() - -test.run(program=test.workpath('rpcclnt'+_exe)) - -test.fail_test(not test.stdout() in ["Hello!\n", "Hello!\r\n"]) - -test.pass_test() -- cgit v0.12