summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWilliam Deegan <bill@baddogconsulting.com>2019-03-12 18:24:47 (GMT)
committerGitHub <noreply@github.com>2019-03-12 18:24:47 (GMT)
commitcd967c0158ec1c5994e787d6f4b8d0f8ec5a0cb3 (patch)
tree2e92e6453528c0720c80b351a4ad01b131657685 /src
parent74187aaa981052573d5c9bd166fdde92194d1edb (diff)
parent5089549257a7cdbe5fa7035ed7cac476ec66444c (diff)
downloadSCons-cd967c0158ec1c5994e787d6f4b8d0f8ec5a0cb3.zip
SCons-cd967c0158ec1c5994e787d6f4b8d0f8ec5a0cb3.tar.gz
SCons-cd967c0158ec1c5994e787d6f4b8d0f8ec5a0cb3.tar.bz2
Merge branch 'master' into scons-symlink
Diffstat (limited to 'src')
-rwxr-xr-xsrc/Announce.txt8
-rwxr-xr-xsrc/CHANGES.txt47
-rwxr-xr-xsrc/RELEASE.txt4
-rw-r--r--src/engine/SCons/ActionTests.py33
-rw-r--r--src/engine/SCons/BuilderTests.py16
-rw-r--r--src/engine/SCons/Defaults.py6
-rw-r--r--src/engine/SCons/Environment.py7
-rw-r--r--src/engine/SCons/EnvironmentTests.py16
-rw-r--r--src/engine/SCons/Job.py2
-rw-r--r--src/engine/SCons/Node/FS.py58
-rw-r--r--src/engine/SCons/Node/NodeTests.py4
-rw-r--r--src/engine/SCons/Platform/__init__.py4
-rw-r--r--src/engine/SCons/Platform/win32.py4
-rw-r--r--src/engine/SCons/SConf.py76
-rw-r--r--src/engine/SCons/SConfTests.py8
-rw-r--r--src/engine/SCons/SConsign.py3
-rw-r--r--src/engine/SCons/Scanner/LaTeXTests.py6
-rw-r--r--src/engine/SCons/Scanner/ScannerTests.py6
-rw-r--r--src/engine/SCons/Script/Main.py2
-rw-r--r--src/engine/SCons/Script/SConscript.py11
-rw-r--r--src/engine/SCons/Script/SConscript.xml4
-rw-r--r--src/engine/SCons/TaskmasterTests.py1
-rw-r--r--src/engine/SCons/Tool/JavaCommon.py4
-rw-r--r--src/engine/SCons/Tool/MSCommon/common.py6
-rw-r--r--src/engine/SCons/Tool/MSCommon/vc.py47
-rw-r--r--src/engine/SCons/Tool/__init__.py2
-rw-r--r--src/engine/SCons/Tool/gcc.py38
-rw-r--r--src/engine/SCons/Tool/lex.py44
-rw-r--r--src/engine/SCons/Tool/lex.xml9
-rw-r--r--src/engine/SCons/Tool/link.py2
-rw-r--r--src/engine/SCons/Tool/mingw.py71
-rw-r--r--src/engine/SCons/Tool/msvc.py6
-rw-r--r--src/engine/SCons/Tool/msvs.py4
-rw-r--r--src/engine/SCons/Tool/msvs.xml966
-rw-r--r--src/engine/SCons/Tool/msvsTests.py4
-rw-r--r--src/engine/SCons/Tool/swig.py26
-rw-r--r--src/engine/SCons/Tool/tex.py26
-rw-r--r--src/engine/SCons/Tool/textfile.xml4
-rw-r--r--src/engine/SCons/Tool/yacc.py30
-rw-r--r--src/engine/SCons/cpp.py28
-rw-r--r--src/engine/SCons/cppTests.py3
-rw-r--r--src/engine/SCons/dblite.py7
-rw-r--r--src/script/scons-time.py16
43 files changed, 1063 insertions, 606 deletions
diff --git a/src/Announce.txt b/src/Announce.txt
index 4058aa6..d181de5 100755
--- a/src/Announce.txt
+++ b/src/Announce.txt
@@ -18,12 +18,18 @@ So that everyone using SCons can help each other learn how to use it more
effectively, please go to http://scons.org/lists.html#users to sign up for
the scons-users mailing list.
-RELEASE VERSION/DATE TO BE FILLED IN LATER
+RELEASE 3.0.5.alpha.yyyymmdd - NEW DATE WILL BE INSERTED HERE
Please consult the RELEASE.txt file for a summary of changes since the last
release and consult the CHANGES.txt file for complete a list of changes
since last release. This announcement highlights only the important
changes.
+ Please note the following important changes since release 3.0.3:
+ - Added TEMPFILESUFFIX to allow user to specify suffix for tempfiles used for long command lines
+ - Initial support for ARM architectures with Microsoft Visual Studio 2017. You must set TARGET_ARCH
+ to arm or arm64 to enable.
+ - Fixed issue detecting installs of Microsoft Visual Studio 2017 as well as Microsoft build tools 2017.
+
Please note the following important changes since release 2.5.1:
This is the initial release supporting both python 3.5+ and 2.7.x and pypy
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index 4f61881..fc61bb2 100755
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -5,11 +5,47 @@
Change Log
-RELEASE VERSION/DATE TO BE FILLED IN LATER
+RELEASE 3.0.5.alpha.yyyymmdd - NEW DATE WILL BE INSERTED HERE
+
+ From William Deegan:
+
+ - Fix Issue #3283 - Handle using --config=force in combination with Decider('MD5-timestamp').
+ 3.0.2 in fix for issue #2980 added that deciders can throw DeciderNeedsNode exception.
+ The Configure logic directly calls the decider when using --config=force but wasn't handling
+ that exception. This would yield minimally configure tests using TryLink() not running and
+ leaving TypeError Nonetype exception in config.log
+ - Fix Issue #3303 - Handle --config=force overwriting the Environment passed into Configure()'s
+ Decider and not clearing it when the configure context is completed.
+ - Add default paths for yacc tool on windows to include cygwin, mingw, and chocolatey
+ - Fix issue #2799 - Fix mingw tool to respect SHCCCOMSTR, SHLINKCOMSTR and LDMODULECOMSTR
+
+ From Daniel Moody:
+ - Change the default for AppendENVPath to delete_existing=0, so path
+ order will not be changed, unless explicitly set (Issue #3276)
+ - Fixed bug which threw error when running SCons on windows system with no MSVC installed.
+ - Update link tool to convert target to node before accessing node member
+ - Update mingw tool to remove MSVC like nologo CCFLAG
+ - Add default paths for lex tool on windows to include cygwin, mingw, and chocolatey
+ - Add lex construction variable LEXUNISTD for turning off unix headers on windows
+ - Update lex tool to use win_flex on windows if available
+
+ From Mats Wichmann:
+ - Quiet open file ResourceWarnings on Python >= 3.6 caused by
+ not using a context manager around Popen.stdout
+ - Add the textfile tool to the default tool list
+ - Fix syntax on is/is not clauses: should not use with a literal
+ - Properly retrieve exit code when catching SystemExit
+ - scons-time now uses context managers around file opens
+ - Fix regex patterns that were not specified as raw strings
+
+ From Bernhard M. Wiedemann:
+ - Do not store build host+user name if reproducible builds are wanted
+
+ From Maciej Kumorek:
+ - Update the MSVC tool to include the nologo flag by default in RCFLAGS
+
+RELEASE 3.0.4 - Mon, 20 Jan 2019 22:49:27 +0000
- From John Doe:
- - Whatever John Doe did.
-
From Mats Wichmann:
- Improve finding of Microsoft compiler: add a 'products' wildcard
in case 2017 Build Tools only is installed as it is considered a separate
@@ -19,9 +55,12 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
- scons.py and sconsign.py stopped working if script called as a symlink
to location in scons-local location.
- Fix issue running scons using a symlink to scons.py in an scons-local dir
+ - Doc updates around Default(), and the various *TARGETS variables.
From Daniel Moody:
- Improved support for VC14.1 and Visual Studio 2017, as well as arm and arm64 targets.
+ Issues #3268 & Issue #3222
+ - Initial support for ARM targets with Visual Studio 2017 - Issue #3182 (You must set TARGET_ARCH for this to work)
- Update TempFileMunge class to use PRINT_CMD_LINE_FUNC
From Tobias Herzog
diff --git a/src/RELEASE.txt b/src/RELEASE.txt
index 8987ee2..28376a6 100755
--- a/src/RELEASE.txt
+++ b/src/RELEASE.txt
@@ -1,7 +1,7 @@
- A new SCons checkpoint release, 3.0.4.alpha.yyyymmdd, is now available
+ A new SCons checkpoint release, 3.0.5.alpha.yyyymmdd, is now available
on the SCons download page:
- http://www.scons.org/download.php
+ https://scons.org/pages/download.html
XXX The primary purpose of this release ... XXX
diff --git a/src/engine/SCons/ActionTests.py b/src/engine/SCons/ActionTests.py
index a27f598..efe6e98 100644
--- a/src/engine/SCons/ActionTests.py
+++ b/src/engine/SCons/ActionTests.py
@@ -62,25 +62,28 @@ test = TestCmd.TestCmd(workdir='')
test.write('act.py', """\
import os, string, sys
-f = open(sys.argv[1], 'w')
-f.write("act.py: '" + "' '".join(sys.argv[2:]) + "'\\n")
-try:
- if sys.argv[3]:
- f.write("act.py: '" + os.environ[sys.argv[3]] + "'\\n")
-except:
- pass
-f.close()
+
+with open(sys.argv[1], 'w') as f:
+ f.write("act.py: '" + "' '".join(sys.argv[2:]) + "'\\n")
+ try:
+ if sys.argv[3]:
+ f.write("act.py: '" + os.environ[sys.argv[3]] + "'\\n")
+ except:
+ pass
+
if 'ACTPY_PIPE' in os.environ:
if 'PIPE_STDOUT_FILE' in os.environ:
- stdout_msg = open(os.environ['PIPE_STDOUT_FILE'], 'r').read()
+ with open(os.environ['PIPE_STDOUT_FILE'], 'r') as f:
+ stdout_msg = f.read()
else:
stdout_msg = "act.py: stdout: executed act.py %s\\n" % ' '.join(sys.argv[1:])
sys.stdout.write( stdout_msg )
if 'PIPE_STDERR_FILE' in os.environ:
- stderr_msg = open(os.environ['PIPE_STDERR_FILE'], 'r').read()
+ with open(os.environ['PIPE_STDERR_FILE'], 'r') as f:
+ stderr_msg = f.read()
else:
stderr_msg = "act.py: stderr: executed act.py %s\\n" % ' '.join(sys.argv[1:])
- sys.stderr.write( stderr_msg )
+ sys.stderr.write(stderr_msg)
sys.exit(0)
""")
@@ -490,7 +493,7 @@ class _ActionActionTestCase(unittest.TestCase):
a = SCons.Action._ActionAction(cmdstr='cmdstr')
assert not hasattr(a, 'strfunction')
- assert a.cmdstr is 'cmdstr', a.cmdstr
+ assert a.cmdstr == 'cmdstr', a.cmdstr
a = SCons.Action._ActionAction(cmdstr=None)
assert not hasattr(a, 'strfunction')
@@ -504,7 +507,7 @@ class _ActionActionTestCase(unittest.TestCase):
assert a.presub is func1, a.presub
a = SCons.Action._ActionAction(chdir=1)
- assert a.chdir is 1, a.chdir
+ assert a.chdir == 1, a.chdir
a = SCons.Action._ActionAction(exitstatfunc=func1)
assert a.exitstatfunc is func1, a.exitstatfunc
@@ -518,8 +521,8 @@ class _ActionActionTestCase(unittest.TestCase):
strfunction=func1,
varlist=t,
)
- assert a.chdir is 'x', a.chdir
- assert a.cmdstr is 'cmdstr', a.cmdstr
+ assert a.chdir == 'x', a.chdir
+ assert a.cmdstr == 'cmdstr', a.cmdstr
assert a.exitstatfunc is func3, a.exitstatfunc
assert a.presub is func2, a.presub
assert a.strfunction is func1, a.strfunction
diff --git a/src/engine/SCons/BuilderTests.py b/src/engine/SCons/BuilderTests.py
index 1e544a1..847e30a 100644
--- a/src/engine/SCons/BuilderTests.py
+++ b/src/engine/SCons/BuilderTests.py
@@ -680,7 +680,9 @@ class BuilderTestCase(unittest.TestCase):
def test_single_source(self):
"""Test Builder with single_source flag set"""
def func(target, source, env):
- open(str(target[0]), "w")
+ """create the file"""
+ with open(str(target[0]), "w"):
+ pass
if (len(source) == 1 and len(target) == 1):
env['CNT'][0] = env['CNT'][0] + 1
@@ -736,10 +738,12 @@ class BuilderTestCase(unittest.TestCase):
"""Testing handling lists of targets and source"""
def function2(target, source, env, tlist = [outfile, outfile2], **kw):
for t in target:
- open(str(t), 'w').write("function2\n")
+ with open(str(t), 'w') as f:
+ f.write("function2\n")
for t in tlist:
if not t in list(map(str, target)):
- open(t, 'w').write("function2\n")
+ with open(t, 'w') as f:
+ f.write("function2\n")
return 1
env = Environment()
@@ -765,10 +769,12 @@ class BuilderTestCase(unittest.TestCase):
def function3(target, source, env, tlist = [sub1_out, sub2_out]):
for t in target:
- open(str(t), 'w').write("function3\n")
+ with open(str(t), 'w') as f:
+ f.write("function3\n")
for t in tlist:
if not t in list(map(str, target)):
- open(t, 'w').write("function3\n")
+ with open(t, 'w') as f:
+ f.write("function3\n")
return 1
builder = SCons.Builder.Builder(action = function3)
diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py
index 6b07750..479ef7e 100644
--- a/src/engine/SCons/Defaults.py
+++ b/src/engine/SCons/Defaults.py
@@ -210,7 +210,7 @@ def chmod_func(dest, mode):
else:
raise SyntaxError("Could not find +, - or =")
operation_list = operation.split(operator)
- if len(operation_list) is not 2:
+ if len(operation_list) != 2:
raise SyntaxError("More than one operator found")
user = operation_list[0].strip().replace("a", "ugo")
permission = operation_list[1].strip()
@@ -333,8 +333,8 @@ def touch_func(dest):
if os.path.exists(file):
atime = os.path.getatime(file)
else:
- open(file, 'w')
- atime = mtime
+ with open(file, 'w'):
+ atime = mtime
os.utime(file, (atime, mtime))
Touch = ActionFactory(touch_func,
diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py
index 81d0e5a..88fbc3b 100644
--- a/src/engine/SCons/Environment.py
+++ b/src/engine/SCons/Environment.py
@@ -1217,7 +1217,7 @@ class Base(SubstitutionEnvironment):
return path
def AppendENVPath(self, name, newpath, envname = 'ENV',
- sep = os.pathsep, delete_existing=1):
+ sep = os.pathsep, delete_existing=0):
"""Append path elements to the path 'name' in the 'ENV'
dictionary for this environment. Will only add any particular
path once, and will normpath and normcase all paths to help
@@ -1568,12 +1568,12 @@ class Base(SubstitutionEnvironment):
"""
filename = self.subst(filename)
try:
- fp = open(filename, 'r')
+ with open(filename, 'r') as fp:
+ lines = SCons.Util.LogicalLines(fp).readlines()
except IOError:
if must_exist:
raise
return
- lines = SCons.Util.LogicalLines(fp).readlines()
lines = [l for l in lines if l[0] != '#']
tdlist = []
for line in lines:
@@ -2372,6 +2372,7 @@ class OverrideEnvironment(Base):
kw = copy_non_reserved_keywords(kw)
self.__dict__['overrides'].update(semi_deepcopy(kw))
+
# The entry point that will be used by the external world
# to refer to a construction environment. This allows the wrapper
# interface to extend a construction environment for its own purposes
diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py
index 7cd6015..2525e0f 100644
--- a/src/engine/SCons/EnvironmentTests.py
+++ b/src/engine/SCons/EnvironmentTests.py
@@ -963,7 +963,7 @@ class BaseTestCase(unittest.TestCase,TestEnvironmentFixture):
self.assertRaises(AttributeError, getattr, bw, 'foobar')
bw.foobar = 42
- assert bw.foobar is 42
+ assert bw.foobar == 42
# This unit test is currently disabled because we don't think the
# underlying method it tests (Environment.BuilderWrapper.execute())
@@ -1623,9 +1623,9 @@ def exists(env):
env1.AppendENVPath('PATH',r'C:\dir\num\two', sep = ';')
env1.AppendENVPath('PATH',r'C:\dir\num\three', sep = ';')
env1.AppendENVPath('MYPATH',r'C:\mydir\num\three','MYENV', sep = ';')
- env1.AppendENVPath('MYPATH',r'C:\mydir\num\one','MYENV', sep = ';')
+ env1.AppendENVPath('MYPATH',r'C:\mydir\num\one','MYENV', sep = ';', delete_existing=1)
# this should do nothing since delete_existing is 0
- env1.AppendENVPath('MYPATH',r'C:\mydir\num\three','MYENV', sep = ';', delete_existing=0)
+ env1.AppendENVPath('MYPATH',r'C:\mydir\num\three','MYENV', sep = ';')
assert(env1['ENV']['PATH'] == r'C:\dir\num\one;C:\dir\num\two;C:\dir\num\three')
assert(env1['MYENV']['MYPATH'] == r'C:\mydir\num\two;C:\mydir\num\three;C:\mydir\num\one')
@@ -1777,15 +1777,15 @@ def exists(env):
env2 = env1.Clone()
env3 = env1.Clone(tools=[bar, baz])
- assert env1.get('FOO') is 1
+ assert env1.get('FOO') == 1
assert env1.get('BAR') is None
assert env1.get('BAZ') is None
- assert env2.get('FOO') is 1
+ assert env2.get('FOO') == 1
assert env2.get('BAR') is None
assert env2.get('BAZ') is None
- assert env3.get('FOO') is 1
- assert env3.get('BAR') is 2
- assert env3.get('BAZ') is 3
+ assert env3.get('FOO') == 1
+ assert env3.get('BAR') == 2
+ assert env3.get('BAZ') == 3
# Ensure that recursive variable substitution when copying
# environments works properly.
diff --git a/src/engine/SCons/Job.py b/src/engine/SCons/Job.py
index c0e80b1..3720ca2 100644
--- a/src/engine/SCons/Job.py
+++ b/src/engine/SCons/Job.py
@@ -199,7 +199,7 @@ class Serial(object):
task.prepare()
if task.needs_execute():
task.execute()
- except:
+ except Exception as e:
if self.interrupted():
try:
raise SCons.Errors.BuildError(
diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py
index 77c340f..61054f3 100644
--- a/src/engine/SCons/Node/FS.py
+++ b/src/engine/SCons/Node/FS.py
@@ -61,6 +61,8 @@ from . import DeciderNeedsNode
print_duplicate = 0
+MD5_TIMESTAMP_DEBUG = False
+
def sconsign_none(node):
raise NotImplementedError
@@ -3335,20 +3337,42 @@ class File(Base):
List of csigs for provided list of children
"""
prev = []
+ # MD5_TIMESTAMP_DEBUG = False
+
+ if len(dmap) == 0:
+ if MD5_TIMESTAMP_DEBUG: print("Nothing dmap shortcutting")
+ return None
+ if MD5_TIMESTAMP_DEBUG: print("len(dmap):%d"%len(dmap))
# First try the simple name for node
c_str = str(self)
+ if MD5_TIMESTAMP_DEBUG: print("Checking :%s"%c_str)
+ df = dmap.get(c_str, None)
+ if df:
+ return df
+
if os.altsep:
c_str = c_str.replace(os.sep, os.altsep)
- df = dmap.get(c_str, None)
+ df = dmap.get(c_str, None)
+ if MD5_TIMESTAMP_DEBUG: print("-->%s"%df)
+ if df:
+ return df
+
if not df:
try:
# this should yield a path which matches what's in the sconsign
c_str = self.get_path()
+ df = dmap.get(c_str, None)
+ if MD5_TIMESTAMP_DEBUG: print("-->%s"%df)
+ if df:
+ return df
+
if os.altsep:
c_str = c_str.replace(os.sep, os.altsep)
-
- df = dmap.get(c_str, None)
+ df = dmap.get(c_str, None)
+ if MD5_TIMESTAMP_DEBUG: print("-->%s"%df)
+ if df:
+ return df
except AttributeError as e:
raise FileBuildInfoFileToCsigMappingError("No mapping from file name to content signature for :%s"%c_str)
@@ -3388,16 +3412,36 @@ class File(Base):
dependency_map = self._build_dependency_map(bi)
rebuilt = True
- prev_ni = self._get_previous_signatures(dependency_map)
+ if len(dependency_map) == 0:
+ # If there's no dependency map, there's no need to find the
+ # prev_ni as there aren't any
+ # shortcut the rest of the logic
+ if MD5_TIMESTAMP_DEBUG: print("Skipping checks len(dmap)=0")
+
+ # We still need to get the current file's csig
+ # This should be slightly faster than calling self.changed_content(target, new_prev_ni)
+ self.get_csig()
+ return True
+
+ new_prev_ni = self._get_previous_signatures(dependency_map)
+ new = self.changed_timestamp_match(target, new_prev_ni)
+
+ if MD5_TIMESTAMP_DEBUG:
+ old = self.changed_timestamp_match(target, prev_ni)
+
+ if old != new:
+ print("Mismatch self.changed_timestamp_match(%s, prev_ni) old:%s new:%s"%(str(target), old, new))
+ new_prev_ni = self._get_previous_signatures(dependency_map)
+
- if not self.changed_timestamp_match(target, prev_ni):
+ if not new:
try:
# NOTE: We're modifying the current node's csig in a query.
- self.get_ninfo().csig = prev_ni.csig
+ self.get_ninfo().csig = new_prev_ni.csig
except AttributeError:
pass
return False
- return self.changed_content(target, prev_ni)
+ return self.changed_content(target, new_prev_ni)
def changed_timestamp_newer(self, target, prev_ni):
try:
diff --git a/src/engine/SCons/Node/NodeTests.py b/src/engine/SCons/Node/NodeTests.py
index 7dc5f5d..7d347ac 100644
--- a/src/engine/SCons/Node/NodeTests.py
+++ b/src/engine/SCons/Node/NodeTests.py
@@ -1335,9 +1335,9 @@ class NodeListTestCase(unittest.TestCase):
assert s == "['n3', 'n2', 'n1']", s
r = repr(nl)
- r = re.sub('at (0[xX])?[0-9a-fA-F]+', 'at 0x', r)
+ r = re.sub(r'at (0[xX])?[0-9a-fA-F]+', 'at 0x', r)
# Don't care about ancestry: just leaf value of MyNode
- r = re.sub('<.*?\.MyNode', '<MyNode', r)
+ r = re.sub(r'<.*?\.MyNode', '<MyNode', r)
# New-style classes report as "object"; classic classes report
# as "instance"...
r = re.sub("object", "instance", r)
diff --git a/src/engine/SCons/Platform/__init__.py b/src/engine/SCons/Platform/__init__.py
index 3168378..71d292e 100644
--- a/src/engine/SCons/Platform/__init__.py
+++ b/src/engine/SCons/Platform/__init__.py
@@ -155,9 +155,9 @@ class TempFileMunge(object):
env["TEMPFILEPREFIX"] = '' # (the empty string) PC Lint
You can configure the extension of the temporary file through the
- TEMPFILEEXTENSION variable, which defaults to '.lnk' (see comments
+ TEMPFILESUFFIX variable, which defaults to '.lnk' (see comments
in the code below):
- env["TEMPFILEEXTENSION"] = '.lnt' # PC Lint
+ env["TEMPFILESUFFIX"] = '.lnt' # PC Lint
"""
def __init__(self, cmd, cmdstr = None):
self.cmd = cmd
diff --git a/src/engine/SCons/Platform/win32.py b/src/engine/SCons/Platform/win32.py
index 2d40fb8..be30546 100644
--- a/src/engine/SCons/Platform/win32.py
+++ b/src/engine/SCons/Platform/win32.py
@@ -43,6 +43,10 @@ from SCons.Platform.virtualenv import ImportVirtualenv
from SCons.Platform.virtualenv import ignore_virtualenv, enable_virtualenv
import SCons.Util
+CHOCO_DEFAULT_PATH = [
+ r'C:\ProgramData\chocolatey\bin'
+]
+
try:
import msvcrt
import win32api
diff --git a/src/engine/SCons/SConf.py b/src/engine/SCons/SConf.py
index 0dcbab8..b123c11 100644
--- a/src/engine/SCons/SConf.py
+++ b/src/engine/SCons/SConf.py
@@ -56,6 +56,7 @@ import SCons.Warnings
import SCons.Conftest
from SCons.Debug import Trace
+from SCons.Node import DeciderNeedsNode
# Turn off the Conftest error logging
SCons.Conftest.LogInputFiles = 0
@@ -323,18 +324,6 @@ class SConfBuildTask(SCons.Taskmaster.AlwaysTask):
s = sys.stdout = sys.stderr = Streamer(sys.stdout)
try:
env = self.targets[0].get_build_env()
- if cache_mode == FORCE:
- # Set up the Decider() to force rebuilds by saying
- # that every source has changed. Note that we still
- # call the environment's underlying source decider so
- # that the correct .sconsign info will get calculated
- # and keep the build state consistent.
- def force_build(dependency, target, prev_ni,
- env_decider=env.decide_source):
- env_decider(dependency, target, prev_ni)
- return True
- if env.decide_source.__code__ is not force_build.__code__:
- env.Decider(force_build)
env['PSTDOUT'] = env['PSTDERR'] = s
try:
sconf.cached = 0
@@ -405,12 +394,42 @@ class SConfBase(object):
build tests in the VariantDir, not in the SourceDir)
"""
global SConfFS
+
+ # Now create isolated override so setting source_decider doesn't affect parent Environment
+ if cache_mode == FORCE:
+ self.original_env = env
+ self.env = env.Clone()
+
+ # Set up the Decider() to force rebuilds by saying
+ # that every source has changed. Note that we still
+ # call the environment's underlying source decider so
+ # that the correct .sconsign info will get calculated
+ # and keep the build state consistent.
+ def force_build(dependency, target, prev_ni,
+ env_decider=env.decide_source,
+ node=None):
+ try:
+ env_decider(dependency, target, prev_ni)
+ except DeciderNeedsNode as e:
+ e.decider(target, prev_ni, node=target)
+ except Exception as e:
+ raise e
+ return True
+
+ if self.env.decide_source.__code__ is not force_build.__code__:
+ self.env.Decider(force_build)
+
+ else:
+ self.env = env
+
+ # print("Override env:%s"%env)
+
if not SConfFS:
SConfFS = SCons.Node.FS.default_fs or \
SCons.Node.FS.FS(env.fs.pathTop)
if sconf_global is not None:
raise SCons.Errors.UserError
- self.env = env
+
if log_file is not None:
log_file = SConfFS.File(env.subst(log_file))
self.logfile = log_file
@@ -449,6 +468,7 @@ class SConfBase(object):
env = sconf.Finish()
"""
self._shutdown()
+
return self.env
def Define(self, name, value = None, comment = None):
@@ -503,6 +523,20 @@ class SConfBase(object):
n.attributes = SCons.Node.Node.Attrs()
n.attributes.keep_targetinfo = 1
+ if True:
+ # Some checkers have intermediate files (for example anything that compiles a c file into a program to run
+ # Those files need to be set to not release their target info, otherwise taskmaster will throw a
+ # Nonetype not callable
+ for c in n.children(scan=False):
+ # Keep debug code here.
+ # print("Checking [%s] for builders and then setting keep_targetinfo"%c)
+ if c.has_builder():
+ n.store_info = 0
+ if not hasattr(c, 'attributes'):
+ c.attributes = SCons.Node.Node.Attrs()
+ c.attributes.keep_targetinfo = 1
+ # pass
+
ret = 1
try:
@@ -739,10 +773,18 @@ class SConfBase(object):
self.logstream.write("\n")
self.logstream.close()
self.logstream = None
- # remove the SConfSourceBuilder from the environment
- blds = self.env['BUILDERS']
- del blds['SConfSourceBuilder']
- self.env.Replace( BUILDERS=blds )
+
+ # Now reset the decider if we changed it due to --config=force
+ # We saved original Environment passed in and cloned it to isolate
+ # it from being changed.
+ if cache_mode == FORCE:
+ self.env.Decider(self.original_env.decide_source)
+
+ # remove the SConfSourceBuilder from the environment
+ blds = self.env['BUILDERS']
+ del blds['SConfSourceBuilder']
+ self.env.Replace( BUILDERS=blds )
+
self.active = 0
sconf_global = None
if not self.config_h is None:
diff --git a/src/engine/SCons/SConfTests.py b/src/engine/SCons/SConfTests.py
index cf8a7fb..f770450 100644
--- a/src/engine/SCons/SConfTests.py
+++ b/src/engine/SCons/SConfTests.py
@@ -194,7 +194,7 @@ class SConfTestCase(unittest.TestCase):
pass
def add_post_action(self, *actions):
pass
- def children(self):
+ def children(self, scan = 1):
return []
def get_state(self):
return self.state
@@ -298,12 +298,14 @@ int main(void) {
"""Test SConf.TryAction
"""
def actionOK(target, source, env):
- open(str(target[0]), "w").write("RUN OK\n")
+ with open(str(target[0]), "w") as f:
+ f.write("RUN OK\n")
return None
def actionFAIL(target, source, env):
return 1
def actionUnicode(target, source, env):
- open(str(target[0]), "wb").write('2\302\242\n')
+ with open(str(target[0]), "wb") as f:
+ f.write('2\302\242\n')
return None
diff --git a/src/engine/SCons/SConsign.py b/src/engine/SCons/SConsign.py
index 5042aa1..dfafdc9 100644
--- a/src/engine/SCons/SConsign.py
+++ b/src/engine/SCons/SConsign.py
@@ -394,7 +394,8 @@ class DirFile(Dir):
# here, or in any of the following calls, would get
# raised, indicating something like a potentially
# serious disk or network issue.
- open(self.sconsign, 'wb').write(open(fname, 'rb').read())
+ with open(self.sconsign, 'wb') as f, open(fname, 'rb') as f2:
+ f.write(f2.read())
os.chmod(self.sconsign, mode)
try:
os.unlink(temp)
diff --git a/src/engine/SCons/Scanner/LaTeXTests.py b/src/engine/SCons/Scanner/LaTeXTests.py
index 0114d45..6dd7dac 100644
--- a/src/engine/SCons/Scanner/LaTeXTests.py
+++ b/src/engine/SCons/Scanner/LaTeXTests.py
@@ -37,7 +37,7 @@ import SCons.Scanner.LaTeX
test = TestCmd.TestCmd(workdir = '')
-test.write('test1.latex',"""
+test.write('test1.latex',r"""
\include{inc1}
\input{inc2}
include{incNO}
@@ -51,12 +51,12 @@ xyzzy \include{inc6}
\subinputfrom{subdir}{inc3e}
""")
-test.write('test2.latex',"""
+test.write('test2.latex',r"""
\include{inc1}
\include{inc3}
""")
-test.write('test3.latex',"""
+test.write('test3.latex',r"""
\includegraphics{inc4.eps}
\includegraphics[width=60mm]{inc5.xyz}
""")
diff --git a/src/engine/SCons/Scanner/ScannerTests.py b/src/engine/SCons/Scanner/ScannerTests.py
index 5cdd5b1..64a2345 100644
--- a/src/engine/SCons/Scanner/ScannerTests.py
+++ b/src/engine/SCons/Scanner/ScannerTests.py
@@ -461,7 +461,7 @@ class ClassicTestCase(unittest.TestCase):
def test_find_include(self):
"""Test the Scanner.Classic find_include() method"""
env = DummyEnvironment()
- s = SCons.Scanner.Classic("t", ['.suf'], 'MYPATH', '^my_inc (\S+)')
+ s = SCons.Scanner.Classic("t", ['.suf'], 'MYPATH', r'^my_inc (\S+)')
def _find_file(filename, paths):
return paths[0]+'/'+filename
@@ -479,7 +479,7 @@ class ClassicTestCase(unittest.TestCase):
def test_name(self):
"""Test setting the Scanner.Classic name"""
- s = SCons.Scanner.Classic("my_name", ['.s'], 'MYPATH', '^my_inc (\S+)')
+ s = SCons.Scanner.Classic("my_name", ['.s'], 'MYPATH', r'^my_inc (\S+)')
assert s.name == "my_name", s.name
def test_scan(self):
@@ -505,7 +505,7 @@ class ClassicTestCase(unittest.TestCase):
return include, include
env = DummyEnvironment()
- s = MyScanner("t", ['.suf'], 'MYPATH', '^my_inc (\S+)')
+ s = MyScanner("t", ['.suf'], 'MYPATH', r'^my_inc (\S+)')
# This set of tests is intended to test the scanning operation
# of the Classic scanner.
diff --git a/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py
index 2c59808..f3475f2 100644
--- a/src/engine/SCons/Script/Main.py
+++ b/src/engine/SCons/Script/Main.py
@@ -1376,7 +1376,7 @@ def main():
revert_io()
except SystemExit as s:
if s:
- exit_status = s
+ exit_status = s.code
except KeyboardInterrupt:
print("scons: Build interrupted.")
sys.exit(2)
diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py
index 560402c..eabaddb 100644
--- a/src/engine/SCons/Script/SConscript.py
+++ b/src/engine/SCons/Script/SConscript.py
@@ -278,11 +278,12 @@ def _SConscript(fs, *files, **kw):
pass
try:
try:
-# _file_ = SCons.Util.to_str(_file_)
if Main.print_time:
time1 = time.time()
- exec(compile(_file_.read(), _file_.name, 'exec'),
- call_stack[-1].globals)
+ scriptdata = _file_.read()
+ scriptname = _file_.name
+ _file_.close()
+ exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
except SConscriptReturn:
pass
finally:
@@ -397,9 +398,9 @@ class SConsEnvironment(SCons.Environment.Base):
something like 3.2b1."""
version = version_string.split(' ')[0].split('.')
v_major = int(version[0])
- v_minor = int(re.match('\d+', version[1]).group())
+ v_minor = int(re.match(r'\d+', version[1]).group())
if len(version) >= 3:
- v_revision = int(re.match('\d+', version[2]).group())
+ v_revision = int(re.match(r'\d+', version[2]).group())
else:
v_revision = 0
return v_major, v_minor, v_revision
diff --git a/src/engine/SCons/Script/SConscript.xml b/src/engine/SCons/Script/SConscript.xml
index a6258c4..330a56c 100644
--- a/src/engine/SCons/Script/SConscript.xml
+++ b/src/engine/SCons/Script/SConscript.xml
@@ -38,6 +38,10 @@ Multiple calls to
&f-Default;
are legal,
and add to the list of default targets.
+As noted above, both forms of this call affect the
+same global list of default targets; the
+construction environment method applies
+construction variable expansion to the targets.
</para>
<para>
diff --git a/src/engine/SCons/TaskmasterTests.py b/src/engine/SCons/TaskmasterTests.py
index 42ed00e..c0c77b0 100644
--- a/src/engine/SCons/TaskmasterTests.py
+++ b/src/engine/SCons/TaskmasterTests.py
@@ -1085,6 +1085,7 @@ class TaskmasterTestCase(unittest.TestCase):
exception_values = [
"integer division or modulo",
"integer division or modulo by zero",
+ "integer division by zero", # PyPy2
]
assert str(exc_value) in exception_values, exc_value
diff --git a/src/engine/SCons/Tool/JavaCommon.py b/src/engine/SCons/Tool/JavaCommon.py
index 0d4c95a..853f7f2 100644
--- a/src/engine/SCons/Tool/JavaCommon.py
+++ b/src/engine/SCons/Tool/JavaCommon.py
@@ -358,7 +358,9 @@ if java_parsing:
return self.outer_state
def parse_java_file(fn, version=default_java_version):
- return parse_java(open(fn, 'r').read(), version)
+ with open(fn, 'r') as f:
+ data = f.read()
+ return parse_java(data, version)
def parse_java(contents, version=default_java_version, trace=None):
"""Parse a .java file and return a double of package directory,
diff --git a/src/engine/SCons/Tool/MSCommon/common.py b/src/engine/SCons/Tool/MSCommon/common.py
index f7c07b2..6201ba0 100644
--- a/src/engine/SCons/Tool/MSCommon/common.py
+++ b/src/engine/SCons/Tool/MSCommon/common.py
@@ -188,8 +188,10 @@ def get_output(vcbat, args = None, env = None):
# Use the .stdout and .stderr attributes directly because the
# .communicate() method uses the threading module on Windows
# and won't work under Pythons not built with threading.
- stdout = popen.stdout.read()
- stderr = popen.stderr.read()
+ with popen.stdout:
+ stdout = popen.stdout.read()
+ with popen.stderr:
+ stderr = popen.stderr.read()
# Extra debug logic, uncomment if necessary
# debug('get_output():stdout:%s'%stdout)
diff --git a/src/engine/SCons/Tool/MSCommon/vc.py b/src/engine/SCons/Tool/MSCommon/vc.py
index c4ba803..ea053cb 100644
--- a/src/engine/SCons/Tool/MSCommon/vc.py
+++ b/src/engine/SCons/Tool/MSCommon/vc.py
@@ -88,7 +88,7 @@ _ARCH_TO_CANONICAL = {
"arm64" : "arm64",
"aarch64" : "arm64",
}
-
+
# get path to the cl.exe dir for newer VS versions
# based off a tuple of (host, target) platforms
_HOST_TARGET_TO_CL_DIR_GREATER_THAN_14 = {
@@ -135,8 +135,8 @@ _HOST_TARGET_ARCH_TO_BAT_ARCH = {
_CL_EXE_NAME = 'cl.exe'
def get_msvc_version_numeric(msvc_version):
- """Get the raw version numbers from a MSVC_VERSION string, so it
- could be cast to float or other numeric values. For example, '14.0Exp'
+ """Get the raw version numbers from a MSVC_VERSION string, so it
+ could be cast to float or other numeric values. For example, '14.0Exp'
would get converted to '14.0'.
Args:
@@ -296,15 +296,20 @@ def find_vc_pdir_vswhere(msvc_version):
vswhere_cmd = [vswhere_path, '-products', '*', '-version', msvc_version, '-property', 'installationPath']
if os.path.exists(vswhere_path):
- sp = subprocess.Popen(vswhere_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ #TODO PY27 cannot use Popen as context manager
+ # try putting it back to the old way for now
+ sp = subprocess.Popen(vswhere_cmd,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
vsdir, err = sp.communicate()
- vsdir = vsdir.decode("mbcs").splitlines()
- # vswhere could easily return multiple lines
- # we could define a way to pick the one we prefer, but since
- # this data is currently only used to make a check for existence,
- # returning the first hit should be good enough for now.
- vc_pdir = os.path.join(vsdir[0], 'VC')
- return vc_pdir
+ if vsdir:
+ vsdir = vsdir.decode("mbcs").splitlines()
+ # vswhere could easily return multiple lines
+ # we could define a way to pick the one we prefer, but since
+ # this data is currently only used to make a check for existence,
+ # returning the first hit should be good enough for now.
+ vc_pdir = os.path.join(vsdir[0], 'VC')
+ return vc_pdir
else:
# No vswhere on system, no install info available
return None
@@ -414,15 +419,15 @@ def find_batch_file(env,msvc_version,host_arch,target_arch):
__INSTALLED_VCS_RUN = None
def _check_cl_exists_in_vc_dir(env, vc_dir, msvc_version):
- """Find the cl.exe on the filesystem in the vc_dir depending on
- TARGET_ARCH, HOST_ARCH and the msvc version. TARGET_ARCH and
- HOST_ARCH can be extracted from the passed env, unless its None,
+ """Find the cl.exe on the filesystem in the vc_dir depending on
+ TARGET_ARCH, HOST_ARCH and the msvc version. TARGET_ARCH and
+ HOST_ARCH can be extracted from the passed env, unless its None,
which then the native platform is assumed the host and target.
Args:
env: Environment
a construction environment, usually if this is passed its
- because there is a desired TARGET_ARCH to be used when searching
+ because there is a desired TARGET_ARCH to be used when searching
for a cl.exe
vc_dir: str
the path to the VC dir in the MSVC installation
@@ -433,7 +438,7 @@ def _check_cl_exists_in_vc_dir(env, vc_dir, msvc_version):
bool:
"""
-
+
# determine if there is a specific target platform we want to build for and
# use that to find a list of valid VCs, default is host platform == target platform
# and same for if no env is specified to extract target platform from
@@ -459,7 +464,7 @@ def _check_cl_exists_in_vc_dir(env, vc_dir, msvc_version):
try:
with open(default_toolset_file) as f:
vc_specific_version = f.readlines()[0].strip()
- except IOError:
+ except IOError:
debug('_check_cl_exists_in_vc_dir(): failed to read ' + default_toolset_file)
return False
except IndexError:
@@ -483,14 +488,14 @@ def _check_cl_exists_in_vc_dir(env, vc_dir, msvc_version):
if not host_trgt_dir:
debug('_check_cl_exists_in_vc_dir(): unsupported host/target platform combo')
return False
-
+
cl_path = os.path.join(vc_dir, 'bin', host_trgt_dir, _CL_EXE_NAME)
debug('_check_cl_exists_in_vc_dir(): checking for ' + _CL_EXE_NAME + ' at ' + cl_path)
cl_path_exists = os.path.exists(cl_path)
if not cl_path_exists and host_platform == 'amd64':
- # older versions of visual studio only had x86 binaries,
- # so if the host platform is amd64, we need to check cross
+ # older versions of visual studio only had x86 binaries,
+ # so if the host platform is amd64, we need to check cross
# compile options (x86 binary compiles some other target on a 64 bit os)
host_trgt_dir = _HOST_TARGET_TO_CL_DIR.get(('x86', target_platform), None)
if not host_trgt_dir:
@@ -514,7 +519,7 @@ def _check_cl_exists_in_vc_dir(env, vc_dir, msvc_version):
else:
# version not support return false
debug('_check_cl_exists_in_vc_dir(): unsupported MSVC version: ' + str(ver_num))
-
+
return False
def cached_get_installed_vcs(env=None):
diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py
index f3f0630..74dba75 100644
--- a/src/engine/SCons/Tool/__init__.py
+++ b/src/engine/SCons/Tool/__init__.py
@@ -1305,6 +1305,8 @@ def tool_list(platform, env):
'tex', 'latex', 'pdflatex', 'pdftex',
# Archivers
'tar', 'zip',
+ # File builders (text)
+ 'textfile',
], env)
tools = ([linker, c_compiler, cxx_compiler,
diff --git a/src/engine/SCons/Tool/gcc.py b/src/engine/SCons/Tool/gcc.py
index fabcc96..79b64f0 100644
--- a/src/engine/SCons/Tool/gcc.py
+++ b/src/engine/SCons/Tool/gcc.py
@@ -68,32 +68,40 @@ def exists(env):
def detect_version(env, cc):
"""Return the version of the GNU compiler, or None if it is not a GNU compiler."""
+ version = None
cc = env.subst(cc)
if not cc:
- return None
- version = None
+ return version
+
+ # -dumpversion was added in GCC 3.0. As long as we're supporting
+ # GCC versions older than that, we should use --version and a
+ # regular expression.
# pipe = SCons.Action._subproc(env, SCons.Util.CLVar(cc) + ['-dumpversion'],
pipe = SCons.Action._subproc(env, SCons.Util.CLVar(cc) + ['--version'],
stdin='devnull',
stderr='devnull',
stdout=subprocess.PIPE)
- # -dumpversion was added in GCC 3.0. As long as we're supporting
- # GCC versions older than that, we should use --version and a
- # regular expression.
- # line = pipe.stdout.read().strip()
+ if pipe.wait() != 0:
+ return version
+
+ with pipe.stdout:
+ # -dumpversion variant:
+ # line = pipe.stdout.read().strip()
+ # --version variant:
+ line = SCons.Util.to_str(pipe.stdout.readline())
+ # Non-GNU compiler's output (like AIX xlc's) may exceed the stdout buffer:
+ # So continue with reading to let the child process actually terminate.
+ while SCons.Util.to_str(pipe.stdout.readline()):
+ pass
+
+ # -dumpversion variant:
# if line:
- # version = line
- line = SCons.Util.to_str(pipe.stdout.readline())
+ # version = line
+ # --version variant:
match = re.search(r'[0-9]+(\.[0-9]+)+', line)
if match:
version = match.group(0)
- # Non-GNU compiler's output (like AIX xlc's) may exceed the stdout buffer:
- # So continue with reading to let the child process actually terminate.
- while SCons.Util.to_str(pipe.stdout.readline()):
- pass
- ret = pipe.wait()
- if ret != 0:
- return None
+
return version
# Local Variables:
diff --git a/src/engine/SCons/Tool/lex.py b/src/engine/SCons/Tool/lex.py
index 280c768..a63ddc9 100644
--- a/src/engine/SCons/Tool/lex.py
+++ b/src/engine/SCons/Tool/lex.py
@@ -34,10 +34,14 @@ selection method.
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import os.path
+import sys
import SCons.Action
import SCons.Tool
import SCons.Util
+from SCons.Platform.mingw import MINGW_DEFAULT_PATHS
+from SCons.Platform.cygwin import CYGWIN_DEFAULT_PATHS
+from SCons.Platform.win32 import CHOCO_DEFAULT_PATH
LexAction = SCons.Action.Action("$LEXCOM", "$LEXCOMSTR")
@@ -64,6 +68,29 @@ def lexEmitter(target, source, env):
target.append(fileName)
return (target, source)
+def get_lex_path(env, append_paths=False):
+ """
+ Find the a path containing the lex or flex binaries. If a construction
+ environment is passed in then append the path to the ENV PATH.
+ """
+ # save existing path to reset if we don't want to append any paths
+ envPath = env['ENV']['PATH']
+ bins = ['flex', 'lex', 'win_flex']
+
+ for prog in bins:
+ bin_path = SCons.Tool.find_program_path(
+ env,
+ prog,
+ default_paths=CHOCO_DEFAULT_PATH + MINGW_DEFAULT_PATHS + CYGWIN_DEFAULT_PATHS )
+ if bin_path:
+ if not append_paths:
+ env['ENV']['PATH'] = envPath
+ else:
+ env.AppendENVPath('PATH', os.path.dirname(bin_path))
+ return bin_path
+ SCons.Warnings.Warning('lex tool requested, but lex or flex binary not found in ENV PATH')
+
+
def generate(env):
"""Add Builders and construction variables for lex to an Environment."""
c_file, cxx_file = SCons.Tool.createCFileBuilders(env)
@@ -83,12 +110,23 @@ def generate(env):
cxx_file.add_action(".ll", LexAction)
cxx_file.add_emitter(".ll", lexEmitter)
- env["LEX"] = env.Detect("flex") or "lex"
env["LEXFLAGS"] = SCons.Util.CLVar("")
- env["LEXCOM"] = "$LEX $LEXFLAGS -t $SOURCES > $TARGET"
+
+ if sys.platform == 'win32':
+ get_lex_path(env, append_paths=True)
+ env["LEX"] = env.Detect(['flex', 'lex', 'win_flex'])
+ if not env.get("LEXUNISTD"):
+ env["LEXUNISTD"] = SCons.Util.CLVar("")
+ env["LEXCOM"] = "$LEX $LEXUNISTD $LEXFLAGS -t $SOURCES > $TARGET"
+ else:
+ env["LEX"] = env.Detect(["flex", "lex"])
+ env["LEXCOM"] = "$LEX $LEXFLAGS -t $SOURCES > $TARGET"
def exists(env):
- return env.Detect(["flex", "lex"])
+ if sys.platform == 'win32':
+ return get_lex_path(env)
+ else:
+ return env.Detect(["flex", "lex"])
# Local Variables:
# tab-width:4
diff --git a/src/engine/SCons/Tool/lex.xml b/src/engine/SCons/Tool/lex.xml
index 0388ee3..f933451 100644
--- a/src/engine/SCons/Tool/lex.xml
+++ b/src/engine/SCons/Tool/lex.xml
@@ -33,6 +33,7 @@ Sets construction variables for the &lex; lexical analyser.
<item>LEX</item>
<item>LEXFLAGS</item>
<item>LEXCOM</item>
+<item>LEXUNISTD</item>
</sets>
<uses>
<item>LEXCOMSTR</item>
@@ -78,4 +79,12 @@ General options passed to the lexical analyzer generator.
</summary>
</cvar>
+<cvar name="LEXUNISTD">
+<summary>
+<para>
+Used only on windows environments to set a lex flag to prevent 'unistd.h' from being included. The default value is '--nounistd'.
+</para>
+</summary>
+</cvar>
+
</sconsdoc>
diff --git a/src/engine/SCons/Tool/link.py b/src/engine/SCons/Tool/link.py
index 5adc6ca..5d920fb 100644
--- a/src/engine/SCons/Tool/link.py
+++ b/src/engine/SCons/Tool/link.py
@@ -81,6 +81,8 @@ def _lib_emitter(target, source, env, **kw):
if Verbose:
print("_lib_emitter: target[0]={!r}".format(target[0].get_path()))
for tgt in target:
+ if SCons.Util.is_String(tgt):
+ tgt = env.File(tgt)
tgt.attributes.shared = 1
try:
diff --git a/src/engine/SCons/Tool/mingw.py b/src/engine/SCons/Tool/mingw.py
index 738460d..df88d79 100644
--- a/src/engine/SCons/Tool/mingw.py
+++ b/src/engine/SCons/Tool/mingw.py
@@ -43,7 +43,6 @@ import SCons.Defaults
import SCons.Tool
import SCons.Util
-
mingw_paths = [
r'c:\MinGW\bin',
r'C:\cygwin64\bin',
@@ -52,8 +51,9 @@ mingw_paths = [
r'C:\msys',
]
+
def shlib_generator(target, source, env, for_signature):
- cmd = SCons.Util.CLVar(['$SHLINK', '$SHLINKFLAGS'])
+ cmd = SCons.Util.CLVar(['$SHLINK', '$SHLINKFLAGS'])
dll = env.FindIxes(target, 'SHLIBPREFIX', 'SHLIBSUFFIX')
if dll: cmd.extend(['-o', dll])
@@ -61,31 +61,32 @@ def shlib_generator(target, source, env, for_signature):
cmd.extend(['$SOURCES', '$_LIBDIRFLAGS', '$_LIBFLAGS'])
implib = env.FindIxes(target, 'LIBPREFIX', 'LIBSUFFIX')
- if implib: cmd.append('-Wl,--out-implib,'+implib.get_string(for_signature))
+ if implib: cmd.append('-Wl,--out-implib,' + implib.get_string(for_signature))
def_target = env.FindIxes(target, 'WINDOWSDEFPREFIX', 'WINDOWSDEFSUFFIX')
insert_def = env.subst("$WINDOWS_INSERT_DEF")
if not insert_def in ['', '0', 0] and def_target: \
- cmd.append('-Wl,--output-def,'+def_target.get_string(for_signature))
+ cmd.append('-Wl,--output-def,' + def_target.get_string(for_signature))
return [cmd]
+
def shlib_emitter(target, source, env):
dll = env.FindIxes(target, 'SHLIBPREFIX', 'SHLIBSUFFIX')
no_import_lib = env.get('no_import_lib', 0)
if not dll:
- raise SCons.Errors.UserError("A shared library should have exactly one target with the suffix: %s Target(s) are:%s" % \
+ raise SCons.Errors.UserError(
+ "A shared library should have exactly one target with the suffix: %s Target(s) are:%s" % \
(env.subst("$SHLIBSUFFIX"), ",".join([str(t) for t in target])))
-
- if not no_import_lib and \
- not env.FindIxes(target, 'LIBPREFIX', 'LIBSUFFIX'):
+ if not no_import_lib and \
+ not env.FindIxes(target, 'LIBPREFIX', 'LIBSUFFIX'):
# Create list of target libraries as strings
- targetStrings=env.ReplaceIxes(dll,
- 'SHLIBPREFIX', 'SHLIBSUFFIX',
- 'LIBPREFIX', 'LIBSUFFIX')
-
+ targetStrings = env.ReplaceIxes(dll,
+ 'SHLIBPREFIX', 'SHLIBSUFFIX',
+ 'LIBPREFIX', 'LIBSUFFIX')
+
# Now add file nodes to target list
target.append(env.fs.File(targetStrings))
@@ -97,17 +98,18 @@ def shlib_emitter(target, source, env):
skip_def_insert = env.subst("$WINDOWS_INSERT_DEF") in ['', '0', 0]
if not def_source and not def_target and not skip_def_insert:
# Create list of target libraries and def files as strings
- targetStrings=env.ReplaceIxes(dll,
- 'SHLIBPREFIX', 'SHLIBSUFFIX',
- 'WINDOWSDEFPREFIX', 'WINDOWSDEFSUFFIX')
-
+ targetStrings = env.ReplaceIxes(dll,
+ 'SHLIBPREFIX', 'SHLIBSUFFIX',
+ 'WINDOWSDEFPREFIX', 'WINDOWSDEFSUFFIX')
+
# Now add file nodes to target list
target.append(env.fs.File(targetStrings))
return (target, source)
-
-shlib_action = SCons.Action.Action(shlib_generator, generator=1)
+
+shlib_action = SCons.Action.Action(shlib_generator, '$SHLINKCOMSTR', generator=1)
+ldmodule_action = SCons.Action.Action(shlib_generator, '$LDMODULECOMSTR', generator=1)
res_action = SCons.Action.Action('$RCCOM', '$RCCOMSTR')
@@ -120,7 +122,6 @@ SCons.Tool.SourceFileScanner.add_scanner('.rc', SCons.Defaults.CScan)
key_program = 'mingw32-make'
-
def find_version_specific_mingw_paths():
"""
One example of default mingw install paths is:
@@ -129,14 +130,14 @@ def find_version_specific_mingw_paths():
Use glob'ing to find such and add to mingw_paths
"""
new_paths = glob.glob(r"C:\mingw-w64\*\mingw64\bin")
-
+
return new_paths
def generate(env):
global mingw_paths
# Check for reasoanble mingw default paths
- mingw_paths +=find_version_specific_mingw_paths()
+ mingw_paths += find_version_specific_mingw_paths()
mingw = SCons.Tool.find_program_path(env, key_program, default_paths=mingw_paths)
if mingw:
@@ -148,26 +149,31 @@ def generate(env):
for tool in gnu_tools:
SCons.Tool.Tool(tool)(env)
- #... but a few things differ:
+ # ... but a few things differ:
env['CC'] = 'gcc'
+ # make sure the msvc tool doesnt break us, it added a /flag
+ if 'CCFLAGS' in env:
+ # make sure its a CLVar to handle list or str cases
+ if type(env['CCFLAGS']) is not SCons.Util.CLVar:
+ env['CCFLAGS'] = SCons.Util.CLVar(env['CCFLAGS'])
+ env['CCFLAGS'] = SCons.Util.CLVar(str(env['CCFLAGS']).replace('/nologo', ''))
env['SHCCFLAGS'] = SCons.Util.CLVar('$CCFLAGS')
env['CXX'] = 'g++'
env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS')
env['SHLINKFLAGS'] = SCons.Util.CLVar('$LINKFLAGS -shared')
- env['SHLINKCOM'] = shlib_action
- env['LDMODULECOM'] = shlib_action
- env.Append(SHLIBEMITTER = [shlib_emitter])
- env.Append(LDMODULEEMITTER = [shlib_emitter])
+ env['SHLINKCOM'] = shlib_action
+ env['LDMODULECOM'] = ldmodule_action
+ env.Append(SHLIBEMITTER=[shlib_emitter])
+ env.Append(LDMODULEEMITTER=[shlib_emitter])
env['AS'] = 'as'
- env['WIN32DEFPREFIX'] = ''
- env['WIN32DEFSUFFIX'] = '.def'
- env['WINDOWSDEFPREFIX'] = '${WIN32DEFPREFIX}'
- env['WINDOWSDEFSUFFIX'] = '${WIN32DEFSUFFIX}'
+ env['WIN32DEFPREFIX'] = ''
+ env['WIN32DEFSUFFIX'] = '.def'
+ env['WINDOWSDEFPREFIX'] = '${WIN32DEFPREFIX}'
+ env['WINDOWSDEFSUFFIX'] = '${WIN32DEFSUFFIX}'
env['SHOBJSUFFIX'] = '.o'
env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 1
-
env['RC'] = 'windres'
env['RCFLAGS'] = SCons.Util.CLVar('')
env['RCINCFLAGS'] = '$( ${_concat(RCINCPREFIX, CPPPATH, RCINCSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)'
@@ -175,13 +181,14 @@ def generate(env):
env['RCINCSUFFIX'] = ''
env['RCCOM'] = '$RC $_CPPDEFFLAGS $RCINCFLAGS ${RCINCPREFIX} ${SOURCE.dir} $RCFLAGS -i $SOURCE -o $TARGET'
env['BUILDERS']['RES'] = res_builder
-
+
# Some setting from the platform also have to be overridden:
env['OBJSUFFIX'] = '.o'
env['LIBPREFIX'] = 'lib'
env['LIBSUFFIX'] = '.a'
env['PROGSUFFIX'] = '.exe'
+
def exists(env):
mingw = SCons.Tool.find_program_path(env, key_program, default_paths=mingw_paths)
if mingw:
diff --git a/src/engine/SCons/Tool/msvc.py b/src/engine/SCons/Tool/msvc.py
index 9f3c1fa..6cfa245 100644
--- a/src/engine/SCons/Tool/msvc.py
+++ b/src/engine/SCons/Tool/msvc.py
@@ -262,7 +262,7 @@ def generate(env):
env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 1
env['RC'] = 'rc'
- env['RCFLAGS'] = SCons.Util.CLVar('')
+ env['RCFLAGS'] = SCons.Util.CLVar('/nologo')
env['RCSUFFIXES']=['.rc','.rc2']
env['RCCOM'] = '$RC $_CPPDEFFLAGS $_CPPINCFLAGS $RCFLAGS /fo$TARGET $SOURCES'
env['BUILDERS']['RES'] = res_builder
@@ -271,6 +271,10 @@ def generate(env):
env['SHOBJPREFIX'] = '$OBJPREFIX'
env['SHOBJSUFFIX'] = '$OBJSUFFIX'
+ # MSVC probably wont support unistd.h so default
+ # without it for lex generation
+ env["LEXUNISTD"] = SCons.Util.CLVar("--nounistd")
+
# Set-up ms tools paths
msvc_setup_env_once(env)
diff --git a/src/engine/SCons/Tool/msvs.py b/src/engine/SCons/Tool/msvs.py
index 60ba278..f4439ba 100644
--- a/src/engine/SCons/Tool/msvs.py
+++ b/src/engine/SCons/Tool/msvs.py
@@ -520,7 +520,7 @@ class _DSPGenerator(object):
config.cmdargs = cmdargs
config.runfile = runfile
- match = re.match('(.*)\|(.*)', variant)
+ match = re.match(r'(.*)\|(.*)', variant)
if match:
config.variant = match.group(1)
config.platform = match.group(2)
@@ -1428,7 +1428,7 @@ class _GenerateV7DSW(_DSWGenerator):
def AddConfig(self, variant, dswfile=dswfile):
config = Config()
- match = re.match('(.*)\|(.*)', variant)
+ match = re.match(r'(.*)\|(.*)', variant)
if match:
config.variant = match.group(1)
config.platform = match.group(2)
diff --git a/src/engine/SCons/Tool/msvs.xml b/src/engine/SCons/Tool/msvs.xml
index c4701e1..6467a2b 100644
--- a/src/engine/SCons/Tool/msvs.xml
+++ b/src/engine/SCons/Tool/msvs.xml
@@ -17,160 +17,212 @@ See its __doc__ string for a discussion of the format.
<!ENTITY % variables-mod SYSTEM "../../../../doc/generated/variables.mod">
%variables-mod;
]>
-<sconsdoc
-xsi:schemaLocation="http://www.scons.org/dbxsd/v1.0 http://www.scons.org/dbxsd/v1.0/scons.xsd"
-xmlns="http://www.scons.org/dbxsd/v1.0"
-xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-xmlns:xs="http://www.w3.org/2001/XMLSchema"
-xmlns:ns="http://www.scons.org/dbxsd/v1.0"><tool name="msvs"> <summary> <para>
-Sets construction variables for Microsoft Visual Studio. </para> </summary>
-<sets> <item>MSVSPROJECTCOM</item> <item>MSVSSOLUTIONCOM</item>
-<item>MSVSSCONSCRIPT</item> <item>MSVSSCONS</item> <item>MSVSSCONSFLAGS</item>
-<item>MSVSSCONSCOM</item> <item>MSVSBUILDCOM</item>
-<item>MSVSREBUILDCOM</item> <item>MSVSCLEANCOM</item>
-<item>MSVSENCODING</item> </sets> <uses> </uses> </tool> <builder
-name="MSVSProject"> <summary> <para> Builds a Microsoft Visual Studio project
-file, and by default builds a solution file as well. </para> <para> This
-builds a Visual Studio project file, based on the version of Visual Studio
-that is configured (either the latest installed version, or the version
-specified by &cv-link-MSVS_VERSION; in the Environment constructor). For
-Visual Studio 6, it will generate a <filename>.dsp</filename> file. For Visual
-Studio 7 (.NET) and later versions, it will generate a
-<filename>.vcproj</filename> file. </para> <para> By default, this also
-generates a solution file for the specified project, a
-<filename>.dsw</filename> file for Visual Studio 6 or a
-<filename>.sln</filename> file for Visual Studio 7 (.NET). This behavior may
-be disabled by specifying <literal>auto_build_solution=0</literal> when you
-call &b-MSVSProject;, in which case you presumably want to build the solution
-file(s) by calling the &b-MSVSSolution; Builder (see below). </para> <para>
-The &b-MSVSProject; builder takes several lists of filenames to be placed into
-the project file. These are currently limited to <literal>srcs</literal>,
-<literal>incs</literal>, <literal>localincs</literal>,
-<literal>resources</literal>, and <literal>misc</literal>. These are pretty
-self-explanatory, but it should be noted that these lists are added to the
-&cv-link-SOURCES; construction variable as strings, NOT as SCons File Nodes.
-This is because they represent file names to be added to the project file, not
-the source files used to build the project file. </para> <para> The above
-filename lists are all optional, although at least one must be specified for
-the resulting project file to be non-empty. </para> <para> In addition to the
-above lists of values, the following values may be specified:
-</para><variablelist>
- <varlistentry>
- <term>target</term>
-
- <listitem>
- <para>The name of the target <filename>.dsp</filename> or
- <filename>.vcproj</filename> file. The correct suffix for the version
- of Visual Studio must be used, but the &cv-link-MSVSPROJECTSUFFIX;
- construction variable will be defined to the correct value (see
- example below).</para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>variant</term>
-
- <listitem>
- <para>The name of this particular variant. For Visual Studio 7
- projects, this can also be a list of variant names. These are
- typically things like "Debug" or "Release", but really can be anything
- you want. For Visual Studio 7 projects, they may also specify a target
- platform separated from the variant name by a <literal>|</literal>
- (vertical pipe) character: <literal>Debug|Xbox</literal>. The default
- target platform is Win32. Multiple calls to &b-MSVSProject; with
- different variants are allowed; all variants will be added to the
- project file with their appropriate build targets and
- sources.</para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>cmdargs</term>
-
- <listitem>
- <para>Additional command line arguments for the different
- variants. The number of <literal>cmdargs</literal> entries must match
- the number of <literal>variant</literal> entries, or be empty (not
- specified). If you give only one, it will automatically be propagated
- to all variants.</para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>buildtarget</term>
-
- <listitem>
- <para>An optional string, node, or list of strings or nodes (one
- per build variant), to tell the Visual Studio debugger what output
- target to use in what build variant. The number of
- <literal>buildtarget</literal> entries must match the number of
- <literal>variant</literal> entries.</para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>runfile</term>
-
- <listitem>
- <para>The name of the file that Visual Studio 7 and later will
- run and debug. This appears as the value of the
- <literal>Output</literal> field in the resulting Visual Studio project
- file. If this is not specified, the default is the same as the
- specified <literal>buildtarget</literal> value.</para>
- </listitem>
- </varlistentry>
- </variablelist><para> Note that because &SCons; always executes its build
-commands from the directory in which the &SConstruct; file is located, if you
-generate a project file in a different directory than the &SConstruct;
-directory, users will not be able to double-click on the file name in
-compilation error messages displayed in the Visual Studio console output
-window. This can be remedied by adding the Visual C/C++ <literal>/FC</literal>
-compiler option to the &cv-link-CCFLAGS; variable so that the compiler will
-print the full path name of any files that cause compilation errors. </para>
-<para> Example usage: </para>
- <example_commands>
+<sconsdoc xmlns="http://www.scons.org/dbxsd/v1.0" xmlns:ns="http://www.scons.org/dbxsd/v1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.scons.org/dbxsd/v1.0 http://www.scons.org/dbxsd/v1.0/scons.xsd">
+ <tool name="msvs">
+ <summary>
+ <para>Sets construction variables for Microsoft Visual Studio.</para>
+ </summary>
+ <sets>
+ <item>MSVSPROJECTCOM</item>
+ <item>MSVSSOLUTIONCOM</item>
+ <item>MSVSSCONSCRIPT</item>
+ <item>MSVSSCONS</item>
+ <item>MSVSSCONSFLAGS</item>
+ <item>MSVSSCONSCOM</item>
+ <item>MSVSBUILDCOM</item>
+ <item>MSVSREBUILDCOM</item>
+ <item>MSVSCLEANCOM</item>
+ <item>MSVSENCODING</item>
+ </sets>
+ <uses />
+ </tool>
+ <builder name="MSVSProject">
+ <summary>
+ <para>
+ Builds a Microsoft Visual Studio project file, and by default
+ builds a solution file as well.
+ </para>
+ <para>
+ This builds a Visual Studio project file, based on the
+ version of Visual Studio that is configured (either the
+ latest installed version, or the version specified by
+ &cv-link-MSVS_VERSION; in the Environment constructor). For
+ Visual Studio 6, it will generate a <filename>.dsp</filename>
+ file. For Visual Studio 7 (.NET) and later versions, it will
+ generate a <filename>.vcproj</filename> file.
+ </para>
+ <para>
+ By default, this also generates a solution file for the
+ specified project, a <filename>.dsw</filename> file for
+ Visual Studio 6 or a <filename>.sln</filename> file for
+ Visual Studio 7 (.NET). This behavior may be disabled by
+ specifying <literal>auto_build_solution=0</literal> when you
+ call &b-MSVSProject;, in which case you presumably want to
+ build the solution file(s) by calling the &b-MSVSSolution;
+ Builder (see below).
+ </para>
+ <para>
+ The &b-MSVSProject; builder takes several lists of filenames
+ to be placed into the project file. These are currently
+ limited to <literal>srcs</literal>, <literal>incs</literal>,
+ <literal>localincs</literal>, <literal>resources</literal>, and
+ <literal>misc</literal>. These are pretty self-explanatory,
+ but it should be noted that these lists are added to the
+ &cv-link-SOURCES; construction variable as strings, NOT as
+ SCons File Nodes. This is because they represent file names
+ to be added to the project file, not the source files used
+ to build the project file.
+ </para>
+ <para>
+ The above filename lists are all optional, although at least
+ one must be specified for the resulting project file to
+ be non-empty.
+ </para>
+ <para>
+ In addition to the above lists of values, the following values
+ may be specified:
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term>target</term>
+ <listitem>
+ <para>
+ The name of the target <filename>.dsp</filename>
+ or <filename>.vcproj</filename> file.
+ The correct suffix for the version of Visual Studio
+ must be used, but the &cv-link-MSVSPROJECTSUFFIX;
+ construction variable will be defined to the correct
+ value (see example below).
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>variant</term>
+ <listitem>
+ <para>
+ The name of this particular variant. For Visual Studio 7
+ projects, this can also be a list of variant names. These
+ are typically things like "Debug" or "Release", but
+ really can be anything you want. For Visual Studio
+ 7 projects, they may also specify a target platform
+ separated from the variant name by a <literal>|</literal>
+ (vertical pipe) character: <literal>Debug|Xbox</literal>.
+ The default target platform is Win32. Multiple calls
+ to &b-MSVSProject; with different variants are allowed;
+ all variants will be added to the project file with
+ their appropriate build targets and sources.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>cmdargs</term>
+ <listitem>
+ <para>
+ Additional command line arguments
+ for the different variants. The number of
+ <literal>cmdargs</literal> entries must match the number
+ of <literal>variant</literal> entries, or be empty (not
+ specified). If you give only one, it will automatically
+ be propagated to all variants.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>buildtarget</term>
+ <listitem>
+ <para>
+ An optional string, node, or list of strings
+ or nodes (one per build variant), to tell
+ the Visual Studio debugger what output target
+ to use in what build variant. The number of
+ <literal>buildtarget</literal> entries must match the
+ number of <literal>variant</literal> entries.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>runfile</term>
+ <listitem>
+ <para>
+ The name of the file that Visual Studio 7 and
+ later will run and debug. This appears as the
+ value of the <literal>Output</literal> field in the
+ resulting Visual Studio project file. If this is not
+ specified, the default is the same as the specified
+ <literal>buildtarget</literal> value.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ <para>
+ Note that because &SCons; always executes its build commands
+ from the directory in which the &SConstruct; file is located,
+ if you generate a project file in a different directory
+ than the &SConstruct; directory, users will not be able to
+ double-click on the file name in compilation error messages
+ displayed in the Visual Studio console output window. This can
+ be remedied by adding the Visual C/C++ <literal>/FC</literal>
+ compiler option to the &cv-link-CCFLAGS; variable so that
+ the compiler will print the full path name of any files that
+ cause compilation errors.
+ </para>
+ <para>Example usage:</para>
+ <example_commands>
barsrcs = ['bar.cpp']
barincs = ['bar.h']
barlocalincs = ['StdAfx.h']
barresources = ['bar.rc','resource.h']
barmisc = ['bar_readme.txt']
-dll = env.SharedLibrary(target = 'bar.dll',
- source = barsrcs)
+dll = env.SharedLibrary(target='bar.dll',
+ source=barsrcs)
buildtarget = [s for s in dll if str(s).endswith('dll')]
-env.MSVSProject(target = 'Bar' + env['MSVSPROJECTSUFFIX'],
- srcs = barsrcs,
- incs = barincs,
- localincs = barlocalincs,
- resources = barresources,
- misc = barmisc,
- buildtarget = buildtarget,
- variant = 'Release')
-</example_commands>
-<para>Starting with version 2.4 of
-SCons it's also possible to specify the optional argument
-<parameter>DebugSettings</parameter>, which creates files for debugging under
-Visual Studio:</para><variablelist>
- <varlistentry>
- <term>DebugSettings</term>
-
- <listitem>
- <para>A dictionary of debug settings that get written to the
- <filename>.vcproj.user</filename> or the
- <filename>.vcxproj.user</filename> file, depending on the version
- installed. As it is done for cmdargs (see above), you can specify a
- <parameter>DebugSettings</parameter> dictionary per variant. If you
- give only one, it will be propagated to all variants.</para>
- </listitem>
- </varlistentry>
- </variablelist><para>Currently, only Visual Studio v9.0 and Visual Studio
-version v11 are implemented, for other versions no file is generated. To
-generate the user file, you just need to add a
-<parameter>DebugSettings</parameter> dictionary to the environment with the
-right parameters for your MSVS version. If the dictionary is empty, or does
-not contain any good value, no file will be generated.</para><para>Following
-is a more contrived example, involving the setup of a project for variants and
-DebugSettings:</para><example_commands># Assuming you store your defaults in a file
+env.MSVSProject(target='Bar' + env['MSVSPROJECTSUFFIX'],
+ srcs=barsrcs,
+ incs=barincs,
+ localincs=barlocalincs,
+ resources=barresources,
+ misc=barmisc,
+ buildtarget=buildtarget,
+ variant='Release')
+ </example_commands>
+ <para>
+ Starting with version 2.4 of SCons it is
+ also possible to specify the optional argument
+ <parameter>DebugSettings</parameter>, which creates files
+ for debugging under Visual Studio:
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term>DebugSettings</term>
+ <listitem>
+ <para>
+ A dictionary of debug settings that get written
+ to the <filename>.vcproj.user</filename> or the
+ <filename>.vcxproj.user</filename> file, depending on the
+ version installed. As it is done for cmdargs (see above),
+ you can specify a <parameter>DebugSettings</parameter>
+ dictionary per variant. If you give only one, it will
+ be propagated to all variants.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ <para>
+ Currently, only Visual Studio v9.0 and Visual Studio
+ version v11 are implemented, for other versions no file
+ is generated. To generate the user file, you just need to
+ add a <parameter>DebugSettings</parameter> dictionary to the
+ environment with the right parameters for your MSVS version. If
+ the dictionary is empty, or does not contain any good value,
+ no file will be generated.
+ </para>
+ <para>
+ Following is a more contrived example, involving the setup
+ of a project for variants and DebugSettings:
+ </para>
+ <example_commands>
+# Assuming you store your defaults in a file
vars = Variables('variables.py')
msvcver = vars.args.get('vc', '9')
@@ -179,7 +231,7 @@ if msvcver == '9' or msvcver == '11':
env = Environment(MSVC_VERSION=msvcver+'.0', MSVC_BATCH=False)
else:
env = Environment()
-
+
AddOption('--userfile', action='store_true', dest='userfile', default=False,
help="Create Visual Studio Project user file")
@@ -214,10 +266,10 @@ V9DebugSettings = {
}
#
-# 2. Because there are a lot of different options depending on the Microsoft
-# Visual Studio version, if you use more than one version you have to
-# define a dictionary per version, for instance if you want to create a user
-# file to launch a specific application for testing your dll with Microsoft
+# 2. Because there are a lot of different options depending on the Microsoft
+# Visual Studio version, if you use more than one version you have to
+# define a dictionary per version, for instance if you want to create a user
+# file to launch a specific application for testing your dll with Microsoft
# Visual Studio 2012 (v11):
#
V10DebugSettings = {
@@ -249,7 +301,7 @@ V10DebugSettings = {
}
#
-# 3. Select the dictionary you want depending on the version of visual Studio
+# 3. Select the dictionary you want depending on the version of visual Studio
# Files you want to generate.
#
if not env.GetOption('userfile'):
@@ -258,7 +310,7 @@ elif env.get('MSVC_VERSION', None) == '9.0':
dbgSettings = V9DebugSettings
elif env.get('MSVC_VERSION', None) == '11.0':
dbgSettings = V10DebugSettings
-else:
+else:
dbgSettings = None
#
@@ -270,251 +322,365 @@ barlocalincs = ['StdAfx.h']
barresources = ['bar.rc','resource.h']
barmisc = ['ReadMe.txt']
-dll = env.SharedLibrary(target = 'bar.dll',
- source = barsrcs)
-
-env.MSVSProject(target = 'Bar' + env['MSVSPROJECTSUFFIX'],
- srcs = barsrcs,
- incs = barincs,
- localincs = barlocalincs,
- resources = barresources,
- misc = barmisc,
- buildtarget = [dll[0]] * 2,
- variant = ('Debug|Win32', 'Release|Win32'),
- cmdargs = 'vc=%s' % msvcver,
- DebugSettings = (dbgSettings, {}))
-</example_commands> </summary> </builder> <builder
-name="MSVSSolution"> <summary> <para>Builds a Microsoft Visual Studio solution
-file. </para> <para>This builds a Visual Studio solution file, based on the
-version of Visual Studio that is configured (either the latest installed
-version, or the version specified by &cv-link-MSVS_VERSION; in the
-construction environment). For Visual Studio 6, it will generate a
-<filename>.dsw</filename> file. For Visual Studio 7 (.NET), it will generate a
-<filename>.sln</filename> file. </para> <para> The following values must be
-specified: </para><variablelist>
- <varlistentry>
- <term>target</term>
-
- <listitem>
- <para>The name of the target .dsw or .sln file. The correct
- suffix for the version of Visual Studio must be used, but the value
- &cv-link-MSVSSOLUTIONSUFFIX; will be defined to the correct value (see
- example below).</para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>variant</term>
-
- <listitem>
- <para>The name of this particular variant, or a list of variant
- names (the latter is only supported for MSVS 7 solutions). These are
- typically things like "Debug" or "Release", but really can be anything
- you want. For MSVS 7 they may also specify target platform, like this
- "Debug|Xbox". Default platform is Win32.</para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>projects</term>
-
- <listitem>
- <para>A list of project file names, or Project nodes returned by
- calls to the &b-MSVSProject; Builder, to be placed into the solution
- file. It should be noted that these file names are NOT added to the
- $SOURCES environment variable in form of files, but rather as strings.
- This is because they represent file names to be added to the solution
- file, not the source files used to build the solution
- file.</para>
- </listitem>
- </varlistentry>
- </variablelist> <para> Example Usage: </para> <example_commands>
-env.MSVSSolution(target = 'Bar' + env['MSVSSOLUTIONSUFFIX'], projects = ['bar'
-+ env['MSVSPROJECTSUFFIX']], variant = 'Release')
-</example_commands></summary></builder> <cvar name="MSVS"> <summary> <para>
-When the Microsoft Visual Studio tools are initialized, they set up this
-dictionary with the following keys: </para><variablelist>
- <varlistentry>
- <term>VERSION</term>
-
- <listitem>
- <para>the version of MSVS being used (can be set via
- &cv-link-MSVS_VERSION;)</para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>VERSIONS</term>
-
- <listitem>
- <para>the available versions of MSVS installed</para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>VCINSTALLDIR</term>
-
- <listitem>
- <para>installed directory of Visual C++</para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>VSINSTALLDIR</term>
-
- <listitem>
- <para>installed directory of Visual Studio</para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>FRAMEWORKDIR</term>
-
- <listitem>
- <para>installed directory of the .NET framework</para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>FRAMEWORKVERSIONS</term>
-
- <listitem>
- <para>list of installed versions of the .NET framework, sorted
- latest to oldest.</para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>FRAMEWORKVERSION</term>
-
- <listitem>
- <para>latest installed version of the .NET
- framework</para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>FRAMEWORKSDKDIR</term>
-
- <listitem>
- <para>installed location of the .NET SDK.</para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>PLATFORMSDKDIR</term>
-
- <listitem>
- <para>installed location of the Platform SDK.</para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>PLATFORMSDK_MODULES</term>
-
- <listitem>
- <para>dictionary of installed Platform SDK modules, where the
- dictionary keys are keywords for the various modules, and the values
- are 2-tuples where the first is the release date, and the second is
- the version number.</para>
- </listitem>
- </varlistentry>
- </variablelist><para>If a value isn't set, it wasn't available in the
-registry.</para></summary></cvar> <cvar name="MSVS_ARCH"> <summary> <para>Sets
-the architecture for which the generated project(s) should build. </para>
-<para>The default value is <literal>x86</literal>. <literal>amd64</literal> is
-also supported by &SCons; for some Visual Studio versions. Trying to set
-&cv-MSVS_ARCH; to an architecture that's not supported for a given Visual
-Studio version will generate an error. </para> </summary> </cvar> <cvar
-name="MSVS_PROJECT_GUID"> <summary> <para>The string placed in a generated
+dll = env.SharedLibrary(target='bar.dll',
+ source=barsrcs)
+
+env.MSVSProject(target='Bar' + env['MSVSPROJECTSUFFIX'],
+ srcs=barsrcs,
+ incs=barincs,
+ localincs=barlocalincs,
+ resources=barresources,
+ misc=barmisc,
+ buildtarget=[dll[0]] * 2,
+ variant=('Debug|Win32', 'Release|Win32'),
+ cmdargs='vc=%s' % msvcver,
+ DebugSettings=(dbgSettings, {}))
+ </example_commands>
+ </summary>
+ </builder>
+ <builder name="MSVSSolution">
+ <summary>
+ <para>Builds a Microsoft Visual Studio solution file.</para>
+ <para>
+ This builds a Visual Studio solution file, based on the
+ version of Visual Studio that is configured (either the
+ latest installed version, or the version specified by
+ &cv-link-MSVS_VERSION; in the construction environment). For
+ Visual Studio 6, it will generate a <filename>.dsw</filename>
+ file. For Visual Studio 7 (.NET), it will generate a
+ <filename>.sln</filename> file.
+ </para>
+ <para>The following values must be specified:</para>
+ <variablelist>
+ <varlistentry>
+ <term>target</term>
+ <listitem>
+ <para>
+ The name of the target .dsw or .sln file. The correct
+ suffix for the version of Visual Studio must be used,
+ but the value &cv-link-MSVSSOLUTIONSUFFIX; will be
+ defined to the correct value (see example below).
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry>
+ <term>variant</term> <listitem>
+ <para>
+ The name of this particular variant, or a list of
+ variant names (the latter is only supported for MSVS
+ 7 solutions). These are typically things like "Debug"
+ or "Release", but really can be anything you want. For
+ MSVS 7 they may also specify target platform, like this
+ "Debug|Xbox". Default platform is Win32.
+ </para>
+ </listitem>
+ </varlistentry> <varlistentry>
+ <term>projects</term> <listitem>
+ <para>
+ A list of project file names, or Project nodes returned
+ by calls to the &b-MSVSProject; Builder, to be placed
+ into the solution file. It should be noted that these
+ file names are NOT added to the $SOURCES environment
+ variable in form of files, but rather as strings.
+ This is because they represent file names to be added
+ to the solution file, not the source files used to
+ build the solution file.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ <para>Example Usage:</para>
+ <example_commands>
+env.MSVSSolution(target='Bar' + env['MSVSSOLUTIONSUFFIX'], projects=['bar' + env['MSVSPROJECTSUFFIX']], variant='Release')
+ </example_commands>
+ </summary>
+ </builder> <cvar name="MSVS">
+ <summary>
+ <para>
+ When the Microsoft Visual Studio tools are initialized,
+ they set up this dictionary with the following keys:
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term>VERSION</term> <listitem>
+ <para>the version of MSVS being used (can be set via
+ &cv-link-MSVS_VERSION;)</para>
+ </listitem>
+ </varlistentry> <varlistentry>
+ <term>VERSIONS</term> <listitem>
+ <para>the available versions of MSVS installed</para>
+ </listitem>
+ </varlistentry> <varlistentry>
+ <term>VCINSTALLDIR</term> <listitem>
+ <para>installed directory of Visual C++</para>
+ </listitem>
+ </varlistentry> <varlistentry>
+ <term>VSINSTALLDIR</term> <listitem>
+ <para>installed directory of Visual Studio</para>
+ </listitem>
+ </varlistentry> <varlistentry>
+ <term>FRAMEWORKDIR</term> <listitem>
+ <para>installed directory of the .NET framework</para>
+ </listitem>
+ </varlistentry> <varlistentry>
+ <term>FRAMEWORKVERSIONS</term> <listitem>
+ <para>
+ list of installed versions of the .NET framework,
+ sorted latest to oldest.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>FRAMEWORKVERSION</term>
+ <listitem>
+ <para>latest installed version of the .NET framework</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>FRAMEWORKSDKDIR</term>
+ <listitem>
+ <para>installed location of the .NET SDK.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>PLATFORMSDKDIR</term>
+ <listitem>
+ <para>installed location of the Platform SDK.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>PLATFORMSDK_MODULES</term>
+ <listitem>
+ <para>
+ dictionary of installed Platform SDK modules, where the
+ dictionary keys are keywords for the various modules,
+ and the values are 2-tuples where the first is the
+ release date, and the second is the version number.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ <para>If a value is not set, it was not available in the registry.</para>
+ </summary>
+ </cvar> <cvar name="MSVS_ARCH">
+ <summary>
+ <para>Sets the architecture for which the generated project(s) should build.</para>
+ <para>
+ The default value is <literal>x86</literal>.
+ <literal>amd64</literal> is also supported by &SCons; for
+ most Visual Studio versions. Since Visual Studio 2015
+ <literal>arm</literal> is supported, and since Visual Studio
+ 2017 <literal>arm64</literal> is supported.
+ Trying to set &cv-MSVS_ARCH;
+ to an architecture that's not supported for a given Visual
+ Studio version will generate an error.
+ </para>
+ </summary>
+ </cvar> <cvar name="MSVS_PROJECT_GUID">
+ <summary>
+ <para>
+ The string placed in a generated
Microsoft Visual Studio project file as the value of the
-<literal>ProjectGUID</literal> attribute. There is no default value. If not
-defined, a new GUID is generated. </para> </summary> </cvar> <cvar
-name="MSVS_SCC_AUX_PATH"> <summary> <para>The path name placed in a generated
+ <literal>ProjectGUID</literal> attribute. There is no default
+ value. If not
+defined, a new GUID is generated.
+
+ </para>
+ </summary>
+ </cvar> <cvar name="MSVS_SCC_AUX_PATH">
+ <summary>
+ <para>
+ The path name placed in a generated
Microsoft Visual Studio project file as the value of the
-<literal>SccAuxPath</literal> attribute if the
-<envar>MSVS_SCC_PROVIDER</envar> construction variable is also set. There is
-no default value. </para> </summary> </cvar> <cvar
-name="MSVS_SCC_CONNECTION_ROOT"> <summary> <para>The root path of projects in
-your SCC workspace, i.e the path under which all project and solution files
-will be generated. It is used as a reference path from which the relative
-paths of the generated Microsoft Visual Studio project and solution files are
-computed. The relative project file path is placed as the value of the
-<literal>SccLocalPath</literal> attribute of the project file and as the
-values of the
-<literal>SccProjectFilePathRelativizedFromConnection[i]</literal> (where [i]
-ranges from 0 to the number of projects in the solution) attributes of the
-<literal>GlobalSection(SourceCodeControl)</literal> section of the Microsoft
-Visual Studio solution file. Similarly the relative solution file path is
-placed as the values of the <literal>SccLocalPath[i]</literal> (where [i]
-ranges from 0 to the number of projects in the solution) attributes of the
-<literal>GlobalSection(SourceCodeControl)</literal> section of the Microsoft
-Visual Studio solution file. This is used only if the
-<envar>MSVS_SCC_PROVIDER</envar> construction variable is also set. The
-default value is the current working directory. </para> </summary> </cvar>
-<cvar name="MSVS_SCC_PROJECT_NAME"> <summary> <para>The project name placed in
-a generated Microsoft Visual Studio project file as the value of the
-<literal>SccProjectName</literal> attribute if the
-<envar>MSVS_SCC_PROVIDER</envar> construction variable is also set. In this
-case the string is also placed in the <literal>SccProjectName0</literal>
-attribute of the <literal>GlobalSection(SourceCodeControl)</literal> section
-of the Microsoft Visual Studio solution file. There is no default value.
-</para> </summary> </cvar> <cvar name="MSVS_SCC_PROVIDER"> <summary> <para>The
-string placed in a generated Microsoft Visual Studio project file as the value
-of the <literal>SccProvider</literal> attribute. The string is also placed in
-the <literal>SccProvider0</literal> attribute of the
-<literal>GlobalSection(SourceCodeControl)</literal> section of the Microsoft
-Visual Studio solution file. There is no default value. </para> </summary>
-</cvar> <cvar name="MSVS_VERSION"> <summary> <para>Sets the preferred version
-of Microsoft Visual Studio to use. </para> <para>If &cv-MSVS_VERSION; is not
-set, &SCons; will (by default) select the latest version of Visual Studio
-installed on your system. So, if you have version 6 and version 7 (MSVS .NET)
-installed, it will prefer version 7. You can override this by specifying the
-<envar>MSVS_VERSION</envar> variable in the Environment initialization,
-setting it to the appropriate version ('6.0' or '7.0', for example). If the
-specified version isn't installed, tool initialization will fail. </para>
-<para>This is obsolete: use &cv-MSVC_VERSION; instead. If &cv-MSVS_VERSION; is
-set and &cv-MSVC_VERSION; is not, &cv-MSVC_VERSION; will be set automatically
-to &cv-MSVS_VERSION;. If both are set to different values, scons will raise an
-error. </para> </summary> </cvar> <cvar name="MSVSBUILDCOM"> <summary>
-<para>The build command line placed in a generated Microsoft Visual Studio
-project file. The default is to have Visual Studio invoke SCons with any
-specified build targets. </para> </summary> </cvar> <cvar name="MSVSCLEANCOM">
-<summary> <para>The clean command line placed in a generated Microsoft Visual
-Studio project file. The default is to have Visual Studio invoke SCons with
-the -c option to remove any specified targets. </para> </summary> </cvar>
-<cvar name="MSVSENCODING"> <summary> <para>The encoding string placed in a
-generated Microsoft Visual Studio project file. The default is encoding
-<literal>Windows-1252</literal>. </para> </summary> </cvar> <cvar
-name="MSVSPROJECTCOM"> <summary> <para>The action used to generate Microsoft
-Visual Studio project files. </para> </summary> </cvar> <cvar
-name="MSVSPROJECTSUFFIX"> <summary> <para>The suffix used for Microsoft Visual
-Studio project (DSP) files. The default value is <filename>.vcproj</filename>
-when using Visual Studio version 7.x (.NET) or later version, and
-<filename>.dsp</filename> when using earlier versions of Visual Studio.
-</para> </summary> </cvar> <cvar name="MSVSREBUILDCOM"> <summary> <para>The
-rebuild command line placed in a generated Microsoft Visual Studio project
-file. The default is to have Visual Studio invoke SCons with any specified
-rebuild targets. </para> </summary> </cvar> <cvar name="MSVSSCONS"> <summary>
-<para>The SCons used in generated Microsoft Visual Studio project files. The
-default is the version of SCons being used to generate the project file.
-</para> </summary> </cvar> <cvar name="MSVSSCONSFLAGS"> <summary> <para>The
-SCons flags used in generated Microsoft Visual Studio project files. </para>
-</summary> </cvar> <cvar name="MSVSSCONSCOM"> <summary> <para>The default
-SCons command used in generated Microsoft Visual Studio project files. </para>
-</summary> </cvar> <cvar name="MSVSSCONSCRIPT"> <summary> <para>The sconscript
-file (that is, &SConstruct; or &SConscript; file) that will be invoked by
-Visual Studio project files (through the &cv-link-MSVSSCONSCOM; variable). The
-default is the same sconscript file that contains the call to &b-MSVSProject;
-to build the project file. </para> </summary> </cvar> <cvar
-name="MSVSSOLUTIONCOM"> <summary> <para>The action used to generate Microsoft
-Visual Studio solution files. </para> </summary> </cvar> <cvar
-name="MSVSSOLUTIONSUFFIX"> <summary> <para>The suffix used for Microsoft
-Visual Studio solution (DSW) files. The default value is
-<filename>.sln</filename> when using Visual Studio version 7.x (.NET), and
-<filename>.dsw</filename> when using earlier versions of Visual Studio.
-</para> </summary> </cvar> <cvar name="SCONS_HOME"> <summary> <para>The
-(optional) path to the SCons library directory, initialized from the external
-environment. If set, this is used to construct a shorter and more efficient
-search path in the &cv-link-MSVSSCONS; command line executed from Microsoft
-Visual Studio project files. </para> </summary> </cvar></sconsdoc>
+ <literal>SccAuxPath</literal> attribute if the
+ <envar>MSVS_SCC_PROVIDER</envar> construction variable is
+ also set. There is
+no default value.
+
+ </para>
+ </summary>
+ </cvar> <cvar name="MSVS_SCC_CONNECTION_ROOT">
+ <summary>
+ <para>
+ The root path of projects in your SCC workspace, i.e the
+ path under which all project and solution files will be
+ generated. It is used as a reference path from which the
+ relative paths of the generated Microsoft Visual Studio project
+ and solution files are computed. The relative project file path
+ is placed as the value of the <literal>SccLocalPath</literal>
+ attribute of the project file and as the values of the
+ <literal>SccProjectFilePathRelativizedFromConnection[i]</literal>
+ (where [i] ranges from 0 to the number of projects in the solution)
+ attributes of the <literal>GlobalSection(SourceCodeControl)</literal>
+ section of the Microsoft Visual Studio solution file. Similarly
+ the relative solution file path is placed as the values of the
+ <literal>SccLocalPath[i]</literal> (where [i] ranges from 0
+ to the number of projects in the solution) attributes of the
+ <literal>GlobalSection(SourceCodeControl)</literal> section of
+ the Microsoft Visual Studio solution file. This is used only if
+ the <envar>MSVS_SCC_PROVIDER</envar> construction variable is
+ also set. The default value is the current working directory.
+ </para>
+ </summary>
+ </cvar> <cvar name="MSVS_SCC_PROJECT_NAME">
+ <summary>
+ <para>
+ The project name placed in a generated Microsoft
+ Visual Studio project file as the value of the
+ <literal>SccProjectName</literal> attribute if the
+ <envar>MSVS_SCC_PROVIDER</envar> construction variable
+ is also set. In this case the string is also placed in
+ the <literal>SccProjectName0</literal> attribute of the
+ <literal>GlobalSection(SourceCodeControl)</literal> section
+ of the Microsoft Visual Studio solution file. There is no
+ default value.
+ </para>
+ </summary>
+ </cvar> <cvar name="MSVS_SCC_PROVIDER">
+ <summary>
+ <para>
+ The string placed in a generated Microsoft
+ Visual Studio project file as the value of the
+ <literal>SccProvider</literal> attribute. The string is
+ also placed in the <literal>SccProvider0</literal> attribute
+ of the <literal>GlobalSection(SourceCodeControl)</literal>
+ section of the Microsoft Visual Studio solution file. There
+ is no default value.
+ </para>
+ </summary>
+ </cvar> <cvar name="MSVS_VERSION">
+ <summary>
+ <para>Sets the preferred version of Microsoft Visual Studio to use.</para>
+ <para>
+ If &cv-MSVS_VERSION; is not set, &SCons; will (by default)
+ select the latest version of Visual Studio installed on your
+ system. So, if you have version 6 and version 7 (MSVS .NET)
+ installed, it will prefer version 7. You can override this by
+ specifying the <envar>MSVS_VERSION</envar> variable in the
+ Environment initialization, setting it to the appropriate
+ version ('6.0' or '7.0', for example). If the specified
+ version isn't installed, tool initialization will fail.
+ </para>
+ <para>
+ This is obsolete: use &cv-MSVC_VERSION; instead. If
+ &cv-MSVS_VERSION; is set and &cv-MSVC_VERSION; is
+ not, &cv-MSVC_VERSION; will be set automatically to
+ &cv-MSVS_VERSION;. If both are set to different values,
+ scons will raise an error.
+ </para>
+ </summary>
+ </cvar>
+ <cvar name="MSVSBUILDCOM">
+ <summary>
+ <para>
+ The build command line placed in a generated Microsoft Visual
+ Studio project file. The default is to have Visual Studio
+ invoke SCons with any specified build targets.
+ </para>
+ </summary>
+ </cvar>
+ <cvar name="MSVSCLEANCOM">
+ <summary>
+ <para>
+ The clean command line placed in a generated Microsoft Visual
+ Studio project file. The default is to have Visual Studio
+ invoke SCons with the -c option to remove any specified
+ targets.
+ </para>
+ </summary>
+ </cvar> <cvar name="MSVSENCODING">
+ <summary>
+ <para>
+ The encoding string placed in a generated Microsoft
+ Visual Studio project file. The default is encoding
+ <literal>Windows-1252</literal>.
+ </para>
+ </summary>
+ </cvar>
+ <cvar name="MSVSPROJECTCOM">
+ <summary>
+ <para>The action used to generate Microsoft Visual Studio project files.</para>
+ </summary>
+ </cvar>
+ <cvar name="MSVSPROJECTSUFFIX">
+ <summary>
+ <para>
+ The suffix used for Microsoft Visual Studio project (DSP)
+ files. The default value is <filename>.vcproj</filename>
+ when using Visual Studio version 7.x (.NET) or later version,
+ and <filename>.dsp</filename> when using earlier versions of
+ Visual Studio.
+ </para>
+ </summary>
+ </cvar>
+ <cvar name="MSVSREBUILDCOM">
+ <summary>
+ <para>
+ The rebuild command line placed in a generated Microsoft
+ Visual Studio project file. The default is to have Visual
+ Studio invoke SCons with any specified rebuild targets.
+
+ </para>
+ </summary>
+ </cvar>
+ <cvar name="MSVSSCONS">
+ <summary>
+ <para>
+ The SCons used in generated Microsoft Visual Studio project
+ files. The default is the version of SCons being used to
+ generate the project file.
+ </para>
+ </summary>
+ </cvar>
+ <cvar name="MSVSSCONSFLAGS">
+ <summary>
+ <para>
+ The SCons flags used in generated Microsoft Visual Studio project files.
+ </para>
+ </summary>
+ </cvar>
+ <cvar name="MSVSSCONSCOM">
+ <summary>
+ <para>
+ The default SCons command used in generated Microsoft Visual
+ Studio project files.
+ </para>
+ </summary>
+ </cvar>
+ <cvar name="MSVSSCONSCRIPT">
+ <summary>
+ <para>
+ The sconscript file (that is, &SConstruct; or &SConscript;
+ file) that will be invoked by Visual Studio project files
+ (through the &cv-link-MSVSSCONSCOM; variable). The default
+ is the same sconscript file that contains the call to
+ &b-MSVSProject; to build the project file.
+ </para>
+ </summary>
+ </cvar>
+ <cvar name="MSVSSOLUTIONCOM">
+ <summary>
+ <para>The action used to generate Microsoft Visual Studio solution files.</para>
+ </summary>
+ </cvar> <cvar name="MSVSSOLUTIONSUFFIX">
+ <summary>
+ <para>
+ The suffix used for Microsoft Visual Studio solution (DSW)
+ files. The default value is <filename>.sln</filename>
+ when using Visual Studio version 7.x (.NET), and
+ <filename>.dsw</filename> when using earlier versions of
+ Visual Studio.
+ </para>
+ </summary>
+ </cvar>
+ <cvar name="SCONS_HOME">
+ <summary>
+ <para>
+ The (optional) path to the SCons library directory,
+ initialized from the external environment. If set, this is
+ used to construct a shorter and more efficient search path in
+ the &cv-link-MSVSSCONS; command line executed from Microsoft
+ Visual Studio project files.
+ </para>
+ </summary>
+ </cvar>
+</sconsdoc>
diff --git a/src/engine/SCons/Tool/msvsTests.py b/src/engine/SCons/Tool/msvsTests.py
index 6adc598..477694a 100644
--- a/src/engine/SCons/Tool/msvsTests.py
+++ b/src/engine/SCons/Tool/msvsTests.py
@@ -482,8 +482,8 @@ class DummyRegistry(object):
def parse(self, data):
parents = [None, None]
parents[0] = self.root
- keymatch = re.compile('^\[(.*)\]$')
- valmatch = re.compile('^(?:"(.*)"|[@])="(.*)"$')
+ keymatch = re.compile(r'^\[(.*)\]$')
+ valmatch = re.compile(r'^(?:"(.*)"|[@])="(.*)"$')
for line in data:
m1 = keymatch.match(line)
if m1:
diff --git a/src/engine/SCons/Tool/swig.py b/src/engine/SCons/Tool/swig.py
index 08881a0..c6abefb 100644
--- a/src/engine/SCons/Tool/swig.py
+++ b/src/engine/SCons/Tool/swig.py
@@ -70,7 +70,9 @@ def _find_modules(src):
directors = 0
mnames = []
try:
- matches = _reModule.findall(open(src).read())
+ with open(src) as f:
+ data = f.read()
+ matches = _reModule.findall(data)
except IOError:
# If the file's not yet generated, guess the module name from the file stem
matches = []
@@ -135,21 +137,31 @@ def _swigEmitter(target, source, env):
def _get_swig_version(env, swig):
"""Run the SWIG command line tool to get and return the version number"""
+ version = None
swig = env.subst(swig)
+ if not swig:
+ return version
pipe = SCons.Action._subproc(env, SCons.Util.CLVar(swig) + ['-version'],
stdin = 'devnull',
stderr = 'devnull',
stdout = subprocess.PIPE)
- if pipe.wait() != 0: return
+ if pipe.wait() != 0:
+ return version
# MAYBE: out = SCons.Util.to_str (pipe.stdout.read())
- out = SCons.Util.to_str(pipe.stdout.read())
- match = re.search('SWIG Version\s+(\S+).*', out, re.MULTILINE)
+ with pipe.stdout:
+ out = SCons.Util.to_str(pipe.stdout.read())
+
+ match = re.search(r'SWIG Version\s+(\S+).*', out, re.MULTILINE)
if match:
- if verbose: print("Version is:%s"%match.group(1))
- return match.group(1)
+ version = match.group(1)
+ if verbose:
+ print("Version is: %s" % version)
else:
- if verbose: print("Unable to detect version: [%s]"%out)
+ if verbose:
+ print("Unable to detect version: [%s]" % out)
+
+ return version
def generate(env):
"""Add Builders and construction variables for swig to an Environment."""
diff --git a/src/engine/SCons/Tool/tex.py b/src/engine/SCons/Tool/tex.py
index 2dfa229..d361dac 100644
--- a/src/engine/SCons/Tool/tex.py
+++ b/src/engine/SCons/Tool/tex.py
@@ -74,15 +74,15 @@ openout_bcf_re = re.compile(r"OUTPUT *(.*\.bcf)")
#printglossary_re = re.compile(r"^[^%]*\\printglossary", re.MULTILINE)
# search to find rerun warnings
-warning_rerun_str = '(^LaTeX Warning:.*Rerun)|(^Package \w+ Warning:.*Rerun)'
+warning_rerun_str = r'(^LaTeX Warning:.*Rerun)|(^Package \w+ Warning:.*Rerun)'
warning_rerun_re = re.compile(warning_rerun_str, re.MULTILINE)
# search to find citation rerun warnings
-rerun_citations_str = "^LaTeX Warning:.*\n.*Rerun to get citations correct"
+rerun_citations_str = r"^LaTeX Warning:.*\n.*Rerun to get citations correct"
rerun_citations_re = re.compile(rerun_citations_str, re.MULTILINE)
# search to find undefined references or citations warnings
-undefined_references_str = '(^LaTeX Warning:.*undefined references)|(^Package \w+ Warning:.*undefined citations)'
+undefined_references_str = r'(^LaTeX Warning:.*undefined references)|(^Package \w+ Warning:.*undefined citations)'
undefined_references_re = re.compile(undefined_references_str, re.MULTILINE)
# used by the emitter
@@ -297,7 +297,8 @@ def InternalLaTeXAuxAction(XXXLaTeXAction, target = None, source= None, env=None
logfilename = targetbase + '.log'
logContent = ''
if os.path.isfile(logfilename):
- logContent = open(logfilename, "r").read()
+ with open(logfilename, "r") as f:
+ logContent = f.read()
# Read the fls file to find all .aux files
@@ -305,7 +306,8 @@ def InternalLaTeXAuxAction(XXXLaTeXAction, target = None, source= None, env=None
flsContent = ''
auxfiles = []
if os.path.isfile(flsfilename):
- flsContent = open(flsfilename, "r").read()
+ with open(flsfilename, "r") as f:
+ flsContent = f.read()
auxfiles = openout_aux_re.findall(flsContent)
# remove duplicates
dups = {}
@@ -315,7 +317,8 @@ def InternalLaTeXAuxAction(XXXLaTeXAction, target = None, source= None, env=None
bcffiles = []
if os.path.isfile(flsfilename):
- flsContent = open(flsfilename, "r").read()
+ with open(flsfilename, "r") as f:
+ flsContent = f.read()
bcffiles = openout_bcf_re.findall(flsContent)
# remove duplicates
dups = {}
@@ -338,7 +341,8 @@ def InternalLaTeXAuxAction(XXXLaTeXAction, target = None, source= None, env=None
already_bibtexed.append(auxfilename)
target_aux = os.path.join(targetdir, auxfilename)
if os.path.isfile(target_aux):
- content = open(target_aux, "r").read()
+ with open(target_aux, "r") as f:
+ content = f.read()
if content.find("bibdata") != -1:
if Verbose:
print("Need to run bibtex on ",auxfilename)
@@ -361,7 +365,8 @@ def InternalLaTeXAuxAction(XXXLaTeXAction, target = None, source= None, env=None
already_bibtexed.append(bcffilename)
target_bcf = os.path.join(targetdir, bcffilename)
if os.path.isfile(target_bcf):
- content = open(target_bcf, "r").read()
+ with open(target_bcf, "r") as f:
+ content = f.read()
if content.find("bibdata") != -1:
if Verbose:
print("Need to run biber on ",bcffilename)
@@ -647,7 +652,7 @@ def ScanFiles(theFile, target, paths, file_tests, file_tests_search, env, graphi
if incResult:
aux_files.append(os.path.join(targetdir, incResult.group(1)))
if Verbose:
- print("\include file names : ", aux_files)
+ print(r"\include file names : ", aux_files)
# recursively call this on each of the included files
inc_files = [ ]
inc_files.extend( include_re.findall(content) )
@@ -813,7 +818,8 @@ def tex_emitter_core(target, source, env, graphics_extensions):
# read fls file to get all other files that latex creates and will read on the next pass
# remove files from list that we explicitly dealt with above
if os.path.isfile(flsfilename):
- content = open(flsfilename, "r").read()
+ with open(flsfilename, "r") as f:
+ content = f.read()
out_files = openout_re.findall(content)
myfiles = [auxfilename, logfilename, flsfilename, targetbase+'.dvi',targetbase+'.pdf']
for filename in out_files[:]:
diff --git a/src/engine/SCons/Tool/textfile.xml b/src/engine/SCons/Tool/textfile.xml
index 08bbb76..3b4a038 100644
--- a/src/engine/SCons/Tool/textfile.xml
+++ b/src/engine/SCons/Tool/textfile.xml
@@ -147,7 +147,7 @@ and the result replaces the key.
</para>
<example_commands>
-env = Environment(tools = ['default', 'textfile'])
+env = Environment(tools=['default'])
env['prefix'] = '/usr/bin'
script_dict = {'@prefix@': '/bin', '@exec_prefix@': '$prefix'}
@@ -174,7 +174,7 @@ env.Substfile('bar.in', SUBST_DICT = good_bar)
# the SUBST_DICT may be in common (and not an override)
substutions = {}
-subst = Environment(tools = ['textfile'], SUBST_DICT = substitutions)
+subst = Environment(tools=['textfile'], SUBST_DICT=substitutions)
substitutions['@foo@'] = 'foo'
subst['SUBST_DICT']['@bar@'] = 'bar'
subst.Substfile('pgm1.c', [Value('#include "@foo@.h"'),
diff --git a/src/engine/SCons/Tool/yacc.py b/src/engine/SCons/Tool/yacc.py
index cd9b9a8..5db49d3 100644
--- a/src/engine/SCons/Tool/yacc.py
+++ b/src/engine/SCons/Tool/yacc.py
@@ -41,6 +41,7 @@ import SCons.Tool
import SCons.Util
from SCons.Platform.mingw import MINGW_DEFAULT_PATHS
from SCons.Platform.cygwin import CYGWIN_DEFAULT_PATHS
+from SCons.Platform.win32 import CHOCO_DEFAULT_PATH
YaccAction = SCons.Action.Action("$YACCCOM", "$YACCCOMSTR")
@@ -97,6 +98,28 @@ def ymEmitter(target, source, env):
def yyEmitter(target, source, env):
return _yaccEmitter(target, source, env, ['.yy'], '$YACCHXXFILESUFFIX')
+def get_yacc_path(env, append_paths=False):
+ """
+ Find the a path containing the lex or flex binaries. If a construction
+ environment is passed in then append the path to the ENV PATH.
+ """
+ # save existing path to reset if we don't want to append any paths
+ envPath = env['ENV']['PATH']
+ bins = ['bison', 'yacc', 'win_bison']
+
+ for prog in bins:
+ bin_path = SCons.Tool.find_program_path(
+ env,
+ prog,
+ default_paths=CHOCO_DEFAULT_PATH + MINGW_DEFAULT_PATHS + CYGWIN_DEFAULT_PATHS )
+ if bin_path:
+ if not append_paths:
+ env['ENV']['PATH'] = envPath
+ else:
+ env.AppendENVPath('PATH', os.path.dirname(bin_path))
+ return bin_path
+ SCons.Warnings.Warning('lex tool requested, but lex or flex binary not found in ENV PATH')
+
def generate(env):
"""Add Builders and construction variables for yacc to an Environment."""
c_file, cxx_file = SCons.Tool.createCFileBuilders(env)
@@ -124,7 +147,12 @@ def generate(env):
else:
SCons.Warnings.Warning('yacc tool requested, but bison binary not found in ENV PATH')
- env['YACC'] = env.Detect('bison') or 'yacc'
+ if sys.platform == 'win32':
+ get_yacc_path(env, append_paths=True)
+ env["YACC"] = env.Detect(['bison', 'yacc', 'win_bison'])
+ else:
+ env["YACC"] = env.Detect(["bison", "yacc"])
+
env['YACCFLAGS'] = SCons.Util.CLVar('')
env['YACCCOM'] = '$YACC $YACCFLAGS -o $TARGET $SOURCES'
env['YACCHFILESUFFIX'] = '.h'
diff --git a/src/engine/SCons/cpp.py b/src/engine/SCons/cpp.py
index cdd3923..a413690 100644
--- a/src/engine/SCons/cpp.py
+++ b/src/engine/SCons/cpp.py
@@ -45,16 +45,16 @@ import re
cpp_lines_dict = {
# Fetch the rest of a #if/#elif as one argument,
# with white space optional.
- ('if', 'elif') : '\s*(.+)',
+ ('if', 'elif') : r'\s*(.+)',
# Fetch the rest of a #ifdef/#ifndef as one argument,
# separated from the keyword by white space.
- ('ifdef', 'ifndef',): '\s+(.+)',
+ ('ifdef', 'ifndef',): r'\s+(.+)',
# Fetch the rest of a #import/#include/#include_next line as one
# argument, with white space optional.
('import', 'include', 'include_next',)
- : '\s*(.+)',
+ : r'\s*(.+)',
# We don't care what comes after a #else or #endif line.
('else', 'endif',) : '',
@@ -64,10 +64,10 @@ cpp_lines_dict = {
# 2) The optional parentheses and arguments (if it's a function-like
# macro, '' if it's not).
# 3) The expansion value.
- ('define',) : '\s+([_A-Za-z][_A-Za-z0-9_]*)(\([^)]*\))?\s*(.*)',
+ ('define',) : r'\s+([_A-Za-z][_A-Za-z0-9_]*)(\([^)]*\))?\s*(.*)',
# Fetch the #undefed keyword from a #undef line.
- ('undef',) : '\s+([_A-Za-z][A-Za-z0-9_]*)',
+ ('undef',) : r'\s+([_A-Za-z][A-Za-z0-9_]*)',
}
# Create a table that maps each individual C preprocessor directive to
@@ -97,7 +97,7 @@ l = [override.get(x, x) for x in list(Table.keys())]
# a list of tuples, one for each preprocessor line. The preprocessor
# directive will be the first element in each tuple, and the rest of
# the line will be the second element.
-e = '^\s*#\s*(' + '|'.join(l) + ')(.*)$'
+e = r'^\s*#\s*(' + '|'.join(l) + ')(.*)$'
# And last but not least, compile the expression.
CPP_Expression = re.compile(e, re.M)
@@ -144,12 +144,12 @@ CPP_to_Python_Ops_Expression = re.compile(expr)
# A separate list of expressions to be evaluated and substituted
# sequentially, not all at once.
CPP_to_Python_Eval_List = [
- ['defined\s+(\w+)', '"\\1" in __dict__'],
- ['defined\s*\((\w+)\)', '"\\1" in __dict__'],
- ['/\*.*\*/', ''],
- ['/\*.*', ''],
- ['//.*', ''],
- ['(0x[0-9A-Fa-f]*)[UL]+', '\\1'],
+ [r'defined\s+(\w+)', '"\\1" in __dict__'],
+ [r'defined\s*\((\w+)\)', '"\\1" in __dict__'],
+ [r'/\*.*\*/', ''],
+ [r'/\*.*', ''],
+ [r'//.*', ''],
+ [r'(0x[0-9A-Fa-f]*)[UL]+', '\\1'],
]
# Replace the string representations of the regular expressions in the
@@ -225,11 +225,11 @@ line_continuations = re.compile('\\\\\r?\n')
# Search for a "function call" macro on an expansion. Returns the
# two-tuple of the "function" name itself, and a string containing the
# arguments within the call parentheses.
-function_name = re.compile('(\S+)\(([^)]*)\)')
+function_name = re.compile(r'(\S+)\(([^)]*)\)')
# Split a string containing comma-separated function call arguments into
# the separate arguments.
-function_arg_separator = re.compile(',\s*')
+function_arg_separator = re.compile(r',\s*')
diff --git a/src/engine/SCons/cppTests.py b/src/engine/SCons/cppTests.py
index ebf7fde..0b346e8 100644
--- a/src/engine/SCons/cppTests.py
+++ b/src/engine/SCons/cppTests.py
@@ -817,7 +817,8 @@ class fileTestCase(unittest.TestCase):
return '\n'.join(map(strip_spaces, lines))
def write(self, file, contents):
- open(file, 'w').write(self.strip_initial_spaces(contents))
+ with open(file, 'w') as f:
+ f.write(self.strip_initial_spaces(contents))
def test_basic(self):
"""Test basic file inclusion"""
diff --git a/src/engine/SCons/dblite.py b/src/engine/SCons/dblite.py
index 628182b..14bd93d 100644
--- a/src/engine/SCons/dblite.py
+++ b/src/engine/SCons/dblite.py
@@ -108,16 +108,19 @@ class dblite(object):
self._chgrp_to = -1 # don't chgrp
if self._flag == "n":
- self._open(self._file_name, "wb", self._mode)
+ with self._open(self._file_name, "wb", self._mode):
+ pass # just make sure it exists
else:
try:
f = self._open(self._file_name, "rb")
except IOError as e:
if self._flag != "c":
raise e
- self._open(self._file_name, "wb", self._mode)
+ with self._open(self._file_name, "wb", self._mode):
+ pass # just make sure it exists
else:
p = f.read()
+ f.close()
if len(p) > 0:
try:
if bytes is not str:
diff --git a/src/script/scons-time.py b/src/script/scons-time.py
index d114f9a..5d0a042 100644
--- a/src/script/scons-time.py
+++ b/src/script/scons-time.py
@@ -814,7 +814,9 @@ class SConsTimer(object):
self.title = a
if self.config_file:
- exec(open(self.config_file, 'r').read(), self.__dict__)
+ with open(self.config_file, 'r') as f:
+ config = f.read()
+ exec(config, self.__dict__)
if self.chdir:
os.chdir(self.chdir)
@@ -933,7 +935,9 @@ class SConsTimer(object):
self.title = a
if self.config_file:
- HACK_for_exec(open(self.config_file, 'r').read(), self.__dict__)
+ with open(self.config_file, 'r') as f:
+ config = f.read()
+ HACK_for_exec(config, self.__dict__)
if self.chdir:
os.chdir(self.chdir)
@@ -1053,7 +1057,9 @@ class SConsTimer(object):
object_name = args.pop(0)
if self.config_file:
- HACK_for_exec(open(self.config_file, 'r').read(), self.__dict__)
+ with open(self.config_file, 'r') as f:
+ config = f.read()
+ HACK_for_exec(config, self.__dict__)
if self.chdir:
os.chdir(self.chdir)
@@ -1191,7 +1197,9 @@ class SConsTimer(object):
sys.exit(1)
if self.config_file:
- exec(open(self.config_file, 'r').read(), self.__dict__)
+ with open(self.config_file, 'r') as f:
+ config = f.read()
+ exec(config, self.__dict__)
if args:
self.archive_list = args