From b8661de3379a931485fd73d6f2242edc93cc032d Mon Sep 17 00:00:00 2001 From: mbyt Date: Wed, 19 Oct 2016 20:14:18 +0200 Subject: the file builtin does not exist in python3 --- src/engine/SCons/Platform/win32.py | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/engine/SCons/Platform/win32.py b/src/engine/SCons/Platform/win32.py index 269007d..cb82df3 100644 --- a/src/engine/SCons/Platform/win32.py +++ b/src/engine/SCons/Platform/win32.py @@ -60,16 +60,8 @@ except AttributeError: else: parallel_msg = None - _builtin_file = file _builtin_open = open - class _scons_file(_builtin_file): - def __init__(self, *args, **kw): - _builtin_file.__init__(self, *args, **kw) - win32api.SetHandleInformation(msvcrt.get_osfhandle(self.fileno()), - win32con.HANDLE_FLAG_INHERIT, 0) - - def _scons_open(*args, **kw): fp = _builtin_open(*args, **kw) win32api.SetHandleInformation(msvcrt.get_osfhandle(fp.fileno()), @@ -77,9 +69,29 @@ else: 0) return fp - file = _scons_file open = _scons_open + if sys.version_info.major == 2: + _builtin_file = file + class _scons_file(_builtin_file): + def __init__(self, *args, **kw): + _builtin_file.__init__(self, *args, **kw) + win32api.SetHandleInformation(msvcrt.get_osfhandle(self.fileno()), + win32con.HANDLE_FLAG_INHERIT, 0) + file = _scons_file + else: + import io + for io_class in ['BufferedReader', 'BufferedWriter', 'BufferedRWPair', + 'BufferedRandom', 'TextIOWrapper']: + _builtin_file = getattr(io, io_class) + class _scons_file(_builtin_file): + def __init__(self, *args, **kw): + _builtin_file.__init__(self, *args, **kw) + win32api.SetHandleInformation(msvcrt.get_osfhandle(self.fileno()), + win32con.HANDLE_FLAG_INHERIT, 0) + setattr(io, io_class, _builtin_file) + + try: import threading spawn_lock = threading.Lock() -- cgit v0.12 From 51abbd22089b2274161ee95d48d00525d7905b01 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Sun, 27 Nov 2016 21:27:10 -0500 Subject: Python3 test fixes for Fortran/Side-effect. --- runtest.py | 2 +- test/Fortran/F03.py | 18 ++---------------- test/Fortran/F03FILESUFFIXES.py | 17 ++--------------- test/Fortran/F03FILESUFFIXES2.py | 17 ++--------------- test/Fortran/F03FLAGS.py | 26 ++++---------------------- test/Fortran/F08.py | 18 ++---------------- test/Fortran/F08FILESUFFIXES.py | 17 ++--------------- test/Fortran/F08FILESUFFIXES2.py | 17 ++--------------- test/Fortran/F08FLAGS.py | 26 ++++---------------------- test/Fortran/F77.py | 17 ++--------------- test/Fortran/F77FILESUFFIXES.py | 17 ++--------------- test/Fortran/F77FILESUFFIXES2.py | 17 ++--------------- test/Fortran/F77FLAGS.py | 23 +++-------------------- test/Fortran/F90.py | 18 ++---------------- test/Fortran/F90FILESUFFIXES.py | 17 ++--------------- test/Fortran/F90FILESUFFIXES2.py | 17 ++--------------- test/Fortran/F90FLAGS.py | 27 ++++----------------------- test/Fortran/F95.py | 20 ++------------------ test/Fortran/F95FILESUFFIXES.py | 19 ++----------------- test/Fortran/F95FILESUFFIXES2.py | 19 ++----------------- test/Fortran/F95FLAGS.py | 28 ++++------------------------ test/Fortran/FORTRAN.py | 20 +++----------------- test/Fortran/FORTRANFILESUFFIXES.py | 19 ++----------------- test/Fortran/FORTRANFILESUFFIXES2.py | 19 ++----------------- test/Fortran/FORTRANFLAGS.py | 25 +++---------------------- test/Fortran/FORTRANMODDIR.py | 2 +- test/Fortran/FORTRANPPFILESUFFIXES.py | 7 ++++--- test/Fortran/FORTRANSUFFIXES.py | 2 +- test/Fortran/SHF03.py | 20 ++------------------ test/Fortran/SHF08.py | 20 ++------------------ test/Fortran/SHF77.py | 20 ++------------------ test/Fortran/SHF77FLAGS.py | 25 +++---------------------- test/Fortran/SHF90.py | 20 ++------------------ test/Fortran/SHF90FLAGS.py | 28 ++++------------------------ test/Fortran/SHF95.py | 20 ++------------------ test/Fortran/SHF95FLAGS.py | 28 ++++------------------------ test/Fortran/SHFORTRAN.py | 21 +++------------------ test/Fortran/SHFORTRANFLAGS.py | 25 +++---------------------- test/Fortran/USE-MODULE.py | 2 +- test/Fortran/fixture/myfortran.py | 14 ++++++++++++++ test/Fortran/fixture/myfortran_flags.py | 16 ++++++++++++++++ test/Fortran/fixture/sconstest.skip | 0 test/Fortran/module-subdir.py | 10 +++++----- test/SideEffect/basic.py | 2 +- test/SideEffect/parallel.py | 4 ++-- test/SideEffect/variant_dir.py | 2 +- 46 files changed, 133 insertions(+), 635 deletions(-) create mode 100644 test/Fortran/fixture/myfortran.py create mode 100644 test/Fortran/fixture/myfortran_flags.py create mode 100644 test/Fortran/fixture/sconstest.skip diff --git a/runtest.py b/runtest.py index d636b73..cfdc0c9 100755 --- a/runtest.py +++ b/runtest.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # __COPYRIGHT__ # diff --git a/test/Fortran/F03.py b/test/Fortran/F03.py index 3c6bba4..61688c3 100644 --- a/test/Fortran/F03.py +++ b/test/Fortran/F03.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,22 +33,7 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() test.file_fixture('mylink.py') - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -length = len(comment) -opts, args = getopt.getopt(sys.argv[2:], 'co:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:length] != comment.encode(): - outfile.write(l) -sys.exit(0) -""") +test.file_fixture(os.path.join('fixture', 'myfortran.py')) test.write('SConstruct', """ env = Environment(LINK = r'%(_python_)s mylink.py', diff --git a/test/Fortran/F03FILESUFFIXES.py b/test/Fortran/F03FILESUFFIXES.py index b1d2b93..9f1a031 100644 --- a/test/Fortran/F03FILESUFFIXES.py +++ b/test/Fortran/F03FILESUFFIXES.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,21 +33,7 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() test.file_fixture('mylink.py') - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'co:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture(os.path.join('fixture', 'myfortran.py')) # Test default file suffix: .f90/.F90 for F90 test.write('SConstruct', """ diff --git a/test/Fortran/F03FILESUFFIXES2.py b/test/Fortran/F03FILESUFFIXES2.py index 44be880..d84b089 100644 --- a/test/Fortran/F03FILESUFFIXES2.py +++ b/test/Fortran/F03FILESUFFIXES2.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,21 +33,7 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() test.file_fixture('mylink.py') - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'co:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture(os.path.join('fixture', 'myfortran.py')) # Test non-default file suffix: .f/.F for F03 test.write('SConstruct', """ diff --git a/test/Fortran/F03FLAGS.py b/test/Fortran/F03FLAGS.py index 4e99db8..a031005 100644 --- a/test/Fortran/F03FLAGS.py +++ b/test/Fortran/F03FLAGS.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,33 +33,14 @@ test = TestSCons.TestSCons() _exe = TestSCons._exe test.file_fixture('mylink.py') - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'co:xy') -optstring = '' -for opt, arg in opts: - if opt == '-o': out = arg - else: optstring = optstring + ' ' + opt -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -outfile.write(optstring + "\n") -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") - - +test.file_fixture(os.path.join('fixture', 'myfortran_flags.py')) test.write('SConstruct', """ env = Environment(LINK = r'%(_python_)s mylink.py', LINKFLAGS = [], - F03 = r'%(_python_)s myfortran.py g03', + F03 = r'%(_python_)s myfortran_flags.py g03', F03FLAGS = '-x', - FORTRAN = r'%(_python_)s myfortran.py fortran', + FORTRAN = r'%(_python_)s myfortran_flags.py fortran', FORTRANFLAGS = '-y') env.Program(target = 'test01', source = 'test01.f') env.Program(target = 'test02', source = 'test02.F') diff --git a/test/Fortran/F08.py b/test/Fortran/F08.py index a28389e..3b08f6e 100644 --- a/test/Fortran/F08.py +++ b/test/Fortran/F08.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,22 +33,7 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() test.file_fixture('mylink.py') - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -length = len(comment) -opts, args = getopt.getopt(sys.argv[2:], 'co:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:length] != comment: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture(os.path.join('fixture', 'myfortran.py')) test.write('SConstruct', """ env = Environment(LINK = r'%(_python_)s mylink.py', diff --git a/test/Fortran/F08FILESUFFIXES.py b/test/Fortran/F08FILESUFFIXES.py index 41059af..5b078b1 100644 --- a/test/Fortran/F08FILESUFFIXES.py +++ b/test/Fortran/F08FILESUFFIXES.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,21 +33,7 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() test.file_fixture('mylink.py') - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'co:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture(os.path.join('fixture', 'myfortran.py')) # Test default file suffix: .f90/.F90 for F90 test.write('SConstruct', """ diff --git a/test/Fortran/F08FILESUFFIXES2.py b/test/Fortran/F08FILESUFFIXES2.py index e53cee1..955d64a 100644 --- a/test/Fortran/F08FILESUFFIXES2.py +++ b/test/Fortran/F08FILESUFFIXES2.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,21 +33,7 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() test.file_fixture('mylink.py') - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'co:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture(os.path.join('fixture', 'myfortran.py')) # Test non-default file suffix: .f/.F for F08 test.write('SConstruct', """ diff --git a/test/Fortran/F08FLAGS.py b/test/Fortran/F08FLAGS.py index c693c82..f91765b 100644 --- a/test/Fortran/F08FLAGS.py +++ b/test/Fortran/F08FLAGS.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,33 +33,14 @@ test = TestSCons.TestSCons() _exe = TestSCons._exe test.file_fixture('mylink.py') - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'co:xy') -optstring = '' -for opt, arg in opts: - if opt == '-o': out = arg - else: optstring = optstring + ' ' + opt -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -outfile.write(optstring + "\n") -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") - - +test.file_fixture(os.path.join('fixture', 'myfortran_flags.py')) test.write('SConstruct', """ env = Environment(LINK = r'%(_python_)s mylink.py', LINKFLAGS = [], - F08 = r'%(_python_)s myfortran.py g08', + F08 = r'%(_python_)s myfortran_flags.py g08', F08FLAGS = '-x', - FORTRAN = r'%(_python_)s myfortran.py fortran', + FORTRAN = r'%(_python_)s myfortran_flags.py fortran', FORTRANFLAGS = '-y') env.Program(target = 'test01', source = 'test01.f') env.Program(target = 'test02', source = 'test02.F') diff --git a/test/Fortran/F77.py b/test/Fortran/F77.py index 8fdd391..cea0485 100644 --- a/test/Fortran/F77.py +++ b/test/Fortran/F77.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,21 +33,7 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() test.file_fixture('mylink.py') - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'co:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture(os.path.join('fixture', 'myfortran.py')) test.write('SConstruct', """ env = Environment(LINK = r'%(_python_)s mylink.py', diff --git a/test/Fortran/F77FILESUFFIXES.py b/test/Fortran/F77FILESUFFIXES.py index 1715ce9..26cf30c 100644 --- a/test/Fortran/F77FILESUFFIXES.py +++ b/test/Fortran/F77FILESUFFIXES.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,21 +33,7 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() test.file_fixture('mylink.py') - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'co:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture(os.path.join('fixture', 'myfortran.py')) # Test default file suffix: .f77/.F77 for F77 test.write('SConstruct', """ diff --git a/test/Fortran/F77FILESUFFIXES2.py b/test/Fortran/F77FILESUFFIXES2.py index 1938af1..7a000fe 100644 --- a/test/Fortran/F77FILESUFFIXES2.py +++ b/test/Fortran/F77FILESUFFIXES2.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,21 +33,7 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() test.file_fixture('mylink.py') - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'co:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture(os.path.join('fixture', 'myfortran.py')) # Test non-default file suffix: .f/.F for F77 test.write('SConstruct', """ diff --git a/test/Fortran/F77FLAGS.py b/test/Fortran/F77FLAGS.py index 9b4c56c..d4e6e8a 100644 --- a/test/Fortran/F77FLAGS.py +++ b/test/Fortran/F77FLAGS.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,30 +33,12 @@ test = TestSCons.TestSCons() _exe = TestSCons._exe test.file_fixture('mylink.py') - -test.write('myg77.py', r""" -import getopt -import sys -opts, args = getopt.getopt(sys.argv[1:], 'co:x') -optstring = '' -for opt, arg in opts: - if opt == '-o': out = arg - else: optstring = optstring + ' ' + opt -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -outfile.write(optstring + "\n") -for l in infile.readlines(): - if l[:4] != '#g77': - outfile.write(l) -sys.exit(0) -""") - - +test.file_fixture(os.path.join('fixture', 'myfortran_flags.py')) test.write('SConstruct', """ env = Environment(LINK = r'%(_python_)s mylink.py', LINKFLAGS = [], - F77 = r'%(_python_)s myg77.py', + F77 = r'%(_python_)s myfortran_flags.py g77', F77FLAGS = '-x') env.Program(target = 'test09', source = 'test09.f77') env.Program(target = 'test10', source = 'test10.F77') diff --git a/test/Fortran/F90.py b/test/Fortran/F90.py index 633b174..817a735 100644 --- a/test/Fortran/F90.py +++ b/test/Fortran/F90.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,22 +33,7 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() test.file_fixture('mylink.py') - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -length = len(comment) -opts, args = getopt.getopt(sys.argv[2:], 'co:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:length] != comment: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture(os.path.join('fixture', 'myfortran.py')) test.write('SConstruct', """ env = Environment(LINK = r'%(_python_)s mylink.py', diff --git a/test/Fortran/F90FILESUFFIXES.py b/test/Fortran/F90FILESUFFIXES.py index 47da08e..a747570 100644 --- a/test/Fortran/F90FILESUFFIXES.py +++ b/test/Fortran/F90FILESUFFIXES.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,21 +33,7 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() test.file_fixture('mylink.py') - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'co:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture(os.path.join('fixture', 'myfortran.py')) # Test default file suffix: .f90/.F90 for F90 test.write('SConstruct', """ diff --git a/test/Fortran/F90FILESUFFIXES2.py b/test/Fortran/F90FILESUFFIXES2.py index 7039530..111c42b 100644 --- a/test/Fortran/F90FILESUFFIXES2.py +++ b/test/Fortran/F90FILESUFFIXES2.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,21 +33,7 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() test.file_fixture('mylink.py') - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'co:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture(os.path.join('fixture', 'myfortran.py')) # Test non-default file suffix: .f/.F for F90 test.write('SConstruct', """ diff --git a/test/Fortran/F90FLAGS.py b/test/Fortran/F90FLAGS.py index cf2b3b3..607ef60 100644 --- a/test/Fortran/F90FLAGS.py +++ b/test/Fortran/F90FLAGS.py @@ -25,42 +25,23 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons - - _python_ = TestSCons._python_ test = TestSCons.TestSCons() _exe = TestSCons._exe test.file_fixture('mylink.py') - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'co:xy') -optstring = '' -for opt, arg in opts: - if opt == '-o': out = arg - else: optstring = optstring + ' ' + opt -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -outfile.write(optstring + "\n") -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") - +test.file_fixture(os.path.join('fixture', 'myfortran_flags.py')) test.write('SConstruct', """ env = Environment(LINK = r'%(_python_)s mylink.py', LINKFLAGS = [], - F90 = r'%(_python_)s myfortran.py g90', + F90 = r'%(_python_)s myfortran_flags.py g90', F90FLAGS = '-x', - FORTRAN = r'%(_python_)s myfortran.py fortran', + FORTRAN = r'%(_python_)s myfortran_flags.py fortran', FORTRANFLAGS = '-y') env.Program(target = 'test01', source = 'test01.f') env.Program(target = 'test02', source = 'test02.F') diff --git a/test/Fortran/F95.py b/test/Fortran/F95.py index 0912f71..07d1dc3 100644 --- a/test/Fortran/F95.py +++ b/test/Fortran/F95.py @@ -24,32 +24,16 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons - - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() test.file_fixture('mylink.py') - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -length = len(comment) -opts, args = getopt.getopt(sys.argv[2:], 'co:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:length] != comment: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture(os.path.join('fixture', 'myfortran.py')) test.write('SConstruct', """ env = Environment(LINK = r'%(_python_)s mylink.py', diff --git a/test/Fortran/F95FILESUFFIXES.py b/test/Fortran/F95FILESUFFIXES.py index 8643a24..ac563cc 100644 --- a/test/Fortran/F95FILESUFFIXES.py +++ b/test/Fortran/F95FILESUFFIXES.py @@ -24,31 +24,16 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons - - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() test.file_fixture('mylink.py') - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'co:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture(os.path.join('fixture', 'myfortran.py')) # Test default file suffix: .f90/.F90 for F90 test.write('SConstruct', """ diff --git a/test/Fortran/F95FILESUFFIXES2.py b/test/Fortran/F95FILESUFFIXES2.py index d267a24..c6691e8 100644 --- a/test/Fortran/F95FILESUFFIXES2.py +++ b/test/Fortran/F95FILESUFFIXES2.py @@ -24,31 +24,16 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons - - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() test.file_fixture('mylink.py') - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'co:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture(os.path.join('fixture', 'myfortran.py')) # Test non-default file suffix: .f/.F for F95 test.write('SConstruct', """ diff --git a/test/Fortran/F95FLAGS.py b/test/Fortran/F95FLAGS.py index cc5a5e3..dd542f1 100644 --- a/test/Fortran/F95FLAGS.py +++ b/test/Fortran/F95FLAGS.py @@ -24,43 +24,23 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons - - _python_ = TestSCons._python_ test = TestSCons.TestSCons() _exe = TestSCons._exe test.file_fixture('mylink.py') - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'co:xy') -optstring = '' -for opt, arg in opts: - if opt == '-o': out = arg - else: optstring = optstring + ' ' + opt -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -outfile.write(optstring + "\n") -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") - - +test.file_fixture(os.path.join('fixture', 'myfortran_flags.py')) test.write('SConstruct', """ env = Environment(LINK = r'%(_python_)s mylink.py', LINKFLAGS = [], - F95 = r'%(_python_)s myfortran.py g95', + F95 = r'%(_python_)s myfortran_flags.py g95', F95FLAGS = '-x', - FORTRAN = r'%(_python_)s myfortran.py fortran', + FORTRAN = r'%(_python_)s myfortran_flags.py fortran', FORTRANFLAGS = '-y') env.Program(target = 'test01', source = 'test01.f') env.Program(target = 'test02', source = 'test02.F') diff --git a/test/Fortran/FORTRAN.py b/test/Fortran/FORTRAN.py index 577421e..379dfe9 100644 --- a/test/Fortran/FORTRAN.py +++ b/test/Fortran/FORTRAN.py @@ -24,35 +24,21 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons - - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() test.file_fixture('mylink.py') - -test.write('myg77.py', r""" -import getopt -import sys -opts, args = getopt.getopt(sys.argv[1:], 'co:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:4] != '#g77': - outfile.write(l) -sys.exit(0) -""") +test.file_fixture(os.path.join('fixture', 'myfortran.py')) test.write('SConstruct', """ env = Environment(LINK = r'%(_python_)s mylink.py', LINKFLAGS = [], - FORTRAN = r'%(_python_)s myg77.py') + FORTRAN = r'%(_python_)s myfortran.py g77') env.Program(target = 'test01', source = 'test01.f') env.Program(target = 'test02', source = 'test02.F') env.Program(target = 'test03', source = 'test03.for') diff --git a/test/Fortran/FORTRANFILESUFFIXES.py b/test/Fortran/FORTRANFILESUFFIXES.py index e4b6192..5294836 100644 --- a/test/Fortran/FORTRANFILESUFFIXES.py +++ b/test/Fortran/FORTRANFILESUFFIXES.py @@ -24,31 +24,16 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons - - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() test.file_fixture('mylink.py') - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'co:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture(os.path.join('fixture', 'myfortran.py')) # Test default file suffix: .f/.F for FORTRAN test.write('SConstruct', """ diff --git a/test/Fortran/FORTRANFILESUFFIXES2.py b/test/Fortran/FORTRANFILESUFFIXES2.py index 79231ac..141fc31 100644 --- a/test/Fortran/FORTRANFILESUFFIXES2.py +++ b/test/Fortran/FORTRANFILESUFFIXES2.py @@ -24,31 +24,16 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons - - _python_ = TestSCons._python_ _exe = TestSCons._exe test = TestSCons.TestSCons() test.file_fixture('mylink.py') - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'co:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") +test.file_fixture(os.path.join('fixture', 'myfortran.py')) # Test non default file suffix: .f, .f90 and .f95 for FORTRAN test.write('SConstruct', """ diff --git a/test/Fortran/FORTRANFLAGS.py b/test/Fortran/FORTRANFLAGS.py index 7b9f7d7..6ef2d72 100644 --- a/test/Fortran/FORTRANFLAGS.py +++ b/test/Fortran/FORTRANFLAGS.py @@ -24,40 +24,21 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons - - _python_ = TestSCons._python_ test = TestSCons.TestSCons() _exe = TestSCons._exe test.file_fixture('mylink.py') - -test.write('myfortran.py', r""" -import getopt -import sys -opts, args = getopt.getopt(sys.argv[1:], 'co:x') -optstring = '' -for opt, arg in opts: - if opt == '-o': out = arg - else: optstring = optstring + ' ' + opt -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -outfile.write(optstring + "\n") -for l in infile.readlines(): - if l[:8] != '#fortran': - outfile.write(l) -sys.exit(0) -""") - - +test.file_fixture(os.path.join('fixture', 'myfortran_flags.py')) test.write('SConstruct', """ env = Environment(LINK = r'%(_python_)s mylink.py', LINKFLAGS = [], - FORTRAN = r'%(_python_)s myfortran.py', + FORTRAN = r'%(_python_)s myfortran_flags.py fortran', FORTRANFLAGS = '-x') env.Program(target = 'test01', source = 'test01.f') env.Program(target = 'test02', source = 'test02.F') diff --git a/test/Fortran/FORTRANMODDIR.py b/test/Fortran/FORTRANMODDIR.py index 3c14632..723efaf 100644 --- a/test/Fortran/FORTRANMODDIR.py +++ b/test/Fortran/FORTRANMODDIR.py @@ -42,7 +42,7 @@ contents = open(sys.argv[2]).read() modules = re.findall(mod_regex, contents) modules = [os.path.join(sys.argv[1], m.lower()+'.mod') for m in modules] for t in sys.argv[3:] + modules: - open(t, 'wb').write('myfortran.py wrote %s\n' % os.path.split(t)[1]) + open(t, 'wb').write(('myfortran.py wrote %s\n' % os.path.split(t)[1]).encode()) sys.exit(0) """) diff --git a/test/Fortran/FORTRANPPFILESUFFIXES.py b/test/Fortran/FORTRANPPFILESUFFIXES.py index 2791b91..6b3b3d8 100644 --- a/test/Fortran/FORTRANPPFILESUFFIXES.py +++ b/test/Fortran/FORTRANPPFILESUFFIXES.py @@ -43,7 +43,8 @@ test.write('myfortran.py', r""" import getopt import sys -comment = '#' + sys.argv[1] +comment = ('#' + sys.argv[1]).encode() +length = len(comment) args = sys.argv[2:] # First parse defines, since getopt won't have it defines = [] @@ -58,9 +59,9 @@ for opt, arg in opts: infile = open(args[0], 'rb') outfile = open(out, 'wb') for d in defines: - outfile.write("#define %s\n" % (d,)) + outfile.write(("#define %s\n" % (d,)).encode()) for l in infile.readlines(): - if l[:len(comment)] != comment: + if l[:length] != comment: outfile.write(l) sys.exit(0) """) diff --git a/test/Fortran/FORTRANSUFFIXES.py b/test/Fortran/FORTRANSUFFIXES.py index 9673e6f..c1b3455 100644 --- a/test/Fortran/FORTRANSUFFIXES.py +++ b/test/Fortran/FORTRANSUFFIXES.py @@ -38,7 +38,7 @@ test.write('myfc.py', r""" import sys def do_file(outf, inf): for line in open(inf, 'rb').readlines(): - if line[:15] == " INCLUDE '": + if line[:15] == b" INCLUDE '": do_file(outf, line[15:-2]) else: outf.write(line) diff --git a/test/Fortran/SHF03.py b/test/Fortran/SHF03.py index d514f64..5327c4c 100644 --- a/test/Fortran/SHF03.py +++ b/test/Fortran/SHF03.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,24 +33,7 @@ obj_ = TestSCons.shobj_ test = TestSCons.TestSCons() - - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'cf:o:K:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") - - +test.file_fixture(os.path.join('fixture', 'myfortran.py')) test.write('SConstruct', """ env = Environment(SHF03 = r'%(_python_)s myfortran.py g03', diff --git a/test/Fortran/SHF08.py b/test/Fortran/SHF08.py index 0aed858..10f9314 100644 --- a/test/Fortran/SHF08.py +++ b/test/Fortran/SHF08.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,24 +33,7 @@ obj_ = TestSCons.shobj_ test = TestSCons.TestSCons() - - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'cf:o:K:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") - - +test.file_fixture(os.path.join('fixture', 'myfortran.py')) test.write('SConstruct', """ env = Environment(SHF08 = r'%(_python_)s myfortran.py g08', diff --git a/test/Fortran/SHF77.py b/test/Fortran/SHF77.py index 3c2565b..ba3ac2e 100644 --- a/test/Fortran/SHF77.py +++ b/test/Fortran/SHF77.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,24 +33,7 @@ obj_ = TestSCons.shobj_ test = TestSCons.TestSCons() - - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'cf:o:K:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") - - +test.file_fixture(os.path.join('fixture', 'myfortran.py')) test.write('SConstruct', """ env = Environment(SHF77 = r'%(_python_)s myfortran.py g77', diff --git a/test/Fortran/SHF77FLAGS.py b/test/Fortran/SHF77FLAGS.py index 1b9628c..e3f78a8 100644 --- a/test/Fortran/SHF77FLAGS.py +++ b/test/Fortran/SHF77FLAGS.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,30 +33,10 @@ _obj = TestSCons._shobj obj_ = TestSCons.shobj_ test = TestSCons.TestSCons() - - - -test.write('myg77.py', r""" -import getopt -import sys -opts, args = getopt.getopt(sys.argv[1:], 'cf:K:o:x') -optstring = '' -for opt, arg in opts: - if opt == '-o': out = arg - elif opt not in ('-f', '-K'): optstring = optstring + ' ' + opt -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -outfile.write(optstring + "\n") -for l in infile.readlines(): - if l[:4] != '#g77': - outfile.write(l) -sys.exit(0) -""") - - +test.file_fixture(os.path.join('fixture', 'myfortran_flags.py')) test.write('SConstruct', """ -env = Environment(SHF77 = r'%(_python_)s myg77.py') +env = Environment(SHF77 = r'%(_python_)s myfortran_flags.py g77') env.Append(SHF77FLAGS = '-x') env.SharedObject(target = 'test09', source = 'test09.f77') env.SharedObject(target = 'test10', source = 'test10.F77') diff --git a/test/Fortran/SHF90.py b/test/Fortran/SHF90.py index 46bf4ae..c56772e 100644 --- a/test/Fortran/SHF90.py +++ b/test/Fortran/SHF90.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,24 +33,7 @@ obj_ = TestSCons.shobj_ test = TestSCons.TestSCons() - - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'cf:o:K:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") - - +test.file_fixture(os.path.join('fixture', 'myfortran.py')) test.write('SConstruct', """ env = Environment(SHF90 = r'%(_python_)s myfortran.py g90', diff --git a/test/Fortran/SHF90FLAGS.py b/test/Fortran/SHF90FLAGS.py index 0f9e2ba3..6f7ee00 100644 --- a/test/Fortran/SHF90FLAGS.py +++ b/test/Fortran/SHF90FLAGS.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,32 +33,11 @@ _obj = TestSCons._shobj obj_ = TestSCons.shobj_ test = TestSCons.TestSCons() - - - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'cf:K:o:xy') -optstring = '' -for opt, arg in opts: - if opt == '-o': out = arg - elif opt not in ('-f', '-K'): optstring = optstring + ' ' + opt -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -outfile.write(optstring + "\n") -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") - - +test.file_fixture(os.path.join('fixture', 'myfortran_flags.py')) test.write('SConstruct', """ -env = Environment(SHF90 = r'%(_python_)s myfortran.py g90', - SHFORTRAN = r'%(_python_)s myfortran.py fortran') +env = Environment(SHF90 = r'%(_python_)s myfortran_flags.py g90', + SHFORTRAN = r'%(_python_)s myfortran_flags.py fortran') env.Append(SHF90FLAGS = '-x', SHFORTRANFLAGS = '-y') env.SharedObject(target = 'test01', source = 'test01.f') diff --git a/test/Fortran/SHF95.py b/test/Fortran/SHF95.py index 6329c9e..ff0604b 100644 --- a/test/Fortran/SHF95.py +++ b/test/Fortran/SHF95.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,24 +33,7 @@ obj_ = TestSCons.shobj_ test = TestSCons.TestSCons() - - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'cf:o:K:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") - - +test.file_fixture(os.path.join('fixture', 'myfortran.py')) test.write('SConstruct', """ env = Environment(SHF95 = r'%(_python_)s myfortran.py g95', diff --git a/test/Fortran/SHF95FLAGS.py b/test/Fortran/SHF95FLAGS.py index e573eb4..45c37bc 100644 --- a/test/Fortran/SHF95FLAGS.py +++ b/test/Fortran/SHF95FLAGS.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,32 +33,11 @@ _obj = TestSCons._shobj obj_ = TestSCons.shobj_ test = TestSCons.TestSCons() - - - -test.write('myfortran.py', r""" -import getopt -import sys -comment = '#' + sys.argv[1] -opts, args = getopt.getopt(sys.argv[2:], 'cf:K:o:xy') -optstring = '' -for opt, arg in opts: - if opt == '-o': out = arg - elif opt not in ('-f', '-K'): optstring = optstring + ' ' + opt -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -outfile.write(optstring + "\n") -for l in infile.readlines(): - if l[:len(comment)] != comment: - outfile.write(l) -sys.exit(0) -""") - - +test.file_fixture(os.path.join('fixture', 'myfortran_flags.py')) test.write('SConstruct', """ -env = Environment(SHF95 = r'%(_python_)s myfortran.py g95', - SHFORTRAN = r'%(_python_)s myfortran.py fortran') +env = Environment(SHF95 = r'%(_python_)s myfortran_flags.py g95', + SHFORTRAN = r'%(_python_)s myfortran_flags.py fortran') env.Append(SHF95FLAGS = '-x', SHFORTRANFLAGS = '-y') env.SharedObject(target = 'test01', source = 'test01.f') diff --git a/test/Fortran/SHFORTRAN.py b/test/Fortran/SHFORTRAN.py index fdcba7f..2155736 100644 --- a/test/Fortran/SHFORTRAN.py +++ b/test/Fortran/SHFORTRAN.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -32,26 +33,10 @@ obj_ = TestSCons.shobj_ test = TestSCons.TestSCons() - - -test.write('myfortran.py', r""" -import getopt -import sys -opts, args = getopt.getopt(sys.argv[1:], 'cf:o:K:') -for opt, arg in opts: - if opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:8] != '#fortran': - outfile.write(l) -sys.exit(0) -""") - - +test.file_fixture(os.path.join('fixture', 'myfortran.py')) test.write('SConstruct', """ -env = Environment(SHFORTRAN = r'%(_python_)s myfortran.py') +env = Environment(SHFORTRAN = r'%(_python_)s myfortran.py fortran') env.SharedObject(target = 'test01', source = 'test01.f') env.SharedObject(target = 'test02', source = 'test02.F') env.SharedObject(target = 'test03', source = 'test03.for') diff --git a/test/Fortran/SHFORTRANFLAGS.py b/test/Fortran/SHFORTRANFLAGS.py index 7067c6f..70c353b 100644 --- a/test/Fortran/SHFORTRANFLAGS.py +++ b/test/Fortran/SHFORTRANFLAGS.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons _python_ = TestSCons._python_ @@ -31,30 +32,10 @@ _obj = TestSCons._shobj obj_ = TestSCons.shobj_ test = TestSCons.TestSCons() - - - -test.write('myfortran.py', r""" -import getopt -import sys -opts, args = getopt.getopt(sys.argv[1:], 'cf:K:o:x') -optstring = '' -for opt, arg in opts: - if opt == '-o': out = arg - elif opt not in ('-f', '-K'): optstring = optstring + ' ' + opt -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -outfile.write(optstring + "\n") -for l in infile.readlines(): - if l[:8] != '#fortran': - outfile.write(l) -sys.exit(0) -""") - - +test.file_fixture(os.path.join('fixture', 'myfortran_flags.py')) test.write('SConstruct', """ -env = Environment(SHFORTRAN = r'%(_python_)s myfortran.py') +env = Environment(SHFORTRAN = r'%(_python_)s myfortran_flags.py fortran') env.Append(SHFORTRANFLAGS = '-x') env.SharedObject(target = 'test01', source = 'test01.f') env.SharedObject(target = 'test02', source = 'test02.F') diff --git a/test/Fortran/USE-MODULE.py b/test/Fortran/USE-MODULE.py index 8f537dd..0d78e7a 100644 --- a/test/Fortran/USE-MODULE.py +++ b/test/Fortran/USE-MODULE.py @@ -42,7 +42,7 @@ contents = open(sys.argv[1]).read() modules = re.findall(mod_regex, contents) modules = [m.lower()+'.mod' for m in modules] for t in sys.argv[2:] + modules: - open(t, 'wb').write('myfortran.py wrote %s\n' % os.path.split(t)[1]) + open(t, 'wb').write(('myfortran.py wrote %s\n' % os.path.split(t)[1]).encode()) sys.exit(0) """) diff --git a/test/Fortran/fixture/myfortran.py b/test/Fortran/fixture/myfortran.py new file mode 100644 index 0000000..08d1489 --- /dev/null +++ b/test/Fortran/fixture/myfortran.py @@ -0,0 +1,14 @@ +import getopt +import sys +print(sys.argv) +comment = ('#' + sys.argv[1]).encode() +length = len(comment) +opts, args = getopt.getopt(sys.argv[2:], 'cf:o:K:') +for opt, arg in opts: + if opt == '-o': out = arg +infile = open(args[0], 'rb') +outfile = open(out, 'wb') +for l in infile.readlines(): + if l[:length] != comment: + outfile.write(l) +sys.exit(0) diff --git a/test/Fortran/fixture/myfortran_flags.py b/test/Fortran/fixture/myfortran_flags.py new file mode 100644 index 0000000..b972e35 --- /dev/null +++ b/test/Fortran/fixture/myfortran_flags.py @@ -0,0 +1,16 @@ +import getopt +import sys +comment = ('#' + sys.argv[1]).encode() +opts, args = getopt.getopt(sys.argv[2:], 'cf:o:xy') +optstring = '' +length = len(comment) +for opt, arg in opts: + if opt == '-o': out = arg + elif opt not in ('-f', '-K'): optstring = optstring + ' ' + opt +infile = open(args[0], 'rb') +outfile = open(out, 'wb') +outfile.write((optstring + "\n").encode()) +for l in infile.readlines(): + if l[:length] != comment: + outfile.write(l) +sys.exit(0) diff --git a/test/Fortran/fixture/sconstest.skip b/test/Fortran/fixture/sconstest.skip new file mode 100644 index 0000000..e69de29 diff --git a/test/Fortran/module-subdir.py b/test/Fortran/module-subdir.py index def1e5c..6570e0f 100644 --- a/test/Fortran/module-subdir.py +++ b/test/Fortran/module-subdir.py @@ -45,7 +45,7 @@ test.write('myfortran.py', r""" import getopt import os import sys -comment = '#' + sys.argv[1] +comment = ('#' + sys.argv[1]).encode() length = len(comment) opts, args = getopt.getopt(sys.argv[2:], 'cM:o:') for opt, arg in opts: @@ -55,9 +55,9 @@ import os infile = open(args[0], 'rb') outfile = open(out, 'wb') for l in infile.readlines(): - if l[:7] == 'module ': - module = modsubdir + os.sep + l[7:-1] + '.mod' - open(module, 'wb').write('myfortran.py wrote %s\n' % module) + if l[:7] == b'module ': + module = modsubdir + os.sep + l[7:-1].decode() + '.mod' + open(module, 'wb').write(('myfortran.py wrote %s\n' % module).encode()) if l[:length] != comment: outfile.write(l) sys.exit(0) @@ -103,7 +103,7 @@ end module """) -test.run(arguments = '.') +test.run(arguments = '. --tree=all') somemodule = os.path.join('subdir', 'build', 'somemodule.mod') diff --git a/test/SideEffect/basic.py b/test/SideEffect/basic.py index 0ded6b6..af6c264 100644 --- a/test/SideEffect/basic.py +++ b/test/SideEffect/basic.py @@ -43,7 +43,7 @@ def build(env, source, target): copy(str(source[0]), str(target[0])) if target[0].side_effects: side_effect = open(str(target[0].side_effects[0]), "ab") - side_effect.write('%%s -> %%s\\n'%%(str(source[0]), str(target[0]))) + side_effect.write(('%%s -> %%s\\n'%%(str(source[0]), str(target[0]))).encode()) Build = Builder(action=build) env = Environment(BUILDERS={'Build':Build}, SUBDIR='subdir') diff --git a/test/SideEffect/parallel.py b/test/SideEffect/parallel.py index ff883c4..f750903 100644 --- a/test/SideEffect/parallel.py +++ b/test/SideEffect/parallel.py @@ -45,14 +45,14 @@ logfile = 'log.txt' try: os.mkdir(lockdir) -except OSError, e: +except OSError as e: msg = 'could not create lock directory: %s\\n' % e sys.stderr.write(msg) sys.exit(1) src, target = sys.argv[1:] -open(logfile, 'ab').write('%s -> %s\\n' % (src, target)) +open(logfile, 'ab').write(('%s -> %s\\n' % (src, target)).encode()) # Give the other threads a chance to start. time.sleep(1) diff --git a/test/SideEffect/variant_dir.py b/test/SideEffect/variant_dir.py index cc7b8e9..711e426 100644 --- a/test/SideEffect/variant_dir.py +++ b/test/SideEffect/variant_dir.py @@ -44,7 +44,7 @@ def build(env, source, target): copy(str(source[0]), str(target[0])) if target[0].side_effects: side_effect = open(str(target[0].side_effects[0]), "ab") - side_effect.write('%s -> %s\\n'%(str(source[0]), str(target[0]))) + side_effect.write(('%s -> %s\\n'%(str(source[0]), str(target[0]))).encode()) Build = Builder(action=build) env = Environment(BUILDERS={'Build':Build}) -- cgit v0.12 From 98b77fecd17937c0b10d809906c4c0760ca077e5 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Sun, 27 Nov 2016 22:05:26 -0500 Subject: Reverted Python3 change to runtest.py. --- runtest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtest.py b/runtest.py index cfdc0c9..d636b73 100755 --- a/runtest.py +++ b/runtest.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python # # __COPYRIGHT__ # -- cgit v0.12 From 2a13b4ee309325261f69cbcb7bb69a78ef27a08a Mon Sep 17 00:00:00 2001 From: William Blevins Date: Sun, 27 Nov 2016 22:11:10 -0500 Subject: Revert of minor debug change for python3 update. --- test/Fortran/module-subdir.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Fortran/module-subdir.py b/test/Fortran/module-subdir.py index 6570e0f..6224d44 100644 --- a/test/Fortran/module-subdir.py +++ b/test/Fortran/module-subdir.py @@ -103,7 +103,7 @@ end module """) -test.run(arguments = '. --tree=all') +test.run(arguments = '.') somemodule = os.path.join('subdir', 'build', 'somemodule.mod') -- cgit v0.12 From 1c19e9f962b8cab0f9086615bb6409f8a326c0b8 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 28 Nov 2016 07:33:57 -0800 Subject: Add better error messaging when missing (or surplus) shared library targets with file extension --- src/engine/SCons/Tool/mingw.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/engine/SCons/Tool/mingw.py b/src/engine/SCons/Tool/mingw.py index 948ebe5..778db3c 100644 --- a/src/engine/SCons/Tool/mingw.py +++ b/src/engine/SCons/Tool/mingw.py @@ -86,7 +86,8 @@ def shlib_emitter(target, source, env): no_import_lib = env.get('no_import_lib', 0) if not dll: - raise SCons.Errors.UserError("A shared library should have exactly one target with the suffix: %s" % env.subst("$SHLIBSUFFIX")) + raise SCons.Errors.UserError("A shared library should have exactly one target with the suffix: %s Target(s) are:%s" % \ + (env.subst("$SHLIBSUFFIX"), ",".join([str(t) for t in target]))) if not no_import_lib and \ not env.FindIxes(target, 'LIBPREFIX', 'LIBSUFFIX'): -- cgit v0.12 From 694e80ea463c655d2e011afd4fe35109c119d6e7 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 28 Nov 2016 08:53:37 -0800 Subject: Fix tests failing on win32 AR and Fortran and M4 --- src/engine/SCons/Tool/__init__.py | 2 +- src/engine/SCons/Tool/ar.py | 4 ++-- test/AR/ARCOM.py | 2 ++ test/AR/ARCOMSTR.py | 1 + test/Fortran/F03COM.py | 18 +++++++++++++----- test/Fortran/F08COM.py | 16 +++++++++++----- test/Fortran/F77COM.py | 17 ++++++++++++----- test/Fortran/F90COM.py | 20 ++++++++++++++------ test/Fortran/F95COM.py | 18 ++++++++++++------ test/Fortran/FORTRANCOM.py | 15 +++++++++++---- test/Fortran/SHF77COM.py | 16 +++++++++++----- test/Fortran/SHF90COM.py | 19 +++++++++++++------ test/Fortran/SHF95COM.py | 18 ++++++++++++------ test/Fortran/SHFORTRANCOM.py | 14 ++++++++++---- test/M4/M4.py | 8 +++++++- 15 files changed, 132 insertions(+), 56 deletions(-) diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index 45d0aa1..15c8109 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -263,7 +263,7 @@ def createStaticLibBuilder(env): static_lib = env['BUILDERS']['StaticLibrary'] except KeyError: action_list = [ SCons.Action.Action("$ARCOM", "$ARCOMSTR") ] - if env.Detect('ranlib'): + if env.get('RANLIB',False) or env.Detect('ranlib'): ranlib_action = SCons.Action.Action("$RANLIBCOM", "$RANLIBCOMSTR") action_list.append(ranlib_action) diff --git a/src/engine/SCons/Tool/ar.py b/src/engine/SCons/Tool/ar.py index 0c3ac09..2cd15c8 100644 --- a/src/engine/SCons/Tool/ar.py +++ b/src/engine/SCons/Tool/ar.py @@ -48,8 +48,8 @@ def generate(env): env['LIBPREFIX'] = 'lib' env['LIBSUFFIX'] = '.a' - if env.Detect('ranlib'): - env['RANLIB'] = 'ranlib' + if env.get('RANLIB',env.Detect('ranlib')) : + env['RANLIB'] = env.get('RANLIB','ranlib') env['RANLIBFLAGS'] = SCons.Util.CLVar('') env['RANLIBCOM'] = '$RANLIB $RANLIBFLAGS $TARGET' diff --git a/test/AR/ARCOM.py b/test/AR/ARCOM.py index f9d0038..9ae5b9f 100644 --- a/test/AR/ARCOM.py +++ b/test/AR/ARCOM.py @@ -40,6 +40,7 @@ test.file_fixture('myrewrite.py') test.write('SConstruct', """ env = Environment(tools=['default', 'ar'], ARCOM = r'%(_python_)s mycompile.py ar $TARGET $SOURCES', + RANLIB = True, RANLIBCOM = r'%(_python_)s myrewrite.py ranlib $TARGET', LIBPREFIX = '', LIBSUFFIX = '.lib') @@ -49,6 +50,7 @@ env.Library(target = 'output', source = ['file.1', 'file.2']) test.write('file.1', "file.1\n/*ar*/\n/*ranlib*/\n") test.write('file.2', "file.2\n/*ar*/\n/*ranlib*/\n") + test.run(arguments = '.') test.must_match('output.lib', "file.1\nfile.2\n") diff --git a/test/AR/ARCOMSTR.py b/test/AR/ARCOMSTR.py index 3235f12..a3a9c8e 100644 --- a/test/AR/ARCOMSTR.py +++ b/test/AR/ARCOMSTR.py @@ -42,6 +42,7 @@ test.write('SConstruct', """ env = Environment(tools=['default', 'ar'], ARCOM = r'%(_python_)s mycompile.py ar $TARGET $SOURCES', ARCOMSTR = 'Archiving $TARGET from $SOURCES', + RANLIB = True, RANLIBCOM = r'%(_python_)s myrewrite.py ranlib $TARGET', LIBPREFIX = '', LIBSUFFIX = '.lib') diff --git a/test/Fortran/F03COM.py b/test/Fortran/F03COM.py index 4a42d22..aaa790c 100644 --- a/test/Fortran/F03COM.py +++ b/test/Fortran/F03COM.py @@ -25,6 +25,9 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons +import sys + +is_windows = (sys.platform == 'win32') _python_ = TestSCons._python_ _exe = TestSCons._exe @@ -76,18 +79,23 @@ test.write('test22.F03', "This is a .F03 file.\n#link\n/*f03pp*/\n") test.run(arguments = '.', stderr = None) test.must_match('test01' + _exe, "This is a .f file.\n") -test.must_match('test02' + _exe, "This is a .F file.\n") test.must_match('test03' + _exe, "This is a .for file.\n") -test.must_match('test04' + _exe, "This is a .FOR file.\n") test.must_match('test05' + _exe, "This is a .ftn file.\n") -test.must_match('test06' + _exe, "This is a .FTN file.\n") test.must_match('test07' + _exe, "This is a .fpp file.\n") test.must_match('test08' + _exe, "This is a .FPP file.\n") test.must_match('test13' + _exe, "This is a .f03 file.\n") -test.must_match('test14' + _exe, "This is a .F03 file.\n") test.must_match('test21' + _exe, "This is a .f03 file.\n") -test.must_match('test22' + _exe, "This is a .F03 file.\n") + +if not is_windows: + # Skip checking files we expect to differ in behavior + # based on file extension case + test.must_match('test02' + _exe, "This is a .F file.\n") + test.must_match('test04' + _exe, "This is a .FOR file.\n") + test.must_match('test06' + _exe, "This is a .FTN file.\n") + test.must_match('test14' + _exe, "This is a .F03 file.\n") + test.must_match('test22' + _exe, "This is a .F03 file.\n") + test.pass_test() diff --git a/test/Fortran/F08COM.py b/test/Fortran/F08COM.py index ba7d64e..f159a53 100644 --- a/test/Fortran/F08COM.py +++ b/test/Fortran/F08COM.py @@ -25,6 +25,9 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons +import sys + +is_windows = ( sys.platform =='win32') _python_ = TestSCons._python_ _exe = TestSCons._exe @@ -67,15 +70,18 @@ test.write('test10.F08', "This is a .F08 file.\n#link\n/*f08pp*/\n") test.run(arguments = '.', stderr = None) test.must_match('test01' + _exe, "This is a .f file.\n") -test.must_match('test02' + _exe, "This is a .F file.\n") test.must_match('test03' + _exe, "This is a .for file.\n") -test.must_match('test04' + _exe, "This is a .FOR file.\n") test.must_match('test05' + _exe, "This is a .ftn file.\n") -test.must_match('test06' + _exe, "This is a .FTN file.\n") test.must_match('test07' + _exe, "This is a .fpp file.\n") -test.must_match('test08' + _exe, "This is a .FPP file.\n") test.must_match('test09' + _exe, "This is a .f08 file.\n") -test.must_match('test10' + _exe, "This is a .F08 file.\n") +if not is_windows: + # Skip checking files we expect to differ in behavior + # based on file extension case + test.must_match('test02' + _exe, "This is a .F file.\n") + test.must_match('test04' + _exe, "This is a .FOR file.\n") + test.must_match('test06' + _exe, "This is a .FTN file.\n") + test.must_match('test08' + _exe, "This is a .FPP file.\n") + test.must_match('test10' + _exe, "This is a .F08 file.\n") test.pass_test() diff --git a/test/Fortran/F77COM.py b/test/Fortran/F77COM.py index e7a3cca..6550d92 100644 --- a/test/Fortran/F77COM.py +++ b/test/Fortran/F77COM.py @@ -25,6 +25,9 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons +import sys + +is_windows = ( sys.platform =='win32') _python_ = TestSCons._python_ _exe = TestSCons._exe @@ -67,15 +70,19 @@ test.write('test10.F77', "This is a .F77 file.\n#link\n/*f77pp*/\n") test.run(arguments = '.', stderr = None) test.must_match('test01' + _exe, "This is a .f file.\n") -test.must_match('test02' + _exe, "This is a .F file.\n") test.must_match('test03' + _exe, "This is a .for file.\n") -test.must_match('test04' + _exe, "This is a .FOR file.\n") test.must_match('test05' + _exe, "This is a .ftn file.\n") -test.must_match('test06' + _exe, "This is a .FTN file.\n") test.must_match('test07' + _exe, "This is a .fpp file.\n") -test.must_match('test08' + _exe, "This is a .FPP file.\n") test.must_match('test09' + _exe, "This is a .f77 file.\n") -test.must_match('test10' + _exe, "This is a .F77 file.\n") + +if not is_windows: + # Skip checking files we expect to differ in behavior + # based on file extension case + test.must_match('test02' + _exe, "This is a .F file.\n") + test.must_match('test04' + _exe, "This is a .FOR file.\n") + test.must_match('test06' + _exe, "This is a .FTN file.\n") + test.must_match('test08' + _exe, "This is a .FPP file.\n") + test.must_match('test10' + _exe, "This is a .F77 file.\n") test.pass_test() diff --git a/test/Fortran/F90COM.py b/test/Fortran/F90COM.py index a4f37c2..180e6b7 100644 --- a/test/Fortran/F90COM.py +++ b/test/Fortran/F90COM.py @@ -25,6 +25,9 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons +import sys + +is_windows = ( sys.platform =='win32') _python_ = TestSCons._python_ _exe = TestSCons._exe @@ -76,18 +79,23 @@ test.write('test22.F90', "This is a .F90 file.\n#link\n/*f90pp*/\n") test.run(arguments = '.', stderr = None) test.must_match('test01' + _exe, "This is a .f file.\n") -test.must_match('test02' + _exe, "This is a .F file.\n") test.must_match('test03' + _exe, "This is a .for file.\n") -test.must_match('test04' + _exe, "This is a .FOR file.\n") test.must_match('test05' + _exe, "This is a .ftn file.\n") -test.must_match('test06' + _exe, "This is a .FTN file.\n") test.must_match('test07' + _exe, "This is a .fpp file.\n") -test.must_match('test08' + _exe, "This is a .FPP file.\n") test.must_match('test11' + _exe, "This is a .f90 file.\n") -test.must_match('test12' + _exe, "This is a .F90 file.\n") test.must_match('test21' + _exe, "This is a .f90 file.\n") -test.must_match('test22' + _exe, "This is a .F90 file.\n") + +if not is_windows: + # Skip checking files we expect to differ in behavior + # based on file extension case + test.must_match('test02' + _exe, "This is a .F file.\n") + test.must_match('test04' + _exe, "This is a .FOR file.\n") + test.must_match('test06' + _exe, "This is a .FTN file.\n") + test.must_match('test08' + _exe, "This is a .FPP file.\n") + test.must_match('test12' + _exe, "This is a .F90 file.\n") + test.must_match('test22' + _exe, "This is a .F90 file.\n") + test.pass_test() diff --git a/test/Fortran/F95COM.py b/test/Fortran/F95COM.py index 32ae594..2d48770 100644 --- a/test/Fortran/F95COM.py +++ b/test/Fortran/F95COM.py @@ -25,6 +25,9 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons +import sys + +is_windows = ( sys.platform =='win32') _python_ = TestSCons._python_ _exe = TestSCons._exe @@ -76,18 +79,21 @@ test.write('test22.F95', "This is a .F95 file.\n#link\n/*f95pp*/\n") test.run(arguments = '.', stderr = None) test.must_match('test01' + _exe, "This is a .f file.\n") -test.must_match('test02' + _exe, "This is a .F file.\n") test.must_match('test03' + _exe, "This is a .for file.\n") -test.must_match('test04' + _exe, "This is a .FOR file.\n") test.must_match('test05' + _exe, "This is a .ftn file.\n") -test.must_match('test06' + _exe, "This is a .FTN file.\n") test.must_match('test07' + _exe, "This is a .fpp file.\n") -test.must_match('test08' + _exe, "This is a .FPP file.\n") test.must_match('test13' + _exe, "This is a .f95 file.\n") -test.must_match('test14' + _exe, "This is a .F95 file.\n") test.must_match('test21' + _exe, "This is a .f95 file.\n") -test.must_match('test22' + _exe, "This is a .F95 file.\n") +if not is_windows: + # Skip checking files we expect to differ in behavior + # based on file extension case + test.must_match('test02' + _exe, "This is a .F file.\n") + test.must_match('test04' + _exe, "This is a .FOR file.\n") + test.must_match('test06' + _exe, "This is a .FTN file.\n") + test.must_match('test08' + _exe, "This is a .FPP file.\n") + test.must_match('test14' + _exe, "This is a .F95 file.\n") + test.must_match('test22' + _exe, "This is a .F95 file.\n") test.pass_test() diff --git a/test/Fortran/FORTRANCOM.py b/test/Fortran/FORTRANCOM.py index a07d427..d3d7e7f 100644 --- a/test/Fortran/FORTRANCOM.py +++ b/test/Fortran/FORTRANCOM.py @@ -25,6 +25,10 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons +import sys + +is_windows = ( sys.platform =='win32') + _python_ = TestSCons._python_ _exe = TestSCons._exe @@ -61,13 +65,16 @@ test.write('test08.FPP', "This is a .FPP file.\n#link\n/*fortranpp*/\n") test.run(arguments = '.', stderr = None) test.must_match('test01' + _exe, "This is a .f file.\n") -test.must_match('test02' + _exe, "This is a .F file.\n") test.must_match('test03' + _exe, "This is a .for file.\n") -test.must_match('test04' + _exe, "This is a .FOR file.\n") test.must_match('test05' + _exe, "This is a .ftn file.\n") -test.must_match('test06' + _exe, "This is a .FTN file.\n") test.must_match('test07' + _exe, "This is a .fpp file.\n") -test.must_match('test08' + _exe, "This is a .FPP file.\n") +if not is_windows: + # Skip checking files we expect to differ in behavior + # based on file extension case + test.must_match('test02' + _exe, "This is a .F file.\n") + test.must_match('test04' + _exe, "This is a .FOR file.\n") + test.must_match('test06' + _exe, "This is a .FTN file.\n") + test.must_match('test08' + _exe, "This is a .FPP file.\n") test.pass_test() diff --git a/test/Fortran/SHF77COM.py b/test/Fortran/SHF77COM.py index 9289fa3..bd3d1e2 100644 --- a/test/Fortran/SHF77COM.py +++ b/test/Fortran/SHF77COM.py @@ -25,6 +25,9 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons +import sys + +is_windows = ( sys.platform =='win32') _python_ = TestSCons._python_ _obj = TestSCons._shobj @@ -65,15 +68,18 @@ test.write('test10.F77', "This is a .F77 file.\n/*f77pp*/\n") test.run(arguments = '.', stderr = None) test.must_match(obj_ + 'test01' + _obj, "This is a .f file.\n") -test.must_match(obj_ + 'test02' + _obj, "This is a .F file.\n") test.must_match(obj_ + 'test03' + _obj, "This is a .for file.\n") -test.must_match(obj_ + 'test04' + _obj, "This is a .FOR file.\n") test.must_match(obj_ + 'test05' + _obj, "This is a .ftn file.\n") -test.must_match(obj_ + 'test06' + _obj, "This is a .FTN file.\n") test.must_match(obj_ + 'test07' + _obj, "This is a .fpp file.\n") -test.must_match(obj_ + 'test08' + _obj, "This is a .FPP file.\n") test.must_match(obj_ + 'test09' + _obj, "This is a .f77 file.\n") -test.must_match(obj_ + 'test10' + _obj, "This is a .F77 file.\n") +if not is_windows: + # Skip checking files we expect to differ in behavior + # based on file extension case + test.must_match(obj_ + 'test02' + _obj, "This is a .F file.\n") + test.must_match(obj_ + 'test04' + _obj, "This is a .FOR file.\n") + test.must_match(obj_ + 'test06' + _obj, "This is a .FTN file.\n") + test.must_match(obj_ + 'test08' + _obj, "This is a .FPP file.\n") + test.must_match(obj_ + 'test10' + _obj, "This is a .F77 file.\n") test.pass_test() diff --git a/test/Fortran/SHF90COM.py b/test/Fortran/SHF90COM.py index 9eef8b6..f66c347 100644 --- a/test/Fortran/SHF90COM.py +++ b/test/Fortran/SHF90COM.py @@ -25,6 +25,10 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons +import sys + +is_windows = ( sys.platform =='win32') + _python_ = TestSCons._python_ _obj = TestSCons._shobj @@ -72,18 +76,21 @@ test.write('test22.F90', "This is a .F90 file.\n/*f90pp*/\n") test.run(arguments = '.', stderr = None) test.must_match(obj_ + 'test01' + _obj, "This is a .f file.\n") -test.must_match(obj_ + 'test02' + _obj, "This is a .F file.\n") test.must_match(obj_ + 'test03' + _obj, "This is a .for file.\n") -test.must_match(obj_ + 'test04' + _obj, "This is a .FOR file.\n") test.must_match(obj_ + 'test05' + _obj, "This is a .ftn file.\n") -test.must_match(obj_ + 'test06' + _obj, "This is a .FTN file.\n") test.must_match(obj_ + 'test07' + _obj, "This is a .fpp file.\n") -test.must_match(obj_ + 'test08' + _obj, "This is a .FPP file.\n") test.must_match(obj_ + 'test11' + _obj, "This is a .f90 file.\n") -test.must_match(obj_ + 'test12' + _obj, "This is a .F90 file.\n") test.must_match(obj_ + 'test21' + _obj, "This is a .f90 file.\n") -test.must_match(obj_ + 'test22' + _obj, "This is a .F90 file.\n") +if not is_windows: + # Skip checking files we expect to differ in behavior + # based on file extension case + test.must_match(obj_ + 'test02' + _obj, "This is a .F file.\n") + test.must_match(obj_ + 'test04' + _obj, "This is a .FOR file.\n") + test.must_match(obj_ + 'test06' + _obj, "This is a .FTN file.\n") + test.must_match(obj_ + 'test08' + _obj, "This is a .FPP file.\n") + test.must_match(obj_ + 'test12' + _obj, "This is a .F90 file.\n") + test.must_match(obj_ + 'test22' + _obj, "This is a .F90 file.\n") test.pass_test() diff --git a/test/Fortran/SHF95COM.py b/test/Fortran/SHF95COM.py index e31cf45..85de45e 100644 --- a/test/Fortran/SHF95COM.py +++ b/test/Fortran/SHF95COM.py @@ -25,6 +25,9 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons +import sys + +is_windows = ( sys.platform =='win32') _python_ = TestSCons._python_ _obj = TestSCons._shobj @@ -72,18 +75,21 @@ test.write('test22.F95', "This is a .F95 file.\n/*f95pp*/\n") test.run(arguments = '.', stderr = None) test.must_match(obj_ + 'test01' + _obj, "This is a .f file.\n") -test.must_match(obj_ + 'test02' + _obj, "This is a .F file.\n") test.must_match(obj_ + 'test03' + _obj, "This is a .for file.\n") -test.must_match(obj_ + 'test04' + _obj, "This is a .FOR file.\n") test.must_match(obj_ + 'test05' + _obj, "This is a .ftn file.\n") -test.must_match(obj_ + 'test06' + _obj, "This is a .FTN file.\n") test.must_match(obj_ + 'test07' + _obj, "This is a .fpp file.\n") -test.must_match(obj_ + 'test08' + _obj, "This is a .FPP file.\n") test.must_match(obj_ + 'test13' + _obj, "This is a .f95 file.\n") -test.must_match(obj_ + 'test14' + _obj, "This is a .F95 file.\n") test.must_match(obj_ + 'test21' + _obj, "This is a .f95 file.\n") -test.must_match(obj_ + 'test22' + _obj, "This is a .F95 file.\n") +if not is_windows: + # Skip checking files we expect to differ in behavior + # based on file extension case + test.must_match(obj_ + 'test02' + _obj, "This is a .F file.\n") + test.must_match(obj_ + 'test04' + _obj, "This is a .FOR file.\n") + test.must_match(obj_ + 'test06' + _obj, "This is a .FTN file.\n") + test.must_match(obj_ + 'test08' + _obj, "This is a .FPP file.\n") + test.must_match(obj_ + 'test14' + _obj, "This is a .F95 file.\n") + test.must_match(obj_ + 'test22' + _obj, "This is a .F95 file.\n") test.pass_test() diff --git a/test/Fortran/SHFORTRANCOM.py b/test/Fortran/SHFORTRANCOM.py index 56958b2..5c42864 100644 --- a/test/Fortran/SHFORTRANCOM.py +++ b/test/Fortran/SHFORTRANCOM.py @@ -25,6 +25,9 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons +import sys + +is_windows = ( sys.platform =='win32') _python_ = TestSCons._python_ _obj = TestSCons._shobj @@ -59,13 +62,16 @@ test.write('test08.FPP', "This is a .FPP file.\n/*fortranpp*/\n") test.run(arguments = '.', stderr = None) test.must_match(obj_ + 'test01' + _obj, "This is a .f file.\n") -test.must_match(obj_ + 'test02' + _obj, "This is a .F file.\n") test.must_match(obj_ + 'test03' + _obj, "This is a .for file.\n") -test.must_match(obj_ + 'test04' + _obj, "This is a .FOR file.\n") test.must_match(obj_ + 'test05' + _obj, "This is a .ftn file.\n") -test.must_match(obj_ + 'test06' + _obj, "This is a .FTN file.\n") test.must_match(obj_ + 'test07' + _obj, "This is a .fpp file.\n") -test.must_match(obj_ + 'test08' + _obj, "This is a .FPP file.\n") +if not is_windows: + # Skip checking files we expect to differ in behavior + # based on file extension case + test.must_match(obj_ + 'test02' + _obj, "This is a .F file.\n") + test.must_match(obj_ + 'test04' + _obj, "This is a .FOR file.\n") + test.must_match(obj_ + 'test06' + _obj, "This is a .FTN file.\n") + test.must_match(obj_ + 'test08' + _obj, "This is a .FPP file.\n") test.pass_test() diff --git a/test/M4/M4.py b/test/M4/M4.py index 4306558..76010e6 100644 --- a/test/M4/M4.py +++ b/test/M4/M4.py @@ -59,7 +59,13 @@ line 3 test.run() -test.must_match(test.workpath('aaa.x'), "line 1\nmym4.py\nline 3\n") +import sys + +if sys.platform == 'win32': + # Handle carriage returns. + test.must_match(test.workpath('aaa.x'), "line 1\r\nmym4.py\r\nline 3\r\n") +else: + test.must_match(test.workpath('aaa.x'), "line 1\nmym4.py\nline 3\n") -- cgit v0.12 From a3aa375f59535bfbe0aecdaabdeb40bc419125e1 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 28 Nov 2016 10:35:43 -0800 Subject: fix test to work after updates to ar.py tool --- test/RANLIB/RANLIBFLAGS.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/RANLIB/RANLIBFLAGS.py b/test/RANLIB/RANLIBFLAGS.py index 0de0cdc..e13bac8 100644 --- a/test/RANLIB/RANLIBFLAGS.py +++ b/test/RANLIB/RANLIBFLAGS.py @@ -42,8 +42,8 @@ test.file_fixture('wrapper.py') test.write('SConstruct', """ foo = Environment(LIBS = ['foo'], LIBPATH = ['.']) -bar = Environment(LIBS = ['bar'], LIBPATH = ['.'], RANLIB = '', - RANLIBFLAGS = foo.subst(r'%(_python_)s wrapper.py $RANLIB $RANLIBFLAGS')) +bar = Environment(LIBS = ['bar'], LIBPATH = ['.'], RANLIB = r'%(_python_)s wrapper.py', + RANLIBFLAGS = foo.subst(r'$RANLIB $RANLIBFLAGS')) foo.Library(target = 'foo', source = 'foo.c') bar.Library(target = 'bar', source = 'bar.c') -- cgit v0.12 From 055dc8f39e8b0d175a7acdd5977bb35b152ad170 Mon Sep 17 00:00:00 2001 From: William Blevins Date: Mon, 28 Nov 2016 20:25:38 -0500 Subject: Fixing merge conflict resolution: removed old test files. --- test/CC/shared-fixture/.exclude_tests | 1 - test/CC/shared-fixture/mycc.py | 6 ------ test/CC/shared-fixture/test1.c | 2 -- test/YACC/YACCCOM-fixture/.exclude_tests | 1 - test/YACC/YACCCOM-fixture/myyacc.py | 7 ------- test/YACC/shared-fixture/.exclude_tests | 1 - test/YACC/shared-fixture/aaa.y | 2 -- test/YACC/shared-fixture/bbb.yacc | 2 -- test/ZIP/ZIPCOM-fixture/.exclude_tests | 1 - test/ZIP/ZIPCOM-fixture/myzip.py | 6 ------ test/ZIP/ZIPCOM-fixture/test1.in | 2 -- test/ZIP/ZIPCOMSTR-fixture/.exclude_tests | 1 - test/ZIP/ZIPCOMSTR-fixture/aaa.in | 2 -- test/ZIP/ZIPCOMSTR-fixture/myzip.py | 7 ------- 14 files changed, 41 deletions(-) delete mode 100644 test/CC/shared-fixture/.exclude_tests delete mode 100644 test/CC/shared-fixture/mycc.py delete mode 100644 test/CC/shared-fixture/test1.c delete mode 100644 test/YACC/YACCCOM-fixture/.exclude_tests delete mode 100644 test/YACC/YACCCOM-fixture/myyacc.py delete mode 100644 test/YACC/shared-fixture/.exclude_tests delete mode 100644 test/YACC/shared-fixture/aaa.y delete mode 100644 test/YACC/shared-fixture/bbb.yacc delete mode 100644 test/ZIP/ZIPCOM-fixture/.exclude_tests delete mode 100644 test/ZIP/ZIPCOM-fixture/myzip.py delete mode 100644 test/ZIP/ZIPCOM-fixture/test1.in delete mode 100644 test/ZIP/ZIPCOMSTR-fixture/.exclude_tests delete mode 100644 test/ZIP/ZIPCOMSTR-fixture/aaa.in delete mode 100644 test/ZIP/ZIPCOMSTR-fixture/myzip.py diff --git a/test/CC/shared-fixture/.exclude_tests b/test/CC/shared-fixture/.exclude_tests deleted file mode 100644 index 3f2bc0f..0000000 --- a/test/CC/shared-fixture/.exclude_tests +++ /dev/null @@ -1 +0,0 @@ -mycc.py diff --git a/test/CC/shared-fixture/mycc.py b/test/CC/shared-fixture/mycc.py deleted file mode 100644 index b96c31c..0000000 --- a/test/CC/shared-fixture/mycc.py +++ /dev/null @@ -1,6 +0,0 @@ -import sys -outfile = open(sys.argv[1], 'wb') -infile = open(sys.argv[2], 'rb') -for l in [l for l in infile.readlines() if l[:6] != b'/*cc*/']: - outfile.write(l) -sys.exit(0) diff --git a/test/CC/shared-fixture/test1.c b/test/CC/shared-fixture/test1.c deleted file mode 100644 index 9c281d7..0000000 --- a/test/CC/shared-fixture/test1.c +++ /dev/null @@ -1,2 +0,0 @@ -test1.c -/*cc*/ diff --git a/test/YACC/YACCCOM-fixture/.exclude_tests b/test/YACC/YACCCOM-fixture/.exclude_tests deleted file mode 100644 index f12c4d0..0000000 --- a/test/YACC/YACCCOM-fixture/.exclude_tests +++ /dev/null @@ -1 +0,0 @@ -myyacc.py diff --git a/test/YACC/YACCCOM-fixture/myyacc.py b/test/YACC/YACCCOM-fixture/myyacc.py deleted file mode 100644 index 1502800..0000000 --- a/test/YACC/YACCCOM-fixture/myyacc.py +++ /dev/null @@ -1,7 +0,0 @@ -import sys -outfile = open(sys.argv[1], 'wb') -for f in sys.argv[2:]: - infile = open(f, 'rb') - for l in [l for l in infile.readlines() if l != b'/*yacc*/\n']: - outfile.write(l) -sys.exit(0) diff --git a/test/YACC/shared-fixture/.exclude_tests b/test/YACC/shared-fixture/.exclude_tests deleted file mode 100644 index f12c4d0..0000000 --- a/test/YACC/shared-fixture/.exclude_tests +++ /dev/null @@ -1 +0,0 @@ -myyacc.py diff --git a/test/YACC/shared-fixture/aaa.y b/test/YACC/shared-fixture/aaa.y deleted file mode 100644 index f7f4cc7..0000000 --- a/test/YACC/shared-fixture/aaa.y +++ /dev/null @@ -1,2 +0,0 @@ -aaa.y -/*yacc*/ diff --git a/test/YACC/shared-fixture/bbb.yacc b/test/YACC/shared-fixture/bbb.yacc deleted file mode 100644 index b3c856f..0000000 --- a/test/YACC/shared-fixture/bbb.yacc +++ /dev/null @@ -1,2 +0,0 @@ -bbb.yacc -/*yacc*/ diff --git a/test/ZIP/ZIPCOM-fixture/.exclude_tests b/test/ZIP/ZIPCOM-fixture/.exclude_tests deleted file mode 100644 index dae6f60..0000000 --- a/test/ZIP/ZIPCOM-fixture/.exclude_tests +++ /dev/null @@ -1 +0,0 @@ -myzip.py diff --git a/test/ZIP/ZIPCOM-fixture/myzip.py b/test/ZIP/ZIPCOM-fixture/myzip.py deleted file mode 100644 index adbc6ac..0000000 --- a/test/ZIP/ZIPCOM-fixture/myzip.py +++ /dev/null @@ -1,6 +0,0 @@ -import sys -outfile = open(sys.argv[1], 'wb') -infile = open(sys.argv[2], 'rb') -for l in [l for l in infile.readlines() if l != b'/*zip*/\n']: - outfile.write(l) -sys.exit(0) diff --git a/test/ZIP/ZIPCOM-fixture/test1.in b/test/ZIP/ZIPCOM-fixture/test1.in deleted file mode 100644 index 0546626..0000000 --- a/test/ZIP/ZIPCOM-fixture/test1.in +++ /dev/null @@ -1,2 +0,0 @@ -test1.in -/*zip*/ diff --git a/test/ZIP/ZIPCOMSTR-fixture/.exclude_tests b/test/ZIP/ZIPCOMSTR-fixture/.exclude_tests deleted file mode 100644 index dae6f60..0000000 --- a/test/ZIP/ZIPCOMSTR-fixture/.exclude_tests +++ /dev/null @@ -1 +0,0 @@ -myzip.py diff --git a/test/ZIP/ZIPCOMSTR-fixture/aaa.in b/test/ZIP/ZIPCOMSTR-fixture/aaa.in deleted file mode 100644 index 8474a29..0000000 --- a/test/ZIP/ZIPCOMSTR-fixture/aaa.in +++ /dev/null @@ -1,2 +0,0 @@ -aaa.in -/*zip*/ diff --git a/test/ZIP/ZIPCOMSTR-fixture/myzip.py b/test/ZIP/ZIPCOMSTR-fixture/myzip.py deleted file mode 100644 index f0fcc51..0000000 --- a/test/ZIP/ZIPCOMSTR-fixture/myzip.py +++ /dev/null @@ -1,7 +0,0 @@ -import sys -outfile = open(sys.argv[1], 'wb') -for f in sys.argv[2:]: - infile = open(f, 'rb') - for l in [l for l in infile.readlines() if l != b'/*zip*/\n']: - outfile.write(l) -sys.exit(0) -- cgit v0.12 From 810413128c22359f06c7bd0f7de4840fe5657c31 Mon Sep 17 00:00:00 2001 From: Rick Lupton Date: Tue, 29 Nov 2016 08:02:08 +0000 Subject: Skip import.sty test when Latex package missing --- test/TEX/recursive_scanner_dependencies_import.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/TEX/recursive_scanner_dependencies_import.py b/test/TEX/recursive_scanner_dependencies_import.py index d9d2625..b31dfbe 100644 --- a/test/TEX/recursive_scanner_dependencies_import.py +++ b/test/TEX/recursive_scanner_dependencies_import.py @@ -34,6 +34,7 @@ dependencies are found only by the scanner. """ +import os import TestSCons test = TestSCons.TestSCons() @@ -43,6 +44,10 @@ pdflatex = test.where_is('pdflatex') if not pdflatex: test.skip_test("Could not find pdflatex; skipping test(s).\n") +latex_import = os.system('kpsewhich import.sty') +if latex_import != 0: + test.skip_test("import.sty not installed; skipping test(s).\n") + test.subdir('subdir') test.subdir('subdir/subdir2') -- cgit v0.12 From a559337466acf9fd91bf266fab72946ebbb64632 Mon Sep 17 00:00:00 2001 From: mbyt Date: Tue, 29 Nov 2016 20:07:10 +0100 Subject: fixing typo, it must be _scons_file --- src/engine/SCons/Platform/win32.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/SCons/Platform/win32.py b/src/engine/SCons/Platform/win32.py index cb82df3..98094b3 100644 --- a/src/engine/SCons/Platform/win32.py +++ b/src/engine/SCons/Platform/win32.py @@ -89,7 +89,7 @@ else: _builtin_file.__init__(self, *args, **kw) win32api.SetHandleInformation(msvcrt.get_osfhandle(self.fileno()), win32con.HANDLE_FLAG_INHERIT, 0) - setattr(io, io_class, _builtin_file) + setattr(io, io_class, _scons_file) try: -- cgit v0.12 From 7e55f7120bf5b54d12a8f1ab01ad36da3b930bc5 Mon Sep 17 00:00:00 2001 From: Jason Kenny Date: Fri, 23 Dec 2016 13:02:02 -0600 Subject: Make c++ proxy files to the cxx forms Change the old c++ files to be cxx to help make it easier and safer to import correctly --- src/engine/SCons/Tool/aixc++.py | 36 +--------- src/engine/SCons/Tool/aixcxx.py | 75 +++++++++++++++++++++ src/engine/SCons/Tool/c++.py | 60 +---------------- src/engine/SCons/Tool/cxx.py | 100 ++++++++++++++++++++++++++++ src/engine/SCons/Tool/g++.py | 38 +---------- src/engine/SCons/Tool/gxx.py | 79 ++++++++++++++++++++++ src/engine/SCons/Tool/hpc++.py | 43 +----------- src/engine/SCons/Tool/hpcxx.py | 84 ++++++++++++++++++++++++ src/engine/SCons/Tool/sgic++.py | 19 +----- src/engine/SCons/Tool/sgicxx.py | 58 ++++++++++++++++ src/engine/SCons/Tool/sunc++.py | 101 +--------------------------- src/engine/SCons/Tool/suncxx.py | 142 ++++++++++++++++++++++++++++++++++++++++ 12 files changed, 550 insertions(+), 285 deletions(-) create mode 100644 src/engine/SCons/Tool/aixcxx.py create mode 100644 src/engine/SCons/Tool/cxx.py create mode 100644 src/engine/SCons/Tool/gxx.py create mode 100644 src/engine/SCons/Tool/hpcxx.py create mode 100644 src/engine/SCons/Tool/sgicxx.py create mode 100644 src/engine/SCons/Tool/suncxx.py diff --git a/src/engine/SCons/Tool/aixc++.py b/src/engine/SCons/Tool/aixc++.py index f03f763..c3efaea 100644 --- a/src/engine/SCons/Tool/aixc++.py +++ b/src/engine/SCons/Tool/aixc++.py @@ -33,40 +33,8 @@ selection method. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -import os.path - -import SCons.Platform.aix - -cplusplus = __import__('c++', globals(), locals(), []) - -packages = ['vacpp.cmp.core', 'vacpp.cmp.batch', 'vacpp.cmp.C', 'ibmcxx.cmp'] - -def get_xlc(env): - xlc = env.get('CXX', 'xlC') - return SCons.Platform.aix.get_xlc(env, xlc, packages) - -def generate(env): - """Add Builders and construction variables for xlC / Visual Age - suite to an Environment.""" - path, _cxx, version = get_xlc(env) - if path and _cxx: - _cxx = os.path.join(path, _cxx) - - if 'CXX' not in env: - env['CXX'] = _cxx - - cplusplus.generate(env) - - if version: - env['CXXVERSION'] = version - -def exists(env): - path, _cxx, version = get_xlc(env) - if path and _cxx: - xlc = os.path.join(path, _cxx) - if os.path.exists(xlc): - return xlc - return None +#forward proxy to the preffered cxx version +from SCons.Tool.aixcxx import * # Local Variables: # tab-width:4 diff --git a/src/engine/SCons/Tool/aixcxx.py b/src/engine/SCons/Tool/aixcxx.py new file mode 100644 index 0000000..f03f763 --- /dev/null +++ b/src/engine/SCons/Tool/aixcxx.py @@ -0,0 +1,75 @@ +"""SCons.Tool.aixc++ + +Tool-specific initialization for IBM xlC / Visual Age C++ compiler. + +There normally shouldn't be any need to import this module directly. +It will usually be imported through the generic SCons.Tool.Tool() +selection method. + +""" + +# +# __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.path + +import SCons.Platform.aix + +cplusplus = __import__('c++', globals(), locals(), []) + +packages = ['vacpp.cmp.core', 'vacpp.cmp.batch', 'vacpp.cmp.C', 'ibmcxx.cmp'] + +def get_xlc(env): + xlc = env.get('CXX', 'xlC') + return SCons.Platform.aix.get_xlc(env, xlc, packages) + +def generate(env): + """Add Builders and construction variables for xlC / Visual Age + suite to an Environment.""" + path, _cxx, version = get_xlc(env) + if path and _cxx: + _cxx = os.path.join(path, _cxx) + + if 'CXX' not in env: + env['CXX'] = _cxx + + cplusplus.generate(env) + + if version: + env['CXXVERSION'] = version + +def exists(env): + path, _cxx, version = get_xlc(env) + if path and _cxx: + xlc = os.path.join(path, _cxx) + if os.path.exists(xlc): + return xlc + return None + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/src/engine/SCons/Tool/c++.py b/src/engine/SCons/Tool/c++.py index 430851c..6b772fa 100644 --- a/src/engine/SCons/Tool/c++.py +++ b/src/engine/SCons/Tool/c++.py @@ -32,66 +32,10 @@ selection method. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -import os.path -import SCons.Tool -import SCons.Defaults -import SCons.Util +#forward proxy to the preffered cxx version +from SCons.Tool.cxx import * -compilers = ['CC', 'c++'] - -CXXSuffixes = ['.cpp', '.cc', '.cxx', '.c++', '.C++', '.mm'] -if SCons.Util.case_sensitive_suffixes('.c', '.C'): - CXXSuffixes.append('.C') - -def iscplusplus(source): - if not source: - # Source might be None for unusual cases like SConf. - return 0 - for s in source: - if s.sources: - ext = os.path.splitext(str(s.sources[0]))[1] - if ext in CXXSuffixes: - return 1 - return 0 - -def generate(env): - """ - Add Builders and construction variables for Visual Age C++ compilers - to an Environment. - """ - import SCons.Tool - import SCons.Tool.cc - static_obj, shared_obj = SCons.Tool.createObjBuilders(env) - - for suffix in CXXSuffixes: - static_obj.add_action(suffix, SCons.Defaults.CXXAction) - shared_obj.add_action(suffix, SCons.Defaults.ShCXXAction) - static_obj.add_emitter(suffix, SCons.Defaults.StaticObjectEmitter) - shared_obj.add_emitter(suffix, SCons.Defaults.SharedObjectEmitter) - - SCons.Tool.cc.add_common_cc_variables(env) - - if 'CXX' not in env: - env['CXX'] = env.Detect(compilers) or compilers[0] - env['CXXFLAGS'] = SCons.Util.CLVar('') - env['CXXCOM'] = '$CXX -o $TARGET -c $CXXFLAGS $CCFLAGS $_CCCOMCOM $SOURCES' - env['SHCXX'] = '$CXX' - env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS') - env['SHCXXCOM'] = '$SHCXX -o $TARGET -c $SHCXXFLAGS $SHCCFLAGS $_CCCOMCOM $SOURCES' - - env['CPPDEFPREFIX'] = '-D' - env['CPPDEFSUFFIX'] = '' - env['INCPREFIX'] = '-I' - env['INCSUFFIX'] = '' - env['SHOBJSUFFIX'] = '.os' - env['OBJSUFFIX'] = '.o' - env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 0 - - env['CXXFILESUFFIX'] = '.cc' - -def exists(env): - return env.Detect(env.get('CXX', compilers)) # Local Variables: # tab-width:4 diff --git a/src/engine/SCons/Tool/cxx.py b/src/engine/SCons/Tool/cxx.py new file mode 100644 index 0000000..430851c --- /dev/null +++ b/src/engine/SCons/Tool/cxx.py @@ -0,0 +1,100 @@ +"""SCons.Tool.c++ + +Tool-specific initialization for generic Posix C++ compilers. + +There normally shouldn't be any need to import this module directly. +It will usually be imported through the generic SCons.Tool.Tool() +selection method. +""" + +# +# __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.path + +import SCons.Tool +import SCons.Defaults +import SCons.Util + +compilers = ['CC', 'c++'] + +CXXSuffixes = ['.cpp', '.cc', '.cxx', '.c++', '.C++', '.mm'] +if SCons.Util.case_sensitive_suffixes('.c', '.C'): + CXXSuffixes.append('.C') + +def iscplusplus(source): + if not source: + # Source might be None for unusual cases like SConf. + return 0 + for s in source: + if s.sources: + ext = os.path.splitext(str(s.sources[0]))[1] + if ext in CXXSuffixes: + return 1 + return 0 + +def generate(env): + """ + Add Builders and construction variables for Visual Age C++ compilers + to an Environment. + """ + import SCons.Tool + import SCons.Tool.cc + static_obj, shared_obj = SCons.Tool.createObjBuilders(env) + + for suffix in CXXSuffixes: + static_obj.add_action(suffix, SCons.Defaults.CXXAction) + shared_obj.add_action(suffix, SCons.Defaults.ShCXXAction) + static_obj.add_emitter(suffix, SCons.Defaults.StaticObjectEmitter) + shared_obj.add_emitter(suffix, SCons.Defaults.SharedObjectEmitter) + + SCons.Tool.cc.add_common_cc_variables(env) + + if 'CXX' not in env: + env['CXX'] = env.Detect(compilers) or compilers[0] + env['CXXFLAGS'] = SCons.Util.CLVar('') + env['CXXCOM'] = '$CXX -o $TARGET -c $CXXFLAGS $CCFLAGS $_CCCOMCOM $SOURCES' + env['SHCXX'] = '$CXX' + env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS') + env['SHCXXCOM'] = '$SHCXX -o $TARGET -c $SHCXXFLAGS $SHCCFLAGS $_CCCOMCOM $SOURCES' + + env['CPPDEFPREFIX'] = '-D' + env['CPPDEFSUFFIX'] = '' + env['INCPREFIX'] = '-I' + env['INCSUFFIX'] = '' + env['SHOBJSUFFIX'] = '.os' + env['OBJSUFFIX'] = '.o' + env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 0 + + env['CXXFILESUFFIX'] = '.cc' + +def exists(env): + return env.Detect(env.get('CXX', compilers)) + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/src/engine/SCons/Tool/g++.py b/src/engine/SCons/Tool/g++.py index c5eb579..88d88ca 100644 --- a/src/engine/SCons/Tool/g++.py +++ b/src/engine/SCons/Tool/g++.py @@ -33,44 +33,10 @@ selection method. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -import os.path -import re -import subprocess -import SCons.Tool -import SCons.Util +#forward proxy to the preffered cxx version +from SCons.Tool.gxx import * -from . import gcc -cplusplus = __import__(__package__+'.c++', globals(), locals(), ['*']) - -compilers = ['g++'] - -def generate(env): - """Add Builders and construction variables for g++ to an Environment.""" - static_obj, shared_obj = SCons.Tool.createObjBuilders(env) - - if 'CXX' not in env: - env['CXX'] = env.Detect(compilers) or compilers[0] - - cplusplus.generate(env) - - # platform specific settings - if env['PLATFORM'] == 'aix': - env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS -mminimal-toc') - env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 1 - env['SHOBJSUFFIX'] = '$OBJSUFFIX' - elif env['PLATFORM'] == 'hpux': - env['SHOBJSUFFIX'] = '.pic.o' - elif env['PLATFORM'] == 'sunos': - env['SHOBJSUFFIX'] = '.pic.o' - # determine compiler version - version = gcc.detect_version(env, env['CXX']) - if version: - env['CXXVERSION'] = version - -def exists(env): - # is executable, and is a GNU compiler (or accepts '--version' at least) - return gcc.detect_version(env, env.Detect(env.get('CXX', compilers))) # Local Variables: # tab-width:4 diff --git a/src/engine/SCons/Tool/gxx.py b/src/engine/SCons/Tool/gxx.py new file mode 100644 index 0000000..c5eb579 --- /dev/null +++ b/src/engine/SCons/Tool/gxx.py @@ -0,0 +1,79 @@ +"""SCons.Tool.g++ + +Tool-specific initialization for g++. + +There normally shouldn't be any need to import this module directly. +It will usually be imported through the generic SCons.Tool.Tool() +selection method. + +""" + +# +# __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.path +import re +import subprocess + +import SCons.Tool +import SCons.Util + +from . import gcc +cplusplus = __import__(__package__+'.c++', globals(), locals(), ['*']) + +compilers = ['g++'] + +def generate(env): + """Add Builders and construction variables for g++ to an Environment.""" + static_obj, shared_obj = SCons.Tool.createObjBuilders(env) + + if 'CXX' not in env: + env['CXX'] = env.Detect(compilers) or compilers[0] + + cplusplus.generate(env) + + # platform specific settings + if env['PLATFORM'] == 'aix': + env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS -mminimal-toc') + env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 1 + env['SHOBJSUFFIX'] = '$OBJSUFFIX' + elif env['PLATFORM'] == 'hpux': + env['SHOBJSUFFIX'] = '.pic.o' + elif env['PLATFORM'] == 'sunos': + env['SHOBJSUFFIX'] = '.pic.o' + # determine compiler version + version = gcc.detect_version(env, env['CXX']) + if version: + env['CXXVERSION'] = version + +def exists(env): + # is executable, and is a GNU compiler (or accepts '--version' at least) + return gcc.detect_version(env, env.Detect(env.get('CXX', compilers))) + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/src/engine/SCons/Tool/hpc++.py b/src/engine/SCons/Tool/hpc++.py index 2b8ed3f..9631277 100644 --- a/src/engine/SCons/Tool/hpc++.py +++ b/src/engine/SCons/Tool/hpc++.py @@ -33,49 +33,10 @@ selection method. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -import os.path -import SCons.Util +#forward proxy to the preffered cxx version +from SCons.Tool.hpcxx import * -cplusplus = __import__('c++', globals(), locals(), []) - -acc = None - -# search for the acc compiler and linker front end - -try: - dirs = os.listdir('/opt') -except (IOError, OSError): - # Not being able to read the directory because it doesn't exist - # (IOError) or isn't readable (OSError) is okay. - dirs = [] - -for dir in dirs: - cc = '/opt/' + dir + '/bin/aCC' - if os.path.exists(cc): - acc = cc - break - - -def generate(env): - """Add Builders and construction variables for g++ to an Environment.""" - cplusplus.generate(env) - - if acc: - env['CXX'] = acc or 'aCC' - env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS +Z') - # determine version of aCC - line = os.popen(acc + ' -V 2>&1').readline().rstrip() - if line.find('aCC: HP ANSI C++') == 0: - env['CXXVERSION'] = line.split()[-1] - - if env['PLATFORM'] == 'cygwin': - env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS') - else: - env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS +Z') - -def exists(env): - return acc # Local Variables: # tab-width:4 diff --git a/src/engine/SCons/Tool/hpcxx.py b/src/engine/SCons/Tool/hpcxx.py new file mode 100644 index 0000000..2b8ed3f --- /dev/null +++ b/src/engine/SCons/Tool/hpcxx.py @@ -0,0 +1,84 @@ +"""SCons.Tool.hpc++ + +Tool-specific initialization for c++ on HP/UX. + +There normally shouldn't be any need to import this module directly. +It will usually be imported through the generic SCons.Tool.Tool() +selection method. + +""" + +# +# __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.path + +import SCons.Util + +cplusplus = __import__('c++', globals(), locals(), []) + +acc = None + +# search for the acc compiler and linker front end + +try: + dirs = os.listdir('/opt') +except (IOError, OSError): + # Not being able to read the directory because it doesn't exist + # (IOError) or isn't readable (OSError) is okay. + dirs = [] + +for dir in dirs: + cc = '/opt/' + dir + '/bin/aCC' + if os.path.exists(cc): + acc = cc + break + + +def generate(env): + """Add Builders and construction variables for g++ to an Environment.""" + cplusplus.generate(env) + + if acc: + env['CXX'] = acc or 'aCC' + env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS +Z') + # determine version of aCC + line = os.popen(acc + ' -V 2>&1').readline().rstrip() + if line.find('aCC: HP ANSI C++') == 0: + env['CXXVERSION'] = line.split()[-1] + + if env['PLATFORM'] == 'cygwin': + env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS') + else: + env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS +Z') + +def exists(env): + return acc + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/src/engine/SCons/Tool/sgic++.py b/src/engine/SCons/Tool/sgic++.py index 35547ac..63c66e2 100644 --- a/src/engine/SCons/Tool/sgic++.py +++ b/src/engine/SCons/Tool/sgic++.py @@ -33,23 +33,8 @@ selection method. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -import SCons.Util - -cplusplus = __import__('c++', globals(), locals(), []) - -def generate(env): - """Add Builders and construction variables for SGI MIPS C++ to an Environment.""" - - cplusplus.generate(env) - - env['CXX'] = 'CC' - env['CXXFLAGS'] = SCons.Util.CLVar('-LANG:std') - env['SHCXX'] = '$CXX' - env['SHOBJSUFFIX'] = '.o' - env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 1 - -def exists(env): - return env.Detect('CC') +#forward proxy to the preffered cxx version +from SCons.Tool.sgicxx import * # Local Variables: # tab-width:4 diff --git a/src/engine/SCons/Tool/sgicxx.py b/src/engine/SCons/Tool/sgicxx.py new file mode 100644 index 0000000..35547ac --- /dev/null +++ b/src/engine/SCons/Tool/sgicxx.py @@ -0,0 +1,58 @@ +"""SCons.Tool.sgic++ + +Tool-specific initialization for MIPSpro C++ on SGI. + +There normally shouldn't be any need to import this module directly. +It will usually be imported through the generic SCons.Tool.Tool() +selection method. + +""" + +# +# __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 SCons.Util + +cplusplus = __import__('c++', globals(), locals(), []) + +def generate(env): + """Add Builders and construction variables for SGI MIPS C++ to an Environment.""" + + cplusplus.generate(env) + + env['CXX'] = 'CC' + env['CXXFLAGS'] = SCons.Util.CLVar('-LANG:std') + env['SHCXX'] = '$CXX' + env['SHOBJSUFFIX'] = '.o' + env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 1 + +def exists(env): + return env.Detect('CC') + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/src/engine/SCons/Tool/sunc++.py b/src/engine/SCons/Tool/sunc++.py index 49f90ea..3304f80 100644 --- a/src/engine/SCons/Tool/sunc++.py +++ b/src/engine/SCons/Tool/sunc++.py @@ -33,107 +33,10 @@ selection method. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -import SCons -import os -import re -import subprocess +#forward proxy to the preffered cxx version +from SCons.Tool.suncxx import * -cplusplus = __import__('c++', globals(), locals(), []) - -package_info = {} - -def get_package_info(package_name, pkginfo, pkgchk): - try: - return package_info[package_name] - except KeyError: - version = None - pathname = None - try: - sadm_contents = open('/var/sadm/install/contents', 'r').read() - except EnvironmentError: - pass - else: - sadm_re = re.compile('^(\S*/bin/CC)(=\S*)? %s$' % package_name, re.M) - sadm_match = sadm_re.search(sadm_contents) - if sadm_match: - pathname = os.path.dirname(sadm_match.group(1)) - - try: - p = subprocess.Popen([pkginfo, '-l', package_name], - stdout=subprocess.PIPE, - stderr=open('/dev/null', 'w')) - except EnvironmentError: - pass - else: - pkginfo_contents = p.communicate()[0] - version_re = re.compile('^ *VERSION:\s*(.*)$', re.M) - version_match = version_re.search(pkginfo_contents) - if version_match: - version = version_match.group(1) - - if pathname is None: - try: - p = subprocess.Popen([pkgchk, '-l', package_name], - stdout=subprocess.PIPE, - stderr=open('/dev/null', 'w')) - except EnvironmentError: - pass - else: - pkgchk_contents = p.communicate()[0] - pathname_re = re.compile(r'^Pathname:\s*(.*/bin/CC)$', re.M) - pathname_match = pathname_re.search(pkgchk_contents) - if pathname_match: - pathname = os.path.dirname(pathname_match.group(1)) - - package_info[package_name] = (pathname, version) - return package_info[package_name] - -# use the package installer tool lslpp to figure out where cppc and what -# version of it is installed -def get_cppc(env): - cxx = env.subst('$CXX') - if cxx: - cppcPath = os.path.dirname(cxx) - else: - cppcPath = None - - cppcVersion = None - - pkginfo = env.subst('$PKGINFO') - pkgchk = env.subst('$PKGCHK') - - for package in ['SPROcpl']: - path, version = get_package_info(package, pkginfo, pkgchk) - if path and version: - cppcPath, cppcVersion = path, version - break - - return (cppcPath, 'CC', 'CC', cppcVersion) - -def generate(env): - """Add Builders and construction variables for SunPRO C++.""" - path, cxx, shcxx, version = get_cppc(env) - if path: - cxx = os.path.join(path, cxx) - shcxx = os.path.join(path, shcxx) - - cplusplus.generate(env) - - env['CXX'] = cxx - env['SHCXX'] = shcxx - env['CXXVERSION'] = version - env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS -KPIC') - env['SHOBJPREFIX'] = 'so_' - env['SHOBJSUFFIX'] = '.o' - -def exists(env): - path, cxx, shcxx, version = get_cppc(env) - if path and cxx: - cppc = os.path.join(path, cxx) - if os.path.exists(cppc): - return cppc - return None # Local Variables: # tab-width:4 diff --git a/src/engine/SCons/Tool/suncxx.py b/src/engine/SCons/Tool/suncxx.py new file mode 100644 index 0000000..49f90ea --- /dev/null +++ b/src/engine/SCons/Tool/suncxx.py @@ -0,0 +1,142 @@ +"""SCons.Tool.sunc++ + +Tool-specific initialization for C++ on SunOS / Solaris. + +There normally shouldn't be any need to import this module directly. +It will usually be imported through the generic SCons.Tool.Tool() +selection method. + +""" + +# +# __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 SCons + +import os +import re +import subprocess + +cplusplus = __import__('c++', globals(), locals(), []) + +package_info = {} + +def get_package_info(package_name, pkginfo, pkgchk): + try: + return package_info[package_name] + except KeyError: + version = None + pathname = None + try: + sadm_contents = open('/var/sadm/install/contents', 'r').read() + except EnvironmentError: + pass + else: + sadm_re = re.compile('^(\S*/bin/CC)(=\S*)? %s$' % package_name, re.M) + sadm_match = sadm_re.search(sadm_contents) + if sadm_match: + pathname = os.path.dirname(sadm_match.group(1)) + + try: + p = subprocess.Popen([pkginfo, '-l', package_name], + stdout=subprocess.PIPE, + stderr=open('/dev/null', 'w')) + except EnvironmentError: + pass + else: + pkginfo_contents = p.communicate()[0] + version_re = re.compile('^ *VERSION:\s*(.*)$', re.M) + version_match = version_re.search(pkginfo_contents) + if version_match: + version = version_match.group(1) + + if pathname is None: + try: + p = subprocess.Popen([pkgchk, '-l', package_name], + stdout=subprocess.PIPE, + stderr=open('/dev/null', 'w')) + except EnvironmentError: + pass + else: + pkgchk_contents = p.communicate()[0] + pathname_re = re.compile(r'^Pathname:\s*(.*/bin/CC)$', re.M) + pathname_match = pathname_re.search(pkgchk_contents) + if pathname_match: + pathname = os.path.dirname(pathname_match.group(1)) + + package_info[package_name] = (pathname, version) + return package_info[package_name] + +# use the package installer tool lslpp to figure out where cppc and what +# version of it is installed +def get_cppc(env): + cxx = env.subst('$CXX') + if cxx: + cppcPath = os.path.dirname(cxx) + else: + cppcPath = None + + cppcVersion = None + + pkginfo = env.subst('$PKGINFO') + pkgchk = env.subst('$PKGCHK') + + for package in ['SPROcpl']: + path, version = get_package_info(package, pkginfo, pkgchk) + if path and version: + cppcPath, cppcVersion = path, version + break + + return (cppcPath, 'CC', 'CC', cppcVersion) + +def generate(env): + """Add Builders and construction variables for SunPRO C++.""" + path, cxx, shcxx, version = get_cppc(env) + if path: + cxx = os.path.join(path, cxx) + shcxx = os.path.join(path, shcxx) + + cplusplus.generate(env) + + env['CXX'] = cxx + env['SHCXX'] = shcxx + env['CXXVERSION'] = version + env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS -KPIC') + env['SHOBJPREFIX'] = 'so_' + env['SHOBJSUFFIX'] = '.o' + +def exists(env): + path, cxx, shcxx, version = get_cppc(env) + if path and cxx: + cppc = os.path.join(path, cxx) + if os.path.exists(cppc): + return cppc + return None + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: -- cgit v0.12