From: stevenknight Date: Mon, 22 Apr 2002 04:32:17 +0000 (+0000) Subject: Fix Fortran arguments on Win32. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=db7c4736fa82424a67ac01d469da54a25a2d7d0b;p=scons.git Fix Fortran arguments on Win32. git-svn-id: http://scons.tigris.org/svn/scons/trunk@337 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 019b8e70..29857f9e 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 a0b11577..8856db52 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 40a749e4..964682d2 100644 --- a/test/F77.py +++ b/test/F77.py @@ -43,29 +43,47 @@ 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(): if l[:5] != '#link': outfile.write(l) 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 b3e7b310..5241e7b5 100644 --- a/test/F77FLAGS.py +++ b/test/F77FLAGS.py @@ -31,41 +31,66 @@ 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(): if l[:5] != '#link': outfile.write(l) 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 5391170e..43c64858 100644 --- a/test/SHF77.py +++ b/test/SHF77.py @@ -43,29 +43,47 @@ 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(): if l[:5] != '#link': outfile.write(l) 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 e8b52132..cb1e6f68 100644 --- a/test/SHF77FLAGS.py +++ b/test/SHF77FLAGS.py @@ -42,30 +42,61 @@ 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(): if l[:5] != '#link': outfile.write(l) 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)