contents = string.replace(contents, orig, replace)
self.write(fname, contents)
- def msvs_substitute(self, input, msvs_ver, subdir=None, python=sys.executable):
+ def msvs_substitute(self, input, msvs_ver, subdir=None, sconscript=None, python=sys.executable):
if not hasattr(self, '_msvs_versions'):
self.msvs_versions()
else:
workpath = self.workpath()
+ if not sconscript:
+ sconscript = self.workpath('SConstruct')
+
exec_script_main = "from os.path import join; import sys; sys.path = [ join(sys.prefix, 'Lib', 'site-packages', 'scons-%s'), join(sys.prefix, 'scons-%s'), join(sys.prefix, 'Lib', 'site-packages', 'scons'), join(sys.prefix, 'scons') ] + sys.path; import SCons.Script; SCons.Script.main()" % (self._scons_version, self._scons_version)
exec_script_main_xml = string.replace(exec_script_main, "'", "'")
result = string.replace(input, r'<WORKPATH>', workpath)
result = string.replace(result, r'<PYTHON>', python)
+ result = string.replace(result, r'<SCONSCRIPT>', sconscript)
result = string.replace(result, r'<SCONS_SCRIPT_MAIN>', exec_script_main)
result = string.replace(result, r'<SCONS_SCRIPT_MAIN_XML>', exec_script_main_xml)
return result
import TestCmd
import TestSCons
-test = TestSCons.TestSCons(match = TestCmd.match_re)
+test = TestSCons.TestSCons()
if sys.platform != 'win32':
msg = "Skipping Visual Studio test on non-Windows platform '%s'\n" % sys.platform
# End Group
# Begin Source File
-SOURCE="<WORKPATH>\SConstruct"
+SOURCE="<SCONSCRIPT>"
# End Source File
# End Target
# End Project
'''
-test.subdir('work1')
-test.write(['work1', 'SConstruct'], """\
+SConscript_contents = """\
env=Environment(MSVS_VERSION = '6.0')
testsrc = ['test.c']
misc = testmisc,
buildtarget = 'Test.exe',
variant = 'Release')
-""")
+"""
+
+
+
+test.subdir('work1')
+
+test.write(['work1', 'SConstruct'], SConscript_contents)
test.run(chdir='work1', arguments="Test.dsp")
test.must_exist(test.workpath('work1', 'Test.dsp'))
dsp = test.read(['work1', 'Test.dsp'], 'r')
-expect = test.msvs_substitute(expected_dspfile, '6.0', 'work1')
+expect = test.msvs_substitute(expected_dspfile, '6.0', 'work1',
+ test.workpath('work1', 'SConstruct'))
# don't compare the pickled data
assert dsp[:len(expect)] == expect, test.diff_substr(expect, dsp)
test.must_exist(test.workpath('work1', 'Test.dsw'))
dsw = test.read(['work1', 'Test.dsw'], 'r')
-expect = test.msvs_substitute(expected_dswfile, '6.0', 'work1')
+expect = test.msvs_substitute(expected_dswfile, '6.0', 'work1',
+ test.workpath('work1', 'SConstruct'))
assert dsw == expect, test.diff_substr(expect, dsw)
test.run(chdir='work1', arguments='-c .')
+test.subdir('work2', ['work2', 'src'])
+
+test.write(['work2', 'SConstruct'], """\
+SConscript('src/SConscript', build_dir='build')
+""")
+
+test.write(['work2', 'src', 'SConscript'], SConscript_contents)
+
+test.run(chdir='work2', arguments=".")
+
+test.must_match(['work2', 'build', 'Test.dsp'], """\
+This is just a placeholder file.
+The real project file is here:
+%s
+""" % test.workpath('work2', 'src', 'Test.dsp'),
+ mode='r')
+
+dsp = test.read(['work2', 'src', 'Test.dsp'], 'r')
+expect = test.msvs_substitute(expected_dspfile, '6.0', 'work2',
+ test.workpath('work2', 'src', 'SConscript'))
+# don't compare the pickled data
+assert dsp[:len(expect)] == expect, test.diff_substr(expect, dsp)
+
+test.must_match(['work2', 'build', 'Test.dsw'], """\
+This is just a placeholder file.
+The real workspace file is here:
+%s
+""" % test.workpath('work2', 'src', 'Test.dsw'),
+ mode='r')
+
+test.must_exist(test.workpath('work2', 'src', 'Test.dsw'))
+dsw = test.read(['work2', 'src', 'Test.dsw'], 'r')
+expect = test.msvs_substitute(expected_dswfile, '6.0', 'work2\\src')
+assert dsw == expect, test.diff_substr(expect, dsw)
+
+
+
test.pass_test()
import TestCmd
import TestSCons
-test = TestSCons.TestSCons(match = TestCmd.match_re)
+test = TestSCons.TestSCons()
if sys.platform != 'win32':
msg = "Skipping Visual Studio test on non-Windows platform '%s'\n" % sys.platform
\t\t\t</File>
\t\t</Filter>
\t\t<File
-\t\t\tRelativePath="<WORKPATH>\SConstruct">
+\t\t\tRelativePath="<SCONSCRIPT>">
\t\t</File>
\t</Files>
\t<Globals>
"""
-test.subdir('work1')
-test.write(['work1', 'SConstruct'], """\
+SConscript_contents = """\
env=Environment(MSVS_VERSION = '7.0')
testsrc = ['test.cpp']
misc = testmisc,
buildtarget = 'Test.exe',
variant = 'Release')
-""")
+"""
+
+
+
+test.subdir('work1')
+
+test.write(['work1', 'SConstruct'], SConscript_contents)
test.run(chdir='work1', arguments="Test.vcproj")
test.must_exist(test.workpath('work1', 'Test.vcproj'))
vcproj = test.read(['work1', 'Test.vcproj'], 'r')
-expect = test.msvs_substitute(expected_vcprojfile, '7.0', 'work1')
+expect = test.msvs_substitute(expected_vcprojfile, '7.0', 'work1',
+ test.workpath('work1', 'SConstruct'))
# don't compare the pickled data
assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj)
test.must_exist(test.workpath('work1', 'Test.sln'))
sln = test.read(['work1', 'Test.sln'], 'r')
-expect = test.msvs_substitute(expected_slnfile, '7.0', 'work1')
+expect = test.msvs_substitute(expected_slnfile, '7.0', 'work1',
+ test.workpath('work1', 'SConstruct'))
# don't compare the pickled data
assert sln[:len(expect)] == expect, test.diff_substr(expect, sln)
test.must_exist(test.workpath('work1', 'Test.vcproj'))
vcproj = test.read(['work1', 'Test.vcproj'], 'r')
-expect = test.msvs_substitute(expected_vcprojfile, '7.0', 'work1', python=python)
+expect = test.msvs_substitute(expected_vcprojfile, '7.0', 'work1',
+ test.workpath('work1', 'SConstruct'),
+ python=python)
# don't compare the pickled data
assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj)
+test.subdir('work2', ['work2', 'src'])
+
+test.write(['work2', 'SConstruct'], """\
+SConscript('src/SConscript', build_dir='build')
+""")
+
+test.write(['work2', 'src', 'SConscript'], SConscript_contents)
+
+test.run(chdir='work2', arguments=".")
+
+test.must_match(['work2', 'build', 'Test.vcproj'], """\
+This is just a placeholder file.
+The real project file is here:
+%s
+""" % test.workpath('work2', 'src', 'Test.vcproj'),
+ mode='r')
+
+vcproj = test.read(['work2', 'src', 'Test.vcproj'], 'r')
+expect = test.msvs_substitute(expected_vcprojfile, '7.0', 'work2',
+ test.workpath('work2', 'src', 'SConscript'))
+# don't compare the pickled data
+assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj)
+
+test.must_match(['work2', 'build', 'Test.sln'], """\
+This is just a placeholder file.
+The real workspace file is here:
+%s
+""" % test.workpath('work2', 'src', 'Test.sln'),
+ mode='r')
+
+test.must_exist(test.workpath('work2', 'src', 'Test.sln'))
+sln = test.read(['work2', 'src', 'Test.sln'], 'r')
+expect = test.msvs_substitute(expected_slnfile, '7.0', 'work2\\src')
+# don't compare the pickled data
+assert sln[:len(expect)] == expect, test.diff_substr(expect, sln)
+
+
+
test.pass_test()
import TestCmd
import TestSCons
-test = TestSCons.TestSCons(match = TestCmd.match_re)
+test = TestSCons.TestSCons()
if sys.platform != 'win32':
msg = "Skipping Visual Studio test on non-Windows platform '%s'\n" % sys.platform
\t\t\t</File>
\t\t</Filter>
\t\t<File
-\t\t\tRelativePath="<WORKPATH>\SConstruct">
+\t\t\tRelativePath="<SCONSCRIPT>">
\t\t</File>
\t</Files>
\t<Globals>
-test.subdir('work1')
-
-test.write(['work1', 'SConstruct'], """\
+SConscript_contents = """\
env=Environment(MSVS_VERSION = '7.1')
testsrc = ['test.cpp']
misc = testmisc,
buildtarget = 'Test.exe',
variant = 'Release')
-""")
+"""
+
+
+
+test.subdir('work1')
+
+test.write(['work1', 'SConstruct'], SConscript_contents)
test.run(chdir='work1', arguments="Test.vcproj")
test.must_exist(test.workpath('work1', 'Test.vcproj'))
vcproj = test.read(['work1', 'Test.vcproj'], 'r')
-expect = test.msvs_substitute(expected_vcprojfile, '7.1', 'work1')
+expect = test.msvs_substitute(expected_vcprojfile, '7.1', 'work1',
+ test.workpath('work1', 'SConstruct'))
# don't compare the pickled data
assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj)
test.must_exist(test.workpath('work1', 'Test.sln'))
sln = test.read(['work1', 'Test.sln'], 'r')
-expect = test.msvs_substitute(expected_slnfile, '7.1', 'work1')
+expect = test.msvs_substitute(expected_slnfile, '7.1', 'work1',
+ test.workpath('work1', 'SConstruct'))
# don't compare the pickled data
assert sln[:len(expect)] == expect, test.diff_substr(expect, sln)
test.must_exist(test.workpath('work1', 'Test.vcproj'))
vcproj = test.read(['work1', 'Test.vcproj'], 'r')
-expect = test.msvs_substitute(expected_vcprojfile, '7.1', 'work1', python=python)
+expect = test.msvs_substitute(expected_vcprojfile, '7.1', 'work1',
+ test.workpath('work1', 'SConstruct'),
+ python=python)
# don't compare the pickled data
assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj)
+test.subdir('work2', ['work2', 'src'])
+
+test.write(['work2', 'SConstruct'], """\
+SConscript('src/SConscript', build_dir='build')
+""")
+
+test.write(['work2', 'src', 'SConscript'], SConscript_contents)
+
+test.run(chdir='work2', arguments=".")
+
+test.must_match(['work2', 'build', 'Test.vcproj'], """\
+This is just a placeholder file.
+The real project file is here:
+%s
+""" % test.workpath('work2', 'src', 'Test.vcproj'),
+ mode='r')
+
+vcproj = test.read(['work2', 'src', 'Test.vcproj'], 'r')
+expect = test.msvs_substitute(expected_vcprojfile, '7.0', 'work2',
+ test.workpath('work2', 'src', 'SConscript'))
+# don't compare the pickled data
+assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj)
+
+test.must_match(['work2', 'build', 'Test.sln'], """\
+This is just a placeholder file.
+The real workspace file is here:
+%s
+""" % test.workpath('work2', 'src', 'Test.sln'),
+ mode='r')
+
+test.must_exist(test.workpath('work2', 'src', 'Test.sln'))
+sln = test.read(['work2', 'src', 'Test.sln'], 'r')
+expect = test.msvs_substitute(expected_slnfile, '7.0', 'work2\\src')
+# don't compare the pickled data
+assert sln[:len(expect)] == expect, test.diff_substr(expect, sln)
+
+
+
test.pass_test()