summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Deegan <bill@baddogconsulting.com>2015-02-25 11:10:25 -0800
committerWilliam Deegan <bill@baddogconsulting.com>2015-02-25 11:10:25 -0800
commitb9e222b9d0ba04bdb65b1a221893998872547b28 (patch)
tree69cb7892bca7def84b1dbcdbeefcb92a30c463fd
parent914ec3f2131528f45310590e50a38748791f4498 (diff)
parentabca4b0cb82ef9f412ad659a5ff062e193b214b0 (diff)
downloadscons-b9e222b9d0ba04bdb65b1a221893998872547b28.tar.gz
Merged in dirkbaechle/scons (pull request #208)
A few simple refactorings and optimizations
-rw-r--r--src/engine/SCons/Action.py34
-rw-r--r--src/engine/SCons/ActionTests.py2
-rw-r--r--src/engine/SCons/Builder.py4
-rw-r--r--src/engine/SCons/Executor.py19
-rw-r--r--src/engine/SCons/Node/FS.py12
5 files changed, 28 insertions, 43 deletions
diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py
index 1c746be1..eecea11b 100644
--- a/src/engine/SCons/Action.py
+++ b/src/engine/SCons/Action.py
@@ -99,8 +99,6 @@ way for wrapping up the functions.
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
-import SCons.compat
-
import dis
import os
# compat layer imports "cPickle" for us if it's available.
@@ -112,7 +110,6 @@ import subprocess
import SCons.Debug
from SCons.Debug import logInstanceCreation
import SCons.Errors
-import SCons.Executor
import SCons.Util
import SCons.Subst
@@ -357,21 +354,6 @@ def _do_create_action(act, kw):
if isinstance(act, ActionBase):
return act
- if is_List(act):
- return CommandAction(act, **kw)
-
- if callable(act):
- try:
- gen = kw['generator']
- del kw['generator']
- except KeyError:
- gen = 0
- if gen:
- action_type = CommandGeneratorAction
- else:
- action_type = FunctionAction
- return action_type(act, kw)
-
if is_String(act):
var=SCons.Util.get_environment_var(act)
if var:
@@ -388,6 +370,22 @@ def _do_create_action(act, kw):
# The list of string commands may include a LazyAction, so we
# reprocess them via _do_create_list_action.
return _do_create_list_action(commands, kw)
+
+ if is_List(act):
+ return CommandAction(act, **kw)
+
+ if callable(act):
+ try:
+ gen = kw['generator']
+ del kw['generator']
+ except KeyError:
+ gen = 0
+ if gen:
+ action_type = CommandGeneratorAction
+ else:
+ action_type = FunctionAction
+ return action_type(act, kw)
+
# Catch a common error case with a nice message:
if isinstance(act, int) or isinstance(act, float):
raise TypeError("Don't know how to create an Action from a number (%s)"%act)
diff --git a/src/engine/SCons/ActionTests.py b/src/engine/SCons/ActionTests.py
index b46347df..e069d51d 100644
--- a/src/engine/SCons/ActionTests.py
+++ b/src/engine/SCons/ActionTests.py
@@ -23,8 +23,6 @@
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
-import SCons.compat
-
# Define a null function and a null class for use as builder actions.
# Where these are defined in the file seems to affect their byte-code
# contents, so try to minimize changes by defining them here, before we
diff --git a/src/engine/SCons/Builder.py b/src/engine/SCons/Builder.py
index ed7650a8..c82f6ac6 100644
--- a/src/engine/SCons/Builder.py
+++ b/src/engine/SCons/Builder.py
@@ -107,8 +107,6 @@ from SCons.Debug import logInstanceCreation
from SCons.Errors import InternalError, UserError
import SCons.Executor
import SCons.Memoize
-import SCons.Node
-import SCons.Node.FS
import SCons.Util
import SCons.Warnings
@@ -862,7 +860,7 @@ class CompositeBuilder(SCons.Util.Proxy):
self.set_src_suffix(self.cmdgen.src_suffixes())
def is_a_Builder(obj):
- """"Returns True iff the specified obj is one of our Builder classes.
+ """"Returns True if the specified obj is one of our Builder classes.
The test is complicated a bit by the fact that CompositeBuilder
is a proxy, not a subclass of BuilderBase.
diff --git a/src/engine/SCons/Executor.py b/src/engine/SCons/Executor.py
index 051d275f..388f8acb 100644
--- a/src/engine/SCons/Executor.py
+++ b/src/engine/SCons/Executor.py
@@ -554,19 +554,20 @@ def AddBatchExecutor(key, executor):
nullenv = None
+import SCons.Util
+class NullEnvironment(SCons.Util.Null):
+ import SCons.CacheDir
+ _CacheDir_path = None
+ _CacheDir = SCons.CacheDir.CacheDir(None)
+ def get_CacheDir(self):
+ return self._CacheDir
+
+
def get_NullEnvironment():
"""Use singleton pattern for Null Environments."""
global nullenv
- import SCons.Util
- class NullEnvironment(SCons.Util.Null):
- import SCons.CacheDir
- _CacheDir_path = None
- _CacheDir = SCons.CacheDir.CacheDir(None)
- def get_CacheDir(self):
- return self._CacheDir
-
- if not nullenv:
+ if nullenv is None:
nullenv = NullEnvironment()
return nullenv
diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py
index e73dd924..4db1cb33 100644
--- a/src/engine/SCons/Node/FS.py
+++ b/src/engine/SCons/Node/FS.py
@@ -2230,17 +2230,7 @@ class RootDir(Dir):
raise SCons.Errors.UserError(msg)
# There is no Node for this path name, and we're allowed
# to create it.
- # (note: would like to use p.rsplit('/',1) here but
- # that's not in python 2.3)
- # e.g.: dir_name, file_name = p.rsplit('/',1)
- last_slash = p.rindex('/')
- if (last_slash >= 0):
- dir_name = p[:last_slash]
- file_name = p[last_slash+1:]
- else:
- dir_name = p # shouldn't happen, just in case
- file_name = ''
-
+ dir_name, file_name = p.rsplit('/',1)
dir_node = self._lookup_abs(dir_name, Dir)
result = klass(file_name, dir_node, self.fs)