summaryrefslogtreecommitdiffstats
path: root/src/engine
diff options
context:
space:
mode:
authorAlexandre Feblot <devnull@localhost>2014-11-12 20:25:39 (GMT)
committerAlexandre Feblot <devnull@localhost>2014-11-12 20:25:39 (GMT)
commita077d347e339f38cd5559252c0234b63370bf567 (patch)
treee4a4827dcafc9cdca7d3e8e54f9c3246cc757fec /src/engine
parentc60c51f29fa2044ec13b8a3160e2f26bb3531497 (diff)
parent2d510c98fe10cbdc8328da7baea83b2ea74c0788 (diff)
downloadSCons-a077d347e339f38cd5559252c0234b63370bf567.zip
SCons-a077d347e339f38cd5559252c0234b63370bf567.tar.gz
SCons-a077d347e339f38cd5559252c0234b63370bf567.tar.bz2
merge from mainlaine
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/SCons/Environment.py5
-rw-r--r--src/engine/SCons/EnvironmentTests.py10
-rw-r--r--src/engine/SCons/Script/Main.py9
-rw-r--r--src/engine/SCons/Script/SConscript.py3
-rw-r--r--src/engine/SCons/Tool/msvs.py21
-rw-r--r--src/engine/SCons/Tool/msvsTests.py79
6 files changed, 118 insertions, 9 deletions
diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py
index 62d6809..5f2c9ff 100644
--- a/src/engine/SCons/Environment.py
+++ b/src/engine/SCons/Environment.py
@@ -719,6 +719,9 @@ class SubstitutionEnvironment(object):
t = ('-isysroot', arg)
dict['CCFLAGS'].append(t)
dict['LINKFLAGS'].append(t)
+ elif append_next_arg_to == '-isystem':
+ t = ('-isystem', arg)
+ dict['CCFLAGS'].append(t)
elif append_next_arg_to == '-arch':
t = ('-arch', arg)
dict['CCFLAGS'].append(t)
@@ -791,7 +794,7 @@ class SubstitutionEnvironment(object):
elif arg[0] == '+':
dict['CCFLAGS'].append(arg)
dict['LINKFLAGS'].append(arg)
- elif arg in ['-include', '-isysroot', '-arch']:
+ elif arg in ['-include', '-isysroot', '-isystem', '-arch']:
append_next_arg_to = arg
else:
dict['CCFLAGS'].append(arg)
diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py
index b9ef3f2..a0869e8 100644
--- a/src/engine/SCons/EnvironmentTests.py
+++ b/src/engine/SCons/EnvironmentTests.py
@@ -805,7 +805,9 @@ sys.exit(0)
"-pthread " + \
"-fopenmp " + \
"-mno-cygwin -mwindows " + \
- "-arch i386 -isysroot /tmp +DD64 " + \
+ "-arch i386 -isysroot /tmp " + \
+ "-isystem /usr/include/foo " + \
+ "+DD64 " + \
"-DFOO -DBAR=value -D BAZ "
d = env.ParseFlags(s)
@@ -815,6 +817,7 @@ sys.exit(0)
assert d['CCFLAGS'] == ['-X', '-Wa,-as',
'-pthread', '-fopenmp', '-mno-cygwin',
('-arch', 'i386'), ('-isysroot', '/tmp'),
+ ('-isystem', '/usr/include/foo'),
'+DD64'], repr(d['CCFLAGS'])
assert d['CXXFLAGS'] == ['-std=c++0x'], repr(d['CXXFLAGS'])
assert d['CPPDEFINES'] == ['FOO', ['BAR', 'value'], 'BAZ'], d['CPPDEFINES']
@@ -2051,7 +2054,9 @@ def generate(env):
"-F fwd3 " + \
"-pthread " + \
"-mno-cygwin -mwindows " + \
- "-arch i386 -isysroot /tmp +DD64 " + \
+ "-arch i386 -isysroot /tmp " + \
+ "-isystem /usr/include/foo " + \
+ "+DD64 " + \
"-DFOO -DBAR=value")
env.ParseConfig("fake $COMMAND")
assert save_command == ['fake command'], save_command
@@ -2059,6 +2064,7 @@ def generate(env):
assert env['CCFLAGS'] == ['', '-X', '-Wa,-as',
'-pthread', '-mno-cygwin',
('-arch', 'i386'), ('-isysroot', '/tmp'),
+ ('-isystem', '/usr/include/foo'),
'+DD64'], env['CCFLAGS']
assert env['CPPDEFINES'] == ['FOO', ['BAR', 'value']], env['CPPDEFINES']
assert env['CPPFLAGS'] == ['', '-Wp,-cpp'], env['CPPFLAGS']
diff --git a/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py
index 439b869..c7a9d27 100644
--- a/src/engine/SCons/Script/Main.py
+++ b/src/engine/SCons/Script/Main.py
@@ -953,6 +953,14 @@ def _main(parser):
if options.include_dir:
sys.path = options.include_dir + sys.path
+ # If we're about to start SCons in the interactive mode,
+ # inform the FS about this right here. Else, the release_target_info
+ # method could get called on some nodes, like the used "gcc" compiler,
+ # when using the Configure methods within the SConscripts.
+ # This would then cause subtle bugs, as already happened in #2971.
+ if options.interactive:
+ SCons.Node.interactive = True
+
# That should cover (most of) the options. Next, set up the variables
# that hold command-line arguments, so the SConscript files that we
# read and execute have access to them.
@@ -1082,7 +1090,6 @@ def _main(parser):
platform = SCons.Platform.platform_module()
if options.interactive:
- SCons.Node.interactive = True
SCons.Script.Interactive.interact(fs, OptionsParser, options,
targets, target_top)
diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py
index 111d091..f4a7f07 100644
--- a/src/engine/SCons/Script/SConscript.py
+++ b/src/engine/SCons/Script/SConscript.py
@@ -461,7 +461,8 @@ class SConsEnvironment(SCons.Environment.Base):
def EnsureSConsVersion(self, major, minor, revision=0):
"""Exit abnormally if the SCons version is not late enough."""
- if SCons.__version__ == '__VERSION__':
+ # split string to avoid replacement during build process
+ if SCons.__version__ == '__' + 'VERSION__':
SCons.Warnings.warn(SCons.Warnings.DevelopmentVersionWarning,
"EnsureSConsVersion is ignored for development version")
return
diff --git a/src/engine/SCons/Tool/msvs.py b/src/engine/SCons/Tool/msvs.py
index 06ce486..cb4ca55 100644
--- a/src/engine/SCons/Tool/msvs.py
+++ b/src/engine/SCons/Tool/msvs.py
@@ -289,9 +289,17 @@ class _DSPGenerator(object):
runfile.append(s)
self.sconscript = env['MSVSSCONSCRIPT']
-
- cmdargs = env.get('cmdargs', '')
-
+
+ if 'cmdargs' not in env or env['cmdargs'] == None:
+ cmdargs = [''] * len(variants)
+ elif SCons.Util.is_String(env['cmdargs']):
+ cmdargs = [env['cmdargs']] * len(variants)
+ elif SCons.Util.is_List(env['cmdargs']):
+ if len(env['cmdargs']) != len(variants):
+ raise SCons.Errors.InternalError("Sizes of 'cmdargs' and 'variant' lists must be the same.")
+ else:
+ cmdargs = env['cmdargs']
+
self.env = env
if 'name' in self.env:
@@ -354,7 +362,7 @@ class _DSPGenerator(object):
print "Adding '" + self.name + ' - ' + config.variant + '|' + config.platform + "' to '" + str(dspfile) + "'"
for i in range(len(variants)):
- AddConfig(self, variants[i], buildtarget[i], outdir[i], runfile[i], cmdargs)
+ AddConfig(self, variants[i], buildtarget[i], outdir[i], runfile[i], cmdargs[i])
self.platforms = []
for key in self.configs.keys():
@@ -892,6 +900,7 @@ V10DSPPropertyGroupCondition = """\
\t<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='%(variant)s|%(platform)s'" Label="Configuration">
\t\t<ConfigurationType>Makefile</ConfigurationType>
\t\t<UseOfMfc>false</UseOfMfc>
+\t\t<PlatformToolset>%(toolset)s</PlatformToolset>
\t</PropertyGroup>
"""
@@ -972,6 +981,10 @@ class _GenerateV10DSP(_DSPGenerator):
self.file.write('\t<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />\n')
+ toolset = ''
+ if 'MSVC_VERSION' in self.env:
+ version_num, suite = msvs_parse_version(self.env['MSVC_VERSION'])
+ toolset = 'v%d' % (version_num * 10)
for kind in confkeys:
variant = self.configs[kind].variant
platform = self.configs[kind].platform
diff --git a/src/engine/SCons/Tool/msvsTests.py b/src/engine/SCons/Tool/msvsTests.py
index 2f4f302..261dbcc 100644
--- a/src/engine/SCons/Tool/msvsTests.py
+++ b/src/engine/SCons/Tool/msvsTests.py
@@ -40,6 +40,7 @@ from SCons.Tool.MSCommon.common import debug
from SCons.Tool.MSCommon import get_default_version, \
query_versions
+from SCons.Tool.msvs import _GenerateV6DSP, _GenerateV7DSP, _GenerateV10DSP
regdata_6a = r'''[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio]
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0]
@@ -591,6 +592,84 @@ class msvsTestCase(unittest.TestCase):
assert not v1 or str(v1[0]) == self.highest_version, \
(v1, self.highest_version)
assert len(v1) == self.number_of_versions, v1
+
+ def test_config_generation(self):
+ """Test _DSPGenerator.__init__(...)"""
+ if not self.highest_version :
+ return
+
+ # Initialize 'static' variables
+ version_num, suite = msvs_parse_version(self.highest_version)
+ if version_num >= 10.0:
+ function_test = _GenerateV10DSP
+ elif version_num >= 7.0:
+ function_test = _GenerateV7DSP
+ else:
+ function_test = _GenerateV6DSP
+
+ str_function_test = str(function_test.__init__)
+ dspfile = 'test.dsp'
+ source = 'test.cpp'
+
+ # Create the cmdargs test list
+ list_variant = ['Debug|Win32','Release|Win32',
+ 'Debug|x64', 'Release|x64']
+ list_cmdargs = ['debug=True target_arch=32',
+ 'debug=False target_arch=32',
+ 'debug=True target_arch=x64',
+ 'debug=False target_arch=x64']
+
+ # Tuple list : (parameter, dictionary of expected result per variant)
+ tests_cmdargs = [(None, dict.fromkeys(list_variant, '')),
+ ('', dict.fromkeys(list_variant, '')),
+ (list_cmdargs[0], dict.fromkeys(list_variant, list_cmdargs[0])),
+ (list_cmdargs, dict(zip(list_variant, list_cmdargs)))]
+
+ # Run the test for each test case
+ for param_cmdargs, expected_cmdargs in tests_cmdargs:
+ debug('Testing %s. with :\n variant = %s \n cmdargs = "%s"' % \
+ (str_function_test, list_variant, param_cmdargs))
+ param_configs = []
+ expected_configs = {}
+ for platform in ['Win32', 'x64']:
+ for variant in ['Debug', 'Release']:
+ variant_platform = '%s|%s' % (variant, platform)
+ runfile = '%s\\%s\\test.exe' % (platform, variant)
+ buildtarget = '%s\\%s\\test.exe' % (platform, variant)
+ outdir = '%s\\%s' % (platform, variant)
+
+ # Create parameter list for this variant_platform
+ param_configs.append([variant_platform, runfile, buildtarget, outdir])
+
+ # Create expected dictionary result for this variant_platform
+ expected_configs[variant_platform] = \
+ {'variant': variant, 'platform': platform,
+ 'runfile': runfile,
+ 'buildtarget': buildtarget,
+ 'outdir': outdir,
+ 'cmdargs': expected_cmdargs[variant_platform]}
+
+ # Create parameter environment with final parameter dictionary
+ param_dict = dict(zip(('variant', 'runfile', 'buildtarget', 'outdir'),
+ [list(l) for l in zip(*param_configs)]))
+ param_dict['cmdargs'] = param_cmdargs
+
+ # Hack to be able to run the test with a 'DummyEnv'
+ class _DummyEnv(DummyEnv):
+ def subst(self, string) :
+ return string
+
+ env = _DummyEnv(param_dict)
+ env['MSVSSCONSCRIPT'] = ''
+ env['MSVS_VERSION'] = self.highest_version
+
+ # Call function to test
+ genDSP = function_test(dspfile, source, env)
+
+ # Check expected result
+ self.assertListEqual(genDSP.configs.keys(), expected_configs.keys())
+ for key in genDSP.configs.keys():
+ self.assertDictEqual(genDSP.configs[key].__dict__, expected_configs[key])
class msvs6aTestCase(msvsTestCase):
"""Test MSVS 6 Registry"""