More cleanups to scons.

This commit is contained in:
Relintai 2022-03-20 01:42:37 +01:00
parent 56654077b4
commit 27ebad5fdd
6 changed files with 2 additions and 1834 deletions

View File

@ -1,575 +0,0 @@
# MIT License
#
# Copyright The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import unittest
import random
import math
import sys
import time
import os
import TestUnit
import SCons.Job
def get_cpu_nums():
# Linux, Unix and MacOS:
if hasattr( os, "sysconf" ):
if "SC_NPROCESSORS_ONLN" in os.sysconf_names:
# Linux & Unix:
ncpus = os.sysconf( "SC_NPROCESSORS_ONLN" )
if isinstance(ncpus, int) and ncpus > 0:
return ncpus
else: # OSX:
return int(os.popen2("sysctl -n hw.ncpu")[1].read() )
# Windows:
if "NUMBER_OF_PROCESSORS" in os.environ:
ncpus = int(os.environ["NUMBER_OF_PROCESSORS"])
if ncpus > 0:
return ncpus
return 1 # Default
# a large number
num_sines = 500
# how many parallel jobs to perform for the test
num_jobs = get_cpu_nums()*2
# in case we werent able to detect num cpus for this test
# just make a hardcoded suffcient large number, though not future proof
if num_jobs == 2:
num_jobs = 33
# how many tasks to perform for the test
num_tasks = num_jobs*5
class DummyLock:
"""fake lock class to use if threads are not supported"""
def acquire(self):
pass
def release(self):
pass
class NoThreadsException(Exception):
"""raised by the ParallelTestCase if threads are not supported"""
def __str__(self):
return "the interpreter doesn't support threads"
class Task:
"""A dummy task class for testing purposes."""
def __init__(self, i, taskmaster):
self.i = i
self.taskmaster = taskmaster
self.was_executed = 0
self.was_prepared = 0
def prepare(self):
self.was_prepared = 1
def _do_something(self):
pass
def needs_execute(self):
return True
def execute(self):
self.taskmaster.test_case.assertTrue(self.was_prepared,
"the task wasn't prepared")
self.taskmaster.guard.acquire()
self.taskmaster.begin_list.append(self.i)
self.taskmaster.guard.release()
# while task is executing, represent this in the parallel_list
# and then turn it off
self.taskmaster.parallel_list[self.i] = 1
self._do_something()
self.taskmaster.parallel_list[self.i] = 0
# check if task was executing while another was also executing
for j in range(1, self.taskmaster.num_tasks):
if self.taskmaster.parallel_list[j + 1] == 1:
self.taskmaster.found_parallel = True
break
self.was_executed = 1
self.taskmaster.guard.acquire()
self.taskmaster.end_list.append(self.i)
self.taskmaster.guard.release()
def executed(self):
self.taskmaster.num_executed = self.taskmaster.num_executed + 1
self.taskmaster.test_case.assertTrue(self.was_prepared,
"the task wasn't prepared")
self.taskmaster.test_case.assertTrue(self.was_executed,
"the task wasn't really executed")
self.taskmaster.test_case.assertTrue(isinstance(self, Task),
"the task wasn't really a Task instance")
def failed(self):
self.taskmaster.num_failed = self.taskmaster.num_failed + 1
self.taskmaster.stop = 1
self.taskmaster.test_case.assertTrue(self.was_prepared,
"the task wasn't prepared")
def postprocess(self):
self.taskmaster.num_postprocessed = self.taskmaster.num_postprocessed + 1
def exception_set(self):
pass
class RandomTask(Task):
def _do_something(self):
# do something that will take some random amount of time:
for i in range(random.randrange(0, 100 + num_sines, 1)):
x = math.sin(i)
time.sleep(0.01)
class ExceptionTask:
"""A dummy task class for testing purposes."""
def __init__(self, i, taskmaster):
self.taskmaster = taskmaster
self.was_prepared = 0
def prepare(self):
self.was_prepared = 1
def needs_execute(self):
return True
def execute(self):
raise Exception
def executed(self):
self.taskmaster.num_executed = self.taskmaster.num_executed + 1
self.taskmaster.test_case.assertTrue(self.was_prepared,
"the task wasn't prepared")
self.taskmaster.test_case.assertTrue(self.was_executed,
"the task wasn't really executed")
self.taskmaster.test_case.assertTrue(self.__class__ is Task,
"the task wasn't really a Task instance")
def failed(self):
self.taskmaster.num_failed = self.taskmaster.num_failed + 1
self.taskmaster.stop = 1
self.taskmaster.test_case.assertTrue(self.was_prepared,
"the task wasn't prepared")
def postprocess(self):
self.taskmaster.num_postprocessed = self.taskmaster.num_postprocessed + 1
def exception_set(self):
self.taskmaster.exception_set()
class Taskmaster:
"""A dummy taskmaster class for testing the job classes."""
def __init__(self, n, test_case, Task):
"""n is the number of dummy tasks to perform."""
self.test_case = test_case
self.stop = None
self.num_tasks = n
self.num_iterated = 0
self.num_executed = 0
self.num_failed = 0
self.num_postprocessed = 0
self.parallel_list = [0] * (n+1)
self.found_parallel = False
self.Task = Task
# 'guard' guards 'task_begin_list' and 'task_end_list'
try:
import threading
self.guard = threading.Lock()
except ImportError:
self.guard = DummyLock()
# keep track of the order tasks are begun in
self.begin_list = []
# keep track of the order tasks are completed in
self.end_list = []
def next_task(self):
if self.stop or self.all_tasks_are_iterated():
return None
else:
self.num_iterated = self.num_iterated + 1
return self.Task(self.num_iterated, self)
def all_tasks_are_executed(self):
return self.num_executed == self.num_tasks
def all_tasks_are_iterated(self):
return self.num_iterated == self.num_tasks
def all_tasks_are_postprocessed(self):
return self.num_postprocessed == self.num_tasks
def tasks_were_serial(self):
"""analyze the task order to see if they were serial"""
return not self.found_parallel
def exception_set(self):
pass
def cleanup(self):
pass
SaveThreadPool = None
ThreadPoolCallList = []
class ParallelTestCase(unittest.TestCase):
def runTest(self):
"""test parallel jobs"""
try:
import threading
except ImportError:
raise NoThreadsException()
taskmaster = Taskmaster(num_tasks, self, RandomTask)
jobs = SCons.Job.Jobs(num_jobs, taskmaster)
jobs.run()
self.assertTrue(not taskmaster.tasks_were_serial(),
"the tasks were not executed in parallel")
self.assertTrue(taskmaster.all_tasks_are_executed(),
"all the tests were not executed")
self.assertTrue(taskmaster.all_tasks_are_iterated(),
"all the tests were not iterated over")
self.assertTrue(taskmaster.all_tasks_are_postprocessed(),
"all the tests were not postprocessed")
self.assertFalse(taskmaster.num_failed,
"some task(s) failed to execute")
# Verify that parallel jobs will pull all of the completed tasks
# out of the queue at once, instead of one by one. We do this by
# replacing the default ThreadPool class with one that records the
# order in which tasks are put() and get() to/from the pool, and
# which sleeps a little bit before call get() to let the initial
# tasks complete and get their notifications on the resultsQueue.
class SleepTask(Task):
def _do_something(self):
time.sleep(0.01)
global SaveThreadPool
SaveThreadPool = SCons.Job.ThreadPool
class WaitThreadPool(SaveThreadPool):
def put(self, task):
ThreadPoolCallList.append('put(%s)' % task.i)
return SaveThreadPool.put(self, task)
def get(self):
time.sleep(0.05)
result = SaveThreadPool.get(self)
ThreadPoolCallList.append('get(%s)' % result[0].i)
return result
SCons.Job.ThreadPool = WaitThreadPool
try:
taskmaster = Taskmaster(3, self, SleepTask)
jobs = SCons.Job.Jobs(2, taskmaster)
jobs.run()
# The key here is that we get(1) and get(2) from the
# resultsQueue before we put(3), but get(1) and get(2) can
# be in either order depending on how the first two parallel
# tasks get scheduled by the operating system.
expect = [
['put(1)', 'put(2)', 'get(1)', 'get(2)', 'put(3)', 'get(3)'],
['put(1)', 'put(2)', 'get(2)', 'get(1)', 'put(3)', 'get(3)'],
]
assert ThreadPoolCallList in expect, ThreadPoolCallList
finally:
SCons.Job.ThreadPool = SaveThreadPool
class SerialTestCase(unittest.TestCase):
def runTest(self):
"""test a serial job"""
taskmaster = Taskmaster(num_tasks, self, RandomTask)
jobs = SCons.Job.Jobs(1, taskmaster)
jobs.run()
self.assertTrue(taskmaster.tasks_were_serial(),
"the tasks were not executed in series")
self.assertTrue(taskmaster.all_tasks_are_executed(),
"all the tests were not executed")
self.assertTrue(taskmaster.all_tasks_are_iterated(),
"all the tests were not iterated over")
self.assertTrue(taskmaster.all_tasks_are_postprocessed(),
"all the tests were not postprocessed")
self.assertFalse(taskmaster.num_failed,
"some task(s) failed to execute")
class NoParallelTestCase(unittest.TestCase):
def runTest(self):
"""test handling lack of parallel support"""
def NoParallel(tm, num, stack_size):
raise NameError
save_Parallel = SCons.Job.Parallel
SCons.Job.Parallel = NoParallel
try:
taskmaster = Taskmaster(num_tasks, self, RandomTask)
jobs = SCons.Job.Jobs(2, taskmaster)
self.assertTrue(jobs.num_jobs == 1,
"unexpected number of jobs %d" % jobs.num_jobs)
jobs.run()
self.assertTrue(taskmaster.tasks_were_serial(),
"the tasks were not executed in series")
self.assertTrue(taskmaster.all_tasks_are_executed(),
"all the tests were not executed")
self.assertTrue(taskmaster.all_tasks_are_iterated(),
"all the tests were not iterated over")
self.assertTrue(taskmaster.all_tasks_are_postprocessed(),
"all the tests were not postprocessed")
self.assertFalse(taskmaster.num_failed,
"some task(s) failed to execute")
finally:
SCons.Job.Parallel = save_Parallel
class SerialExceptionTestCase(unittest.TestCase):
def runTest(self):
"""test a serial job with tasks that raise exceptions"""
taskmaster = Taskmaster(num_tasks, self, ExceptionTask)
jobs = SCons.Job.Jobs(1, taskmaster)
jobs.run()
self.assertFalse(taskmaster.num_executed,
"a task was executed")
self.assertTrue(taskmaster.num_iterated == 1,
"exactly one task should have been iterated")
self.assertTrue(taskmaster.num_failed == 1,
"exactly one task should have failed")
self.assertTrue(taskmaster.num_postprocessed == 1,
"exactly one task should have been postprocessed")
class ParallelExceptionTestCase(unittest.TestCase):
def runTest(self):
"""test parallel jobs with tasks that raise exceptions"""
taskmaster = Taskmaster(num_tasks, self, ExceptionTask)
jobs = SCons.Job.Jobs(num_jobs, taskmaster)
jobs.run()
self.assertFalse(taskmaster.num_executed,
"a task was executed")
self.assertTrue(taskmaster.num_iterated >= 1,
"one or more task should have been iterated")
self.assertTrue(taskmaster.num_failed >= 1,
"one or more tasks should have failed")
self.assertTrue(taskmaster.num_postprocessed >= 1,
"one or more tasks should have been postprocessed")
#---------------------------------------------------------------------
# Above tested Job object with contrived Task and Taskmaster objects.
# Now test Job object with actual Task and Taskmaster objects.
import SCons.Taskmaster
import SCons.Node
import time
class DummyNodeInfo:
def update(self, obj):
pass
class testnode (SCons.Node.Node):
def __init__(self):
SCons.Node.Node.__init__(self)
self.expect_to_be = SCons.Node.executed
self.ninfo = DummyNodeInfo()
class goodnode (testnode):
def __init__(self):
SCons.Node.Node.__init__(self)
self.expect_to_be = SCons.Node.up_to_date
self.ninfo = DummyNodeInfo()
class slowgoodnode (goodnode):
def prepare(self):
# Delay to allow scheduled Jobs to run while the dispatcher
# sleeps. Keep this short because it affects the time taken
# by this test.
time.sleep(0.15)
goodnode.prepare(self)
class badnode (goodnode):
def __init__(self):
goodnode.__init__(self)
self.expect_to_be = SCons.Node.failed
def build(self, **kw):
raise Exception('badnode exception')
class slowbadnode (badnode):
def build(self, **kw):
# Appears to take a while to build, allowing faster builds to
# overlap. Time duration is not especially important, but if
# it is faster than slowgoodnode then these could complete
# while the scheduler is sleeping.
time.sleep(0.05)
raise Exception('slowbadnode exception')
class badpreparenode (badnode):
def prepare(self):
raise Exception('badpreparenode exception')
class _SConsTaskTest(unittest.TestCase):
def _test_seq(self, num_jobs):
for node_seq in [
[goodnode],
[badnode],
[slowbadnode],
[slowgoodnode],
[badpreparenode],
[goodnode, badnode],
[slowgoodnode, badnode],
[goodnode, slowbadnode],
[goodnode, goodnode, goodnode, slowbadnode],
[goodnode, slowbadnode, badpreparenode, slowgoodnode],
[goodnode, slowbadnode, slowgoodnode, badnode]
]:
self._do_test(num_jobs, node_seq)
def _do_test(self, num_jobs, node_seq):
testnodes = []
for tnum in range(num_tasks):
testnodes.append(node_seq[tnum % len(node_seq)]())
taskmaster = SCons.Taskmaster.Taskmaster(testnodes,
tasker=SCons.Taskmaster.AlwaysTask)
jobs = SCons.Job.Jobs(num_jobs, taskmaster)
# Exceptions thrown by tasks are not actually propagated to
# this level, but are instead stored in the Taskmaster.
jobs.run()
# Now figure out if tests proceeded correctly. The first test
# that fails will shutdown the initiation of subsequent tests,
# but any tests currently queued for execution will still be
# processed, and any tests that completed before the failure
# would have resulted in new tests being queued for execution.
# Apply the following operational heuristics of Job.py:
# 0) An initial jobset of tasks will be queued before any
# good/bad results are obtained (from "execute" of task in
# thread).
# 1) A goodnode will complete immediately on its thread and
# allow another node to be queued for execution.
# 2) A badnode will complete immediately and suppress any
# subsequent execution queuing, but all currently queued
# tasks will still be processed.
# 3) A slowbadnode will fail later. It will block slots in
# the job queue. Nodes that complete immediately will
# allow other nodes to be queued in their place, and this
# will continue until either (#2) above or until all job
# slots are filled with slowbadnode entries.
# One approach to validating this test would be to try to
# determine exactly how many nodes executed, how many didn't,
# and the results of each, and then to assert failure on any
# mismatch (including the total number of built nodes).
# However, while this is possible to do for a single-processor
# system, it is nearly impossible to predict correctly for a
# multi-processor system and still test the characteristics of
# delayed execution nodes. Stated another way, multithreading
# is inherently non-deterministic unless you can completely
# characterize the entire system, and since that's not
# possible here, we shouldn't try.
# Therefore, this test will simply scan the set of nodes to
# see if the node was executed or not and if it was executed
# that it obtained the expected value for that node
# (i.e. verifying we don't get failure crossovers or
# mislabelling of results).
for N in testnodes:
state = N.get_state()
self.assertTrue(state in [SCons.Node.no_state, N.expect_to_be],
"Node %s got unexpected result: %s" % (N, state))
self.assertTrue([N for N in testnodes if N.get_state()],
"no nodes ran at all.")
class SerialTaskTest(_SConsTaskTest):
def runTest(self):
"""test serial jobs with actual Taskmaster and Task"""
self._test_seq(1)
class ParallelTaskTest(_SConsTaskTest):
def runTest(self):
"""test parallel jobs with actual Taskmaster and Task"""
self._test_seq(num_jobs)
#---------------------------------------------------------------------
def suite():
suite = unittest.TestSuite()
suite.addTest(ParallelTestCase())
suite.addTest(SerialTestCase())
suite.addTest(NoParallelTestCase())
suite.addTest(SerialExceptionTestCase())
suite.addTest(ParallelExceptionTestCase())
suite.addTest(SerialTaskTest())
suite.addTest(ParallelTaskTest())
return suite
if __name__ == "__main__":
runner = TestUnit.cli.get_runner()
result = runner().run(suite())
if (len(result.failures) == 0
and len(result.errors) == 1
and isinstance(result.errors[0][0], SerialTestCase)
and isinstance(result.errors[0][1][0], NoThreadsException)):
sys.exit(2)
elif not result.wasSuccessful():
sys.exit(1)
# Local Variables:
# tab-width:4
# indent-tabs-mode:nil
# End:
# vim: set expandtab tabstop=4 shiftwidth=4:

View File

@ -1,64 +0,0 @@
# MIT License
#
# Copyright The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""SCons.Tool.DCommon
Common code for the various D tools.
Coded by Russel Winder (russel@winder.org.uk)
2012-09-06
"""
import os.path
def isD(env, source):
if not source:
return 0
for s in source:
if s.sources:
ext = os.path.splitext(str(s.sources[0]))[1]
if ext == '.d':
return 1
return 0
def addDPATHToEnv(env, executable):
dPath = env.WhereIs(executable)
if dPath:
phobosDir = dPath[:dPath.rindex(executable)] + '/../src/phobos'
if os.path.isdir(phobosDir):
env.Append(DPATH=[phobosDir])
def allAtOnceEmitter(target, source, env):
if env['DC'] in ('ldc2', 'dmd'):
env.SideEffect(str(target[0]) + '.o', target[0])
env.Clean(target[0], str(target[0]) + '.o')
return target, source
# Local Variables:
# tab-width:4
# indent-tabs-mode:nil
# End:
# vim: set expandtab tabstop=4 shiftwidth=4:

View File

@ -1,126 +0,0 @@
#
# __COPYRIGHT__
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import os
import unittest
import TestUnit
import SCons.Errors
import SCons.Tool
class DummyEnvironment:
def __init__(self):
self.dict = {}
def Detect(self, progs):
if not SCons.Util.is_List(progs):
progs = [ progs ]
return progs[0]
def Append(self, **kw):
self.dict.update(kw)
def __getitem__(self, key):
return self.dict[key]
def __setitem__(self, key, val):
self.dict[key] = val
def __contains__(self, key):
return key in self.dict
def subst(self, string, *args, **kwargs):
return string
PHONY_PATH = "/usr/phony/bin"
def WhereIs(self, key_program):
# for pathfind test for Issue #3336:
# need to fake the case where extra paths are searched, and
# if one has a "hit" after some fails, the fails are left in
# the environment's PATH. So construct a positive answer if
# we see a magic known path component in PATH; answer in
# the negative otherwise.
paths = self['ENV']['PATH']
if self.PHONY_PATH in paths:
return os.path.join(self.PHONY_PATH, key_program)
return None
def AppendENVPath(self, pathvar, path):
# signature matches how called from find_program_path()
self['ENV'][pathvar] = self['ENV'][pathvar] + os.pathsep + path
class ToolTestCase(unittest.TestCase):
def test_Tool(self):
"""Test the Tool() function"""
env = DummyEnvironment()
env['BUILDERS'] = {}
env['ENV'] = {}
env['PLATFORM'] = 'test'
t = SCons.Tool.Tool('g++')
t(env)
assert (env['CXX'] == 'c++' or env['CXX'] == 'g++'), env['CXX']
assert env['INCPREFIX'] == '-I', env['INCPREFIX']
assert env['TOOLS'] == ['g++'], env['TOOLS']
exc_caught = None
try:
SCons.Tool.Tool()
except TypeError:
exc_caught = 1
assert exc_caught, "did not catch expected UserError"
exc_caught = None
try:
p = SCons.Tool.Tool('_does_not_exist_')
except SCons.Errors.UserError as e:
exc_caught = 1
# Old msg was Python-style "No tool named", check for new msg:
assert "No tool module" in str(e), e
assert exc_caught, "did not catch expected UserError"
def test_pathfind(self):
"""Test that find_program_path() does not alter PATH"""
env = DummyEnvironment()
PHONY_PATHS = [
r'C:\cygwin64\bin',
r'C:\cygwin\bin',
'/usr/local/dummy/bin',
env.PHONY_PATH, # will be recognized by dummy WhereIs
]
env['ENV'] = {}
env['ENV']['PATH'] = '/usr/local/bin:/opt/bin:/bin:/usr/bin'
pre_path = env['ENV']['PATH']
_ = SCons.Tool.find_program_path(env, 'no_tool', default_paths=PHONY_PATHS)
assert env['ENV']['PATH'] == pre_path, env['ENV']['PATH']
if __name__ == "__main__":
suite = unittest.makeSuite(ToolTestCase, 'test_')
TestUnit.run(suite)
# Local Variables:
# tab-width:4
# indent-tabs-mode:nil
# End:
# vim: set expandtab tabstop=4 shiftwidth=4:

View File

@ -27,7 +27,6 @@ Common link/shared library logic
import SCons.Util import SCons.Util
import SCons.Warnings import SCons.Warnings
from SCons.Tool.DCommon import isD
from SCons.Util import is_List from SCons.Util import is_List
issued_mixed_link_warning = False issued_mixed_link_warning = False
@ -131,17 +130,8 @@ def smart_link(source, target, env, for_signature):
import SCons.Tool.cxx import SCons.Tool.cxx
has_cplusplus = SCons.Tool.cxx.iscplusplus(source) has_cplusplus = SCons.Tool.cxx.iscplusplus(source)
has_d = isD(env, source)
if has_cplusplus and not has_d: if has_cplusplus:
global issued_mixed_link_warning
if not issued_mixed_link_warning:
issued_mixed_link_warning = True
return '$CXX'
elif has_d:
env['LINKCOM'] = env['DLINKCOM']
env['SHLINKCOM'] = env['SHDLINKCOM']
return '$DC'
elif has_cplusplus:
return '$CXX' return '$CXX'
return '$CC' return '$CC'

View File

@ -1,997 +0,0 @@
#
# __COPYRIGHT__
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import os
import sys
import unittest
import copy
import TestCmd
import TestUnit
from SCons.Tool.msvs import *
from SCons.Tool.MSCommon.vs import SupportedVSList
import SCons.Node.FS
import SCons.Util
import SCons.Warnings
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]
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0\ServicePacks]
"sp3"=""
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0\Setup]
"VsCommonDir"="C:\Program Files\Microsoft Visual Studio\Common"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0\Setup\Microsoft Developer Network Library - Visual Studio 6.0a]
"ProductDir"="C:\Program Files\Microsoft Visual Studio\MSDN98\98VSa\1033"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0\Setup\Microsoft Visual C++]
"ProductDir"="C:\Program Files\Microsoft Visual Studio\VC98"
'''.split('\n')
regdata_6b = r'''[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio]
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0]
"InstallDir"="C:\VS6\Common\IDE\IDE98"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0\ServicePacks]
"sp5"=""
"latest"=dword:00000005
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0\Setup]
"VsCommonDir"="C:\VS6\Common"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0\Setup\Microsoft Visual Basic]
"ProductDir"="C:\VS6\VB98"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0\Setup\Microsoft Visual C++]
"ProductDir"="C:\VS6\VC98"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0\Setup\Microsoft Visual Studio]
"ProductDir"="C:\VS6"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0\Setup\Microsoft VSEE Client]
"ProductDir"="C:\VS6\Common\Tools"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0\Setup\Visual Studio 98]
'''.split('\n')
regdata_7 = r'''
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0]
"InstallDir"="C:\Program Files\Microsoft Visual Studio .NET\Common7\IDE\"
"Source Directories"="C:\Program Files\Microsoft Visual Studio .NET\Vc7\crt\;C:\Program Files\Microsoft Visual Studio .NET\Vc7\atlmfc\src\mfc\;C:\Program Files\Microsoft Visual Studio .NET\Vc7\atlmfc\src\atl\"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\InstalledProducts]
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\InstalledProducts\CrystalReports]
@="#15007"
"Package"="{F05E92C6-8346-11D3-B4AD-00A0C9B04E7B}"
"ProductDetails"="#15009"
"LogoID"="0"
"PID"="#15008"
"UseInterface"=dword:00000001
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\InstalledProducts\Visual Basic.NET]
@=""
"DefaultProductAttribute"="VB"
"Package"="{164B10B9-B200-11D0-8C61-00A0C91E29D5}"
"UseInterface"=dword:00000001
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\InstalledProducts\Visual C#]
@=""
"Package"="{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}"
"UseInterface"=dword:00000001
"DefaultProductAttribute"="C#"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\InstalledProducts\VisualC++]
"UseInterface"=dword:00000001
"Package"="{F1C25864-3097-11D2-A5C5-00C04F7968B4}"
"DefaultProductAttribute"="VC"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\Setup]
"Dbghelp_path"="C:\Program Files\Microsoft Visual Studio .NET\Common7\IDE\"
"dw_dir"="C:\Program Files\Microsoft Visual Studio .NET\Common7\IDE\"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\Setup\MSDN]
"ProductDir"="C:\Program Files\Microsoft Visual Studio .NET\Msdn\1033\"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\Setup\Servicing\SKU]
"Visual Studio .NET Professional - English"="{D0610409-7D65-11D5-A54F-0090278A1BB8}"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\Setup\VB]
"ProductDir"="C:\Program Files\Microsoft Visual Studio .NET\Vb7\"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\Setup\VC]
"ProductDir"="C:\Program Files\Microsoft Visual Studio .NET\Vc7\"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\Setup\VC#]
"ProductDir"="C:\Program Files\Microsoft Visual Studio .NET\VC#\"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\Setup\Visual Studio .NET Professional - English]
"InstallSuccess"=dword:00000001
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\Setup\VS]
"EnvironmentDirectory"="C:\Program Files\Microsoft Visual Studio .NET\Common7\IDE\"
"EnvironmentPath"="C:\Program Files\Microsoft Visual Studio .NET\Common7\IDE\devenv.exe"
"VS7EnvironmentLocation"="C:\Program Files\Microsoft Visual Studio .NET\Common7\IDE\devenv.exe"
"MSMDir"="C:\Program Files\Common Files\Merge Modules\"
"ProductDir"="C:\Program Files\Microsoft Visual Studio .NET\"
"VS7CommonBinDir"="C:\Program Files\Microsoft Visual Studio .NET\Common7\Tools\"
"VS7CommonDir"="C:\Program Files\Microsoft Visual Studio .NET\Common7\"
"VSUpdateDir"="C:\Program Files\Microsoft Visual Studio .NET\Setup\VSUpdate\"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\Setup\VS\BuildNumber]
"1033"="7.0.9466"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\Setup\VS\Pro]
"ProductDir"="C:\Program Files\Microsoft Visual Studio .NET\"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\VC]
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\VC\VC_OBJECTS_PLATFORM_INFO]
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\VC\VC_OBJECTS_PLATFORM_INFO\Win32]
@="{A54AAE91-30C2-11D3-87BF-A04A4CC10000}"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\VC\VC_OBJECTS_PLATFORM_INFO\Win32\Directories]
"Path Dirs"="$(VCInstallDir)bin;$(VSInstallDir)Common7\Tools\bin\prerelease;$(VSInstallDir)Common7\Tools\bin;$(VSInstallDir)Common7\tools;$(VSInstallDir)Common7\ide;C:\Program Files\HTML Help Workshop\;$(FrameworkSDKDir)bin;$(FrameworkDir)$(FrameworkVersion);C:\perl\bin;C:\cygwin\bin;c:\cygwin\usr\bin;C:\bin;C:\program files\perforce;C:\cygwin\usr\local\bin\i686-pc-cygwin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem"
"Library Dirs"="$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(VCInstallDir)PlatformSDK\lib\prerelease;$(VCInstallDir)PlatformSDK\lib;$(FrameworkSDKDir)lib"
"Include Dirs"="$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(VCInstallDir)PlatformSDK\include\prerelease;$(VCInstallDir)PlatformSDK\include;$(FrameworkSDKDir)include"
"Source Dirs"="$(VCInstallDir)atlmfc\src\mfc;$(VCInstallDir)atlmfc\src\atl;$(VCInstallDir)crt\src"
"Reference Dirs"=""
'''.split('\n')
regdata_7_1 = r'''
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1]
@=""
"Source Directories"="C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\crt\src\;C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\src\mfc\;C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\src\atl\"
"ThisVersionSolutionCLSID"="{246C57AE-40DD-4d6b-9E8D-B0F5757BB2A8}"
"ThisVersionDTECLSID"="{8CD2DD97-4EC1-4bc4-9359-89A3EEDD57A6}"
"InstallDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\"
"CLR Version"="v1.1.4322"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\InstalledProducts]
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\InstalledProducts\Smart Device Extensions]
"UseInterface"=dword:00000001
"VS7InstallDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\"
"VBDeviceInstallDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\VB7\"
"CSharpDeviceInstallDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\VC#\"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\InstalledProducts\Visual Basic.NET]
"UseInterface"=dword:00000001
"Package"="{164B10B9-B200-11D0-8C61-00A0C91E29D5}"
"DefaultProductAttribute"="VB"
@=""
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\InstalledProducts\Visual C#]
"DefaultProductAttribute"="C#"
"UseInterface"=dword:00000001
"Package"="{FAE04EC1-301F-11D3-BF4B-00C04F79EFBC}"
@=""
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\InstalledProducts\Visual JSharp]
@=""
"Package"="{E6FDF8B0-F3D1-11D4-8576-0002A516ECE8}"
"UseInterface"=dword:00000001
"DefaultProductAttribute"="Visual JSharp"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\InstalledProducts\VisualC++]
"UseInterface"=dword:00000001
"Package"="{F1C25864-3097-11D2-A5C5-00C04F7968B4}"
"DefaultProductAttribute"="VC"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup]
"Dbghelp_path"="C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\"
"dw_dir"="C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\CSDPROJ]
"ProductDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\VC#\"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\JSHPROJ]
"ProductDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\VJ#\"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\Servicing]
"CurrentSULevel"=dword:00000000
"CurrentSPLevel"=dword:00000000
"Server Path"=""
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\Servicing\Package]
"FxSDK"=""
"VB"=""
"VC"=""
"VCS"=""
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\Servicing\SKU]
"Visual Studio .NET Professional 2003 - English"="{20610409-CA18-41A6-9E21-A93AE82EE7C5}"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\VB]
"ProductDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\Vb7\"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\VBDPROJ]
"ProductDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\Vb7\"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\VC]
"ProductDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\VC#]
"ProductDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\VC#\"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\Visual Studio .NET Professional 2003 - English]
"InstallSuccess"=dword:00000001
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\VS]
"EnvironmentDirectory"="C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\"
"EnvironmentPath"="C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\devenv.exe"
"VS7EnvironmentLocation"="C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\devenv.exe"
"MSMDir"="C:\Program Files\Common Files\Merge Modules\"
"VS7CommonBinDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools\"
"VS7CommonDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\"
"ProductDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\"
"VSUpdateDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\Setup\VSUpdate\"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\VS\BuildNumber]
"1033"="7.1.3088"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\VS\Pro]
"ProductDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\VC]
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\VC\VC_OBJECTS_PLATFORM_INFO]
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\VC\VC_OBJECTS_PLATFORM_INFO\Win32]
@="{759354D0-6B42-4705-AFFB-56E34D2BC3D4}"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\VC\VC_OBJECTS_PLATFORM_INFO\Win32\Directories]
"Path Dirs"="$(VCInstallDir)bin;$(VSInstallDir)Common7\Tools\bin\prerelease;$(VSInstallDir)Common7\Tools\bin;$(VSInstallDir)Common7\tools;$(VSInstallDir)Common7\ide;C:\Program Files\HTML Help Workshop\;$(FrameworkSDKDir)bin;$(FrameworkDir)$(FrameworkVersion);C:\Perl\bin\;c:\bin;c:\cygwin\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Common Files\Avid;C:\Program Files\backburner 2\;C:\Program Files\cvsnt;C:\Program Files\Subversion\bin;C:\Program Files\Common Files\Adobe\AGL;C:\Program Files\HTMLDoc"
"Library Dirs"="$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(VCInstallDir)PlatformSDK\lib\prerelease;$(VCInstallDir)PlatformSDK\lib;$(FrameworkSDKDir)lib"
"Include Dirs"="$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(VCInstallDir)PlatformSDK\include\prerelease;$(VCInstallDir)PlatformSDK\include;$(FrameworkSDKDir)include"
"Source Dirs"="$(VCInstallDir)atlmfc\src\mfc;$(VCInstallDir)atlmfc\src\atl;$(VCInstallDir)crt\src"
"Reference Dirs"="$(FrameWorkDir)$(FrameWorkVersion)"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\VC\VC_OBJECTS_PLATFORM_INFO\Win32\ToolDefaultExtensionLists]
"VCCLCompilerTool"="*.cpp;*.cxx;*.cc;*.c"
"VCLinkerTool"="*.obj;*.res;*.lib;*.rsc"
"VCLibrarianTool"="*.obj;*.res;*.lib;*.rsc"
"VCMIDLTool"="*.idl;*.odl"
"VCCustomBuildTool"="*.bat"
"VCResourceCompilerTool"="*.rc"
"VCPreBuildEventTool"="*.bat"
"VCPreLinkEventTool"="*.bat"
"VCPostBuildEventTool"="*.bat"
"VCBscMakeTool"="*.sbr"
"VCNMakeTool"=""
"VCWebServiceProxyGeneratorTool"="*.discomap"
"VCWebDeploymentTool"=""
"VCALinkTool"="*.resources"
"VCManagedResourceCompilerTool"="*.resx"
"VCXMLDataGeneratorTool"="*.xsd"
"VCManagedWrapperGeneratorTool"=""
"VCAuxiliaryManagedWrapperGeneratorTool"=""
"VCPrimaryInteropTool"=""
'''.split('\n')
regdata_8exp = r'''
[HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\8.0]
"CLR Version"="v2.0.50727"
"ApplicationID"="VCExpress"
"SecurityAppID"="{741726F6-1EAE-4680-86A6-6085E8872CF8}"
"InstallDir"="C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\"
"EnablePreloadCLR"=dword:00000001
"RestoreAppPath"=dword:00000001
[HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\8.0\InstalledProducts]
[HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\8.0\InstalledProducts\Microsoft Visual C++]
"UseInterface"=dword:00000001
"Package"="{F1C25864-3097-11D2-A5C5-00C04F7968B4}"
"DefaultProductAttribute"="VC"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\8.0\Setup]
[HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\8.0\Setup\VC]
"ProductDir"="C:\Program Files\Microsoft Visual Studio 8\VC\"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\8.0\Setup\VS]
"ProductDir"="C:\Program Files\Microsoft Visual Studio 8\"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\8.0\VC]
[HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\8.0\VC\VC_OBJECTS_PLATFORM_INFO]
[HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\8.0\VC\VC_OBJECTS_PLATFORM_INFO\Win32]
@="{72f11281-2429-11d7-8bf6-00b0d03daa06}"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\8.0\VC\VC_OBJECTS_PLATFORM_INFO\Win32\ToolDefaultExtensionLists]
"VCCLCompilerTool"="*.cpp;*.cxx;*.cc;*.c"
"VCLinkerTool"="*.obj;*.res;*.lib;*.rsc;*.licenses"
"VCLibrarianTool"="*.obj;*.res;*.lib;*.rsc"
"VCMIDLTool"="*.idl;*.odl"
"VCCustomBuildTool"="*.bat"
"VCResourceCompilerTool"="*.rc"
"VCPreBuildEventTool"="*.bat"
"VCPreLinkEventTool"="*.bat"
"VCPostBuildEventTool"="*.bat"
"VCBscMakeTool"="*.sbr"
"VCFxCopTool"="*.dll;*.exe"
"VCNMakeTool"=""
"VCWebServiceProxyGeneratorTool"="*.discomap"
"VCWebDeploymentTool"=""
"VCALinkTool"="*.resources"
"VCManagedResourceCompilerTool"="*.resx"
"VCXMLDataGeneratorTool"="*.xsd"
"VCManifestTool"="*.manifest"
"VCXDCMakeTool"="*.xdc"
'''.split('\n')
regdata_80 = r'''
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0]
"CLR Version"="v2.0.50727"
"ApplicationID"="VisualStudio"
"ThisVersionDTECLSID"="{BA018599-1DB3-44f9-83B4-461454C84BF8}"
"ThisVersionSolutionCLSID"="{1B2EEDD6-C203-4d04-BD59-78906E3E8AAB}"
"SecurityAppID"="{DF99D4F5-9F04-4CEF-9D39-095821B49C77}"
"InstallDir"="C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\"
"EnablePreloadCLR"=dword:00000001
"RestoreAppPath"=dword:00000001
"Source Directories"="C:\Program Files\Microsoft Visual Studio 8\VC\crt\src\;C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\src\mfc\;C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\src\atl\;C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\include\"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\InstalledProducts]
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\InstalledProducts\Microsoft Visual C++]
"UseInterface"=dword:00000001
"Package"="{F1C25864-3097-11D2-A5C5-00C04F7968B4}"
"DefaultProductAttribute"="VC"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\Setup]
"Dbghelp_path"="C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\Setup\EF]
"ProductDir"="C:\Program Files\Microsoft Visual Studio 8\EnterpriseFrameworks\"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\Setup\Microsoft Visual Studio 2005 Professional Edition - ENU]
"SrcPath"="d:\vs\"
"InstallSuccess"=dword:00000001
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\Setup\VC]
"ProductDir"="C:\Program Files\Microsoft Visual Studio 8\VC\"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\Setup\VS]
"ProductDir"="C:\Program Files\Microsoft Visual Studio 8\"
"VS7EnvironmentLocation"="C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv.exe"
"EnvironmentPath"="C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv.exe"
"EnvironmentDirectory"="C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\"
"VS7CommonDir"="C:\Program Files\Microsoft Visual Studio 8\Common7\"
"VS7CommonBinDir"="C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\Setup\VS\BuildNumber]
"1033"="8.0.50727.42"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\Setup\VS\Pro]
"ProductDir"="C:\Program Files\Microsoft Visual Studio 8\"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\VC]
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\VC\VC_OBJECTS_PLATFORM_INFO]
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\VC\VC_OBJECTS_PLATFORM_INFO\Win32]
@="{72f11281-2429-11d7-8bf6-00b0d03daa06}"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\VC\VC_OBJECTS_PLATFORM_INFO\Win32\ToolDefaultExtensionLists]
"VCCLCompilerTool"="*.cpp;*.cxx;*.cc;*.c"
"VCLinkerTool"="*.obj;*.res;*.lib;*.rsc;*.licenses"
"VCLibrarianTool"="*.obj;*.res;*.lib;*.rsc"
"VCMIDLTool"="*.idl;*.odl"
"VCCustomBuildTool"="*.bat"
"VCResourceCompilerTool"="*.rc"
"VCPreBuildEventTool"="*.bat"
"VCPreLinkEventTool"="*.bat"
"VCPostBuildEventTool"="*.bat"
"VCBscMakeTool"="*.sbr"
"VCFxCopTool"="*.dll;*.exe"
"VCNMakeTool"=""
"VCWebServiceProxyGeneratorTool"="*.discomap"
"VCWebDeploymentTool"=""
"VCALinkTool"="*.resources"
"VCManagedResourceCompilerTool"="*.resx"
"VCXMLDataGeneratorTool"="*.xsd"
"VCManifestTool"="*.manifest"
"VCXDCMakeTool"="*.xdc"
'''.split('\n')
regdata_140 = r'''
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS]
"MSMDir"="C:\\Program Files (x86)\\Common Files\\Merge Modules\\"
"ProductDir"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\"
"VS7EnvironmentLocation"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\devenv.exe"
"EnvironmentPath"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\devenv.exe"
"EnvironmentDirectory"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\"
"VS7CommonDir"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\"
"VS7CommonBinDir"=""
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\BuildNumber]
"1033"="14.0"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\Community]
"ProductDir"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\JSLS_MSI]
"Version"="14.0.25527"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\JSPS_MSI]
"Version"="14.0.25527"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\Pro]
"ProductDir"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\professional]
"IsInstallInProgress"="0"
"CurrentOperation"="install"
"SetupFeedUri"="http://go.microsoft.com/fwlink/?LinkID=659004&clcid=0x409"
"SetupFeedLocalCache"="C:\\ProgramData\\Microsoft\\VisualStudioSecondaryInstaller\\14.0\\LastUsedFeed\\{68432bbb-c9a5-4a7b-bab3-ae5a49b28303}\\Feed.xml"
"InstallResult"="0"
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\SecondaryInstaller]
[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\SecondaryInstaller\AppInsightsTools]
"Version"="7.0.20620.1"
'''.split('\n')
regdata_cv = r'''[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion]
"ProgramFilesDir"="C:\Program Files"
"CommonFilesDir"="C:\Program Files\Common Files"
"MediaPath"="C:\WINDOWS\Media"
'''.split('\n')
regdata_none = []
class DummyEnv:
def __init__(self, dict=None):
self.fs = SCons.Node.FS.FS()
if dict:
self.dict = dict
else:
self.dict = {}
def Dictionary(self, key = None):
if not key:
return self.dict
return self.dict[key]
def __setitem__(self, key, value):
self.dict[key] = value
def __getitem__(self, key):
return self.dict[key]
def __contains__(self, key):
return key in self.dict
def get(self, name, value=None):
if name in self.dict:
return self.dict[name]
else:
return value
def Dir(self, name):
return self.fs.Dir(name)
class RegKey:
"""key class for storing an 'open' registry key"""
def __init__(self,key):
self.key = key
# Warning: this is NOT case-insensitive, unlike the Windows registry.
# So e.g. HKLM\Software is NOT the same key as HKLM\SOFTWARE.
class RegNode:
"""node in the dummy registry"""
def __init__(self,name):
self.valdict = {}
self.keydict = {}
self.keyarray = []
self.valarray = []
self.name = name
def value(self,val):
if val in self.valdict:
return (self.valdict[val],1)
else:
raise SCons.Util.RegError
def addValue(self,name,val):
self.valdict[name] = val
self.valarray.append(name)
def valindex(self,index):
rv = None
try:
rv = (self.valarray[index],self.valdict[self.valarray[index]],1)
except KeyError:
raise SCons.Util.RegError
return rv
def key(self,key,sep = '\\'):
if key.find(sep) != -1:
keyname, subkeys = key.split(sep,1)
else:
keyname = key
subkeys = ""
try:
# recurse, and return the lowest level key node
if subkeys:
return self.keydict[keyname].key(subkeys)
else:
return self.keydict[keyname]
except KeyError:
raise SCons.Util.RegError
def addKey(self,name,sep = '\\'):
if name.find(sep) != -1:
keyname, subkeys = name.split(sep, 1)
else:
keyname = name
subkeys = ""
if keyname not in self.keydict:
self.keydict[keyname] = RegNode(keyname)
self.keyarray.append(keyname)
# recurse, and return the lowest level key node
if subkeys:
return self.keydict[keyname].addKey(subkeys)
else:
return self.keydict[keyname]
def keyindex(self,index):
return self.keydict[self.keyarray[index]]
def __str__(self):
return self._doStr()
def _doStr(self, indent = ''):
rv = ""
for value in self.valarray:
rv = rv + '%s"%s" = "%s"\n' % (indent, value, self.valdict[value])
for key in self.keyarray:
rv = rv + "%s%s: {\n"%(indent, key)
rv = rv + self.keydict[key]._doStr(indent + ' ')
rv = rv + indent + '}\n'
return rv
class DummyRegistry:
"""registry class for storing fake registry attributes"""
def __init__(self,data):
"""parse input data into the fake registry"""
self.root = RegNode('REGISTRY')
self.root.addKey('HKEY_LOCAL_MACHINE')
self.root.addKey('HKEY_CURRENT_USER')
self.root.addKey('HKEY_USERS')
self.root.addKey('HKEY_CLASSES_ROOT')
self.parse(data)
def parse(self, data):
parents = [None, None]
parents[0] = self.root
keymatch = re.compile(r'^\[(.*)\]$')
valmatch = re.compile(r'^(?:"(.*)"|[@])="(.*)"$')
for line in data:
m1 = keymatch.match(line)
if m1:
# add a key, set it to current parent.
# Also create subkey for Wow6432Node of HKLM\Software;
# that's where it looks on a 64-bit machine (tests will fail w/o this)
parents[0] = self.root.addKey(m1.group(1))
if 'HKEY_LOCAL_MACHINE\\Software' in m1.group(1):
p1 = m1.group(1).replace('HKEY_LOCAL_MACHINE\\Software', 'HKEY_LOCAL_MACHINE\\Software\\Wow6432Node')
parents[1] = self.root.addKey(p1)
else:
parents[1] = None
else:
m2 = valmatch.match(line)
if m2:
for p in parents:
if p:
p.addValue(m2.group(1),m2.group(2))
def OpenKeyEx(self,root,key):
if root == SCons.Util.HKEY_CLASSES_ROOT:
mykey = 'HKEY_CLASSES_ROOT\\' + key
if root == SCons.Util.HKEY_USERS:
mykey = 'HKEY_USERS\\' + key
if root == SCons.Util.HKEY_CURRENT_USER:
mykey = 'HKEY_CURRENT_USER\\' + key
if root == SCons.Util.HKEY_LOCAL_MACHINE:
mykey = 'HKEY_LOCAL_MACHINE\\' + key
debug("Open Key:%s"%mykey)
return self.root.key(mykey)
def DummyOpenKeyEx(root, key):
return registry.OpenKeyEx(root,key)
def DummyEnumKey(key, index):
rv = None
try:
rv = key.keyarray[index]
except IndexError:
raise SCons.Util.RegError
# DEBUG
# print "Enum Key",key.name,"[",index,"] =>",rv
return rv
def DummyEnumValue(key, index):
rv = key.valindex(index)
# DEBUG
# print "Enum Value",key.name,"[",index,"] =>",rv
return rv
def DummyQueryValue(key, value):
rv = key.value(value)
# DEBUG
# print "Query Value",key.name+"\\"+value,"=>",rv
return rv
def DummyExists(path):
return 1
def DummyVsWhere(msvc_version, env):
# not testing versions with vswhere, so return none
return None
class msvsTestCase(unittest.TestCase):
"""This test case is run several times with different defaults.
See its subclasses below."""
def setUp(self):
debug("THIS TYPE :%s"%self)
global registry
registry = self.registry
from SCons.Tool.MSCommon.vs import reset_installed_visual_studios
reset_installed_visual_studios()
self.test = TestCmd.TestCmd(workdir='')
# FS doesn't like the cwd to be something other than its root.
os.chdir(self.test.workpath(""))
self.fs = SCons.Node.FS.FS()
def test_get_default_version(self):
"""Test retrieval of the default visual studio version"""
debug("Testing for default version %s"%self.default_version)
env = DummyEnv()
v1 = get_default_version(env)
if v1:
assert env['MSVS_VERSION'] == self.default_version, \
("env['MSVS_VERSION'] != self.default_version",
env['MSVS_VERSION'],self.default_version)
assert env['MSVS']['VERSION'] == self.default_version, \
("env['MSVS']['VERSION'] != self.default_version",
env['MSVS']['VERSION'], self.default_version)
assert v1 == self.default_version, (self.default_version, v1)
env = DummyEnv({'MSVS_VERSION':'7.0'})
v2 = get_default_version(env)
assert env['MSVS_VERSION'] == '7.0', env['MSVS_VERSION']
assert env['MSVS']['VERSION'] == '7.0', env['MSVS']['VERSION']
assert v2 == '7.0', v2
env = DummyEnv()
v3 = get_default_version(env)
if v3 == '7.1':
override = '7.0'
else:
override = '7.1'
env['MSVS_VERSION'] = override
v3 = get_default_version(env)
assert env['MSVS_VERSION'] == override, env['MSVS_VERSION']
assert env['MSVS']['VERSION'] == override, env['MSVS']['VERSION']
assert v3 == override, v3
def _TODO_test_merge_default_version(self):
"""Test the merge_default_version() function"""
pass
def test_query_versions(self):
"""Test retrieval of the list of visual studio versions"""
v1 = query_versions()
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
suffix = '.vcxproj'
elif version_num >= 7.0:
function_test = _GenerateV7DSP
suffix = '.dsp'
else:
function_test = _GenerateV6DSP
suffix = '.dsp'
# Avoid any race conditions between the test cases when we test
# actually writing the files.
dspfile = 'test%s%s' % (hash(self), suffix)
str_function_test = str(function_test.__init__)
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']
list_cppdefines = [['_A', '_B', 'C'], ['_B', '_C_'], ['D'], []]
list_cpppaths = [[r'C:\test1'], [r'C:\test1;C:\test2'],
[self.fs.Dir('subdir')], []]
list_cppflags = [['/std:c++17', '/Zc:__cplusplus'],
['/std:c++14', '/Zc:__cplusplus'],
['/std:c++11', '/Zc:__cplusplus'], []]
def TestParamsFromList(test_variant, test_list):
"""
Generates test data based on the parameters passed in.
Returns tuple list:
1. Parameter.
2. Dictionary of expected result per variant.
"""
def normalizeParam(param):
"""
Converts the raw data based into the AddConfig function of
msvs.py to the expected result.
Expects the following behavior:
1. A value of None will be converted to an empty list.
2. A File or Directory object will be converted to an
absolute path (because those objects can't be pickled).
3. Otherwise, the parameter will be used.
"""
if param is None:
return []
elif isinstance(param, list):
return [normalizeParam(p) for p in param]
elif hasattr(param, 'abspath'):
return param.abspath
else:
return param
return [
(None, dict.fromkeys(test_variant, '')),
('', dict.fromkeys(test_variant, '')),
(test_list[0], dict.fromkeys(test_variant, normalizeParam(test_list[0]))),
(test_list, dict(list(zip(test_variant, [normalizeParam(x) for x in test_list]))))
]
tests_cmdargs = TestParamsFromList(list_variant, list_cmdargs)
tests_cppdefines = TestParamsFromList(list_variant, list_cppdefines)
tests_cpppaths = TestParamsFromList(list_variant, list_cpppaths)
tests_cppflags = TestParamsFromList(list_variant, list_cppflags)
# Run the test for each test case
for param_cmdargs, expected_cmdargs in tests_cmdargs:
for param_cppdefines, expected_cppdefines in tests_cppdefines:
for param_cpppaths, expected_cpppaths in tests_cpppaths:
for param_cppflags, expected_cppflags in tests_cppflags:
# DEBUG:
# print(
# 'Testing %s. with :\n variant = %s \n cmdargs = "%s" \n cppdefines = "%s" \n cpppaths = "%s" \n cppflags = "%s"'
# % (
# str_function_test,
# list_variant,
# param_cmdargs,
# param_cppdefines,
# param_cpppaths,
# param_cppflags,
# )
# )
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],
'cppdefines': expected_cppdefines[variant_platform],
'cpppaths': expected_cpppaths[variant_platform],
'cppflags': expected_cppflags[variant_platform],
}
# Create parameter environment with final parameter dictionary
param_dict = dict(list(zip(('variant', 'runfile', 'buildtarget', 'outdir'),
[list(l) for l in zip(*param_configs)])))
param_dict['cmdargs'] = param_cmdargs
param_dict['cppdefines'] = param_cppdefines
param_dict['cpppaths'] = param_cpppaths
param_dict['cppflags'] = param_cppflags
# Hack to be able to run the test with a 'DummyEnv'
class _DummyEnv(DummyEnv):
def subst(self, string, *args, **kwargs):
return string
env = _DummyEnv(param_dict)
env['MSVSSCONSCRIPT'] = ''
env['MSVS_VERSION'] = self.highest_version
env['MSVSBUILDTARGET'] = 'target'
# Call function to test
genDSP = function_test(dspfile, source, env)
# Check expected result
self.assertListEqual(list(genDSP.configs.keys()), list(expected_configs.keys()))
for key, v in genDSP.configs.items():
self.assertDictEqual(v.__dict__, expected_configs[key])
genDSP.Build()
# Delete the resulting file so we don't leave anything behind.
for file in [dspfile, dspfile + '.filters']:
path = os.path.realpath(file)
try:
os.remove(path)
except OSError:
pass
class msvs6aTestCase(msvsTestCase):
"""Test MSVS 6 Registry"""
registry = DummyRegistry(regdata_6a + regdata_cv)
default_version = '6.0'
highest_version = '6.0'
number_of_versions = 1
install_locs = {
'6.0' : {'VSINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio\\VC98', 'VCINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio\\VC98\\Bin'},
'7.0' : {},
'7.1' : {},
'8.0' : {},
'8.0Exp' : {},
}
default_install_loc = install_locs['6.0']
class msvs6bTestCase(msvsTestCase):
"""Test Other MSVS 6 Registry"""
registry = DummyRegistry(regdata_6b + regdata_cv)
default_version = '6.0'
highest_version = '6.0'
number_of_versions = 1
install_locs = {
'6.0' : {'VSINSTALLDIR': 'C:\\VS6\\VC98', 'VCINSTALLDIR': 'C:\\VS6\\VC98\\Bin'},
'7.0' : {},
'7.1' : {},
'8.0' : {},
'8.0Exp' : {},
}
default_install_loc = install_locs['6.0']
class msvs6and7TestCase(msvsTestCase):
"""Test MSVS 6 & 7 Registry"""
registry = DummyRegistry(regdata_6b + regdata_7 + regdata_cv)
default_version = '7.0'
highest_version = '7.0'
number_of_versions = 2
install_locs = {
'6.0' : {'VSINSTALLDIR': 'C:\\VS6\\VC98',
'VCINSTALLDIR': 'C:\\VS6\\VC98\\Bin'},
'7.0' : {'VSINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio .NET\\Common7',
'VCINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio .NET\\Common7\\Tools'},
'7.1' : {},
'8.0' : {},
'8.0Exp' : {},
}
default_install_loc = install_locs['7.0']
class msvs7TestCase(msvsTestCase):
"""Test MSVS 7 Registry"""
registry = DummyRegistry(regdata_7 + regdata_cv)
default_version = '7.0'
highest_version = '7.0'
number_of_versions = 1
install_locs = {
'6.0' : {},
'7.0' : {'VSINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio .NET\\Common7',
'VCINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio .NET\\Common7\\Tools'},
'7.1' : {},
'8.0' : {},
'8.0Exp' : {},
}
default_install_loc = install_locs['7.0']
class msvs71TestCase(msvsTestCase):
"""Test MSVS 7.1 Registry"""
registry = DummyRegistry(regdata_7_1 + regdata_cv)
default_version = '7.1'
highest_version = '7.1'
number_of_versions = 1
install_locs = {
'6.0' : {},
'7.0' : {},
'7.1' : {'VSINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio .NET 2003\\Common7',
'VCINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio .NET 2003\\Common7\\Tools'},
'8.0' : {},
'8.0Exp' : {},
}
default_install_loc = install_locs['7.1']
class msvs8ExpTestCase(msvsTestCase): # XXX: only one still not working
"""Test MSVS 8 Express Registry"""
registry = DummyRegistry(regdata_8exp + regdata_cv)
default_version = '8.0Exp'
highest_version = '8.0Exp'
number_of_versions = 1
install_locs = {
'6.0' : {},
'7.0' : {},
'7.1' : {},
'8.0' : {},
'8.0Exp' : {'VSINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio 8',
'VCINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio 8\\VC'},
}
default_install_loc = install_locs['8.0Exp']
class msvs80TestCase(msvsTestCase):
"""Test MSVS 8 Registry"""
registry = DummyRegistry(regdata_80 + regdata_cv)
default_version = '8.0'
highest_version = '8.0'
number_of_versions = 1
install_locs = {
'6.0' : {},
'7.0' : {},
'7.1' : {},
'8.0' : {'VSINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio 8',
'VCINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio 8\\VC'},
'8.0Exp' : {},
}
default_install_loc = install_locs['8.0']
class msvs140TestCase(msvsTestCase):
"""Test MSVS 140 Registry"""
registry = DummyRegistry(regdata_140 + regdata_cv)
default_version = '14.0'
highest_version = '14.0'
number_of_versions = 2
install_locs = {
'14.0' : {'VSINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio 14.0',
'VCINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio 14.0\\VC'},
}
default_install_loc = install_locs['14.0']
class msvsEmptyTestCase(msvsTestCase):
"""Test Empty Registry"""
registry = DummyRegistry(regdata_none)
default_version = SupportedVSList[0].version
highest_version = None
number_of_versions = 0
install_locs = {
'6.0' : {},
'7.0' : {},
'7.1' : {},
'8.0' : {},
'8.0Exp' : {},
}
default_install_loc = install_locs['8.0Exp']
if __name__ == "__main__":
# only makes sense to test this on win32
if sys.platform != 'win32':
sys.stdout.write("NO RESULT for msvsTests.py: '%s' is not win32\n" % sys.platform)
sys.exit(0)
SCons.Util.RegOpenKeyEx = DummyOpenKeyEx
SCons.Util.RegEnumKey = DummyEnumKey
SCons.Util.RegEnumValue = DummyEnumValue
SCons.Util.RegQueryValueEx = DummyQueryValue
SCons.Tool.MSCommon.vc.find_vc_pdir_vswhere = DummyVsWhere
os.path.exists = DummyExists # make sure all files exist :-)
os.path.isfile = DummyExists # make sure all files are files :-)
os.path.isdir = DummyExists # make sure all dirs are dirs :-)
exit_val = 0
test_classes = [
msvs6aTestCase,
msvs6bTestCase,
msvs6and7TestCase,
msvs7TestCase,
msvs71TestCase,
msvs8ExpTestCase,
msvs80TestCase,
msvs140TestCase,
msvsEmptyTestCase,
]
for test_class in test_classes:
# DEBUG
# print("TEST: ", test_class.__doc__)
back_osenv = copy.deepcopy(os.environ)
try:
# XXX: overriding the os.environ is bad, but doing it
# correctly is too complicated for now. Those tests should
# be fixed
for k in ['VS71COMNTOOLS',
'VS80COMNTOOLS',
'VS90COMNTOOLS']:
if k in os.environ:
del os.environ[k]
suite = unittest.makeSuite(test_class, 'test_')
if not TestUnit.cli.get_runner()().run(suite).wasSuccessful():
exit_val = 1
finally:
os.env = back_osenv
sys.exit(exit_val)
# Local Variables:
# tab-width:4
# indent-tabs-mode:nil
# End:
# vim: set expandtab tabstop=4 shiftwidth=4:

View File

@ -1,60 +0,0 @@
#
# __COPYRIGHT__
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import unittest
import os.path
import os
import SCons.Errors
from SCons.Tool.wix import *
from SCons.Environment import Environment
import TestCmd
# create fake candle and light, so the tool's exists() method will succeed
test = TestCmd.TestCmd(workdir = '')
test.write('candle.exe', 'rem this is candle')
test.write('light.exe', 'rem this is light')
os.environ['PATH'] += os.pathsep + test.workdir
class WixTestCase(unittest.TestCase):
def test_vars(self):
"""Test that WiX tool adds vars"""
env = Environment(tools=['wix'])
assert env['WIXCANDLE'] is not None
assert env['WIXCANDLEFLAGS'] is not None
assert env['WIXLIGHTFLAGS'] is not None
assert env.subst('$WIXOBJSUF') == '.wixobj'
assert env.subst('$WIXSRCSUF') == '.wxs'
if __name__ == "__main__":
unittest.main()
# Local Variables:
# tab-width:4
# indent-tabs-mode:nil
# End:
# vim: set expandtab tabstop=4 shiftwidth=4: