From a0985b8b24b25d9430de2599308086f03cc5e751 Mon Sep 17 00:00:00 2001 From: stevenknight Date: Fri, 1 Aug 2003 10:45:03 +0000 Subject: [PATCH] Add /TP to CXXFLAGS for msvc. Win32 portability fixes for tests. git-svn-id: http://scons.tigris.org/svn/scons/trunk@755 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- src/CHANGES.txt | 3 ++ src/engine/SCons/ActionTests.py | 32 ++++++++++--------- src/engine/SCons/Tool/msvc.py | 2 +- test/QT.py | 8 ++--- test/QTFLAGS.py | 8 ++--- test/bad-drive.py | 2 +- test/errors.py | 2 +- test/sconsign-script.py | 55 ++++++++++++++++++++++----------- 8 files changed, 69 insertions(+), 43 deletions(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index f966b79c..babc0f34 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -74,6 +74,9 @@ RELEASE 0.XX - XXX - Remove the internal (and superfluous) SCons.Util.argmunge() function. + - Add /TP to the default CXXFLAGS for msvc, so it can compile all + of the suffixes we use as C++ files. + From Gary Oberbrunner: - Report the target being built in error messages when building diff --git a/src/engine/SCons/ActionTests.py b/src/engine/SCons/ActionTests.py index 64b5f536..be143576 100644 --- a/src/engine/SCons/ActionTests.py +++ b/src/engine/SCons/ActionTests.py @@ -63,13 +63,13 @@ except: pass f.close() if os.environ.has_key( 'ACTPY_PIPE' ): - if os.environ.has_key( 'PIPE_STDOUT_MSG' ): - stdout_msg = os.environ['PIPE_STDOUT_MSG'] + if os.environ.has_key( 'PIPE_STDOUT_FILE' ): + stdout_msg = open(os.environ['PIPE_STDOUT_FILE'], 'r').read() else: stdout_msg = "act.py: stdout: executed act.py\\n" sys.stdout.write( stdout_msg ) - if os.environ.has_key( 'PIPE_STDERR_MSG' ): - stderr_msg = os.environ['PIPE_STDERR_MSG'] + if os.environ.has_key( 'PIPE_STDERR_FILE' ): + stderr_msg = open(os.environ['PIPE_STDERR_FILE'], 'r').read() else: stderr_msg = "act.py: stderr: executed act.py\\n" sys.stderr.write( stderr_msg ) @@ -537,28 +537,32 @@ class CommandActionTestCase(unittest.TestCase): self.env['PSTDOUT'].close() pipe_out = test.read( pipe_file ) - if sys.platform == 'win32': - cr = '\r' - else: - cr = '' - act_out = "act.py: stdout: executed act.py\n" - act_err = "act.py: stderr: executed act.py\n" + act_out = "act.py: stdout: executed act.py" + act_err = "act.py: stderr: executed act.py" # Since we are now using select(), stdout and stderr can be # intermixed, so count the lines separately. - outlines = re.findall(act_out + cr, pipe_out) - errlines = re.findall(act_err + cr, pipe_out) + outlines = re.findall(act_out, pipe_out) + errlines = re.findall(act_err, pipe_out) assert len(outlines) == 8, outlines assert len(errlines) == 8, errlines # test redirection operators def test_redirect(self, redir, stdout_msg, stderr_msg): cmd = r'%s %s %s xyzzy %s' % (python, act_py, outfile, redir) + # Write the output and error messages to files because Win32 + # can't handle strings that are too big in its external + # environment (os.spawnve() returns EINVAL, "Invalid + # argument"). + stdout_file = test.workpath('stdout_msg') + stderr_file = test.workpath('stderr_msg') + open(stdout_file, 'w').write(stdout_msg) + open(stderr_file, 'w').write(stderr_msg) pipe = open( pipe_file, "w" ) act = SCons.Action.CommandAction(cmd) env = Environment( ENV = {'ACTPY_PIPE' : '1', - 'PIPE_STDOUT_MSG' : stdout_msg, - 'PIPE_STDERR_MSG' : stderr_msg}, + 'PIPE_STDOUT_FILE' : stdout_file, + 'PIPE_STDERR_FILE' : stderr_file}, PIPE_BUILD = 1, PSTDOUT = pipe, PSTDERR = pipe ) r = act([], [], env) diff --git a/src/engine/SCons/Tool/msvc.py b/src/engine/SCons/Tool/msvc.py index 94d0c3e0..fc86ee12 100644 --- a/src/engine/SCons/Tool/msvc.py +++ b/src/engine/SCons/Tool/msvc.py @@ -382,7 +382,7 @@ def generate(env): env['SHCCFLAGS'] = '$CCFLAGS' env['SHCCCOM'] = '$SHCC $SHCCFLAGS $CCCOMFLAGS' env['CXX'] = '$CC' - env['CXXFLAGS'] = '$CCFLAGS' + env['CXXFLAGS'] = '$CCFLAGS $( /TP $)' env['CXXCOM'] = '$CXX $CXXFLAGS $CCCOMFLAGS' env['SHCXX'] = '$CXX' env['SHCXXFLAGS'] = '$CXXFLAGS' diff --git a/test/QT.py b/test/QT.py index ec64d35f..0ee8a30f 100644 --- a/test/QT.py +++ b/test/QT.py @@ -125,10 +125,10 @@ QT_UIC = '%s %s' % (python, test.workpath('qt','bin','myuic.py')) def createSConstruct(test,place): test.write(place, """ -env = Environment(QTDIR='%s', - QT_LIB='%s', - QT_MOC = '%s', - QT_UIC = '%s', +env = Environment(QTDIR = r'%s', + QT_LIB = r'%s', + QT_MOC = r'%s', + QT_UIC = r'%s', tools=['default','qt']) if ARGUMENTS.get('build_dir', 0): if ARGUMENTS.get('chdir', 0): diff --git a/test/QTFLAGS.py b/test/QTFLAGS.py index c61fb9ce..7964d443 100644 --- a/test/QTFLAGS.py +++ b/test/QTFLAGS.py @@ -127,10 +127,10 @@ QT_UIC = '%s %s' % (python, test.workpath('qt','bin','myuic.py')) def createSConstruct(test,place,overrides): test.write(place, """ -env = Environment(QTDIR='%s', - QT_LIB='%s', - QT_MOC = '%s', - QT_UIC = '%s', +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): diff --git a/test/bad-drive.py b/test/bad-drive.py index 56f2127f..d7a820f3 100644 --- a/test/bad-drive.py +++ b/test/bad-drive.py @@ -86,7 +86,7 @@ test.run(arguments = 'aaa.out') test.fail_test(test.read('aaa.out') != "aaa.in\n") test.run(arguments = bad_drive + 'not_mentioned', - stderr = "scons: *** Do not know how to make target `%snot_mentioned'. Stop.\n" % bad_drive, + stderr = "scons: *** No drive `%s' for target `%snot_mentioned'. Stop.\n" % (bad_drive, bad_drive), status = 2) test.run(arguments = bad_drive + 'no_target_1', diff --git a/test/errors.py b/test/errors.py index 420eb5ee..d87b41ab 100644 --- a/test/errors.py +++ b/test/errors.py @@ -94,7 +94,7 @@ a == 1 """) test.run(status = 2, stderr = """\ -NameError: a: +NameError: [^\n]* File "SConstruct", line 1: a == 1 """) diff --git a/test/sconsign-script.py b/test/sconsign-script.py index 1966c279..eac6ab32 100644 --- a/test/sconsign-script.py +++ b/test/sconsign-script.py @@ -30,6 +30,23 @@ import string import TestCmd import TestSCons +# Check for the sconsign script before we instantiate TestSCons(), +# because that will change directory on us. +if os.path.exists('sconsign.py'): + sconsign = 'sconsign.py' +elif os.path.exists('sconsign'): + sconsign = 'sconsign' +else: + print "Can find neither 'sconsign.py' nor 'sconsign' scripts." + test.no_result(1) + +def sort_match(test, lines, expect): + lines = string.split(lines, '\n') + lines.sort() + expect = string.split(expect, '\n') + expect.sort() + return test.match_re(lines, expect) + test = TestSCons.TestSCons(match = TestCmd.match_re) test.subdir('sub1', 'sub2') @@ -74,7 +91,7 @@ test.write(['sub2', 'inc2.h'], r"""\ test.run(arguments = '--implicit-cache .') test.run(interpreter = TestSCons.python, - program = "sconsign", + program = sconsign, arguments = "sub1/.sconsign", stdout = """\ hello.exe: None \S+ None @@ -82,7 +99,7 @@ hello.obj: None \S+ None """) test.run(interpreter = TestSCons.python, - program = "sconsign", + program = sconsign, arguments = "-v sub1/.sconsign", stdout = """\ hello.exe: @@ -96,7 +113,7 @@ hello.obj: """) test.run(interpreter = TestSCons.python, - program = "sconsign", + program = sconsign, arguments = "-b -v sub1/.sconsign", stdout = """\ hello.exe: @@ -106,7 +123,7 @@ hello.obj: """) test.run(interpreter = TestSCons.python, - program = "sconsign", + program = sconsign, arguments = "-c -v sub1/.sconsign", stdout = """\ hello.exe: @@ -116,14 +133,14 @@ hello.obj: """) test.run(interpreter = TestSCons.python, - program = "sconsign", + program = sconsign, arguments = "-e hello.obj sub1/.sconsign", stdout = """\ hello.obj: None \S+ None """) test.run(interpreter = TestSCons.python, - program = "sconsign", + program = sconsign, arguments = "-e hello.obj -e hello.exe -e hello.obj sub1/.sconsign", stdout = """\ hello.obj: None \S+ None @@ -132,7 +149,7 @@ hello.obj: None \S+ None """) test.run(interpreter = TestSCons.python, - program = "sconsign", + program = sconsign, arguments = "sub2/.sconsign", stdout = """\ hello.exe: None \S+ None @@ -143,7 +160,7 @@ hello.obj: None \S+ None string.replace(os.path.join('sub2', 'inc2.h'), '\\', '\\\\'))) test.run(interpreter = TestSCons.python, - program = "sconsign", + program = sconsign, arguments = "-i -v sub2/.sconsign", stdout = """\ hello.exe: @@ -155,7 +172,7 @@ hello.obj: string.replace(os.path.join('sub2', 'inc2.h'), '\\', '\\\\'))) test.run(interpreter = TestSCons.python, - program = "sconsign", + program = sconsign, arguments = "-e hello.obj sub2/.sconsign sub1/.sconsign", stdout = """\ hello.obj: None \S+ None @@ -182,21 +199,23 @@ time.sleep(1) test.run(arguments = '. --max-drift=1') test.run(interpreter = TestSCons.python, - program = "sconsign", - arguments = "sub1/.sconsign", - stdout = """\ + program = sconsign, + arguments = "sub1/.sconsign") + +test.fail_test(not sort_match(test, test.stdout(), """\ hello.exe: None \S+ None hello.c: \d+ None \d+ hello.obj: None \S+ None -""") +""")) test.run(interpreter = TestSCons.python, - program = "sconsign", - arguments = "-r sub1/.sconsign", - stdout = """\ + program = sconsign, + arguments = "-r sub1/.sconsign") + +test.fail_test(not sort_match(test, test.stdout(), """\ hello.exe: None \S+ None -hello.c: '\S+ \S+ \d+ \d\d:\d\d:\d\d \d\d\d\d' None \d+ +hello.c: '\S+ \S+ [ \d]\d \d\d:\d\d:\d\d \d\d\d\d' None \d+ hello.obj: None \S+ None -""") +""")) test.pass_test() -- 2.26.2