From 29249fe40802d8d07f0642ae42590e42a8e8b3f2 Mon Sep 17 00:00:00 2001 From: stevenknight Date: Sat, 6 Mar 2004 03:54:46 +0000 Subject: [PATCH] Update various default paths in MSVS .Net and MSVC 6.0 / 7. (Steve Christensen) git-svn-id: http://scons.tigris.org/svn/scons/trunk@917 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- doc/man/scons.1 | 54 ++++++++++++++++++++++++++++ src/CHANGES.txt | 8 +++++ src/RELEASE.txt | 33 ++++++++++++++---- src/engine/SCons/Tool/msvc.py | 66 +++++++++++++++++++++++++---------- src/engine/SCons/Tool/msvs.py | 9 +++-- 5 files changed, 144 insertions(+), 26 deletions(-) diff --git a/doc/man/scons.1 b/doc/man/scons.1 index 46a5dda4..c4c0f0cf 100644 --- a/doc/man/scons.1 +++ b/doc/man/scons.1 @@ -4702,6 +4702,60 @@ For VS7, it is: .IP Where '' is the installed location of Visual Studio. +.IP MSVS_USE_MFC_DIRS +Tells the MS Visual Studio tool(s) to use +the MFC directories in its default paths +for compiling and linking. +Under MSVS version 6, +setting +.B MSVS_USE_MFC_DIRS +to a non-zero value +adds the +.BR ATL\\include +and +.BR MFC\\include +directories to +the default +.B INCLUDE +external environment variable, +and adds the +.B MFC\\lib +directory to +the default +.B LIB +external environment variable. +Under MSVS version 7, +setting +.B MSVS_USE_MFC_DIRS +to a non-zero value +adds the +.BR atlmfc\\include +directory to the default +.B INCLUDE +external environment variable, +and adds the +.BR atlmfc\\lib +directory to the default +.B LIB +external environment variable. +The current default value is +.BR 1 , +which means these directories +are added to the paths by default. +This default value is likely to change +in a future release, +so users who want the ATL and MFC +values included in their paths +are encouraged to enable the +.B MSVS_USE_MFC_DIRS +value explicitly +to avoid future incompatibility. +This variable has no effect if the +.BR INCLUDE +or +.BR LIB +environment variables are set explictly. + .IP MSVS_VERSION Sets the preferred version of MSVS to use. diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 10609395..64e8d5be 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -45,6 +45,10 @@ RELEASE 0.95 - XXX - Fix the ability to save/restore a PackageOption to a file. + From Steve Christensen: + + - Update the MSVS .NET and MSVC 6.0/7.0 path detection. + From David M. Cooke: - Make the Fortran scanner case-insensitive for the INCLUDE string. @@ -194,6 +198,10 @@ RELEASE 0.95 - XXX - Make things like ${TARGET.dir} work in *PATH construction variables. + - Allow a $MSVS_USE_MFC_DIRS construction variable to control whether + ATL and MFC directories are included in the default INCLUDE and + LIB paths. + From Vincent Risi: - Add support for the bcc32, ilink32 and tlib Borland tools. diff --git a/src/RELEASE.txt b/src/RELEASE.txt index 54a079b4..a26e6f16 100644 --- a/src/RELEASE.txt +++ b/src/RELEASE.txt @@ -36,12 +36,11 @@ RELEASE 0.95 - XXX - The meaning of some of the values of the "mode" argument to the SCons.Util.scons_subst() and SCons.Util.scons_subst_list() - functions have been swapped. The wrapper Environment.subst() - and Environment.subst_list() methods remain completely unchanged, - this so this should have no external effect. (We've listed the - change here because it might cause a problem if you're reaching - into the SCons internals and calling either of the SCons.Util - functions directly.) + functions have been swapped. The wrapper Environment.subst() and + Environment.subst_list() methods remain completely unchanged, so + this should have no external effect. (We've listed the change here + because it might cause a problem if you're reaching into the SCons + internals and calling either of these SCons.Util functions directly.) - The "overrides" keyword argument to calls to the Builder() function used to create new Builder objects has been deprecated and will @@ -56,6 +55,28 @@ RELEASE 0.95 - XXX Builder(action = 'cp $TDIR/$TARGET $SDIR/$SOURCE', TDIR = dir1, SDIR = dir2) + Please note the following FUTURE changes that you may wish to prepare + for: + + - When compiling with Microsoft Visual Studio, SCons currently adds + the ATL and MFC directories to the INCLUDE and LIB environment + variables by default. This default behavior will be changed in + a future release; the current plan is to change it for the 0.97 + release (two releases from now). + + Whether or not the ATL and MFC directories are added to these + environment variables is now controlled by a new MSVS_USE_MFC_DIRS + *construction* variable. Setting this variable to a non-zero + value when you initialize an Environment will ensure that these + directories will be included in your external path(s) even when + the default behavior changes: + + env = Environment(MSVS_USE_MFC_DIRS = 1) + + The MSVS_USE_MFC_DIRS variable may, of course, be set to 0 (or + None) to prevent SCons from adding the ATL and MFC directories to + the INCLUDE and LIB environment variables. + SCons is developed with an extensive regression test suite, and a rigorous development methodology for continually improving that suite. Because of this, SCons is of sufficient quality that you can use it diff --git a/src/engine/SCons/Tool/msvc.py b/src/engine/SCons/Tool/msvc.py index e2c0b65a..a9165012 100644 --- a/src/engine/SCons/Tool/msvc.py +++ b/src/engine/SCons/Tool/msvc.py @@ -52,7 +52,7 @@ CXXSuffixes = ['.cc', '.cpp', '.cxx', '.c++', '.C++'] def _parse_msvc7_overrides(version): """ Parse any overridden defaults for MSVS directory locations in MSVS .NET. """ - + # First, we get the shell folder for this user: if not SCons.Util.can_read_reg: raise SCons.Errors.InternalError, "No Windows registry module was found" @@ -192,7 +192,7 @@ def get_msvc_path (path, version, platform='x86'): # if we got here, then we didn't find the registry entries: raise SCons.Errors.InternalError, "The %s path was not found in the registry."%path -def _get_msvc6_default_paths(version): +def _get_msvc6_default_paths(version, use_mfc_dirs): """Return a 3-tuple of (INCLUDE, LIB, PATH) as the values of those three environment variables that should be set in order to execute the MSVC 6.0 tools properly, if the information wasn't available @@ -217,17 +217,29 @@ def _get_msvc6_default_paths(version): MVSVCdir = os.path.join(MVSdir,'VC98') MVSCommondir = r'%s\Common' % MVSdir - include_path = r'%s\ATL\include;%s\MFC\include;%s\include' % (MVSVCdir, MVSVCdir, MVSVCdir) - lib_path = r'%s\MFC\lib;%s\lib' % (MVSVCdir, MVSVCdir) - exe_path = r'%s\MSDev98\bin;%s\bin' % (MVSCommondir, MVSVCdir) + if use_mfc_dirs: + mfc_include_ = r'%s\ATL\include;%s\MFC\include;' % (MVSVCdir, MVSVCdir) + mfc_lib_ = r'%s\MFC\lib;' % MVSVCdir + else: + mfc_include_ = '' + mfc_lib_ = '' + include_path = r'%s%s\include' % (mfc_include_, MVSVCdir) + lib_path = r'%s%s\lib' % (mfc_lib_, MVSVCdir) + + if os.environ.has_key('OS') and os.environ['OS'] == "Windows_NT": + osdir = 'WINNT' + else: + osdir = 'WIN95' + + exe_path = r'%s\tools\%s;%s\MSDev98\bin;%s\tools;%s\bin' % (MVSCommondir, osdir, MVSCommondir, MVSCommondir, MVSVCdir) return (include_path, lib_path, exe_path) -def _get_msvc7_default_paths(version): +def _get_msvc7_default_paths(version, use_mfc_dirs): """Return a 3-tuple of (INCLUDE, LIB, PATH) as the values of those three environment variables that should be set in order to execute the MSVC .NET tools properly, if the information wasn't available from the registry.""" - + MVSdir = None paths = {} exe_path = '' @@ -243,19 +255,34 @@ def _get_msvc7_default_paths(version): # last resort -- default install location MVSdir = r'C:\Program Files\Microsoft Visual Studio .NET' - if not MVSdir: + if MVSdir: if SCons.Util.can_read_reg and paths.has_key('VCINSTALLDIR'): MVSVCdir = paths['VCINSTALLDIR'] else: MVSVCdir = os.path.join(MVSdir,'Vc7') MVSCommondir = r'%s\Common7' % MVSdir - include_path = r'%s\atlmfc\include;%s\include' % (MVSVCdir, MVSVCdir, MVSVCdir) - lib_path = r'%s\atlmfc\lib;%s\lib' % (MVSVCdir, MVSVCdir) - exe_path = r'%s\Tools\bin;%s\Tools;%s\bin' % (MVSCommondir, MVSCommondir, MVSVCdir) + if use_mfc_dirs: + mfc_include_ = r'%s\atlmfc\include;' % MVSVCdir + mfc_lib_ = r'%s\atlmfc\lib;' % MVSVCdir + else: + mfc_include_ = '' + mfc_lib_ = '' + include_path = r'%s%s\include;%s\PlatformSDK\include' % (mfc_include_, MVSVCdir, MVSVCdir) + lib_path = r'%s%s\lib;%s\PlatformSDK\lib' % (mfc_lib_, MVSVCdir, MVSVCdir) + exe_path = r'%s\IDE;%s\bin;%s\Tools;%s\Tools\bin' % (MVSCommondir,MVSVCdir, MVSCommondir, MVSCommondir ) + + 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'] + + 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']) + return (include_path, lib_path, exe_path) -def get_msvc_paths(version=None): +def get_msvc_paths(version=None, use_mfc_dirs=0): """Return a 3-tuple of (INCLUDE, LIB, PATH) as the values of those three environment variables that should be set in order to execute the MSVC tools properly.""" @@ -276,10 +303,10 @@ def get_msvc_paths(version=None): # base installation from the registry and deduce the default # directories. if float(version) >= 7.0: - defpaths = _get_msvc7_default_paths(version) + defpaths = _get_msvc7_default_paths(version, use_mfc_dirs) else: - defpaths = _get_msvc6_default_paths(version) - + defpaths = _get_msvc6_default_paths(version, use_mfc_dirs) + try: include_path = get_msvc_path("include", version) except (SCons.Util.RegError, SCons.Errors.InternalError): @@ -294,7 +321,7 @@ def get_msvc_paths(version=None): exe_path = get_msvc_path("path", version) except (SCons.Util.RegError, SCons.Errors.InternalError): exe_path = defpaths[2] - + return (include_path, lib_path, exe_path) def get_msvc_default_paths(version = None): @@ -432,7 +459,10 @@ def generate(env): if env.has_key('MSVS_IGNORE_IDE_PATHS') and env['MSVS_IGNORE_IDE_PATHS']: include_path, lib_path, exe_path = get_msvc_default_paths(version) else: - include_path, lib_path, exe_path = get_msvc_paths(version) + # By default, add the MFC directories, because this is what + # we've been doing for a long time. We may change this. + use_mfc_dirs = env.get('MSVS_USE_MFC_DIRS', 1) + include_path, lib_path, exe_path = get_msvc_paths(version, use_mfc_dirs) # since other tools can set these, we just make sure that the # relevant stuff from MSVS is in there somewhere. @@ -453,7 +483,7 @@ def exists(env): v = SCons.Tool.msvs.get_visualstudio_versions() except (SCons.Util.RegError, SCons.Errors.InternalError): pass - + if not v: return env.Detect('cl') else: diff --git a/src/engine/SCons/Tool/msvs.py b/src/engine/SCons/Tool/msvs.py index d7dfffe3..10ab42af 100644 --- a/src/engine/SCons/Tool/msvs.py +++ b/src/engine/SCons/Tool/msvs.py @@ -933,8 +933,13 @@ def get_msvs_install_dirs(version = None): # .NET framework SDK install dir try: - (rv['FRAMEWORKSDKDIR'], t) = SCons.Util.RegGetValue(SCons.Util.HKEY_LOCAL_MACHINE, - r'Software\Microsoft\.NETFramework\sdkInstallRoot') + if rv.has_key('FRAMEWORKVERSION') and rv['FRAMEWORKVERSION'][:4] == 'v1.1': + key = r'Software\Microsoft\.NETFramework\sdkInstallRootv1.1' + else: + key = r'Software\Microsoft\.NETFramework\sdkInstallRoot' + + (rv['FRAMEWORKSDKDIR'], t) = SCons.Util.RegGetValue(SCons.Util.HKEY_LOCAL_MACHINE,key) + except SCons.Util.RegError: pass -- 2.26.2