Commits

Anonymous committed 21762f4

Get rid of MSVCCommon/misc.py and MSVCCommon/version.py, now that
the necessary logic has been migrated to MSVCCommon/vs.py.

Comments (0)

Files changed (4)

src/engine/SCons/Tool/MSVCCommon/__init__.py

 import SCons.Platform.win32
 import SCons.Util
 
-from SCons.Tool.MSVCCommon.misc import FindMSVSBatFile
-
 from SCons.Tool.MSVCCommon.vs import detect_msvs, \
                                      get_default_version, \
                                      merge_default_version, \

src/engine/SCons/Tool/MSVCCommon/misc.py

-#
-# __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__"
-
-__doc__ = """
-"""
-
-import os
-
-import SCons.Errors
-
-from SCons.Tool.MSVCCommon.version import get_default_version
-from SCons.Tool.MSVCCommon.findloc import find_bat
-from SCons.Tool.MSVCCommon.envhelpers import normalize_env, get_output, parse_output
-from SCons.Tool.MSVCCommon.defaults import use_def_env
-from SCons.Tool.MSVCCommon.vs import get_installed_visual_studios
-
-def FindMSVSBatFile(version, flavor='std', arch="x86"):
-    """Returns the location of the MSVS bat file used to set up
-    Visual Studio.  Returns None if it is not found.
-
-    Arguments
-    ---------
-    version: float
-        the supported version are 7.0, 7.1 (VS 2003), 8.0 (VS 2005) and 9.0
-        (VS 2008)
-    flavor: str
-        flavor of VS: "std" and "express" are supported.
-    arch: str
-        only "x86" is supported.
-
-    Note
-    ----
-    The bat file is search in the following order:
-        - first look into the registry
-        - if not found, then look into the environment variable
-          VS*COMMNTOOLS"""
-
-    return find_bat(version, flavor)
-
-def FindDefaultMSVSBatFile(flavor='std', arch='x86'):
-    """Return default version of .bat file, with given flavor and arch."""
-    for v in [9.0, 8.0, 7.1, 7.0]:
-        batfilename = FindMSVSBatFile(v)
-        if batfilename is not None:
-            break
-
-    if batfilename is None:
-        msg = "No batfile for default version was found"
-        raise SCons.Errors.MSVCError(msg)
-
-    return batfilename
-
-def ParseBatFile(env, path, vars=['INCLUDE', 'LIB', 'LIBPATH', 'PATH'], args=None):
-    """Returns a dict of var/value pairs by running the batch file
-    and looking at the resulting environment variables.
-
-    Arguments
-    ---------
-    env: Environment
-        scons environment instance. Is used to provide an environment to
-        execute the bat file during parsing.
-    path: str
-        full path of the .bat file to set up VS environment (vsvarsall.bat,
-        etc...)
-    vars: seq
-        list of variables to look for
-    args: seq or None
-        list of arguments to pass to the .bat file through the cmd.exe
-        shell"""
-    if not os.path.exists(path):
-        raise ValueError("File %s does not exist on the filesystem!" % path)
-
-    # XXX: fix args handling here. Do not use a string but a sequence to avoid
-    # escaping problems, and letting Popen taking care of it for us.
-    msvs_list = get_installed_visual_studios()
-    # TODO(1.5)
-    #varnames = [ msvs.common_tools_var for msvs in msvs_list ]
-    varnames = map(lambda msvs: msvs.common_tools_var, msvs_list)
-    nenv = normalize_env(env['ENV'], varnames + ['COMSPEC'])
-    output = get_output(path, args, env=nenv)
-
-    return parse_output(output, vars)
-
-def MergeMSVSBatFile(env, version=None, batfilename=None,
-                     vars=["INCLUDE", "LIB", "LIBPATH", "PATH"],
-                     args=None):
-    """Find MSVC/MSVS bat file for given version, run it and parse the result
-    to update the environment.
-
-    If batfilename is given, it will be used. If not give, the .bat file
-    corresponding to the given version will be used. If the batfile does not
-    exists or is not found, an exception will be raised.
-
-    Arguments
-    ---------
-    env: Environment
-        the scons Environment instance to update
-    version: float or None
-        version of MSVS to use. If None, a list of versions will be looked
-        for, and the first found will be used.
-    batfilename: str
-        .bat file to use.
-
-    Note
-    ----
-    When version is None, the following versions are looked for, in that order:
-    9.0, 8.0, 7.1, 7.0.
-
-    Examples
-    --------
-    # Put the necessary variables from VS studio: the first version found
-    # will be used
-    MergeMSVSBatFile(env)
-    # Put the necessary variables from VS 2008
-    MergeMSVSBatFile(env, 9.0)
-    # Put the necessary variables from the file vcbatfile.bat
-    MergeMSVSBatFile(env, batfilename='vcbatfile.bat')
-    """
-    if not batfilename:
-        if version is None:
-            batfilename = FindDefaultMSVSBatFile()
-        else:
-            batfilename = FindMSVSBatFile(version)
-            if batfilename is None:
-                msg = "batfile for version %s not found" % version
-                raise SCons.Errors.MSVCError(msg)
-
-    vars = ParseBatFile(env, batfilename, vars, args)
-
-    for k, v in vars.items():
-        env.PrependENVPath(k, v, delete_existing=1)
-
-def merge_default_version(env):
-    version = get_default_version(env)
-    arch = get_default_arch(env)
-
-    # TODO(SK):  move this import up top without introducing circular
-    # problems with others importing merge_default_version().
-    import SCons.Tool.msvs
-    version_num, suite = SCons.Tool.msvs.msvs_parse_version(version)
-
-    batfilename = FindMSVSBatFile(version_num)
-    # XXX: I think this is broken. This will silently set a bogus tool instead
-    # of failing, but there is no other way with the current scons tool
-    # framework
-    if batfilename is not None:
-        vars = ('LIB', 'LIBPATH', 'PATH', 'INCLUDE')
-        vars = ParseBatFile(env, batfilename, vars, arch)
-
-        for k, v in vars.items():
-            env.PrependENVPath(k, v, delete_existing=1)
-
-    #try:
-    #    version = get_default_version(env)
-    #    if version is not None:
-    #        version_num, suite = SCons.Tool.msvs.msvs_parse_version(version)
-    #        if env.has_key('MSVS_USE_DEFAULT_PATHS') and \
-    #           env['MSVS_USE_DEFAULT_PATHS']:
-    #            use_def_env(env, version_num, 'std')
-    #            try:
-    #                use_def_env(env, version_num, 'std')
-    #            except ValueError, e:
-    #                print "Could not get defaultpaths: %s" % e
-    #                MergeMSVSBatFile(env, version_num)
-
-    #        else:
-    #            MergeMSVSBatFile(env, version_num)
-    #    else:
-    #        MergeMSVSBatFile(env)
-
-    #except SCons.Errors.MSVCError:
-    #    pass
-
-# Local Variables:
-# tab-width:4
-# indent-tabs-mode:nil
-# End:
-# vim: set expandtab tabstop=4 shiftwidth=4:

src/engine/SCons/Tool/MSVCCommon/version.py

-#
-# __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__"
-
-__doc__ = """
-"""
-
-import SCons.Util
-import SCons.Errors
-from SCons.Tool.MSVCCommon.findloc import find_bat
-from SCons.Tool.MSVCCommon.vs import get_installed_visual_studios
-
-# Default value of VS to use
-DEFVERSIONSTR = "9.0"
-DEFVERSION = float(DEFVERSIONSTR)
-
-# RDEVE: currently only these flavour have been tested
-SUPPORTED_ARCH = ['x86','amd64']
-
-
-def query_versions():
-    """Query the system to get available versions of VS. A version is
-    considered when a batfile is found."""
-    msvs_list = get_installed_visual_studios()
-    # TODO(1.5)
-    #versions = [ msvs.version for msvs in msvs_list ]
-    versions = map(lambda msvs:  msvs.version, msvs_list)
-    return versions
-
-def get_default_version(env):
-    """Return the default version to use for MSVS
-
-    if no version was requested by the user through the MSVS environment
-    variable, query all the available the visual studios through
-    query_versions, and take the highest one.
-
-    Return
-    ------
-    version: str
-        the default version."""
-    versions = [DEFVERSIONSTR]
-
-    if not env.has_key('MSVS') or not SCons.Util.is_Dict(env['MSVS']):
-        # TODO(1.5):
-        #v = [str(i) for i in query_versions()]
-        v = map(str, query_versions())
-        if v:
-            versions = v
-        env['MSVS'] = {'VERSIONS' : versions}
-    else:
-        versions = env['MSVS'].get('VERSIONS', versions)
-
-    if not env.has_key('MSVS_VERSION'):
-        env['MSVS_VERSION'] = versions[0] #use highest version by default
-
-    env['MSVS']['VERSION'] = env['MSVS_VERSION']
-
-    return env['MSVS_VERSION']
-
-def get_default_arch(env):
-    """Return the default arch to use for MSVS
-
-    if no version was requested by the user through the MSVS_ARCH environment
-    variable, select x86
-
-    Return
-    ------
-    arch: str
-    """
-
-    try:
-      arch=env['MSVS_ARCH']
-    except:
-      arch='x86'
-
-    if not arch in SUPPORTED_ARCH:
-      arch='x86'
-
-    return arch
-
-def detect_msvs():
-    """Return 1 if at least one version of MS toolchain is detected."""
-    version = query_versions()
-    if len(version) > 0:
-        return 1
-    else:
-        return 0
-
-# Local Variables:
-# tab-width:4
-# indent-tabs-mode:nil
-# End:
-# vim: set expandtab tabstop=4 shiftwidth=4:

test/MSVC/query_vcbat.py

 # Test the basics
 
 test.write('SConstruct', """
-from SCons.Tool.MSVCCommon.misc import FindMSVSBatFile, \\
-                                       ParseBatFile, \\
-                                       MergeMSVSBatFile
+#from SCons.Tool.MSVCCommon.misc import FindMSVSBatFile, \\
+#                                       ParseBatFile, \\
+#                                       MergeMSVSBatFile
 from SCons.Tool.MSVCCommon import query_versions
 #env = Environment(tools = ['mingw'])
 DefaultEnvironment(tools = [])