result = string.replace(result, r'<PROJECT_GUID>', project_guid)
return result
+ def get_msvs_executable(self, version):
+ """Returns a full path to the executable (MSDEV or devenv)
+ for the specified version of Visual Studio.
+ """
+ sub_path = {
+ '6.0' : ['Common', 'MSDev98', 'Bin', 'MSDEV.COM'],
+ '7.0' : ['Common7', 'IDE', 'devenv.com'],
+ '7.1' : ['Common7', 'IDE', 'devenv.com'],
+ '8.0' : ['Common7', 'IDE', 'devenv.com'],
+ }
+ from SCons.Tool.msvs import get_msvs_install_dirs
+ vs_path = get_msvs_install_dirs(version)['VSINSTALLDIR']
+ return apply(os.path.join, [vs_path] + sub_path[version])
+
# In some environments, $AR will generate a warning message to stderr
# if the library doesn't previously exist and is being created. One
# way to fix this is to tell AR to be quiet (sometimes the 'c' flag),
- Support the --debug=memory option on Windows when the Python version
has the win32process and win32api modules.
+ - Add support for Visual Studio 2005 Pro.
+
+ - Fix Windows portability issues in various Visual Studio and
+ Java tests.
+
From Christian Maaser:
- Add support for Visual Studio Express Editions.
env['LIBLINKSUFFIX']='$LIBSUFFIX'
msvs_version = env.get('MSVS_VERSION')
- include_path, lib_path, exe_path = get_msvc_paths(msvs_version)
+ include_path, lib_path, exe_path = get_msvc_paths(env, version = msvs_version)
env['ENV']['LIB'] = lib_path
env['ENV']['PATH'] = exe_path
def get_msvc_path(env, path, version):
"""
- Get a list of visualstudio directories (include, lib or path). Return
- a string delimited by ';'. An exception will be raised if unable to
- access the registry or appropriate registry keys not found.
+ Get a list of visualstudio directories (include, lib or path).
+ Return a string delimited by the os.pathsep separator (';'). An
+ exception will be raised if unable to access the registry or
+ appropriate registry keys not found.
"""
if not SCons.Util.can_read_reg:
MVSdir = None
paths = {}
- exe_path = ''
- lib_path = ''
- include_path = ''
+ exe_paths = []
+ lib_paths = []
+ include_paths = []
try:
paths = SCons.Tool.msvs.get_msvs_install_dirs(version)
MVSdir = paths['VSINSTALLDIR']
else:
MVSVCdir = os.path.join(MVSdir,'VC')
- MVSCommondir = r'%s\Common7' % MVSdir
- include_path = r'%s\include' % (MVSVCdir)
- lib_path = r'%s\lib' % (MVSVCdir)
- exe_path = r'%s\IDE;%s\bin;%s\Tools;%s\Tools\bin' % (MVSCommondir,MVSVCdir, MVSCommondir, MVSCommondir)
+ MVSCommondir = os.path.join(MVSdir, 'Common7')
+ include_paths.append( os.path.join(MVSVCdir, 'include') )
+ lib_paths.append( os.path.join(MVSVCdir, 'lib') )
+ for base, subdir in [(MVSCommondir,'IDE'), (MVSVCdir,'bin'),
+ (MVSCommondir,'Tools'), (MVSCommondir,r'Tools\bin')]:
+ exe_paths.append( os.path.join( base, subdir) )
if paths.has_key('PLATFORMSDKDIR'):
PlatformSdkDir = paths['PLATFORMSDKDIR']
- include_path = include_path + r';%sInclude' % PlatformSdkDir
- lib_path = lib_path + r';%s\lib' % PlatformSdkDir
- if use_mfc_dirs:
- include_path = include_path + r';%sInclude\mfc;%sInclude\atl' % (PlatformSdkDir, PlatformSdkDir)
- lib_path = lib_path + r';%s\lib' % paths['PLATFORMSDKDIR']
-
- envvar = 'include'
- SCons.Util.get_environment_var(envvar)
- include_path = include_path + envvar
+ else:
+ PlatformSdkDir = os.path.join(MVSVCdir,'PlatformSDK')
+ platform_include_path = os.path.join( PlatformSdkDir, 'Include' )
+ include_paths.append( platform_include_path )
+ lib_paths.append( os.path.join( PlatformSdkDir, 'Lib' ) )
+ if use_mfc_dirs:
+ if paths.has_key('PLATFORMSDKDIR'):
+ include_paths.append( os.path.join( platform_include_path, 'mfc' ) )
+ include_paths.append( os.path.join( platform_include_path, 'atl' ) )
+ else:
+ atlmfc_path = os.path.join( MVSVCdir, 'atlmfc' )
+ include_paths.append( os.path.join( atlmfc_path, 'include' ) )
+ lib_paths.append( os.path.join( atlmfc_path, 'lib' ) )
+
+ env_include_path = SCons.Util.get_environment_var('INCLUDE')
+ if env_include_path:
+ include_paths.append( env_include_path )
if SCons.Util.can_read_reg and paths.has_key('FRAMEWORKSDKDIR'):
- include_path = include_path + r';%s\include'%paths['FRAMEWORKSDKDIR']
- lib_path = lib_path + r';%s\lib'%paths['FRAMEWORKSDKDIR']
- exe_path = exe_path + r';%s\bin'%paths['FRAMEWORKSDKDIR']
+ include_paths.append( os.path.join( paths['FRAMEWORKSDKDIR'], 'include' ) )
+ lib_paths.append( os.path.join( paths['FRAMEWORKSDKDIR'], 'lib' ) )
+ exe_paths.append( paths['FRAMEWORKSDKDIR'], 'bin' )
if SCons.Util.can_read_reg and paths.has_key('FRAMEWORKDIR') and paths.has_key('FRAMEWORKVERSION'):
- exe_path = exe_path + r';%s\%s'%(paths['FRAMEWORKDIR'],paths['FRAMEWORKVERSION'])
+ exe_paths.append( os.path.join( paths['FRAMEWORKDIR'], paths['FRAMEWORKVERSION'] ) )
+ include_path = string.join( include_paths, os.pathsep )
+ lib_path = string.join(lib_paths, os.pathsep )
+ exe_path = string.join(exe_paths, os.pathsep )
return (include_path, lib_path, exe_path)
def get_msvc_paths(env, version=None, use_mfc_dirs=0):
env['PCHCOM'] = '$CXX $CXXFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS /c $SOURCES /Fo${TARGETS[1]} /Yc$PCHSTOP /Fp${TARGETS[0]} $CCPDBFLAGS $PCHPDBFLAGS'
env['BUILDERS']['PCH'] = pch_builder
+ if not env.has_key('ENV'):
+ env['ENV'] = {}
+ if not env['ENV'].has_key('SystemRoot'): # required for dlls in the winsxs folders
+ env['ENV']['SystemRoot'] = SCons.Platform.win32.get_system_root()
+
def exists(env):
if SCons.Tool.msvs.is_msvs_installed():
# there's at least one version of MSVS installed.
if not env.has_key('MSVS') or not SCons.Util.is_Dict(env['MSVS']):
env['MSVS'] = {}
- if SCons.Util.can_read_reg:
+ if env['MSVS'].has_key('VERSIONS'):
+ versions = env['MSVS']['VERSIONS']
+ elif SCons.Util.can_read_reg:
v = get_visualstudio_versions()
if v:
versions = v
suites = []
- # ToDo: add tests for better suits than VS8 Express here.
+ # Detect Standard, Professional and Team edition
+ try:
+ idk = SCons.Util.RegOpenKeyEx(SCons.Util.HKEY_LOCAL_MACHINE,
+ r'Software\Microsoft\VisualStudio\8.0')
+ id = SCons.Util.RegQueryValueEx(idk, 'InstallDir')
+ editions = { 'PRO': r'Setup\VS\Pro' } # ToDo: add standard and team editions
+ edition_name = 'STD'
+ for name, key_suffix in editions.items():
+ try:
+ idk = SCons.Util.RegOpenKeyEx(SCons.Util.HKEY_LOCAL_MACHINE,
+ r'Software\Microsoft\VisualStudio\8.0' + '\\' + key_suffix )
+ edition_name = name
+ except SCons.Util.RegError:
+ pass
+ suites.append(edition_name)
+ except SCons.Util.RegError:
+ pass
- idk = SCons.Util.RegOpenKeyEx(SCons.Util.HKEY_LOCAL_MACHINE,
- r'Software\Microsoft\VCExpress\8.0')
+ # Detect Expression edition
try:
+ idk = SCons.Util.RegOpenKeyEx(SCons.Util.HKEY_LOCAL_MACHINE,
+ r'Software\Microsoft\VCExpress\8.0')
id = SCons.Util.RegQueryValueEx(idk, 'InstallDir')
suites.append('EXPRESS')
except SCons.Util.RegError:
version_num, suite = msvs_parse_version(version)
+ K = 'Software\\Microsoft\\VisualStudio\\' + str(version_num)
if (version_num >= 8.0):
- K = 'Software\\Microsoft\\VCExpress\\' + str(version_num)
- else:
- K = 'Software\\Microsoft\\VisualStudio\\' + str(version_num)
+ try:
+ SCons.Util.RegOpenKeyEx(SCons.Util.HKEY_LOCAL_MACHINE, K )
+ except SCons.Util.RegError:
+ K = 'Software\\Microsoft\\VCExpress\\' + str(version_num)
# vc++ install dir
rv = {}
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import os
+import os.path
import string
import sys
import TestSCons
test.write('SConstruct', """
foo = Environment(tools = ['javac', 'jar'],
- JAVAC = '%(where_javac)s',
- JAR = '%(where_jar)s')
+ JAVAC = r'%(where_javac)s',
+ JAR = r'%(where_jar)s')
jar = foo.Dictionary('JAR')
bar = foo.Copy(JAR = r'%(python)s wrapper.py ' + jar)
foo.Java(target = 'classes', source = 'com/sub/foo')
test.run(arguments = '.')
+expected_wrapper_out = "wrapper.py %(where_jar)s cf bar.jar classes/com/sub/bar\n"
+expected_wrapper_out = string.replace(expected_wrapper_out, '/', os.sep)
test.must_match('wrapper.out',
- "wrapper.py %(where_jar)s cf bar.jar classes/com/sub/bar\n" % locals())
+ expected_wrapper_out % locals())
test.must_exist('foo.jar')
test.must_exist('bar.jar')
if not where_javac:
test.skip_test("Could not find Java javac, skipping test(s).\n")
+if test.detect_tool('jar', ENV=ENV):
+ where_jar = test.detect('JAR', 'jar', ENV=ENV)
+else:
+ where_jar = test.where_is('jar')
+if not where_jar:
+ test.skip_test("Could not find Java jar, skipping test(s).\n")
+
test.write('SConstruct', """
dir = 'dist'
env = Environment(tools = ['javac', 'jar'],
- JAVAC = '%(where_javac)s',
+ JAVAC = r'%(where_javac)s',
+ JAR = r'%(where_jar)s',
JARCHDIR = dir)
bin = env.Java(dir, Dir('./'))
jar = env.Jar(File('c.jar', dir), bin)
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
-import os.path
+import os
+import string
import TestSCons
if test.detect_tool('jar', ENV=ENV):
where_jar = test.detect('JAR', 'jar', ENV=ENV)
else:
- where_javac = test.where_is('jar')
+ where_jar = test.where_is('jar')
if not where_jar:
test.skip_test("Could not find Java jar, skipping test(s).\n")
test.write('SConstruct', """
env = Environment(tools = ['javac', 'jar'],
- JAVAC = '%(where_javac)s',
- JAR = '%(where_jar)s',
+ JAVAC = r'%(where_javac)s',
+ JAR = r'%(where_jar)s',
JARFLAGS = 'cvf')
env['JARFLAGS'] = 'cvf'
class_files = env.Java(target = 'classes', source = 'src')
}
""")
-test.run(arguments = '.',
- match=TestSCons.match_re_dotall,
- stdout = test.wrap_stdout("""\
+expect = test.wrap_stdout("""\
%(where_javac)s -d classes -sourcepath src src/Example1\.java
%(where_jar)s cvf test.jar classes/src/Example1\.class
.*
adding: classes/src/Example1\.class.*
-""" % locals()))
+""" % locals())
+
+expect = string.replace(expect, '/', os.sep)
+
+test.run(arguments = '.',
+ match=TestSCons.match_re_dotall,
+ stdout = expect)
test.must_exist('test.jar')
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import os
+import os.path
import string
import sys
import TestSCons
test.write('SConstruct', """
foo = Environment(tools = ['javac'],
- JAVAC = '%s')
+ JAVAC = r'%s')
javac = foo.Dictionary('JAVAC')
bar = foo.Copy(JAVAC = r'%s wrapper.py ' + javac)
foo.Java(target = 'class1', source = 'com/sub/foo')
test.run(arguments = '.')
-test.must_match('wrapper.out', "wrapper.py %s -d class2 -sourcepath com/sub/bar com/sub/bar/Example4.java com/sub/bar/Example5.java com/sub/bar/Example6.java\n" % where_javac)
+expected_wrapper_out = "wrapper.py %s -d class2 -sourcepath com/sub/bar com/sub/bar/Example4.java com/sub/bar/Example5.java com/sub/bar/Example6.java\n"
+expected_wrapper_out = string.replace(expected_wrapper_out, '/', os.sep)
+test.must_match('wrapper.out', expected_wrapper_out % where_javac)
test.must_exist(test.workpath('class1', 'com', 'sub', 'foo', 'Example1.class'))
test.must_exist(test.workpath('class1', 'com', 'other', 'Example2.class'))
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
-import os.path
+import os
+import string
import TestSCons
test.write('SConstruct', """
env = Environment(tools = ['javac'],
- JAVAC = '%(where_javac)s',
+ JAVAC = r'%(where_javac)s',
JAVACFLAGS = '-O')
env.Java(target = 'classes', source = 'src')
""" % locals())
}
""")
+expected_wrapper_out = "%(where_javac)s -O -d classes -sourcepath src src/Example1.java\n"
+expected_wrapper_out = string.replace(expected_wrapper_out, '/', os.sep)
test.run(arguments = '.',
- stdout = test.wrap_stdout("%(where_javac)s -O -d classes -sourcepath src src/Example1.java\n" % locals()))
+ stdout = test.wrap_stdout(expected_wrapper_out % locals()))
test.must_exist(['classes', 'src', 'Example1.class'])
test.write('SConstruct', """
foo = Environment(tools = ['javac', 'javah'],
- JAVAC = '%(where_javac)s',
- JAVAH = '%(where_javah)s')
+ JAVAC = r'%(where_javac)s',
+ JAVAH = r'%(where_javah)s')
javah = foo.Dictionary('JAVAH')
bar = foo.Copy(JAVAH = r'%(python)s wrapper.py ' + javah)
foo.Java(target = 'class1', source = 'com/sub/foo')
test.fail_test(test.read(['outdir', 'test2.class']) != "test2.JAVA\nline 3\n")
-
-if not os.path.exists('/usr/local/j2sdk1.3.1/bin/rmic'):
- test.skip_test("Could not find Java; skipping non-simulated test(s).\n")
-
-
+ENV = test.java_ENV()
+
+if test.detect_tool('javac', ENV=ENV):
+ where_javac = test.detect('JAVAC', 'javac', ENV=ENV)
+else:
+ where_javac = test.where_is('javac')
+if not where_javac:
+ test.skip_test("Could not find Java javac, skipping non-simulated test(s).\n")
+
+if test.detect_tool('rmic', ENV=ENV):
+ where_rmic = test.detect('JAVAC', 'rmic', ENV=ENV)
+else:
+ where_rmic = test.where_is('rmic')
+if not where_rmic:
+ test.skip_test("Could not find Java rmic, skipping non-simulated test(s).\n")
test.write("wrapper.py", """\
import os
test.write('SConstruct', """
import string
foo = Environment(tools = ['javac', 'rmic'],
- JAVAC = '/usr/local/j2sdk1.3.1/bin/javac',
- RMIC = '/usr/local/j2sdk1.3.1/bin/rmic')
+ JAVAC = r'%(where_javac)s',
+ RMIC = r'%(where_rmic)s')
foo.Java(target = 'class1', source = 'com/sub/foo')
foo.RMIC(target = 'outdir1',
source = ['class1/com/sub/foo/Example1.class',
JAVACLASSDIR = 'class1')
rmic = foo.Dictionary('RMIC')
-bar = foo.Copy(RMIC = r'%s wrapper.py ' + rmic)
+bar = foo.Copy(RMIC = r'%(python)s wrapper.py ' + rmic)
bar_classes = bar.Java(target = 'class2', source = 'com/sub/bar')
# XXX This is kind of a Python brute-force way to do what Ant
# does with its "excludes" attribute. We should probably find
# a similar friendlier way to do this.
bar_classes = filter(lambda c: string.find(str(c), 'Hello') == -1, bar_classes)
bar.RMIC(target = Dir('outdir2'), source = bar_classes)
-""" % python)
+""" % locals() )
test.subdir('com',
['com', 'other'],
test.run(arguments = '.')
-test.fail_test(test.read('wrapper.out') != "wrapper.py /usr/local/j2sdk1.3.1/bin/rmic -d outdir2 -classpath class2 com.sub.bar.Example3 com.sub.bar.Example4\n")
+test.fail_test(test.read('wrapper.out') != "wrapper.py %s -d outdir2 -classpath class2 com.sub.bar.Example3 com.sub.bar.Example4\n" % where_rmic)
test.fail_test(not os.path.exists(test.workpath('outdir1', 'com', 'sub', 'foo', 'Example1_Skel.class')))
test.fail_test(not os.path.exists(test.workpath('outdir1', 'com', 'sub', 'foo', 'Example1_Stub.class')))
test.run(chdir='sub dir', arguments='.')
test.run(chdir='sub dir',
- program=['msdev'],
+ program=[test.get_msvs_executable('6.0')],
arguments=['Test.dsp', '/MAKE', 'foo - Win32 Release'])
test.run(program=test.workpath('sub dir', 'foo'), stdout="foo.c\n")
test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcproj'))
test.run(chdir='sub dir',
- program=['devenv'],
+ program=[test.get_msvs_executable('7.0')],
arguments=['foo.sln', '/build', 'Release'])
test.run(program=test.workpath('sub dir', 'foo'), stdout="foo.c\n")
test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcproj'))
test.run(chdir='sub dir',
- program=['devenv'],
+ program=[test.get_msvs_executable('7.1')],
arguments=['foo.sln', '/build', 'Release'])
test.run(program=test.workpath('sub dir', 'foo'), stdout="foo.c\n")
test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcproj'))
+import SCons.Platform.win32
+system_dll_path = os.path.join( SCons.Platform.win32.get_system_root(), 'System32' )
+os.environ['PATH'] = os.environ['PATH'] + os.pathsep + system_dll_path
+
test.run(chdir='sub dir',
- program=['devenv'],
+ program=[test.get_msvs_executable('8.0')],
arguments=['foo.sln', '/build', 'Release'])
test.run(program=test.workpath('sub dir', 'foo'), stdout="foo.c\n")