summaryrefslogtreecommitdiffstats
path: root/src/engine
diff options
context:
space:
mode:
authorStefan Zimmermann <zimmermann.code@gmail.com>2014-03-31 15:40:20 (GMT)
committerStefan Zimmermann <zimmermann.code@gmail.com>2014-03-31 15:40:20 (GMT)
commit59ee07b24ed1278d83aa70605f51b6284aa60a82 (patch)
treee44c28ee21a3d4b59d2cab79a529be6a09907881 /src/engine
parent2d2df48b33045bb15b543264114c6ef35773ef29 (diff)
parentcb44210566c28d16c1e2c91d898306ad539fa9f5 (diff)
downloadSCons-59ee07b24ed1278d83aa70605f51b6284aa60a82.zip
SCons-59ee07b24ed1278d83aa70605f51b6284aa60a82.tar.gz
SCons-59ee07b24ed1278d83aa70605f51b6284aa60a82.tar.bz2
Merged with [default]
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/SCons/Action.py14
-rw-r--r--src/engine/SCons/Builder.py7
-rw-r--r--src/engine/SCons/CacheDir.py8
-rw-r--r--src/engine/SCons/Debug.py4
-rw-r--r--src/engine/SCons/Environment.py43
-rw-r--r--src/engine/SCons/EnvironmentTests.py39
-rw-r--r--src/engine/SCons/Executor.py13
-rw-r--r--src/engine/SCons/Node/FS.py152
-rw-r--r--src/engine/SCons/Node/NodeTests.py13
-rw-r--r--src/engine/SCons/Node/__init__.py95
-rw-r--r--src/engine/SCons/Platform/posix.py172
-rw-r--r--src/engine/SCons/SConf.py3
-rw-r--r--src/engine/SCons/SConfTests.py2
-rw-r--r--src/engine/SCons/Script/Main.py36
-rw-r--r--src/engine/SCons/Script/Main.xml21
-rw-r--r--src/engine/SCons/Script/SConsOptions.py47
-rw-r--r--src/engine/SCons/Subst.py14
-rw-r--r--src/engine/SCons/SubstTests.py5
-rw-r--r--src/engine/SCons/Taskmaster.py37
-rw-r--r--src/engine/SCons/TaskmasterTests.py5
-rw-r--r--src/engine/SCons/Tool/MSCommon/common.py8
-rw-r--r--src/engine/SCons/Tool/MSCommon/vc.py17
-rw-r--r--src/engine/SCons/Tool/__init__.py30
-rw-r--r--src/engine/SCons/Tool/docbook/__init__.py197
-rw-r--r--src/engine/SCons/Tool/docbook/__init__.xml34
-rw-r--r--src/engine/SCons/Tool/gs.py30
-rw-r--r--src/engine/SCons/Tool/gs.xml38
-rw-r--r--src/engine/SCons/Tool/msginit.xml4
-rw-r--r--src/engine/SCons/Tool/rpm.py4
-rw-r--r--src/engine/SCons/Tool/zip.xml2
-rw-r--r--src/engine/SCons/Warnings.py3
31 files changed, 749 insertions, 348 deletions
diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py
index 49b9f35..4ca0b1a 100644
--- a/src/engine/SCons/Action.py
+++ b/src/engine/SCons/Action.py
@@ -109,6 +109,7 @@ import re
import sys
import subprocess
+import SCons.Debug
from SCons.Debug import logInstanceCreation
import SCons.Errors
import SCons.Executor
@@ -440,7 +441,8 @@ class ActionBase(object):
vl = self.get_varlist(target, source, env)
if is_String(vl): vl = (vl,)
for v in vl:
- result.append(SCons.Util.to_bytes(env.subst('${'+v+'}')))
+ # do the subst this way to ignore $(...$) parts:
+ result.append(SCons.Util.to_bytes(env.subst_target_source('${'+v+'}', SCons.Subst.SUBST_SIG, target, source)))
return b''.join(result)
def __add__(self, other):
@@ -699,7 +701,7 @@ class CommandAction(_ActionAction):
# factory above does). cmd will be passed to
# Environment.subst_list() for substituting environment
# variables.
- if __debug__: logInstanceCreation(self, 'Action.CommandAction')
+ if SCons.Debug.track_instances: logInstanceCreation(self, 'Action.CommandAction')
_ActionAction.__init__(self, **kw)
if is_List(cmd):
@@ -856,7 +858,7 @@ class CommandAction(_ActionAction):
class CommandGeneratorAction(ActionBase):
"""Class for command-generator actions."""
def __init__(self, generator, kw):
- if __debug__: logInstanceCreation(self, 'Action.CommandGeneratorAction')
+ if SCons.Debug.track_instances: logInstanceCreation(self, 'Action.CommandGeneratorAction')
self.generator = generator
self.gen_kw = kw
self.varlist = kw.get('varlist', ())
@@ -945,7 +947,7 @@ class CommandGeneratorAction(ActionBase):
class LazyAction(CommandGeneratorAction, CommandAction):
def __init__(self, var, kw):
- if __debug__: logInstanceCreation(self, 'Action.LazyAction')
+ if SCons.Debug.track_instances: logInstanceCreation(self, 'Action.LazyAction')
#FUTURE CommandAction.__init__(self, '${'+var+'}', **kw)
CommandAction.__init__(self, '${'+var+'}', **kw)
self.var = SCons.Util.to_String(var)
@@ -987,7 +989,7 @@ class FunctionAction(_ActionAction):
"""Class for Python function actions."""
def __init__(self, execfunction, kw):
- if __debug__: logInstanceCreation(self, 'Action.FunctionAction')
+ if SCons.Debug.track_instances: logInstanceCreation(self, 'Action.FunctionAction')
self.execfunction = execfunction
try:
@@ -1109,7 +1111,7 @@ class FunctionAction(_ActionAction):
class ListAction(ActionBase):
"""Class for lists of other actions."""
def __init__(self, actionlist):
- if __debug__: logInstanceCreation(self, 'Action.ListAction')
+ if SCons.Debug.track_instances: logInstanceCreation(self, 'Action.ListAction')
def list_of_actions(x):
if isinstance(x, ActionBase):
return x
diff --git a/src/engine/SCons/Builder.py b/src/engine/SCons/Builder.py
index 4b41827..db249bf 100644
--- a/src/engine/SCons/Builder.py
+++ b/src/engine/SCons/Builder.py
@@ -102,6 +102,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import collections
import SCons.Action
+import SCons.Debug
from SCons.Debug import logInstanceCreation
from SCons.Errors import InternalError, UserError
import SCons.Executor
@@ -225,7 +226,7 @@ class OverrideWarner(collections.UserDict):
"""
def __init__(self, dict):
collections.UserDict.__init__(self, dict)
- if __debug__: logInstanceCreation(self, 'Builder.OverrideWarner')
+ if SCons.Debug.track_instances: logInstanceCreation(self, 'Builder.OverrideWarner')
self.already_warned = None
def warn(self):
if self.already_warned:
@@ -379,7 +380,7 @@ class BuilderBase(object):
src_builder = None,
ensure_suffix = False,
**overrides):
- if __debug__: logInstanceCreation(self, 'Builder.BuilderBase')
+ if SCons.Debug.track_instances: logInstanceCreation(self, 'Builder.BuilderBase')
self._memo = {}
self.action = action
self.multi = multi
@@ -853,7 +854,7 @@ class CompositeBuilder(SCons.Util.Proxy):
"""
def __init__(self, builder, cmdgen):
- if __debug__: logInstanceCreation(self, 'Builder.CompositeBuilder')
+ if SCons.Debug.track_instances: logInstanceCreation(self, 'Builder.CompositeBuilder')
SCons.Util.Proxy.__init__(self, builder)
# cmdgen should always be an instance of DictCmdGenerator.
diff --git a/src/engine/SCons/CacheDir.py b/src/engine/SCons/CacheDir.py
index 3516018..9dd18e5 100644
--- a/src/engine/SCons/CacheDir.py
+++ b/src/engine/SCons/CacheDir.py
@@ -37,6 +37,7 @@ cache_enabled = True
cache_debug = False
cache_force = False
cache_show = False
+cache_readonly = False
def CacheRetrieveFunc(target, source, env):
t = target[0]
@@ -70,6 +71,8 @@ CacheRetrieve = SCons.Action.Action(CacheRetrieveFunc, CacheRetrieveString)
CacheRetrieveSilent = SCons.Action.Action(CacheRetrieveFunc, None)
def CachePushFunc(target, source, env):
+ if cache_readonly: return
+
t = target[0]
if t.nocache:
return
@@ -150,6 +153,9 @@ class CacheDir(object):
def is_enabled(self):
return (cache_enabled and not self.path is None)
+ def is_readonly(self):
+ return cache_readonly
+
def cachepath(self, node):
"""
"""
@@ -201,7 +207,7 @@ class CacheDir(object):
return False
def push(self, node):
- if not self.is_enabled():
+ if self.is_readonly() or not self.is_enabled():
return
return CachePush(node, [], node.get_build_env())
diff --git a/src/engine/SCons/Debug.py b/src/engine/SCons/Debug.py
index 1c0c638..9974039 100644
--- a/src/engine/SCons/Debug.py
+++ b/src/engine/SCons/Debug.py
@@ -35,6 +35,10 @@ import sys
import time
import weakref
+# Global variable that gets set to 'True' by the Main script,
+# when the creation of class instances should get tracked.
+track_instances = False
+# List of currently tracked classes
tracked_classes = {}
def logInstanceCreation(instance, name=None):
diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py
index 7a369a9..737289b 100644
--- a/src/engine/SCons/Environment.py
+++ b/src/engine/SCons/Environment.py
@@ -43,6 +43,7 @@ from collections import UserDict
import SCons.Action
import SCons.Builder
+import SCons.Debug
from SCons.Debug import logInstanceCreation
import SCons.Defaults
import SCons.Errors
@@ -370,7 +371,7 @@ class SubstitutionEnvironment(object):
def __init__(self, **kw):
"""Initialization of an underlying SubstitutionEnvironment class.
"""
- if __debug__: logInstanceCreation(self, 'Environment.SubstitutionEnvironment')
+ if SCons.Debug.track_instances: logInstanceCreation(self, 'Environment.SubstitutionEnvironment')
self.fs = SCons.Node.FS.get_default_fs()
self.ans = SCons.Node.Alias.default_ans
self.lookup_list = SCons.Node.arg2nodes_lookups
@@ -704,7 +705,7 @@ class SubstitutionEnvironment(object):
# -symbolic (linker global binding)
# -R dir (deprecated linker rpath)
# IBM compilers may also accept -qframeworkdir=foo
-
+
params = shlex.split(arg)
append_next_arg_to = None # for multi-word args
for arg in params:
@@ -794,7 +795,7 @@ class SubstitutionEnvironment(object):
append_next_arg_to = arg
else:
dict['CCFLAGS'].append(arg)
-
+
for arg in flags:
do_parse(arg)
return dict
@@ -858,7 +859,7 @@ class SubstitutionEnvironment(object):
# def MergeShellPaths(self, args, prepend=1):
# """
-# Merge the dict in args into the shell environment in env['ENV'].
+# Merge the dict in args into the shell environment in env['ENV'].
# Shell path elements are appended or prepended according to prepend.
# Uses Pre/AppendENVPath, so it always appends or prepends uniquely.
@@ -931,7 +932,7 @@ class Base(SubstitutionEnvironment):
initialize things in a very specific order that doesn't work
with the much simpler base class initialization.
"""
- if __debug__: logInstanceCreation(self, 'Environment.Base')
+ if SCons.Debug.track_instances: logInstanceCreation(self, 'Environment.Base')
self._memo = {}
self.fs = SCons.Node.FS.get_default_fs()
self.ans = SCons.Node.Alias.default_ans
@@ -961,14 +962,14 @@ class Base(SubstitutionEnvironment):
platform = SCons.Platform.Platform(platform)
self._dict['PLATFORM'] = str(platform)
platform(self)
-
+
self._dict['HOST_OS'] = self._dict.get('HOST_OS',None)
self._dict['HOST_ARCH'] = self._dict.get('HOST_ARCH',None)
-
+
# Now set defaults for TARGET_{OS|ARCH}
self._dict['TARGET_OS'] = self._dict.get('TARGET_OS',None)
self._dict['TARGET_ARCH'] = self._dict.get('TARGET_ARCH',None)
-
+
# Apply the passed-in and customizable variables to the
# environment before calling the tools, because they may use
@@ -1157,7 +1158,7 @@ class Base(SubstitutionEnvironment):
# "continue" statements whenever we finish processing an item,
# but Python 1.5.2 apparently doesn't let you use "continue"
# within try:-except: blocks, so we have to nest our code.
- try:
+ try:
if key == 'CPPDEFINES' and SCons.Util.is_String(self._dict[key]):
self._dict[key] = [self._dict[key]]
orig = self._dict[key]
@@ -1208,7 +1209,7 @@ class Base(SubstitutionEnvironment):
orig = list(orig.items())
orig += val
self._dict[key] = orig
- else:
+ else:
for v in val:
orig[v] = None
else:
@@ -1231,7 +1232,7 @@ class Base(SubstitutionEnvironment):
path = str(self.fs.Dir(path))
return path
- def AppendENVPath(self, name, newpath, envname = 'ENV',
+ def AppendENVPath(self, name, newpath, envname = 'ENV',
sep = os.pathsep, delete_existing=1):
"""Append path elements to the path 'name' in the 'ENV'
dictionary for this environment. Will only add any particular
@@ -1289,7 +1290,7 @@ class Base(SubstitutionEnvironment):
dk = list(dk.items())
elif SCons.Util.is_String(dk):
dk = [(dk,)]
- else:
+ else:
tmp = []
for i in dk:
if SCons.Util.is_List(i):
@@ -1334,7 +1335,7 @@ class Base(SubstitutionEnvironment):
dk = list(filter(lambda x, val=val: x not in val, dk))
self._dict[key] = dk + val
else:
- dk = [x for x in dk if x not in val]
+ dk = [x for x in dk if x not in val]
self._dict[key] = dk + val
else:
# By elimination, val is not a list. Since dk is a
@@ -1381,7 +1382,7 @@ class Base(SubstitutionEnvironment):
builders = self._dict['BUILDERS']
except KeyError:
pass
-
+
clone = copy.copy(self)
# BUILDERS is not safe to do a simple copy
clone._dict = semi_deepcopy_dict(self._dict, ['BUILDERS'])
@@ -1409,12 +1410,12 @@ class Base(SubstitutionEnvironment):
apply_tools(clone, tools, toolpath)
# apply them again in case the tools overwrote them
- clone.Replace(**new)
+ clone.Replace(**new)
# Finally, apply any flags to be merged in
if parse_flags: clone.MergeFlags(parse_flags)
- if __debug__: logInstanceCreation(self, 'Environment.EnvironmentClone')
+ if SCons.Debug.track_instances: logInstanceCreation(self, 'Environment.EnvironmentClone')
return clone
def Copy(self, *args, **kw):
@@ -2086,6 +2087,14 @@ class Base(SubstitutionEnvironment):
t.set_precious()
return tlist
+ def Pseudo(self, *targets):
+ tlist = []
+ for t in targets:
+ tlist.extend(self.arg2nodes(t, self.fs.Entry))
+ for t in tlist:
+ t.set_pseudo()
+ return tlist
+
def Repository(self, *dirs, **kw):
dirs = self.arg2nodes(list(dirs), self.fs.Dir)
self.fs.Repository(*dirs, **kw)
@@ -2270,7 +2279,7 @@ class OverrideEnvironment(Base):
"""
def __init__(self, subject, overrides={}):
- if __debug__: logInstanceCreation(self, 'Environment.OverrideEnvironment')
+ if SCons.Debug.track_instances: logInstanceCreation(self, 'Environment.OverrideEnvironment')
self.__dict__['__subject'] = subject
self.__dict__['overrides'] = overrides
diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py
index 6933b6b..5b4153e 100644
--- a/src/engine/SCons/EnvironmentTests.py
+++ b/src/engine/SCons/EnvironmentTests.py
@@ -171,7 +171,7 @@ class TestEnvironmentFixture(object):
single_source = 1)
kw['BUILDERS'] = {'Object' : static_obj}
static_obj.add_action('.cpp', 'fake action')
-
+
env = Environment(*args, **kw)
return env
@@ -1677,6 +1677,8 @@ def exists(env):
CCC1 = '',
CCC2 = '',
DDD1 = ['a', 'b', 'c'])
+ env['LL1'] = [env.Literal('a literal'), env.Literal('b literal')]
+ env['LL2'] = [env.Literal('c literal'), env.Literal('b literal')]
env.AppendUnique(AAA1 = 'a1',
AAA2 = ['a2'],
AAA3 = ['a3', 'b', 'c', 'c', 'b', 'a3'], # ignore dups
@@ -1689,7 +1691,9 @@ def exists(env):
BBB5 = ['b5.new'],
CCC1 = 'c1',
CCC2 = ['c2'],
- DDD1 = 'b')
+ DDD1 = 'b',
+ LL1 = env.Literal('a literal'),
+ LL2 = env.Literal('a literal'))
assert env['AAA1'] == 'a1a1', env['AAA1']
assert env['AAA2'] == ['a2'], env['AAA2']
@@ -1704,6 +1708,8 @@ def exists(env):
assert env['CCC1'] == 'c1', env['CCC1']
assert env['CCC2'] == ['c2'], env['CCC2']
assert env['DDD1'] == ['a', 'b', 'c'], env['DDD1']
+ assert env['LL1'] == [env.Literal('a literal'), env.Literal('b literal')], env['LL1']
+ assert env['LL2'] == [env.Literal('c literal'), env.Literal('b literal'), env.Literal('a literal')], [str(x) for x in env['LL2']]
env.AppendUnique(DDD1 = 'b', delete_existing=1)
assert env['DDD1'] == ['a', 'c', 'b'], env['DDD1'] # b moves to end
@@ -1711,7 +1717,7 @@ def exists(env):
assert env['DDD1'] == ['c', 'a', 'b'], env['DDD1'] # a & b move to end
env.AppendUnique(DDD1 = ['e','f', 'e'], delete_existing=1)
assert env['DDD1'] == ['c', 'a', 'b', 'f', 'e'], env['DDD1'] # add last
-
+
env['CLVar'] = CLVar([])
env.AppendUnique(CLVar = 'bar')
result = env['CLVar']
@@ -2019,7 +2025,7 @@ def generate(env):
try:
save_command = []
- env.backtick = my_backtick(save_command,
+ env.backtick = my_backtick(save_command,
"-I/usr/include/fum -I bar -X\n" + \
"-L/usr/fax -L foo -lxxx -l yyy " + \
"-Wa,-as -Wl,-link " + \
@@ -2364,7 +2370,7 @@ f5: \
env.PrependUnique(DDD1 = ['a','c'], delete_existing=1)
assert env['DDD1'] == ['a', 'c', 'b'], env['DDD1'] # a & c move to front
env.PrependUnique(DDD1 = ['d','e','d'], delete_existing=1)
- assert env['DDD1'] == ['d', 'e', 'a', 'c', 'b'], env['DDD1']
+ assert env['DDD1'] == ['d', 'e', 'a', 'c', 'b'], env['DDD1']
env['CLVar'] = CLVar([])
@@ -3114,6 +3120,29 @@ def generate(env):
assert t[4].path == 'p_ggg'
assert t[4].precious
+ def test_Pseudo(self):
+ """Test the Pseudo() method"""
+ env = self.TestEnvironment(FOO='ggg', BAR='hhh')
+ env.Dir('p_hhhb')
+ env.File('p_d')
+ t = env.Pseudo('p_a', 'p_${BAR}b', ['p_c', 'p_d'], 'p_$FOO')
+
+ assert t[0].__class__.__name__ == 'Entry', t[0].__class__.__name__
+ assert t[0].path == 'p_a'
+ assert t[0].pseudo
+ assert t[1].__class__.__name__ == 'Dir', t[1].__class__.__name__
+ assert t[1].path == 'p_hhhb'
+ assert t[1].pseudo
+ assert t[2].__class__.__name__ == 'Entry', t[2].__class__.__name__
+ assert t[2].path == 'p_c'
+ assert t[2].pseudo
+ assert t[3].__class__.__name__ == 'File', t[3].__class__.__name__
+ assert t[3].path == 'p_d'
+ assert t[3].pseudo
+ assert t[4].__class__.__name__ == 'Entry', t[4].__class__.__name__
+ assert t[4].path == 'p_ggg'
+ assert t[4].pseudo
+
def test_Repository(self):
"""Test the Repository() method."""
class MyFS(object):
diff --git a/src/engine/SCons/Executor.py b/src/engine/SCons/Executor.py
index 6248cf1..2c53f21 100644
--- a/src/engine/SCons/Executor.py
+++ b/src/engine/SCons/Executor.py
@@ -31,6 +31,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import collections
+import SCons.Debug
from SCons.Debug import logInstanceCreation
import SCons.Errors
import SCons.Memoize
@@ -123,7 +124,7 @@ class Executor(object):
def __init__(self, action, env=None, overridelist=[{}],
targets=[], sources=[], builder_kw={}):
- if __debug__: logInstanceCreation(self, 'Executor.Executor')
+ if SCons.Debug.track_instances: logInstanceCreation(self, 'Executor.Executor')
self.set_action_list(action)
self.pre_actions = []
self.post_actions = []
@@ -229,6 +230,8 @@ class Executor(object):
self.action_list = action
def get_action_list(self):
+ if self.action_list is None:
+ return []
return self.pre_actions + self.action_list + self.post_actions
def get_all_targets(self):
@@ -267,7 +270,8 @@ class Executor(object):
"""
result = SCons.Util.UniqueList([])
for target in self.get_all_targets():
- result.extend(target.prerequisites)
+ if target.prerequisites is not None:
+ result.extend(target.prerequisites)
return result
def get_action_side_effects(self):
@@ -570,12 +574,12 @@ class Null(object):
"""A null Executor, with a null build Environment, that does
nothing when the rest of the methods call it.
- This might be able to disapper when we refactor things to
+ This might be able to disappear when we refactor things to
disassociate Builders from Nodes entirely, so we're not
going to worry about unit tests for this--at least for now.
"""
def __init__(self, *args, **kw):
- if __debug__: logInstanceCreation(self, 'Executor.Null')
+ if SCons.Debug.track_instances: logInstanceCreation(self, 'Executor.Null')
self.batches = [Batch(kw['targets'][:], [])]
def get_build_env(self):
return get_NullEnvironment()
@@ -625,7 +629,6 @@ class Null(object):
self._morph()
self.set_action_list(action)
-
# Local Variables:
# tab-width:4
# indent-tabs-mode:nil
diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py
index 91c6893..2d155ad 100644
--- a/src/engine/SCons/Node/FS.py
+++ b/src/engine/SCons/Node/FS.py
@@ -45,6 +45,7 @@ import time
import codecs
import SCons.Action
+import SCons.Debug
from SCons.Debug import logInstanceCreation
import SCons.Errors
import SCons.Memoize
@@ -582,7 +583,7 @@ class Base(SCons.Node.Node):
our relative and absolute paths, identify our parent
directory, and indicate that this node should use
signatures."""
- if __debug__: logInstanceCreation(self, 'Node.FS.Base')
+ if SCons.Debug.track_instances: logInstanceCreation(self, 'Node.FS.Base')
SCons.Node.Node.__init__(self)
# Filenames and paths are probably reused and are intern'ed to
@@ -1112,7 +1113,7 @@ class FS(LocalFS):
The path argument must be a valid absolute path.
"""
- if __debug__: logInstanceCreation(self, 'Node.FS')
+ if SCons.Debug.track_instances: logInstanceCreation(self, 'Node.FS')
self._memo = {}
@@ -1446,7 +1447,7 @@ class Dir(Base):
BuildInfo = DirBuildInfo
def __init__(self, name, directory, fs):
- if __debug__: logInstanceCreation(self, 'Node.FS.Dir')
+ if SCons.Debug.track_instances: logInstanceCreation(self, 'Node.FS.Dir')
Base.__init__(self, name, directory, fs)
self._morph()
@@ -1842,7 +1843,7 @@ class Dir(Base):
for entry in map(_my_normcase, entries):
d[entry] = True
self.on_disk_entries = d
- if sys.platform == 'win32':
+ if sys.platform == 'win32' or sys.platform == 'cygwin':
name = _my_normcase(name)
result = d.get(name)
if result is None:
@@ -2114,7 +2115,7 @@ class RootDir(Dir):
this directory.
"""
def __init__(self, drive, fs):
- if __debug__: logInstanceCreation(self, 'Node.FS.RootDir')
+ if SCons.Debug.track_instances: logInstanceCreation(self, 'Node.FS.RootDir')
# We're going to be our own parent directory (".." entry and .dir
# attribute) so we have to set up some values so Base.__init__()
# won't gag won't it calls some of our methods.
@@ -2362,7 +2363,7 @@ class File(Base):
"Directory %s found where file expected.")
def __init__(self, name, directory, fs):
- if __debug__: logInstanceCreation(self, 'Node.FS.File')
+ if SCons.Debug.track_instances: logInstanceCreation(self, 'Node.FS.File')
Base.__init__(self, name, directory, fs)
self._morph()
@@ -2398,6 +2399,8 @@ class File(Base):
self.scanner_paths = {}
if not hasattr(self, '_local'):
self._local = 0
+ if not hasattr(self, 'released_target_info'):
+ self.released_target_info = False
# If there was already a Builder set on this entry, then
# we need to make sure we call the target-decider function,
@@ -2725,7 +2728,7 @@ class File(Base):
return self.get_build_env().get_CacheDir().retrieve(self)
def visited(self):
- if self.exists():
+ if self.exists() and self.executor is not None:
self.get_build_env().get_CacheDir().push_if_forced(self)
ninfo = self.get_ninfo()
@@ -2747,6 +2750,58 @@ class File(Base):
self.store_info()
+ def release_target_info(self):
+ """Called just after this node has been marked
+ up-to-date or was built completely.
+
+ This is where we try to release as many target node infos
+ as possible for clean builds and update runs, in order
+ to minimize the overall memory consumption.
+
+ We'd like to remove a lot more attributes like self.sources
+ and self.sources_set, but they might get used
+ in a next build step. For example, during configuration
+ the source files for a built *.o file are used to figure out
+ which linker to use for the resulting Program (gcc vs. g++)!
+ That's why we check for the 'keep_targetinfo' attribute,
+ config Nodes and the Interactive mode just don't allow
+ an early release of most variables.
+
+ In the same manner, we can't simply remove the self.attributes
+ here. The smart linking relies on the shared flag, and some
+ parts of the java Tool use it to transport information
+ about nodes...
+
+ @see: built() and Node.release_target_info()
+ """
+ if (self.released_target_info or SCons.Node.interactive):
+ return
+
+ if not hasattr(self.attributes, 'keep_targetinfo'):
+ # Cache some required values, before releasing
+ # stuff like env, executor and builder...
+ self.changed()
+ self.get_contents_sig()
+ self.get_build_env()
+ # Now purge unneeded stuff to free memory...
+ self.executor = None
+ self._memo.pop('rfile', None)
+ self.prerequisites = None
+ # Cleanup lists, but only if they're empty
+ if not len(self.ignore_set):
+ self.ignore_set = None
+ if not len(self.implicit_set):
+ self.implicit_set = None
+ if not len(self.depends_set):
+ self.depends_set = None
+ if not len(self.ignore):
+ self.ignore = None
+ if not len(self.depends):
+ self.depends = None
+ # Mark this node as done, we only have to release
+ # the memory once...
+ self.released_target_info = True
+
def find_src_builder(self):
if self.rexists():
return None
@@ -2957,6 +3012,48 @@ class File(Base):
SCons.Node.Node.builder_set(self, builder)
self.changed_since_last_build = self.decide_target
+ def built(self):
+ """Called just after this File node is successfully built.
+
+ Just like for 'release_target_info' we try to release
+ some more target node attributes in order to minimize the
+ overall memory consumption.
+
+ @see: release_target_info
+ """
+
+ SCons.Node.Node.built(self)
+
+ if not hasattr(self.attributes, 'keep_targetinfo'):
+ # Ensure that the build infos get computed and cached...
+ self.store_info()
+ # ... then release some more variables.
+ self._specific_sources = False
+ self.labspath = None
+ self._save_str()
+ self.cwd = None
+
+ self.scanner_paths = None
+
+ def changed(self, node=None):
+ """
+ Returns if the node is up-to-date with respect to the BuildInfo
+ stored last time it was built.
+
+ For File nodes this is basically a wrapper around Node.changed(),
+ but we allow the return value to get cached after the reference
+ to the Executor got released in release_target_info().
+ """
+ if node is None:
+ try:
+ return self._memo['changed']
+ except KeyError:
+ pass
+
+ has_changed = SCons.Node.Node.changed(self, node)
+ self._memo['changed'] = has_changed
+ return has_changed
+
def changed_content(self, target, prev_ni):
cur_csig = self.get_csig()
try:
@@ -3090,25 +3187,50 @@ class File(Base):
self.cachedir_csig = self.get_csig()
return self.cachedir_csig
+ def get_contents_sig(self):
+ """
+ A helper method for get_cachedir_bsig.
+
+ It computes and returns the signature for this
+ node's contents.
+ """
+
+ try:
+ return self.contentsig
+ except AttributeError:
+ pass
+
+ executor = self.get_executor()
+
+ result = self.contentsig = SCons.Util.MD5signature(executor.get_contents())
+ return result
+
def get_cachedir_bsig(self):
+ """
+ Return the signature for a cached file, including
+ its children.
+
+ It adds the path of the cached file to the cache signature,
+ because multiple targets built by the same action will all
+ have the same build signature, and we have to differentiate
+ them somehow.
+ """
try:
return self.cachesig
except AttributeError:
pass
-
- # Add the path to the cache signature, because multiple
- # targets built by the same action will all have the same
- # build signature, and we have to differentiate them somehow.
+
+ # Collect signatures for all children
children = self.children()
- executor = self.get_executor()
- # sigs = [n.get_cachedir_csig() for n in children]
sigs = [n.get_cachedir_csig() for n in children]
- sigs.append(SCons.Util.MD5signature(executor.get_contents()))
+ # Append this node's signature...
+ sigs.append(self.get_contents_sig())
+ # ...and it's path
sigs.append(self.path)
+ # Merge this all into a single signature
result = self.cachesig = SCons.Util.MD5collect(sigs)
return result
-
default_fs = None
def get_default_fs():
diff --git a/src/engine/SCons/Node/NodeTests.py b/src/engine/SCons/Node/NodeTests.py
index a301654..076ca65 100644
--- a/src/engine/SCons/Node/NodeTests.py
+++ b/src/engine/SCons/Node/NodeTests.py
@@ -693,6 +693,15 @@ class NodeTestCase(unittest.TestCase):
node.set_precious(7)
assert node.precious == 7
+ def test_set_pseudo(self):
+ """Test setting a Node's pseudo value
+ """
+ node = SCons.Node.Node()
+ node.set_pseudo()
+ assert node.pseudo
+ node.set_pseudo(False)
+ assert not node.pseudo
+
def test_exists(self):
"""Test evaluating whether a Node exists.
"""
@@ -954,7 +963,7 @@ class NodeTestCase(unittest.TestCase):
self.source_scanner = scanner
builder = Builder2(ts1)
-
+
targets = builder([source])
s = targets[0].get_source_scanner(source)
assert s is ts1, s
@@ -967,7 +976,7 @@ class NodeTestCase(unittest.TestCase):
builder = Builder1(env=Environment(SCANNERS = [ts3]))
targets = builder([source])
-
+
s = targets[0].get_source_scanner(source)
assert s is ts3, s
diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py
index 7f5d7ff..9b6ab81 100644
--- a/src/engine/SCons/Node/__init__.py
+++ b/src/engine/SCons/Node/__init__.py
@@ -47,6 +47,7 @@ import collections
import copy
from itertools import chain
+import SCons.Debug
from SCons.Debug import logInstanceCreation
import SCons.Executor
import SCons.Memoize
@@ -57,6 +58,10 @@ from SCons.Debug import Trace
def classname(obj):
return str(obj.__class__).split('.')[-1]
+# Set to false if we're doing a dry run. There's more than one of these
+# little treats
+do_store_info = True
+
# Node states
#
# These are in "priority" order, so that the maximum value for any
@@ -95,6 +100,11 @@ def do_nothing(node): pass
Annotate = do_nothing
+# Gets set to 'True' if we're running in interactive mode. Is
+# currently used to release parts of a target's info during
+# clean builds and update runs (see release_target_info).
+interactive = False
+
# Classes for signature info for Nodes.
class NodeInfoBase(object):
@@ -183,7 +193,7 @@ class Node(object):
pass
def __init__(self):
- if __debug__: logInstanceCreation(self, 'Node.Node')
+ if SCons.Debug.track_instances: logInstanceCreation(self, 'Node.Node')
# Note that we no longer explicitly initialize a self.builder
# attribute to None here. That's because the self.builder
# attribute may be created on-the-fly later by a subclass (the
@@ -204,7 +214,7 @@ class Node(object):
self.depends_set = set()
self.ignore = [] # dependencies to ignore
self.ignore_set = set()
- self.prerequisites = SCons.Util.UniqueList()
+ self.prerequisites = None
self.implicit = None # implicit (scanned) dependencies (None means not scanned yet)
self.waiting_parents = set()
self.waiting_s_e = set()
@@ -214,6 +224,7 @@ class Node(object):
self.env = None
self.state = no_state
self.precious = None
+ self.pseudo = False
self.noclean = 0
self.nocache = 0
self.cached = 0 # is this node pulled from cache?
@@ -286,7 +297,8 @@ class Node(object):
except AttributeError:
pass
else:
- executor.cleanup()
+ if executor is not None:
+ executor.cleanup()
def reset_executor(self):
"Remove cached executor; forces recompute when needed."
@@ -346,10 +358,11 @@ class Node(object):
methods should call this base class method to get the child
check and the BuildInfo structure.
"""
- for d in self.depends:
- if d.missing():
- msg = "Explicit dependency `%s' not found, needed by target `%s'."
- raise SCons.Errors.StopError(msg % (d, self))
+ if self.depends is not None:
+ for d in self.depends:
+ if d.missing():
+ msg = "Explicit dependency `%s' not found, needed by target `%s'."
+ raise SCons.Errors.StopError(msg % (d, self))
if self.implicit is not None:
for i in self.implicit:
if i.missing():
@@ -385,6 +398,13 @@ class Node(object):
self.clear()
+ if self.pseudo:
+ if self.exists():
+ raise SCons.Errors.UserError("Pseudo target " + str(self) + " must not exist")
+ else:
+ if not self.exists() and do_store_info:
+ SCons.Warnings.warn(SCons.Warnings.TargetNotBuiltWarning,
+ "Cannot find target " + str(self) + " after building")
self.ninfo.update(self)
def visited(self):
@@ -400,6 +420,23 @@ class Node(object):
self.ninfo.update(self)
self.store_info()
+ def release_target_info(self):
+ """Called just after this node has been marked
+ up-to-date or was built completely.
+
+ This is where we try to release as many target node infos
+ as possible for clean builds and update runs, in order
+ to minimize the overall memory consumption.
+
+ By purging attributes that aren't needed any longer after
+ a Node (=File) got built, we don't have to care that much how
+ many KBytes a Node actually requires...as long as we free
+ the memory shortly afterwards.
+
+ @see: built() and File.release_target_info()
+ """
+ pass
+
#
#
#
@@ -501,7 +538,7 @@ class Node(object):
def is_derived(self):
"""
- Returns true iff this node is derived (i.e. built).
+ Returns true if this node is derived (i.e. built).
This should return true only for nodes whose path should be in
the variant directory when duplicate=0 and should contribute their build
@@ -788,6 +825,10 @@ class Node(object):
"""Set the Node's precious value."""
self.precious = precious
+ def set_pseudo(self, pseudo = True):
+ """Set the Node's precious value."""
+ self.pseudo = pseudo
+
def set_noclean(self, noclean = 1):
"""Set the Node's noclean value."""
# Make sure noclean is an integer so the --debug=stree
@@ -837,6 +878,8 @@ class Node(object):
def add_prerequisite(self, prerequisite):
"""Adds prerequisites"""
+ if self.prerequisites is None:
+ self.prerequisites = SCons.Util.UniqueList()
self.prerequisites.extend(prerequisite)
self._children_reset()
@@ -924,20 +967,14 @@ class Node(object):
# dictionary patterns I found all ended up using "not in"
# internally anyway...)
if self.ignore_set:
- if self.implicit is None:
- iter = chain(self.sources,self.depends)
- else:
- iter = chain(self.sources, self.depends, self.implicit)
+ iter = chain.from_iterable(filter(None, [self.sources, self.depends, self.implicit]))
children = []
for i in iter:
if i not in self.ignore_set:
children.append(i)
else:
- if self.implicit is None:
- children = self.sources + self.depends
- else:
- children = self.sources + self.depends + self.implicit
+ children = self.all_children(scan=0)
self._memo['children_get'] = children
return children
@@ -964,10 +1001,7 @@ class Node(object):
# using dictionary keys, lose the order, and the only ordered
# dictionary patterns I found all ended up using "not in"
# internally anyway...)
- if self.implicit is None:
- return self.sources + self.depends
- else:
- return self.sources + self.depends + self.implicit
+ return list(chain.from_iterable(filter(None, [self.sources, self.depends, self.implicit])))
def children(self, scan=1):
"""Return a list of the node's direct children, minus those
@@ -1103,17 +1137,18 @@ class Node(object):
Return a text representation, suitable for displaying to the
user, of the include tree for the sources of this node.
"""
- if self.is_derived() and self.env:
+ if self.is_derived():
env = self.get_build_env()
- for s in self.sources:
- scanner = self.get_source_scanner(s)
- if scanner:
- path = self.get_build_scanner_path(scanner)
- else:
- path = None
- def f(node, env=env, scanner=scanner, path=path):
- return node.get_found_includes(env, scanner, path)
- return SCons.Util.render_tree(s, f, 1)
+ if env:
+ for s in self.sources:
+ scanner = self.get_source_scanner(s)
+ if scanner:
+ path = self.get_build_scanner_path(scanner)
+ else:
+ path = None
+ def f(node, env=env, scanner=scanner, path=path):
+ return node.get_found_includes(env, scanner, path)
+ return SCons.Util.render_tree(s, f, 1)
else:
return None
diff --git a/src/engine/SCons/Platform/posix.py b/src/engine/SCons/Platform/posix.py
index 908be4d..2e21e5a 100644
--- a/src/engine/SCons/Platform/posix.py
+++ b/src/engine/SCons/Platform/posix.py
@@ -58,176 +58,32 @@ def escape(arg):
return '"' + arg + '"'
-def exec_system(l, env):
- stat = os.system(' '.join(l))
- if stat & 0xff:
- return stat | 0x80
- return stat >> 8
+def exec_subprocess(l, env):
+ proc = subprocess.Popen(l, env = env, close_fds = True)
+ return proc.wait()
-def exec_spawnvpe(l, env):
- stat = os.spawnvpe(os.P_WAIT, l[0], l, env)
- # os.spawnvpe() returns the actual exit code, not the encoding
- # returned by os.waitpid() or os.system().
- return stat
-
-def exec_fork(l, env):
- pid = os.fork()
- if not pid:
- # Child process.
- exitval = 127
- try:
- os.execvpe(l[0], l, env)
- except OSError as e:
- exitval = exitvalmap.get(e[0], e[0])
- sys.stderr.write("scons: %s: %s\n" % (l[0], e[1]))
- os._exit(exitval)
- else:
- # Parent process.
- pid, stat = os.waitpid(pid, 0)
- if stat & 0xff:
- return stat | 0x80
- return stat >> 8
-
-def _get_env_command(sh, escape, cmd, args, env):
- s = ' '.join(args)
- if env:
- l = ['env', '-'] + \
- [escape(t[0])+'='+escape(t[1]) for t in env.items()] + \
- [sh, '-c', escape(s)]
- s = ' '.join(l)
- return s
-
-def env_spawn(sh, escape, cmd, args, env):
- return exec_system([_get_env_command( sh, escape, cmd, args, env)], env)
-
-def spawnvpe_spawn(sh, escape, cmd, args, env):
- return exec_spawnvpe([sh, '-c', ' '.join(args)], env)
-
-def fork_spawn(sh, escape, cmd, args, env):
- return exec_fork([sh, '-c', ' '.join(args)], env)
-
-def process_cmd_output(cmd_stdout, cmd_stderr, stdout, stderr):
- stdout_eof = stderr_eof = 0
- while not (stdout_eof and stderr_eof):
- try:
- (i,o,e) = select.select([cmd_stdout, cmd_stderr], [], [])
- if cmd_stdout in i:
- str = cmd_stdout.read()
- if len(str) == 0:
- stdout_eof = 1
- elif stdout is not None:
- stdout.write(str)
- if cmd_stderr in i:
- str = cmd_stderr.read()
- if len(str) == 0:
- #sys.__stderr__.write( "stderr_eof=1\n" )
- stderr_eof = 1
- else:
- #sys.__stderr__.write( "str(stderr) = %s\n" % str )
- stderr.write(str)
- except select.error as xxx_todo_changeme:
- (_errno, _strerror) = xxx_todo_changeme.args
- if _errno != errno.EINTR:
- raise
+def subprocess_spawn(sh, escape, cmd, args, env):
+ return exec_subprocess([sh, '-c', ' '.join(args)], env)
def exec_popen3(l, env, stdout, stderr):
- proc = subprocess.Popen(' '.join(l),
- stdout=stdout,
- stderr=stderr,
- shell=True)
- stat = proc.wait()
- if stat & 0xff:
- return stat | 0x80
- return stat >> 8
-
-def exec_piped_fork(l, env, stdout, stderr):
- # spawn using fork / exec and providing a pipe for the command's
- # stdout / stderr stream
- if stdout != stderr:
- (rFdOut, wFdOut) = os.pipe()
- (rFdErr, wFdErr) = os.pipe()
- else:
- (rFdOut, wFdOut) = os.pipe()
- rFdErr = rFdOut
- wFdErr = wFdOut
- # do the fork
- pid = os.fork()
- if not pid:
- # Child process
- os.close( rFdOut )
- if rFdOut != rFdErr:
- os.close( rFdErr )
- os.dup2( wFdOut, 1 ) # is there some symbolic way to do that ?
- os.dup2( wFdErr, 2 )
- os.close( wFdOut )
- if stdout != stderr:
- os.close( wFdErr )
- exitval = 127
- try:
- os.execvpe(l[0], l, env)
- except OSError as e:
- exitval = exitvalmap.get(e[0], e[0])
- stderr.write("scons: %s: %s\n" % (l[0], e[1]))
- os._exit(exitval)
- else:
- # Parent process
- pid, stat = os.waitpid(pid, 0)
- os.close( wFdOut )
- if stdout != stderr:
- os.close( wFdErr )
- childOut = os.fdopen( rFdOut )
- if stdout != stderr:
- childErr = os.fdopen( rFdErr )
- else:
- childErr = childOut
- process_cmd_output(childOut, childErr, stdout, stderr)
- os.close( rFdOut )
- if stdout != stderr:
- os.close( rFdErr )
- if stat & 0xff:
- return stat | 0x80
- return stat >> 8
+ proc = subprocess.Popen(l, env = env, close_fds = True,
+ stdout = stdout,
+ stderr = stderr)
+ return proc.wait()
def piped_env_spawn(sh, escape, cmd, args, env, stdout, stderr):
# spawn using Popen3 combined with the env command
# the command name and the command's stdout is written to stdout
# the command's stderr is written to stderr
- return exec_popen3([_get_env_command(sh, escape, cmd, args, env)],
+ return exec_popen3([sh, '-c', ' '.join(args)],
env, stdout, stderr)
-def piped_fork_spawn(sh, escape, cmd, args, env, stdout, stderr):
- # spawn using fork / exec and providing a pipe for the command's
- # stdout / stderr stream
- return exec_piped_fork([sh, '-c', ' '.join(args)],
- env, stdout, stderr)
-
-
def generate(env):
- # If os.spawnvpe() exists, we use it to spawn commands. Otherwise
- # if the env utility exists, we use os.system() to spawn commands,
- # finally we fall back on os.fork()/os.exec().
- #
- # os.spawnvpe() is prefered because it is the most efficient. But
- # for Python versions without it, os.system() is prefered because it
- # is claimed that it works better with threads (i.e. -j) and is more
- # efficient than forking Python.
- #
- # NB: Other people on the scons-users mailing list have claimed that
- # os.fork()/os.exec() works better than os.system(). There may just
- # not be a default that works best for all users.
-
- if 'spawnvpe' in os.__dict__:
- spawn = spawnvpe_spawn
- elif env.Detect('env'):
- spawn = env_spawn
- else:
- spawn = fork_spawn
-
- if env.Detect('env'):
- pspawn = piped_env_spawn
- else:
- pspawn = piped_fork_spawn
+ # Bearing in mind we have python 2.4 as a baseline, we can just do this:
+ spawn = subprocess_spawn
+ pspawn = piped_env_spawn
+ # Note that this means that 'escape' is no longer used
if 'ENV' not in env:
env['ENV'] = {}
diff --git a/src/engine/SCons/SConf.py b/src/engine/SCons/SConf.py
index 62f2671..be0b9c1 100644
--- a/src/engine/SCons/SConf.py
+++ b/src/engine/SCons/SConf.py
@@ -484,6 +484,9 @@ class SConfBase(object):
# so we really control how it gets written.
for n in nodes:
n.store_info = n.do_not_store_info
+ if not hasattr(n, 'attributes'):
+ n.attributes = SCons.Node.Node.Attrs()
+ n.attributes.keep_targetinfo = 1
ret = 1
diff --git a/src/engine/SCons/SConfTests.py b/src/engine/SCons/SConfTests.py
index ba524fd..5ce4f0a 100644
--- a/src/engine/SCons/SConfTests.py
+++ b/src/engine/SCons/SConfTests.py
@@ -182,7 +182,7 @@ class SConfTestCase(unittest.TestCase):
self.waiting_parents = set()
self.side_effects = []
self.builder = None
- self.prerequisites = []
+ self.prerequisites = None
def disambiguate(self):
return self
def has_builder(self):
diff --git a/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py
index 584960b..7906488 100644
--- a/src/engine/SCons/Script/Main.py
+++ b/src/engine/SCons/Script/Main.py
@@ -81,7 +81,12 @@ def fetch_win32_parallel_msg():
import SCons.Platform.win32
return SCons.Platform.win32.parallel_msg
-#
+def revert_io():
+ # This call is added to revert stderr and stdout to the original
+ # ones just in case some build rule or something else in the system
+ # has redirected them elsewhere.
+ sys.stderr = sys.__stderr__
+ sys.stdout = sys.__stdout__
class SConsPrintHelpException(Exception):
pass
@@ -274,6 +279,9 @@ class BuildTask(SCons.Taskmaster.OutOfDateTask):
(EnvironmentError, SCons.Errors.StopError,
SCons.Errors.UserError))):
type, value, trace = buildError.exc_info
+ if tb and print_stacktrace:
+ sys.stderr.write("scons: internal stack trace:\n")
+ traceback.print_tb(tb, file=sys.stderr)
traceback.print_exception(type, value, trace)
elif tb and print_stacktrace:
sys.stderr.write("scons: internal stack trace:\n")
@@ -624,7 +632,7 @@ def _set_debug_values(options):
debug_values = options.debug
if "count" in debug_values:
- # All of the object counts are within "if __debug__:" blocks,
+ # All of the object counts are within "if track_instances:" blocks,
# which get stripped when running optimized (with python -O or
# from compiled *.pyo files). Provide a warning if __debug__ is
# stripped, so it doesn't just look like --debug=count is broken.
@@ -632,6 +640,7 @@ def _set_debug_values(options):
if __debug__: enable_count = True
if enable_count:
count_stats.enable(sys.stdout)
+ SCons.Debug.track_instances = True
else:
msg = "--debug=count is not supported when running SCons\n" + \
"\twith the python -O option or optimized (.pyo) modules."
@@ -646,6 +655,8 @@ def _set_debug_values(options):
if "memory" in debug_values:
memory_stats.enable(sys.stdout)
print_objects = ("objects" in debug_values)
+ if print_objects:
+ SCons.Debug.track_instances = True
if "presub" in debug_values:
SCons.Action.print_actions_presub = 1
if "stacktrace" in debug_values:
@@ -985,9 +996,9 @@ def _main(parser):
# reading SConscript files and haven't started building
# things yet, stop regardless of whether they used -i or -k
# or anything else.
+ revert_io()
sys.stderr.write("scons: *** %s Stop.\n" % e)
- exit_status = 2
- sys.exit(exit_status)
+ sys.exit(2)
global sconscript_time
sconscript_time = time.time() - start_time
@@ -1065,6 +1076,7 @@ def _main(parser):
platform = SCons.Platform.platform_module()
if options.interactive:
+ SCons.Node.interactive = True
SCons.Script.Interactive.interact(fs, OptionsParser, options,
targets, target_top)
@@ -1073,6 +1085,8 @@ def _main(parser):
# Build the targets
nodes = _build_targets(fs, options, targets, target_top)
if not nodes:
+ revert_io()
+ print('Found nothing to build')
exit_status = 2
def _build_targets(fs, options, targets, target_top):
@@ -1085,12 +1099,14 @@ def _build_targets(fs, options, targets, target_top):
SCons.Action.print_actions = not options.silent
SCons.Action.execute_actions = not options.no_exec
SCons.Node.FS.do_store_info = not options.no_exec
+ SCons.Node.do_store_info = not options.no_exec
SCons.SConf.dryrun = options.no_exec
if options.diskcheck:
SCons.Node.FS.set_diskcheck(options.diskcheck)
SCons.CacheDir.cache_enabled = not options.cache_disable
+ SCons.CacheDir.cache_readonly = options.cache_readonly
SCons.CacheDir.cache_debug = options.cache_debug
SCons.CacheDir.cache_force = options.cache_force
SCons.CacheDir.cache_show = options.cache_show
@@ -1300,12 +1316,8 @@ def _exec_main(parser, values):
prof = Profile()
try:
prof.runcall(_main, parser)
- except SConsPrintHelpException as e:
+ finally:
prof.dump_stats(options.profile_file)
- raise e
- except SystemExit:
- pass
- prof.dump_stats(options.profile_file)
else:
_main(parser)
@@ -1343,7 +1355,10 @@ def main():
OptionsParser = parser
try:
- _exec_main(parser, values)
+ try:
+ _exec_main(parser, values)
+ finally:
+ revert_io()
except SystemExit as s:
if s:
exit_status = s
@@ -1360,6 +1375,7 @@ def main():
parser.print_help()
exit_status = 0
except SCons.Errors.BuildError as e:
+ print(e)
exit_status = e.exitstatus
except:
# An exception here is likely a builtin Python exception Python
diff --git a/src/engine/SCons/Script/Main.xml b/src/engine/SCons/Script/Main.xml
index b582e0d..147e778 100644
--- a/src/engine/SCons/Script/Main.xml
+++ b/src/engine/SCons/Script/Main.xml
@@ -685,6 +685,25 @@ Multiple targets can be passed in to a single call to
</summary>
</scons_function>
+<scons_function name="Pseudo">
+<arguments>
+(target, ...)
+</arguments>
+<summary>
+<para>
+This indicates that each given
+<varname>target</varname>
+should not be created by the build rule, and if the target is created,
+an error will be generated. This is similar to the gnu make .PHONY
+target. However, in the vast majority of cases, an
+&f-Alias;
+is more appropriate.
+
+Multiple targets can be passed in to a single call to
+&f-Pseudo;.
+</para>
+</summary>
+</scons_function>
<scons_function name="SetOption">
<arguments>
(name, value)
@@ -788,4 +807,4 @@ SetOption('max_drift', 1)
</summary>
</scons_function>
-</sconsdoc> \ No newline at end of file
+</sconsdoc>
diff --git a/src/engine/SCons/Script/SConsOptions.py b/src/engine/SCons/Script/SConsOptions.py
index a97fc94..3602663 100644
--- a/src/engine/SCons/Script/SConsOptions.py
+++ b/src/engine/SCons/Script/SConsOptions.py
@@ -248,7 +248,7 @@ class SConsOption(optparse.Option):
class SConsOptionGroup(optparse.OptionGroup):
"""
A subclass for SCons-specific option groups.
-
+
The only difference between this and the base class is that we print
the group's help text flush left, underneath their own title but
lined up with the normal "SCons Options".
@@ -340,7 +340,7 @@ class SConsOptionParser(optparse.OptionParser):
def add_local_option(self, *args, **kw):
"""
Adds a local option to the parser.
-
+
This is initiated by a SetOption() call to add a user-defined
command-line option. We add the option to a separate option
group for the local options, creating the group if necessary.
@@ -394,11 +394,11 @@ class SConsIndentedHelpFormatter(optparse.IndentedHelpFormatter):
out liking:
-- add our own regular expression that doesn't break on hyphens
- (so things like --no-print-directory don't get broken);
+ (so things like --no-print-directory don't get broken);
-- wrap the list of options themselves when it's too long
(the wrapper.fill(opts) call below);
-
+
-- set the subsequent_indent when wrapping the help_text.
"""
# The help for each option consists of two parts:
@@ -564,6 +564,11 @@ def Parser(version):
action="store_true",
help="Copy already-built targets into the CacheDir.")
+ op.add_option('--cache-readonly',
+ dest='cache_readonly', default=False,
+ action="store_true",
+ help="Do not update CacheDir with built targets.")
+
op.add_option('--cache-show',
dest='cache_show', default=False,
action="store_true",
@@ -579,8 +584,10 @@ def Parser(version):
if not value in c_options:
raise OptionValueError(opt_invalid('config', value, c_options))
setattr(parser.values, option.dest, value)
+
opt_config_help = "Controls Configure subsystem: %s." \
% ", ".join(config_options)
+
op.add_option('--config',
nargs=1, type="string",
dest="config", default="auto",
@@ -606,23 +613,25 @@ def Parser(version):
"pdb", "prepare", "presub", "stacktrace",
"time"]
- def opt_debug(option, opt, value, parser,
+ def opt_debug(option, opt, value__, parser,
debug_options=debug_options,
deprecated_debug_options=deprecated_debug_options):
- if value in debug_options:
- parser.values.debug.append(value)
- elif value in deprecated_debug_options.keys():
- parser.values.debug.append(value)
- try:
- parser.values.delayed_warnings
- except AttributeError:
- parser.values.delayed_warnings = []
- msg = deprecated_debug_options[value]
- w = "The --debug=%s option is deprecated%s." % (value, msg)
- t = (SCons.Warnings.DeprecatedDebugOptionsWarning, w)
- parser.values.delayed_warnings.append(t)
- else:
- raise OptionValueError(opt_invalid('debug', value, debug_options))
+ for value in value__.split(','):
+ if value in debug_options:
+ parser.values.debug.append(value)
+ elif value in deprecated_debug_options.keys():
+ parser.values.debug.append(value)
+ try:
+ parser.values.delayed_warnings
+ except AttributeError:
+ parser.values.delayed_warnings = []
+ msg = deprecated_debug_options[value]
+ w = "The --debug=%s option is deprecated%s." % (value, msg)
+ t = (SCons.Warnings.DeprecatedDebugOptionsWarning, w)
+ parser.values.delayed_warnings.append(t)
+ else:
+ raise OptionValueError(opt_invalid('debug', value, debug_options))
+
opt_debug_help = "Print various types of debugging information: %s." \
% ", ".join(debug_options)
op.add_option('--debug',
diff --git a/src/engine/SCons/Subst.py b/src/engine/SCons/Subst.py
index f1e80ac..43f2e1f 100644
--- a/src/engine/SCons/Subst.py
+++ b/src/engine/SCons/Subst.py
@@ -78,6 +78,14 @@ class Literal(object):
def is_literal(self):
return 1
+ def __eq__(self, other):
+ if not isinstance(other, Literal):
+ return False
+ return self.lstr == other.lstr
+
+ def __neq__(self, other):
+ return not self.__eq__(other)
+
class SpecialAttrWrapper(object):
"""This is a wrapper for what we call a 'Node special attribute.'
This is any of the attributes of a Node that we can reference from
@@ -172,7 +180,7 @@ class NLWrapper(object):
In practice, this might be a wash performance-wise, but it's a little
cleaner conceptually...
"""
-
+
def __init__(self, list, func):
self.list = list
self.func = func
@@ -190,7 +198,7 @@ class NLWrapper(object):
self._create_nodelist = self._return_nodelist
return self.nodelist
_create_nodelist = _gen_nodelist
-
+
class Targets_or_Sources(collections.UserList):
"""A class that implements $TARGETS or $SOURCES expansions by in turn
@@ -451,7 +459,7 @@ def scons_subst(strSubst, env, mode=SUBST_RAW, target=None, source=None, gvars={
raise_exception(NameError(key), lvars['TARGETS'], s)
else:
return ''
-
+
# Before re-expanding the result, handle
# recursive expansion by copying the local
# variable dictionary and overwriting a null
diff --git a/src/engine/SCons/SubstTests.py b/src/engine/SCons/SubstTests.py
index 7001899..0540583 100644
--- a/src/engine/SCons/SubstTests.py
+++ b/src/engine/SCons/SubstTests.py
@@ -1148,6 +1148,11 @@ class LiteralTestCase(unittest.TestCase):
cmd_list = escape_list(cmd_list[0], escape_func)
assert cmd_list == ['BAZ', '**$BAR**'], cmd_list
+ def test_LiteralEqualsTest(self):
+ """Test that Literals compare for equality properly"""
+ assert Literal('a literal') == Literal('a literal')
+ assert Literal('a literal') != Literal('b literal')
+
class SpecialAttrWrapperTestCase(unittest.TestCase):
def test_SpecialAttrWrapper(self):
"""Test the SpecialAttrWrapper() function."""
diff --git a/src/engine/SCons/Taskmaster.py b/src/engine/SCons/Taskmaster.py
index 86bff53..00147b2 100644
--- a/src/engine/SCons/Taskmaster.py
+++ b/src/engine/SCons/Taskmaster.py
@@ -187,6 +187,8 @@ class Task(object):
# or implicit dependencies exists, and also initialize the
# .sconsign info.
executor = self.targets[0].get_executor()
+ if executor is None:
+ return
executor.prepare()
for t in executor.get_action_targets():
if print_prepare:
@@ -290,6 +292,7 @@ class Task(object):
post-visit actions that must take place regardless of whether
or not the target was an actual built target or a source Node.
"""
+ global print_prepare
T = self.tm.trace
if T: T.write(self.trace_message('Task.executed_with_callbacks()',
self.node))
@@ -302,7 +305,12 @@ class Task(object):
if not t.cached:
t.push_to_cache()
t.built()
- t.visited()
+ t.visited()
+ if (not print_prepare and
+ (not hasattr(self, 'options') or not self.options.debug_includes)):
+ t.release_target_info()
+ else:
+ t.visited()
executed = executed_with_callbacks
@@ -383,6 +391,7 @@ class Task(object):
This is the default behavior for building only what's necessary.
"""
+ global print_prepare
T = self.tm.trace
if T: T.write(self.trace_message(u'Task.make_ready_current()',
self.node))
@@ -415,6 +424,9 @@ class Task(object):
# parallel build...)
t.visited()
t.set_state(NODE_UP_TO_DATE)
+ if (not print_prepare and
+ (not hasattr(self, 'options') or not self.options.debug_includes)):
+ t.release_target_info()
make_ready = make_ready_current
@@ -454,14 +466,15 @@ class Task(object):
parents[p] = parents.get(p, 0) + 1
for t in targets:
- for s in t.side_effects:
- if s.get_state() == NODE_EXECUTING:
- s.set_state(NODE_NO_STATE)
- for p in s.waiting_parents:
- parents[p] = parents.get(p, 0) + 1
- for p in s.waiting_s_e:
- if p.ref_count == 0:
- self.tm.candidates.append(p)
+ if t.side_effects is not None:
+ for s in t.side_effects:
+ if s.get_state() == NODE_EXECUTING:
+ s.set_state(NODE_NO_STATE)
+ for p in s.waiting_parents:
+ parents[p] = parents.get(p, 0) + 1
+ for p in s.waiting_s_e:
+ if p.ref_count == 0:
+ self.tm.candidates.append(p)
for p, subtract in parents.items():
p.ref_count = p.ref_count - subtract
@@ -924,7 +937,11 @@ class Taskmaster(object):
if node is None:
return None
- tlist = node.get_executor().get_all_targets()
+ executor = node.get_executor()
+ if executor is None:
+ return None
+
+ tlist = executor.get_all_targets()
task = self.tasker(self, tlist, node in self.original_top, node)
try:
diff --git a/src/engine/SCons/TaskmasterTests.py b/src/engine/SCons/TaskmasterTests.py
index 278b690..d1264f3 100644
--- a/src/engine/SCons/TaskmasterTests.py
+++ b/src/engine/SCons/TaskmasterTests.py
@@ -49,7 +49,7 @@ class Node(object):
self.scanned = 0
self.scanner = None
self.targets = [self]
- self.prerequisites = []
+ self.prerequisites = None
class Builder(object):
def targets(self, node):
return node.targets
@@ -141,6 +141,9 @@ class Node(object):
self.clear()
+ def release_target_info(self):
+ pass
+
def has_builder(self):
return not self.builder is None
diff --git a/src/engine/SCons/Tool/MSCommon/common.py b/src/engine/SCons/Tool/MSCommon/common.py
index e1b4820..e5c78e9 100644
--- a/src/engine/SCons/Tool/MSCommon/common.py
+++ b/src/engine/SCons/Tool/MSCommon/common.py
@@ -147,9 +147,11 @@ def get_output(vcbat, args = None, env = None):
# settings in vs.py.
vars = [
'COMSPEC',
-# Still set, but setup script will discard these if registry has values.
-# 'VS110COMNTOOLS',
-# 'VS100COMNTOOLS',
+# VS100 and VS110: Still set, but modern MSVC setup scripts will
+# discard these if registry has values. However Intel compiler setup
+# script still requires these as of 2013/2014.
+ 'VS110COMNTOOLS',
+ 'VS100COMNTOOLS',
'VS90COMNTOOLS',
'VS80COMNTOOLS',
'VS71COMNTOOLS',
diff --git a/src/engine/SCons/Tool/MSCommon/vc.py b/src/engine/SCons/Tool/MSCommon/vc.py
index 1a221ac..8f07569 100644
--- a/src/engine/SCons/Tool/MSCommon/vc.py
+++ b/src/engine/SCons/Tool/MSCommon/vc.py
@@ -258,15 +258,16 @@ def find_batch_file(env,msvc_version,host_arch,target_arch):
installed_sdks=get_installed_sdks()
for _sdk in installed_sdks:
- sdk_bat_file=_sdk.get_sdk_vc_script(host_arch,target_arch)
- sdk_bat_file_path=os.path.join(pdir,sdk_bat_file)
- debug('vc.py:find_batch_file() sdk_bat_file_path:%s'%sdk_bat_file_path)
- if os.path.exists(sdk_bat_file_path):
- return (batfilename,sdk_bat_file_path)
+ sdk_bat_file = _sdk.get_sdk_vc_script(host_arch,target_arch)
+ if not sdk_bat_file:
+ debug("vc.py:find_batch_file() not found:%s"%_sdk)
else:
- debug("vc.py:find_batch_file() not found:%s"%sdk_bat_file_path)
- else:
- return (batfilename,None)
+ sdk_bat_file_path = os.path.join(pdir,sdk_bat_file)
+ if os.path.exists(sdk_bat_file_path):
+ debug('vc.py:find_batch_file() sdk_bat_file_path:%s'%sdk_bat_file_path)
+ return (batfilename,sdk_bat_file_path)
+ return (batfilename,None)
+
__INSTALLED_VCS_RUN = None
diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py
index 517b987..d30159d 100644
--- a/src/engine/SCons/Tool/__init__.py
+++ b/src/engine/SCons/Tool/__init__.py
@@ -258,6 +258,10 @@ def VersionShLibLinkNames(version, libname, env):
print("VersionShLibLinkNames: linkname = ",linkname)
linknames.append(linkname)
elif platform == 'posix':
+ if sys.platform.startswith('openbsd'):
+ # OpenBSD uses x.y shared library versioning numbering convention
+ # and doesn't use symlinks to backwards-compatible libraries
+ return []
# For libfoo.so.x.y.z, linknames libfoo.so libfoo.so.x.y libfoo.so.x
suffix_re = re.escape(shlib_suffix + '.' + version)
# First linkname has no version number
@@ -303,13 +307,17 @@ symlinks for the platform we are on"""
if version:
# set the shared library link flags
if platform == 'posix':
- suffix_re = re.escape(shlib_suffix + '.' + version)
- (major, age, revision) = version.split(".")
- # soname will have only the major version number in it
- soname = re.sub(suffix_re, shlib_suffix, libname) + '.' + major
- shlink_flags += [ '-Wl,-Bsymbolic', '-Wl,-soname=%s' % soname ]
- if Verbose:
- print(" soname ",soname,", shlink_flags ",shlink_flags)
+ shlink_flags += [ '-Wl,-Bsymbolic' ]
+ # OpenBSD doesn't usually use SONAME for libraries
+ if not sys.platform.startswith('openbsd'):
+ # continue setup of shlink flags for all other POSIX systems
+ suffix_re = re.escape(shlib_suffix + '.' + version)
+ (major, age, revision) = version.split(".")
+ # soname will have only the major version number in it
+ soname = re.sub(suffix_re, shlib_suffix, libname) + '.' + major
+ shlink_flags += [ '-Wl,-soname=%s' % soname ]
+ if Verbose:
+ print(" soname ",soname,", shlink_flags ",shlink_flags)
elif platform == 'cygwin':
shlink_flags += [ '-Wl,-Bsymbolic',
'-Wl,--out-implib,${TARGET.base}.a' ]
@@ -357,7 +365,13 @@ symlinks for the platform we are on"""
print("VerShLib: made sym link of %s -> %s" % (linkname, lib_ver))
return result
-ShLibAction = SCons.Action.Action(VersionedSharedLibrary, None)
+# Fix http://scons.tigris.org/issues/show_bug.cgi?id=2903 :
+# Ensure we still depend on SCons.Defaults.ShLinkAction command line which is $SHLINKCOM.
+# This was tricky because we don't want changing LIBPATH to cause a rebuild, but
+# changing other link args should. LIBPATH has $( ... $) around it but until this
+# fix, when the varlist was added to the build sig those ignored parts weren't getting
+# ignored.
+ShLibAction = SCons.Action.Action(VersionedSharedLibrary, None, varlist=['SHLINKCOM'])
def createSharedLibBuilder(env):
"""This is a utility function that creates the SharedLibrary
diff --git a/src/engine/SCons/Tool/docbook/__init__.py b/src/engine/SCons/Tool/docbook/__init__.py
index d6713c6..72ea175 100644
--- a/src/engine/SCons/Tool/docbook/__init__.py
+++ b/src/engine/SCons/Tool/docbook/__init__.py
@@ -260,6 +260,34 @@ def __xml_scan(node, env, path, arg):
docbook_xml_scanner = SCons.Script.Scanner(function = __xml_scan,
argument = None)
+
+#
+# Action generators
+#
+def __generate_xsltproc_action(source, target, env, for_signature):
+ cmd = env['DOCBOOK_XSLTPROCCOM']
+ # Does the environment have a base_dir defined?
+ base_dir = env.subst('$base_dir')
+ if base_dir:
+ # Yes, so replace target path by its filename
+ return cmd.replace('$TARGET','${TARGET.file}')
+ return cmd
+
+
+#
+# Emitters
+#
+def __emit_xsl_basedir(target, source, env):
+ # Does the environment have a base_dir defined?
+ base_dir = env.subst('$base_dir')
+ if base_dir:
+ # Yes, so prepend it to each target
+ return [os.path.join(base_dir, str(t)) for t in target], source
+
+ # No, so simply pass target and source names through
+ return target, source
+
+
#
# Builders
#
@@ -290,9 +318,14 @@ def __build_lxml(target, source, env):
"""
from lxml import etree
+ xslt_ac = etree.XSLTAccessControl(read_file=True,
+ write_file=True,
+ create_dir=True,
+ read_network=False,
+ write_network=False)
xsl_style = env.subst('$DOCBOOK_XSL')
xsl_tree = etree.parse(xsl_style)
- transform = etree.XSLT(xsl_tree)
+ transform = etree.XSLT(xsl_tree, access_control=xslt_ac)
doc = etree.parse(str(source[0]))
# Support for additional parameters
parampass = {}
@@ -340,11 +373,13 @@ def __xinclude_lxml(target, source, env):
__libxml2_builder = SCons.Builder.Builder(
action = __build_libxml2,
src_suffix = '.xml',
- source_scanner = docbook_xml_scanner)
+ source_scanner = docbook_xml_scanner,
+ emitter = __emit_xsl_basedir)
__lxml_builder = SCons.Builder.Builder(
action = __build_lxml,
src_suffix = '.xml',
- source_scanner = docbook_xml_scanner)
+ source_scanner = docbook_xml_scanner,
+ emitter = __emit_xsl_basedir)
__xinclude_libxml2_builder = SCons.Builder.Builder(
action = __xinclude_libxml2,
@@ -358,9 +393,11 @@ __xinclude_lxml_builder = SCons.Builder.Builder(
source_scanner = docbook_xml_scanner)
__xsltproc_builder = SCons.Builder.Builder(
- action = SCons.Action.Action('$DOCBOOK_XSLTPROCCOM','$DOCBOOK_XSLTPROCCOMSTR'),
+ action = SCons.Action.CommandGeneratorAction(__generate_xsltproc_action,
+ {'cmdstr' : '$DOCBOOK_XSLTPROCCOMSTR'}),
src_suffix = '.xml',
- source_scanner = docbook_xml_scanner)
+ source_scanner = docbook_xml_scanner,
+ emitter = __emit_xsl_basedir)
__xmllint_builder = SCons.Builder.Builder(
action = SCons.Action.Action('$DOCBOOK_XMLLINTCOM','$DOCBOOK_XMLLINTCOMSTR'),
suffix = '.xml',
@@ -372,6 +409,124 @@ __fop_builder = SCons.Builder.Builder(
src_suffix = '.fo',
ensure_suffix=1)
+def DocbookEpub(env, target, source=None, *args, **kw):
+ """
+ A pseudo-Builder, providing a Docbook toolchain for ePub output.
+ """
+ import zipfile
+ import shutil
+
+ def build_open_container(target, source, env):
+ """Generate the *.epub file from intermediate outputs
+
+ Constructs the epub file according to the Open Container Format. This
+ function could be replaced by a call to the SCons Zip builder if support
+ was added for different compression formats for separate source nodes.
+ """
+ zf = zipfile.ZipFile(str(target[0]), 'w')
+ mime_file = open('mimetype', 'w')
+ mime_file.write('application/epub+zip')
+ mime_file.close()
+ zf.write(mime_file.name, compress_type = zipfile.ZIP_STORED)
+ for s in source:
+ for dirpath, dirnames, filenames in os.walk(str(s)):
+ for fname in filenames:
+ path = os.path.join(dirpath, fname)
+ if os.path.isfile(path):
+ zf.write(path, os.path.relpath(path, str(env.get('ZIPROOT', ''))),
+ zipfile.ZIP_DEFLATED)
+ zf.close()
+
+ def add_resources(target, source, env):
+ """Add missing resources to the OEBPS directory
+
+ Ensure all the resources in the manifest are present in the OEBPS directory.
+ """
+ hrefs = []
+ content_file = os.path.join(source[0].abspath, 'content.opf')
+ if not os.path.isfile(content_file):
+ return
+
+ hrefs = []
+ if has_libxml2:
+ nsmap = {'opf' : 'http://www.idpf.org/2007/opf'}
+ # Read file and resolve entities
+ doc = libxml2.readFile(content_file, None, 0)
+ opf = doc.getRootElement()
+ # Create xpath context
+ xpath_context = doc.xpathNewContext()
+ # Register namespaces
+ for key, val in nsmap.iteritems():
+ xpath_context.xpathRegisterNs(key, val)
+
+ if hasattr(opf, 'xpathEval') and xpath_context:
+ # Use the xpath context
+ xpath_context.setContextNode(opf)
+ items = xpath_context.xpathEval(".//opf:item")
+ else:
+ items = opf.findall(".//{'http://www.idpf.org/2007/opf'}item")
+
+ for item in items:
+ if hasattr(item, 'prop'):
+ hrefs.append(item.prop('href'))
+ else:
+ hrefs.append(item.attrib['href'])
+
+ doc.freeDoc()
+ xpath_context.xpathFreeContext()
+ elif has_lxml:
+ from lxml import etree
+
+ opf = etree.parse(content_file)
+ # All the opf:item elements are resources
+ for item in opf.xpath('//opf:item',
+ namespaces= { 'opf': 'http://www.idpf.org/2007/opf' }):
+ hrefs.append(item.attrib['href'])
+
+ for href in hrefs:
+ # If the resource was not already created by DocBook XSL itself,
+ # copy it into the OEBPS folder
+ referenced_file = os.path.join(source[0].abspath, href)
+ if not os.path.exists(referenced_file):
+ shutil.copy(href, os.path.join(source[0].abspath, href))
+
+ # Init list of targets/sources
+ target, source = __extend_targets_sources(target, source)
+
+ # Init XSL stylesheet
+ __init_xsl_stylesheet(kw, env, '$DOCBOOK_DEFAULT_XSL_EPUB', ['epub','docbook.xsl'])
+
+ # Setup builder
+ __builder = __select_builder(__lxml_builder, __libxml2_builder, __xsltproc_builder)
+
+ # Create targets
+ result = []
+ if not env.GetOption('clean'):
+ # Ensure that the folders OEBPS and META-INF exist
+ __create_output_dir('OEBPS/')
+ __create_output_dir('META-INF/')
+ dirs = env.Dir(['OEBPS', 'META-INF'])
+
+ # Set the fixed base_dir
+ kw['base_dir'] = 'OEBPS/'
+ tocncx = __builder.__call__(env, 'toc.ncx', source[0], **kw)
+ cxml = env.File('META-INF/container.xml')
+ env.SideEffect(cxml, tocncx)
+
+ env.Depends(tocncx, kw['DOCBOOK_XSL'])
+ result.extend(tocncx+[cxml])
+
+ container = env.Command(__ensure_suffix(str(target[0]), '.epub'),
+ tocncx+[cxml], [add_resources, build_open_container])
+ mimetype = env.File('mimetype')
+ env.SideEffect(mimetype, container)
+
+ result.extend(container)
+ # Add supporting files for cleanup
+ env.Clean(tocncx, dirs)
+
+ return result
+
def DocbookHtml(env, target, source=None, *args, **kw):
"""
A pseudo-Builder, providing a Docbook toolchain for HTML output.
@@ -420,11 +575,11 @@ def DocbookHtmlChunked(env, target, source=None, *args, **kw):
# Create targets
result = []
- r = __builder.__call__(env, base_dir+__ensure_suffix(str(target[0]), '.html'), source[0], **kw)
+ r = __builder.__call__(env, __ensure_suffix(str(target[0]), '.html'), source[0], **kw)
env.Depends(r, kw['DOCBOOK_XSL'])
result.extend(r)
# Add supporting files for cleanup
- env.Clean(r, glob.glob(base_dir+'*.html'))
+ env.Clean(r, glob.glob(os.path.join(base_dir, '*.html')))
return result
@@ -455,12 +610,12 @@ def DocbookHtmlhelp(env, target, source=None, *args, **kw):
# Create targets
result = []
- r = __builder.__call__(env, base_dir+__ensure_suffix(str(target[0]), '.html'), source[0], **kw)
+ r = __builder.__call__(env, __ensure_suffix(str(target[0]), '.html'), source[0], **kw)
env.Depends(r, kw['DOCBOOK_XSL'])
result.extend(r)
# Add supporting files for cleanup
env.Clean(r, ['toc.hhc', 'htmlhelp.hhp', 'index.hhk'] +
- glob.glob(base_dir+'[ar|bk|ch]*.html'))
+ glob.glob(os.path.join(base_dir, '[ar|bk|ch]*.html')))
return result
@@ -605,12 +760,12 @@ def DocbookSlidesHtml(env, target, source=None, *args, **kw):
# Create targets
result = []
- r = __builder.__call__(env, base_dir+__ensure_suffix(str(target[0]), '.html'), source[0], **kw)
+ r = __builder.__call__(env, __ensure_suffix(str(target[0]), '.html'), source[0], **kw)
env.Depends(r, kw['DOCBOOK_XSL'])
result.extend(r)
# Add supporting files for cleanup
- env.Clean(r, [base_dir+'toc.html'] +
- glob.glob(base_dir+'foil*.html'))
+ env.Clean(r, [os.path.join(base_dir, 'toc.html')] +
+ glob.glob(os.path.join(base_dir, 'foil*.html')))
return result
@@ -654,19 +809,19 @@ def DocbookXslt(env, target, source=None, *args, **kw):
return result
-
def generate(env):
"""Add Builders and construction variables for docbook to an Environment."""
env.SetDefault(
# Default names for customized XSL stylesheets
- DOCBOOK_DEFAULT_XSL_HTML = '',
- DOCBOOK_DEFAULT_XSL_HTMLCHUNKED = '',
- DOCBOOK_DEFAULT_XSL_HTMLHELP = '',
- DOCBOOK_DEFAULT_XSL_PDF = '',
- DOCBOOK_DEFAULT_XSL_MAN = '',
- DOCBOOK_DEFAULT_XSL_SLIDESPDF = '',
- DOCBOOK_DEFAULT_XSL_SLIDESHTML = '',
+ DOCBOOK_DEFAULT_XSL_EPUB = '',
+ DOCBOOK_DEFAULT_XSL_HTML = '',
+ DOCBOOK_DEFAULT_XSL_HTMLCHUNKED = '',
+ DOCBOOK_DEFAULT_XSL_HTMLHELP = '',
+ DOCBOOK_DEFAULT_XSL_PDF = '',
+ DOCBOOK_DEFAULT_XSL_MAN = '',
+ DOCBOOK_DEFAULT_XSL_SLIDESPDF = '',
+ DOCBOOK_DEFAULT_XSL_SLIDESHTML = '',
# Paths to the detected executables
DOCBOOK_XSLTPROC = '',
@@ -693,6 +848,7 @@ def generate(env):
_detect(env)
try:
+ env.AddMethod(DocbookEpub, "DocbookEpub")
env.AddMethod(DocbookHtml, "DocbookHtml")
env.AddMethod(DocbookHtmlChunked, "DocbookHtmlChunked")
env.AddMethod(DocbookHtmlhelp, "DocbookHtmlhelp")
@@ -705,6 +861,7 @@ def generate(env):
except AttributeError:
# Looks like we use a pre-0.98 version of SCons...
from SCons.Script.SConscript import SConsEnvironment
+ SConsEnvironment.DocbookEpub = DocbookEpub
SConsEnvironment.DocbookHtml = DocbookHtml
SConsEnvironment.DocbookHtmlChunked = DocbookHtmlChunked
SConsEnvironment.DocbookHtmlhelp = DocbookHtmlhelp
diff --git a/src/engine/SCons/Tool/docbook/__init__.xml b/src/engine/SCons/Tool/docbook/__init__.xml
index be2f2ca..0748738 100644
--- a/src/engine/SCons/Tool/docbook/__init__.xml
+++ b/src/engine/SCons/Tool/docbook/__init__.xml
@@ -97,7 +97,7 @@ accordingly.
</para>
</important>
<para>The rules given above are valid for the Builders &b-link-DocbookHtml;,
-&b-link-DocbookPdf;, &b-link-DocbookSlidesPdf; and &b-link-DocbookXInclude;. For the
+&b-link-DocbookPdf;, &b-link-DocbookEpub;, &b-link-DocbookSlidesPdf; and &b-link-DocbookXInclude;. For the
&b-link-DocbookMan; transformation you
can specify a target name, but the actual output names are automatically
set from the <literal>refname</literal> entries in your XML source.
@@ -136,6 +136,7 @@ variables for setting the default XSL name is provided. These are:
DOCBOOK_DEFAULT_XSL_HTMLCHUNKED
DOCBOOK_DEFAULT_XSL_HTMLHELP
DOCBOOK_DEFAULT_XSL_PDF
+DOCBOOK_DEFAULT_XSL_EPUB
DOCBOOK_DEFAULT_XSL_MAN
DOCBOOK_DEFAULT_XSL_SLIDESPDF
DOCBOOK_DEFAULT_XSL_SLIDESHTML
@@ -153,6 +154,7 @@ env.DocbookHtml('manual') # now uses html.xsl
<item>DOCBOOK_DEFAULT_XSL_HTMLCHUNKED</item>
<item>DOCBOOK_DEFAULT_XSL_HTMLHELP</item>
<item>DOCBOOK_DEFAULT_XSL_PDF</item>
+<item>DOCBOOK_DEFAULT_XSL_EPUB</item>
<item>DOCBOOK_DEFAULT_XSL_MAN</item>
<item>DOCBOOK_DEFAULT_XSL_SLIDESPDF</item>
<item>DOCBOOK_DEFAULT_XSL_SLIDESHTML</item>
@@ -212,6 +214,15 @@ current environment, if no other XSLT gets specified via keyword.
</summary>
</cvar>
+<cvar name="DOCBOOK_DEFAULT_XSL_EPUB">
+<summary>
+<para>
+The default XSLT file for the &b-link-DocbookEpub; builder within the
+current environment, if no other XSLT gets specified via keyword.
+</para>
+</summary>
+</cvar>
+
<cvar name="DOCBOOK_DEFAULT_XSL_MAN">
<summary>
<para>
@@ -473,6 +484,27 @@ env.DocbookPdf('manual')
</summary>
</builder>
+<builder name="DocbookEpub">
+<summary>
+<para>
+A pseudo-Builder, providing a Docbook toolchain for EPUB output.
+</para>
+
+<example_commands>env = Environment(tools=['docbook'])
+env.DocbookEpub('manual.epub', 'manual.xml')
+</example_commands>
+
+<para>
+or simply
+</para>
+
+<example_commands>env = Environment(tools=['docbook'])
+env.DocbookEpub('manual')
+</example_commands>
+
+</summary>
+</builder>
+
<builder name="DocbookMan">
<summary>
<para>
diff --git a/src/engine/SCons/Tool/gs.py b/src/engine/SCons/Tool/gs.py
index c5506ce..443ace2 100644
--- a/src/engine/SCons/Tool/gs.py
+++ b/src/engine/SCons/Tool/gs.py
@@ -34,6 +34,7 @@ selection method.
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import SCons.Action
+import SCons.Builder
import SCons.Platform
import SCons.Util
@@ -52,17 +53,26 @@ GhostscriptAction = None
def generate(env):
"""Add Builders and construction variables for Ghostscript to an
Environment."""
-
global GhostscriptAction
- if GhostscriptAction is None:
- GhostscriptAction = SCons.Action.Action('$GSCOM', '$GSCOMSTR')
-
- from . import pdf
- pdf.generate(env)
-
- bld = env['BUILDERS']['PDF']
- bld.add_action('.ps', GhostscriptAction)
-
+ # The following try-except block enables us to use the Tool
+ # in standalone mode (without the accompanying pdf.py),
+ # whenever we need an explicit call of gs via the Gs()
+ # Builder ...
+ try:
+ if GhostscriptAction is None:
+ GhostscriptAction = SCons.Action.Action('$GSCOM', '$GSCOMSTR')
+
+ from . import pdf
+ pdf.generate(env)
+
+ bld = env['BUILDERS']['PDF']
+ bld.add_action('.ps', GhostscriptAction)
+ except ImportError as e:
+ pass
+
+ gsbuilder = SCons.Builder.Builder(action = SCons.Action.Action('$GSCOM', '$GSCOMSTR'))
+ env['BUILDERS']['Gs'] = gsbuilder
+
env['GS'] = gs
env['GSFLAGS'] = SCons.Util.CLVar('-dNOPAUSE -dBATCH -sDEVICE=pdfwrite')
env['GSCOM'] = '$GS $GSFLAGS -sOutputFile=$TARGET $SOURCES'
diff --git a/src/engine/SCons/Tool/gs.xml b/src/engine/SCons/Tool/gs.xml
index c34f004..3fe5165 100644
--- a/src/engine/SCons/Tool/gs.xml
+++ b/src/engine/SCons/Tool/gs.xml
@@ -26,7 +26,12 @@ See its __doc__ string for a discussion of the format.
<tool name="gs">
<summary>
<para>
-Set construction variables for Ghostscript.
+This Tool sets the required construction variables for working with
+the Ghostscript command. It also registers an appropriate Action
+with the PDF Builder (&b-link-PDF;), such that the conversion from
+PS/EPS to PDF happens automatically for the TeX/LaTeX toolchain.
+Finally, it adds an explicit Ghostscript Builder (&b-link-Gs;) to the
+environment.
</para>
</summary>
<sets>
@@ -42,7 +47,7 @@ Set construction variables for Ghostscript.
<cvar name="GS">
<summary>
<para>
-The Ghostscript program used to convert PostScript to PDF files.
+The Ghostscript program used, e.g. to convert PostScript to PDF files.
</para>
</summary>
</cvar>
@@ -50,7 +55,8 @@ The Ghostscript program used to convert PostScript to PDF files.
<cvar name="GSCOM">
<summary>
<para>
-The Ghostscript command line used to convert PostScript to PDF files.
+The full Ghostscript command line used for the conversion process. Its default
+value is <quote><literal>$GS $GSFLAGS -sOutputFile=$TARGET $SOURCES</literal></quote>.
</para>
</summary>
</cvar>
@@ -59,9 +65,8 @@ The Ghostscript command line used to convert PostScript to PDF files.
<summary>
<para>
The string displayed when
-Ghostscript is used to convert
-a PostScript file to a PDF file.
-If this is not set, then &cv-link-GSCOM; (the command line) is displayed.
+Ghostscript is called for the conversion process.
+If this is not set (the default), then &cv-link-GSCOM; (the command line) is displayed.
</para>
</summary>
</cvar>
@@ -69,10 +74,27 @@ If this is not set, then &cv-link-GSCOM; (the command line) is displayed.
<cvar name="GSFLAGS">
<summary>
<para>
-General options passed to the Ghostscript program
-when converting PostScript to PDF files.
+General options passed to the Ghostscript program,
+when converting PostScript to PDF files for example. Its default value
+is <quote><literal>-dNOPAUSE -dBATCH -sDEVICE=pdfwrite</literal></quote>
</para>
</summary>
</cvar>
+<builder name="Gs">
+<summary>
+<para>
+A Builder for explicitly calling the <literal>gs</literal> executable.
+Depending on the underlying OS, the different names <literal>gs</literal>,
+<literal>gsos2</literal> and <literal>gswin32c</literal>
+are tried.
+</para>
+<example_commands>env = Environment(tools=['gs'])
+env.Gs('cover.jpg','scons-scons.pdf',
+ GSFLAGS='-dNOPAUSE -dBATCH -sDEVICE=jpeg -dFirstPage=1 -dLastPage=1 -q')
+ )
+</example_commands>
+</summary>
+</builder>
+
</sconsdoc> \ No newline at end of file
diff --git a/src/engine/SCons/Tool/msginit.xml b/src/engine/SCons/Tool/msginit.xml
index 0f89020..7ce785c 100644
--- a/src/engine/SCons/Tool/msginit.xml
+++ b/src/engine/SCons/Tool/msginit.xml
@@ -216,8 +216,10 @@ See &t-link-msginit; tool and &b-link-POInit; builder.
Internal ``macro''. Computes locale (language) name based on target filename
(default: <literal>'${TARGET.filebase}' </literal>).
</para>
-</summary>
+<para>
See &t-link-msginit; tool and &b-link-POInit; builder.
+</para>
+</summary>
</cvar>
</sconsdoc> \ No newline at end of file
diff --git a/src/engine/SCons/Tool/rpm.py b/src/engine/SCons/Tool/rpm.py
index 26d2109..1f6eafe 100644
--- a/src/engine/SCons/Tool/rpm.py
+++ b/src/engine/SCons/Tool/rpm.py
@@ -79,7 +79,7 @@ def build_rpm(target, source, env):
errstr=output,
filename=str(target[0]) )
else:
- # XXX: assume that LC_ALL=c is set while running rpmbuild
+ # XXX: assume that LC_ALL=C is set while running rpmbuild
output_files = re.compile( 'Wrote: (.*)' ).findall( output )
for output, input in zip( output_files, target ):
@@ -117,7 +117,7 @@ def generate(env):
bld = RpmBuilder
env['BUILDERS']['Rpm'] = bld
- env.SetDefault(RPM = 'LC_ALL=c rpmbuild')
+ env.SetDefault(RPM = 'LC_ALL=C rpmbuild')
env.SetDefault(RPMFLAGS = SCons.Util.CLVar('-ta'))
env.SetDefault(RPMCOM = rpmAction)
env.SetDefault(RPMSUFFIX = '.rpm')
diff --git a/src/engine/SCons/Tool/zip.xml b/src/engine/SCons/Tool/zip.xml
index af68533..f43aa31 100644
--- a/src/engine/SCons/Tool/zip.xml
+++ b/src/engine/SCons/Tool/zip.xml
@@ -145,11 +145,13 @@ The suffix used for zip file names.
<cvar name="ZIPROOT">
<summary>
+<para>
An optional zip root directory (default empty). The filenames stored
in the zip file will be relative to this directory, if given.
Otherwise the filenames are relative to the current directory of the
command.
For instance:
+</para>
<example_commands>
env = Environment()
env.Zip('foo.zip', 'subdir1/subdir2/file1', ZIPROOT='subdir1')
diff --git a/src/engine/SCons/Warnings.py b/src/engine/SCons/Warnings.py
index a260c4a..ca6acee 100644
--- a/src/engine/SCons/Warnings.py
+++ b/src/engine/SCons/Warnings.py
@@ -42,6 +42,9 @@ class WarningOnByDefault(Warning):
# NOTE: If you add a new warning class, add it to the man page, too!
+class TargetNotBuiltWarning(Warning): # Should go to OnByDefault
+ pass
+
class CacheWriteErrorWarning(Warning):
pass