From 9afa958bb1b299c47b3197589ab7b9b89686cc6b Mon Sep 17 00:00:00 2001 From: Steven Knight Date: Mon, 22 Apr 2002 04:32:17 +0000 Subject: Fix Fortran arguments on Win32. --- src/CHANGES.txt | 2 ++ src/engine/SCons/Defaults.py | 8 +++--- test/F77.py | 31 ++++++++++++++++----- test/F77FLAGS.py | 64 +++++++++++++++++++++++++++++++------------- test/SHF77.py | 33 ++++++++++++++++++----- test/SHF77FLAGS.py | 58 ++++++++++++++++++++++++++++++--------- 6 files changed, 146 insertions(+), 50 deletions(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 019b8e7..29857f9 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -68,6 +68,8 @@ RELEASE 0.07 - that writes to a temporary file and uses the magic MSVC "link @file" argument syntax if the line is longer than 2K characters. + - Fix F77 command-line options on Win32 (use /Fo instead of -o). + From Steve Leblanc: - Add the SConscriptChdir() method. diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py index a0b1157..8856db5 100644 --- a/src/engine/SCons/Defaults.py +++ b/src/engine/SCons/Defaults.py @@ -406,12 +406,12 @@ def make_win32_env_from_paths(include, lib, path): 'CXXFILESUFFIX' : '.cc', 'F77' : 'g77', 'F77FLAGS' : '', - 'F77COM' : '$F77 $F77FLAGS $_INCFLAGS -c -o $TARGET $SOURCES', - 'F77PPCOM' : '$F77 $F77FLAGS $CPPFLAGS $_INCFLAGS -c -o $TARGET $SOURCES', + 'F77COM' : '$F77 $F77FLAGS $_INCFLAGS /c $SOURCES /Fo$TARGET', + 'F77PPCOM' : '$F77 $F77FLAGS $CPPFLAGS $_INCFLAGS /c $SOURCES /Fo$TARGET', 'SHF77' : '$F77', 'SHF77FLAGS' : '$F77FLAGS', - 'SHF77COM' : '$SHF77 $SHF77FLAGS $_INCFLAGS -c -o $TARGET $SOURCES', - 'SHF77PPCOM' : '$SHF77 $SHF77FLAGS $CPPFLAGS $_INCFLAGS -c -o $TARGET $SOURCES', + 'SHF77COM' : '$SHF77 $SHF77FLAGS $_INCFLAGS /c $SOURCES /Fo$TARGET', + 'SHF77PPCOM' : '$SHF77 $SHF77FLAGS $CPPFLAGS $_INCFLAGS /c $SOURCES /Fo$TARGET', 'LINK' : 'link', 'LINKFLAGS' : '/nologo', # XXX - We'd like to do this as follows, but '$LINKCOM' in diff --git a/test/F77.py b/test/F77.py index 40a749e..964682d 100644 --- a/test/F77.py +++ b/test/F77.py @@ -43,16 +43,15 @@ test = TestSCons.TestSCons() if sys.platform == 'win32': test.write('mylink.py', r""" -import getopt -import os +import string import sys args = sys.argv[1:] while args: a = args[0] if a[0] != '/': break - args.pop(0) - if a[:5] == '/OUT:': out = a[5:] + args = args[1:] + if string.lower(a[:5]) == '/out:': out = a[5:] infile = open(args[0], 'rb') outfile = open(out, 'wb') for l in infile.readlines(): @@ -61,11 +60,30 @@ for l in infile.readlines(): sys.exit(0) """) + test.write('myg77.py', r""" +import sys +args = sys.argv[1:] +inf = None +while args: + a = args[0] + args = args[1:] + if a[0] != '/': + if not inf: + inf = a + continue + if a[:3] == '/Fo': out = a[3:] +infile = open(inf, 'rb') +outfile = open(out, 'wb') +for l in infile.readlines(): + if l[:4] != '#g77': + outfile.write(l) +sys.exit(0) +""") + else: test.write('mylink.py', r""" import getopt -import os import sys opts, args = getopt.getopt(sys.argv[1:], 'o:') for opt, arg in opts: @@ -78,9 +96,8 @@ for l in infile.readlines(): sys.exit(0) """) -test.write('myg77.py', r""" + test.write('myg77.py', r""" import getopt -import os import sys opts, args = getopt.getopt(sys.argv[1:], 'co:') for opt, arg in opts: diff --git a/test/F77FLAGS.py b/test/F77FLAGS.py index b3e7b31..5241e7b 100644 --- a/test/F77FLAGS.py +++ b/test/F77FLAGS.py @@ -31,28 +31,25 @@ import TestSCons python = sys.executable -if sys.platform == 'win32': - _exe = '.exe' -else: - _exe = '' - test = TestSCons.TestSCons() - if sys.platform == 'win32': + _exe = '.exe' + + o = ' -x /c' + test.write('mylink.py', r""" -import getopt -import os +import string import sys args = sys.argv[1:] while args: a = args[0] if a[0] != '/': break - args.pop(0) - if a[:5] == '/OUT:': out = a[5:] + args = args[1:] + if string.lower(a[:5]) == '/out:': out = a[5:] infile = open(args[0], 'rb') outfile = open(out, 'wb') for l in infile.readlines(): @@ -61,11 +58,39 @@ for l in infile.readlines(): sys.exit(0) """) + test.write('myg77.py', r""" +import sys +args = sys.argv[1:] +inf = None +optstring = '' +while args: + a = args[0] + args = args[1:] + if not a[0] in '/-': + if not inf: + inf = a + continue + if a[:3] == '/Fo': + out = a[3:] + continue + optstring = optstring + ' ' + a +infile = open(inf, 'rb') +outfile = open(out, 'wb') +outfile.write(optstring + "\n") +for l in infile.readlines(): + if l[:4] != '#g77': + outfile.write(l) +sys.exit(0) +""") + else: + _exe = '' + + o = ' -x -c' + test.write('mylink.py', r""" import getopt -import os import sys opts, args = getopt.getopt(sys.argv[1:], 'o:') for opt, arg in opts: @@ -78,9 +103,8 @@ for l in infile.readlines(): sys.exit(0) """) -test.write('myg77.py', r""" + test.write('myg77.py', r""" import getopt -import os import sys opts, args = getopt.getopt(sys.argv[1:], 'co:x') optstring = '' @@ -96,6 +120,8 @@ for l in infile.readlines(): sys.exit(0) """) + + test.write('SConstruct', """ env = Environment(LINK = r'%s mylink.py', F77 = r'%s myg77.py', F77FLAGS = '-x') @@ -139,17 +165,17 @@ test.write('test6.FPP', r"""This is a .FPP file. test.run(arguments = '.', stderr = None) -test.fail_test(test.read('test1' + _exe) != " -x -c\nThis is a .f file.\n") +test.fail_test(test.read('test1' + _exe) != "%s\nThis is a .f file.\n" % o) -test.fail_test(test.read('test2' + _exe) != " -x -c\nThis is a .for file.\n") +test.fail_test(test.read('test2' + _exe) != "%s\nThis is a .for file.\n" % o) -test.fail_test(test.read('test3' + _exe) != " -x -c\nThis is a .FOR file.\n") +test.fail_test(test.read('test3' + _exe) != "%s\nThis is a .FOR file.\n" % o) -test.fail_test(test.read('test4' + _exe) != " -x -c\nThis is a .F file.\n") +test.fail_test(test.read('test4' + _exe) != "%s\nThis is a .F file.\n" % o) -test.fail_test(test.read('test5' + _exe) != " -x -c\nThis is a .fpp file.\n") +test.fail_test(test.read('test5' + _exe) != "%s\nThis is a .fpp file.\n" % o) -test.fail_test(test.read('test6' + _exe) != " -x -c\nThis is a .FPP file.\n") +test.fail_test(test.read('test6' + _exe) != "%s\nThis is a .FPP file.\n" % o) diff --git a/test/SHF77.py b/test/SHF77.py index 5391170..43c6485 100644 --- a/test/SHF77.py +++ b/test/SHF77.py @@ -43,16 +43,15 @@ test = TestSCons.TestSCons() if sys.platform == 'win32': test.write('mylink.py', r""" -import getopt -import os +import string import sys args = sys.argv[1:] while args: a = args[0] if a[0] != '/': break - args.pop(0) - if a[:5] == '/OUT:': out = a[5:] + args = args[1:] + if string.lower(a[:5]) == '/out:': out = a[5:] infile = open(args[0], 'rb') outfile = open(out, 'wb') for l in infile.readlines(): @@ -61,11 +60,30 @@ for l in infile.readlines(): sys.exit(0) """) + test.write('myg77.py', r""" +import sys +args = sys.argv[1:] +inf = None +while args: + a = args[0] + args = args[1:] + if a[0] != '/': + if not inf: + inf = a + continue + if a[:3] == '/Fo': out = a[3:] +infile = open(inf, 'rb') +outfile = open(out, 'wb') +for l in infile.readlines(): + if l[:4] != '#g77': + outfile.write(l) +sys.exit(0) +""") + else: test.write('mylink.py', r""" import getopt -import os import sys opts, args = getopt.getopt(sys.argv[1:], 'o:') for opt, arg in opts: @@ -78,9 +96,8 @@ for l in infile.readlines(): sys.exit(0) """) -test.write('myg77.py', r""" + test.write('myg77.py', r""" import getopt -import os import sys opts, args = getopt.getopt(sys.argv[1:], 'cf:o:') for opt, arg in opts: @@ -93,6 +110,8 @@ for l in infile.readlines(): sys.exit(0) """) + + test.write('SConstruct', """ env = Environment(LINK = r'%s mylink.py', SHF77 = r'%s myg77.py') diff --git a/test/SHF77FLAGS.py b/test/SHF77FLAGS.py index e8b5213..cb1e6f6 100644 --- a/test/SHF77FLAGS.py +++ b/test/SHF77FLAGS.py @@ -42,17 +42,20 @@ test = TestSCons.TestSCons() if sys.platform == 'win32': + _exe = '.exe' + + o = ' -x /c' + test.write('mylink.py', r""" -import getopt -import os +import string import sys args = sys.argv[1:] while args: a = args[0] if a[0] != '/': break - args.pop(0) - if a[:5] == '/OUT:': out = a[5:] + args = args[1:] + if string.lower(a[:5]) == '/out:': out = a[5:] infile = open(args[0], 'rb') outfile = open(out, 'wb') for l in infile.readlines(): @@ -61,11 +64,39 @@ for l in infile.readlines(): sys.exit(0) """) + test.write('myg77.py', r""" +import sys +args = sys.argv[1:] +inf = None +optstring = '' +while args: + a = args[0] + args = args[1:] + if not a[0] in '/-': + if not inf: + inf = a + continue + if a[:3] == '/Fo': + out = a[3:] + continue + optstring = optstring + ' ' + a +infile = open(inf, 'rb') +outfile = open(out, 'wb') +outfile.write(optstring + "\n") +for l in infile.readlines(): + if l[:4] != '#g77': + outfile.write(l) +sys.exit(0) +""") + else: + _exe = '' + + o = ' -x -c' + test.write('mylink.py', r""" import getopt -import os import sys opts, args = getopt.getopt(sys.argv[1:], 'o:') for opt, arg in opts: @@ -78,9 +109,8 @@ for l in infile.readlines(): sys.exit(0) """) -test.write('myg77.py', r""" + test.write('myg77.py', r""" import getopt -import os import sys opts, args = getopt.getopt(sys.argv[1:], 'co:x') optstring = '' @@ -96,6 +126,8 @@ for l in infile.readlines(): sys.exit(0) """) + + test.write('SConstruct', """ env = Environment(LINK = r'%s mylink.py', SHF77 = r'%s myg77.py', SHF77FLAGS = '-x') @@ -139,17 +171,17 @@ test.write('test6.FPP', r"""This is a .FPP file. test.run(arguments = '.', stderr = None) -test.fail_test(test.read('test1' + _exe) != " -x -c\nThis is a .f file.\n") +test.fail_test(test.read('test1' + _exe) != "%s\nThis is a .f file.\n" % o) -test.fail_test(test.read('test2' + _exe) != " -x -c\nThis is a .for file.\n") +test.fail_test(test.read('test2' + _exe) != "%s\nThis is a .for file.\n" % o) -test.fail_test(test.read('test3' + _exe) != " -x -c\nThis is a .FOR file.\n") +test.fail_test(test.read('test3' + _exe) != "%s\nThis is a .FOR file.\n" % o) -test.fail_test(test.read('test4' + _exe) != " -x -c\nThis is a .F file.\n") +test.fail_test(test.read('test4' + _exe) != "%s\nThis is a .F file.\n" % o) -test.fail_test(test.read('test5' + _exe) != " -x -c\nThis is a .fpp file.\n") +test.fail_test(test.read('test5' + _exe) != "%s\nThis is a .fpp file.\n" % o) -test.fail_test(test.read('test6' + _exe) != " -x -c\nThis is a .FPP file.\n") +test.fail_test(test.read('test6' + _exe) != "%s\nThis is a .FPP file.\n" % o) -- cgit v0.12