summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/Tool
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/SCons/Tool')
-rw-r--r--src/engine/SCons/Tool/as.py4
-rw-r--r--src/engine/SCons/Tool/fortran.py2
-rw-r--r--src/engine/SCons/Tool/gcc.py2
-rw-r--r--src/engine/SCons/Tool/mingw.py3
-rw-r--r--src/engine/SCons/Tool/mslink.xml14
-rw-r--r--src/engine/SCons/Tool/msvc.py12
-rw-r--r--src/engine/SCons/Tool/msvc.xml47
-rw-r--r--src/engine/SCons/Tool/msvs.py104
-rw-r--r--src/engine/SCons/Tool/msvsTests.py12
9 files changed, 139 insertions, 61 deletions
diff --git a/src/engine/SCons/Tool/as.py b/src/engine/SCons/Tool/as.py
index 5a267a5..1b1b4b3 100644
--- a/src/engine/SCons/Tool/as.py
+++ b/src/engine/SCons/Tool/as.py
@@ -52,11 +52,15 @@ def generate(env):
for suffix in ASSuffixes:
static_obj.add_action(suffix, SCons.Defaults.ASAction)
+ shared_obj.add_action(suffix, SCons.Defaults.ASAction)
static_obj.add_emitter(suffix, SCons.Defaults.StaticObjectEmitter)
+ shared_obj.add_emitter(suffix, SCons.Defaults.SharedObjectEmitter)
for suffix in ASPPSuffixes:
static_obj.add_action(suffix, SCons.Defaults.ASPPAction)
+ shared_obj.add_action(suffix, SCons.Defaults.ASPPAction)
static_obj.add_emitter(suffix, SCons.Defaults.StaticObjectEmitter)
+ shared_obj.add_emitter(suffix, SCons.Defaults.SharedObjectEmitter)
env['AS'] = env.Detect(assemblers) or 'as'
env['ASFLAGS'] = SCons.Util.CLVar('')
diff --git a/src/engine/SCons/Tool/fortran.py b/src/engine/SCons/Tool/fortran.py
index b694a58..b83e7d3 100644
--- a/src/engine/SCons/Tool/fortran.py
+++ b/src/engine/SCons/Tool/fortran.py
@@ -146,7 +146,7 @@ def add_to_env(env):
env['FORTRANMODDIR'] = '' # where the compiler should place .mod files
env['FORTRANMODDIRPREFIX'] = '' # some prefix to $FORTRANMODDIR - similar to $INCPREFIX
env['FORTRANMODDIRSUFFIX'] = '' # some suffix to $FORTRANMODDIR - similar to $INCSUFFIX
- env['_FORTRANMODFLAG'] = '$( ${_concat(FORTRANMODDIRPREFIX, FORTRANMODDIR, FORTRANMODDIRSUFFIX, __env__)} $)'
+ env['_FORTRANMODFLAG'] = '$( ${_concat(FORTRANMODDIRPREFIX, FORTRANMODDIR, FORTRANMODDIRSUFFIX, __env__, RDirs)} $)'
env.AppendUnique(FORTRANSUFFIXES = FortranSuffixes + FortranPPSuffixes)
diff --git a/src/engine/SCons/Tool/gcc.py b/src/engine/SCons/Tool/gcc.py
index 1be665a..ad02e0d 100644
--- a/src/engine/SCons/Tool/gcc.py
+++ b/src/engine/SCons/Tool/gcc.py
@@ -46,7 +46,7 @@ def generate(env):
cc.generate(env)
env['CC'] = env.Detect(compilers) or 'gcc'
- if env['PLATFORM'] == 'cygwin':
+ if env['PLATFORM'] in ['cygwin', 'win32']:
env['SHCCFLAGS'] = SCons.Util.CLVar('$CCFLAGS')
else:
env['SHCCFLAGS'] = SCons.Util.CLVar('$CCFLAGS -fPIC')
diff --git a/src/engine/SCons/Tool/mingw.py b/src/engine/SCons/Tool/mingw.py
index 5765e25..d679b53 100644
--- a/src/engine/SCons/Tool/mingw.py
+++ b/src/engine/SCons/Tool/mingw.py
@@ -118,7 +118,7 @@ def generate(env):
# Most of mingw is the same as gcc and friends...
- gnu_tools = ['gcc', 'g++', 'gnulink', 'ar', 'gas']
+ gnu_tools = ['gcc', 'g++', 'gnulink', 'ar', 'gas', 'm4']
for tool in gnu_tools:
SCons.Tool.Tool(tool)(env)
@@ -130,7 +130,6 @@ def generate(env):
env['SHLINKFLAGS'] = SCons.Util.CLVar('$LINKFLAGS -shared')
env['SHLINKCOM'] = shlib_action
env.Append(SHLIBEMITTER = [shlib_emitter])
- env['LINK'] = 'g++'
env['AS'] = 'as'
env['WIN32DEFPREFIX'] = ''
diff --git a/src/engine/SCons/Tool/mslink.xml b/src/engine/SCons/Tool/mslink.xml
index 58cfb1d..6499cfe 100644
--- a/src/engine/SCons/Tool/mslink.xml
+++ b/src/engine/SCons/Tool/mslink.xml
@@ -37,6 +37,20 @@ Example:
<example>
env['PDB'] = 'hello.pdb'
</example>
+
+The Visual C++ compiler switch that SCons uses by default
+to generate PDB information is <option>/Z7</option>.
+This works correctly with parallel (<option>-j</option>) builds
+because it embeds the debug information in the intermediate object files,
+as opposed to sharing a single PDB file between multiple object files.
+This is also the only way to get debug information
+embedded into a static library.
+Using the <option>/Zi</option> instead may yield improved
+link-time performance,
+although parallel builds will no longer work.
+You can generate PDB files with the <option>/Zi</option>
+switch by overriding the default &cv-CCPDBFLAGS; variable;
+see the entry for that variable for specific examples.
</summary>
</cvar>
diff --git a/src/engine/SCons/Tool/msvc.py b/src/engine/SCons/Tool/msvc.py
index 86cde78..80b5926 100644
--- a/src/engine/SCons/Tool/msvc.py
+++ b/src/engine/SCons/Tool/msvc.py
@@ -517,9 +517,10 @@ def _get_msvc8_default_paths(env, version, suite, use_mfc_dirs):
include_paths.append( env_include_path )
if SCons.Util.can_read_reg and paths.has_key('FRAMEWORKSDKDIR'):
- include_paths.append( os.path.join( paths['FRAMEWORKSDKDIR'], 'include' ) )
- lib_paths.append( os.path.join( paths['FRAMEWORKSDKDIR'], 'lib' ) )
- exe_paths.append( paths['FRAMEWORKSDKDIR'], 'bin' )
+ fwdir = paths['FRAMEWORKSDKDIR']
+ include_paths.append( os.path.join( fwdir, 'include' ) )
+ lib_paths.append( os.path.join( fwdir, 'lib' ) )
+ exe_paths.append( os.path.join( fwdir, 'bin' ) )
if SCons.Util.can_read_reg and paths.has_key('FRAMEWORKDIR') and paths.has_key('FRAMEWORKVERSION'):
exe_paths.append( os.path.join( paths['FRAMEWORKDIR'], paths['FRAMEWORKVERSION'] ) )
@@ -658,7 +659,10 @@ pch_builder = SCons.Builder.Builder(action=pch_action, suffix='.pch',
emitter=pch_emitter,
source_scanner=SCons.Tool.SourceFileScanner)
res_action = SCons.Action.Action('$RCCOM', '$RCCOMSTR')
-res_builder = SCons.Builder.Builder(action=res_action, suffix='.res',
+res_builder = SCons.Builder.Builder(action=res_action,
+ src_suffix='.rc',
+ suffix='.res',
+ src_builder=[],
source_scanner=SCons.Tool.SourceFileScanner)
SCons.Tool.SourceFileScanner.add_scanner('.rc', SCons.Defaults.CScan)
diff --git a/src/engine/SCons/Tool/msvc.xml b/src/engine/SCons/Tool/msvc.xml
index 252d962..1c0f3fa 100644
--- a/src/engine/SCons/Tool/msvc.xml
+++ b/src/engine/SCons/Tool/msvc.xml
@@ -47,6 +47,53 @@ env.RES('resource.rc')
</summary>
</builder>
+<cvar name="CCPCHFLAGS">
+<summary>
+Options added to the compiler command line
+to support building with precompiled headers.
+The default value expands expands to the appropriate
+Microsoft Visual C++ command-line options
+when the &cv-PCH; construction variable is set.
+</summary>
+
+<cvar name="CCPDBFLAGS">
+<summary>
+Options added to the compiler command line
+to support storing debugging information in a
+Microsoft Visual C++ PDB file.
+The default value expands expands to appropriate
+Microsoft Visual C++ command-line options
+when the &cv-PDB; construction variable is set.
+
+The Visual C++ compiler option that SCons uses by default
+to generate PDB information is <option>/Z7</option>.
+This works correctly with parallel (<option>-j</option>) builds
+because it embeds the debug information in the intermediate object files,
+as opposed to sharing a single PDB file between multiple object files.
+This is also the only way to get debug information
+embedded into a static library.
+Using the <option>/Zi</option> instead may yield improved
+link-time performance,
+although parallel builds will no longer work.
+
+You can generate PDB files with the <option>/Zi</option>
+switch by overriding the default &cv-CCPDBFLAGS; variable as follows:
+
+<example>
+import SCons.Util
+env['CCPDBFLAGS'] = SCons.Util.CLVar(['${(PDB and "/Zi /Fd%s" % File(PDB)) or ""}'])
+</example>
+
+An alternative would be to use the <option>/Zi</option>
+to put the debugging information in a separate <filename>.pdb</filename>
+file for each object file by overriding
+the &cv-CCPDBFLAGS; variable as follows:
+
+<example>
+env['CCPDBFLAGS'] = '/Zi /Fd${TARGET}.pdb'
+</example>
+</summary>
+
<cvar name="PCH">
<summary>
The Microsoft Visual C++ precompiled header that will be used when compiling
diff --git a/src/engine/SCons/Tool/msvs.py b/src/engine/SCons/Tool/msvs.py
index e8aaf83..e35c92a 100644
--- a/src/engine/SCons/Tool/msvs.py
+++ b/src/engine/SCons/Tool/msvs.py
@@ -297,7 +297,7 @@ class _DSPGenerator:
for n in sourcenames:
self.sources[n].sort(lambda a, b: cmp(a.lower(), b.lower()))
- def AddConfig(variant, buildtarget, outdir, runfile, cmdargs):
+ def AddConfig(self, variant, buildtarget, outdir, runfile, cmdargs, dspfile=dspfile):
config = Config()
config.buildtarget = buildtarget
config.outdir = outdir
@@ -316,7 +316,7 @@ class _DSPGenerator:
print "Adding '" + self.name + ' - ' + config.variant + '|' + config.platform + "' to '" + str(dspfile) + "'"
for i in range(len(variants)):
- AddConfig(variants[i], buildtarget[i], outdir[i], runfile[i], cmdargs)
+ AddConfig(self, variants[i], buildtarget[i], outdir[i], runfile[i], cmdargs)
self.platforms = []
for key in self.configs.keys():
@@ -690,6 +690,29 @@ class _GenerateV7DSP(_DSPGenerator):
pdata = base64.encodestring(pdata)
self.file.write(pdata + '-->\n')
+ def printSources(self, hierarchy, commonprefix):
+ sorteditems = hierarchy.items()
+ sorteditems.sort(lambda a, b: cmp(a[0].lower(), b[0].lower()))
+
+ # First folders, then files
+ for key, value in sorteditems:
+ if SCons.Util.is_Dict(value):
+ self.file.write('\t\t\t<Filter\n'
+ '\t\t\t\tName="%s"\n'
+ '\t\t\t\tFilter="">\n' % (key))
+ self.printSources(value, commonprefix)
+ self.file.write('\t\t\t</Filter>\n')
+
+ for key, value in sorteditems:
+ if SCons.Util.is_String(value):
+ file = value
+ if commonprefix:
+ file = os.path.join(commonprefix, value)
+ file = os.path.normpath(file)
+ self.file.write('\t\t\t<File\n'
+ '\t\t\t\tRelativePath="%s">\n'
+ '\t\t\t</File>\n' % (file))
+
def PrintSourceFiles(self):
categories = {'Source Files': 'cpp;c;cxx;l;y;def;odl;idl;hpj;bat',
'Header Files': 'h;hpp;hxx;hm;inl',
@@ -708,43 +731,26 @@ class _GenerateV7DSP(_DSPGenerator):
'\t\t\tName="%s"\n'
'\t\t\tFilter="%s">\n' % (kind, categories[kind]))
-
- def printSources(hierarchy, commonprefix):
- sorteditems = hierarchy.items()
- sorteditems.sort(lambda a, b: cmp(a[0].lower(), b[0].lower()))
-
- # First folders, then files
- for key, value in sorteditems:
- if SCons.Util.is_Dict(value):
- self.file.write('\t\t\t<Filter\n'
- '\t\t\t\tName="%s"\n'
- '\t\t\t\tFilter="">\n' % (key))
- printSources(value, commonprefix)
- self.file.write('\t\t\t</Filter>\n')
-
- for key, value in sorteditems:
- if SCons.Util.is_String(value):
- file = value
- if commonprefix:
- file = os.path.join(commonprefix, value)
- file = os.path.normpath(file)
- self.file.write('\t\t\t<File\n'
- '\t\t\t\tRelativePath="%s">\n'
- '\t\t\t</File>\n' % (file))
-
sources = self.sources[kind]
# First remove any common prefix
commonprefix = None
if len(sources) > 1:
s = map(os.path.normpath, sources)
- cp = os.path.commonprefix(s)
+ # take the dirname because the prefix may include parts
+ # of the filenames (e.g. if you have 'dir\abcd' and
+ # 'dir\acde' then the cp will be 'dir\a' )
+ cp = os.path.dirname( os.path.commonprefix(s) )
if cp and s[0][len(cp)] == os.sep:
- sources = map(lambda s, l=len(cp): s[l:], sources)
+ # +1 because the filename starts after the separator
+ sources = map(lambda s, l=len(cp)+1: s[l:], sources)
commonprefix = cp
+ elif len(sources) == 1:
+ commonprefix = os.path.dirname( sources[0] )
+ sources[0] = os.path.basename( sources[0] )
hierarchy = makeHierarchy(sources)
- printSources(hierarchy, commonprefix=commonprefix)
+ self.printSources(hierarchy, commonprefix=commonprefix)
if len(cats)>1:
self.file.write('\t\t</Filter>\n')
@@ -873,7 +879,7 @@ class _GenerateV7DSW(_DSWGenerator):
if self.nokeep == 0 and os.path.exists(self.dswfile):
self.Parse()
- def AddConfig(variant):
+ def AddConfig(self, variant, dswfile=dswfile):
config = Config()
match = re.match('(.*)\|(.*)', variant)
@@ -892,10 +898,10 @@ class _GenerateV7DSW(_DSWGenerator):
"You must specify a 'variant' argument (i.e. 'Debug' or " +\
"'Release') to create an MSVS Solution File."
elif SCons.Util.is_String(env['variant']):
- AddConfig(env['variant'])
+ AddConfig(self, env['variant'])
elif SCons.Util.is_List(env['variant']):
for variant in env['variant']:
- AddConfig(variant)
+ AddConfig(self, variant)
self.platforms = []
for key in self.configs.keys():
@@ -1127,32 +1133,24 @@ def GenerateDSW(dswfile, source, env):
def get_default_visualstudio_version(env):
"""Returns the version set in the env, or the latest version
installed, if it can find it, or '6.0' if all else fails. Also
- updated the environment with what it found."""
+ updates the environment with what it found."""
- version = '6.0'
- versions = [version]
+ versions = ['6.0']
if not env.has_key('MSVS') or not SCons.Util.is_Dict(env['MSVS']):
- env['MSVS'] = {}
-
- if env['MSVS'].has_key('VERSIONS'):
- versions = env['MSVS']['VERSIONS']
- elif SCons.Util.can_read_reg:
- v = get_visualstudio_versions()
- if v:
- versions = v
- if env.has_key('MSVS_VERSION'):
- version = env['MSVS_VERSION']
- else:
- version = versions[0] #use highest version by default
-
- env['MSVS_VERSION'] = version
- env['MSVS']['VERSIONS'] = versions
- env['MSVS']['VERSION'] = version
+ v = get_visualstudio_versions()
+ if v:
+ versions = v
+ env['MSVS'] = {'VERSIONS' : versions}
else:
- version = env['MSVS']['VERSION']
+ 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 version
+ return env['MSVS_VERSION']
def get_visualstudio_versions():
"""
diff --git a/src/engine/SCons/Tool/msvsTests.py b/src/engine/SCons/Tool/msvsTests.py
index 6095dff..b1125e7 100644
--- a/src/engine/SCons/Tool/msvsTests.py
+++ b/src/engine/SCons/Tool/msvsTests.py
@@ -471,6 +471,18 @@ class msvsTestCase(unittest.TestCase):
assert env['MSVS']['VERSION'] == '7.0', env['MSVS']['VERSION']
assert v2 == '7.0', v2
+ env = DummyEnv()
+ v3 = get_default_visualstudio_version(env)
+ if v3 == '7.1':
+ override = '7.0'
+ else:
+ override = '7.1'
+ env['MSVS_VERSION'] = override
+ v3 = get_default_visualstudio_version(env)
+ assert env['MSVS_VERSION'] == override, env['MSVS_VERSION']
+ assert env['MSVS']['VERSION'] == override, env['MSVS']['VERSION']
+ assert v3 == override, v3
+
def test_get_visual_studio_versions(self):
"""Test retrieval of the list of visual studio versions"""
v1 = get_visualstudio_versions()