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.
'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
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:
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:
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:
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 = ''
sys.exit(0)
""")
+
+
test.write('SConstruct', """
env = Environment(LINK = r'%s mylink.py',
F77 = r'%s myg77.py', F77FLAGS = '-x')
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)
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:
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:
sys.exit(0)
""")
+
+
test.write('SConstruct', """
env = Environment(LINK = r'%s mylink.py',
SHF77 = r'%s myg77.py')
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:
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 = ''
sys.exit(0)
""")
+
+
test.write('SConstruct', """
env = Environment(LINK = r'%s mylink.py',
SHF77 = r'%s myg77.py', SHF77FLAGS = '-x')
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)