diff --git a/Contrib/System/SConscript b/Contrib/System/SConscript index 40512458..8c842fd7 100644 --- a/Contrib/System/SConscript +++ b/Contrib/System/SConscript @@ -38,10 +38,15 @@ if env['TARGET_ARCH'] != 'amd64' or msvc: # BUGBUG: Call-amd64.S is missing GAS defs += ['SYSTEM_PARTIALCALLSUPPORT'] filename = 'Call' + srcsuff + # When using the MS toolchain, SCons can pass .sx files to cl.exe: + # "D4024 : unrecognized source file type 'file.sx', object file assumed" + # "D4027 : source file 'file.sx' ignored" + # ...and then it returns 0! + # This only happens if TryCompile .S fails (ML/ML64 not in %PATH%?) conf = env.Configure() if conf.TryCompile('END', '.S'): files += ['Source/'+filename+'.S'] - elif conf.TryCompile('.end', '.sx'): + elif (not msvc) and conf.TryCompile('.end', '.sx'): files += ['Source/'+filename+'.sx'] else: print 'WARNING: System.dll: unable to find assembler for '+filename+'.S' diff --git a/SCons/Config/ms b/SCons/Config/ms index 735e6c95..a9d42ba5 100644 --- a/SCons/Config/ms +++ b/SCons/Config/ms @@ -242,6 +242,7 @@ def add_file(file, obj_name=None): # conf = stub_env.Configure() +conf.env.Append(LINKFLAGS = ['/entry:WinMain']) int64test = """ #include diff --git a/SCons/Tools/mstoolkit.py b/SCons/Tools/mstoolkit.py index d200dc3c..d19ee3e9 100644 --- a/SCons/Tools/mstoolkit.py +++ b/SCons/Tools/mstoolkit.py @@ -179,7 +179,7 @@ def win32ShlinkSources(target, source, env, for_signature): # Just treat it as a generic source file. listCmd.append(src) return listCmd - + def win32LibEmitter(target, source, env): # SCons.Tool.msvc.validate_vars(env) @@ -289,7 +289,7 @@ def generate(env): include_path, lib_path, exe_path, sdk_path = "", "", "", "" targ_arc = env.get('TARGET_ARCH', 'x86') - if os.environ.has_key('MSVC_USE_SCRIPT') and "None" == os.environ['MSVC_USE_SCRIPT']: + if "None" == env.get('MSVC_USE_SCRIPT', '!'): for x in ['INCLUDE', 'LIB', 'PATH', 'CL', 'LINK', 'ML']: env['ENV'][x] = "" if not env.WhereIs('cl', os.environ['PATH']): raise SCons.Errors.InternalError("CL not found in %s" % os.environ['PATH']) @@ -300,12 +300,14 @@ def generate(env): if not sdk_path: raise SCons.Errors.InternalError("windows.h not found in %s" % include_path) sdk_path = os.path.normpath(sdk_path + "\..\..") - sdk_path_AR = env.WhereIs('lib', exe_path) sdk_path_LINK = env.WhereIs('link', exe_path) + sdk_path_AR = env.WhereIs('lib', exe_path) else: include_path, lib_path, exe_path, sdk_path = get_msvctoolkit_paths() + if float(env['MSVS_VERSION']) < 7.0: # Override SConstruct default + env['MSVS_VERSION'] = '7.1' + sdk_path_LINK = env.WhereIs('link', exe_path) sdk_path_AR = sdk_path + '\\bin\\Win64\\lib.exe' - sdk_path_LINK = sdk_path + '\\bin\\Win64\\link.exe' env.PrependENVPath('INCLUDE', include_path) env.PrependENVPath('LIB', lib_path) @@ -327,8 +329,13 @@ def generate(env): env['PCHCOM'] = '$CXX $CXXFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS /c $SOURCES /Fo${TARGETS[1]} /Yc$PCHSTOP /Fp${TARGETS[0]} $CCPDBFLAGS' env['BUILDERS']['PCH'] = pch_builder - env['AR'] = '"' + sdk_path_AR + '"' - env['ARFLAGS'] = SCons.Util.CLVar('/nologo') + # VC 2003 Toolkit does not have lib.exe but we can use link.exe + if not sdk_path_AR or not env.File(sdk_path_AR).exists(): + env['AR'] = '"' + sdk_path_LINK + '"' + env['ARFLAGS'] = '/LIB ' + env['ARFLAGS'] + else: + env['AR'] = '"' + sdk_path_AR + '"' + env['ARFLAGS'] = SCons.Util.CLVar('/nologo') env['ARCOM'] = "${TEMPFILE('$AR $ARFLAGS /OUT:$TARGET $SOURCES')}" if 'AMD64' in targ_arc.upper(): @@ -362,8 +369,6 @@ def generate(env): env['REGSVRFLAGS'] = '/s ' env['REGSVRCOM'] = '$REGSVR $REGSVRFLAGS $TARGET' - if not env.has_key('MSVS_VERSION'): env['MSVS_VERSION'] = '7.1' - def exists(env): return env.Detect('cl') diff --git a/SConstruct b/SConstruct index baf1cf1a..add0f181 100644 --- a/SConstruct +++ b/SConstruct @@ -446,6 +446,8 @@ def DistributeExtras(env, target, examples, docs): ###################################################################### if defenv['MSTOOLKIT']: + if ARGUMENTS.get('MSVC_USE_SCRIPT', ''): + defenv['MSVC_USE_SCRIPT'] = ARGUMENTS.get('MSVC_USE_SCRIPT') defenv.Tool('mstoolkit', toolpath = [Dir('SCons/Tools').rdir()]) defenv.Append(CCFLAGS = Split('$APPEND_CCFLAGS'))