summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2003-06-12 15:28:38 (GMT)
committerSteven Knight <knight@baldmt.com>2003-06-12 15:28:38 (GMT)
commit823ab5a50f9856308ee9559f968d62409ad625da (patch)
treec24bc193f5a9acbceed0bb58b44768355f3ee945 /src
parent6c11c2362e17142f384a914d821d0e0cd021ecd2 (diff)
downloadSCons-823ab5a50f9856308ee9559f968d62409ad625da.zip
SCons-823ab5a50f9856308ee9559f968d62409ad625da.tar.gz
SCons-823ab5a50f9856308ee9559f968d62409ad625da.tar.bz2
Raise an error if SConf needs to do something but -n or -q is specified. (Christoph Wiedemann)
Diffstat (limited to 'src')
-rw-r--r--src/engine/SCons/Errors.py6
-rw-r--r--src/engine/SCons/ErrorsTests.py6
-rw-r--r--src/engine/SCons/SConf.py39
-rw-r--r--src/engine/SCons/Script/__init__.py6
4 files changed, 52 insertions, 5 deletions
diff --git a/src/engine/SCons/Errors.py b/src/engine/SCons/Errors.py
index 9743674..cc8bb3d 100644
--- a/src/engine/SCons/Errors.py
+++ b/src/engine/SCons/Errors.py
@@ -55,3 +55,9 @@ class ExplicitExit(Exception):
self.node = node
self.status = status
self.args = args
+
+class ConfigureDryRunError(UserError):
+ """Raised when a file needs to be updated during a Configure process,
+ but the user requested a dry-run"""
+ def __init__(self,file):
+ UserError.__init__(self,"Cannot update configure test (%s) within a dry-run." % str(file))
diff --git a/src/engine/SCons/ErrorsTests.py b/src/engine/SCons/ErrorsTests.py
index b128026..810f840 100644
--- a/src/engine/SCons/ErrorsTests.py
+++ b/src/engine/SCons/ErrorsTests.py
@@ -58,6 +58,12 @@ class ErrorsTestCase(unittest.TestCase):
except SCons.Errors.ExplicitExit, e:
assert e.node == "node"
+ def test_ConfigureDryRunError(self):
+ """Test the ConfigureDryRunError."""
+ try:
+ raise SCons.Errors.ConfigureDryRunError, "FileName"
+ except SCons.Errors.UserError, e:
+ assert e.args == "Cannot update configure test (FileName) within a dry-run."
if __name__ == "__main__":
diff --git a/src/engine/SCons/SConf.py b/src/engine/SCons/SConf.py
index 7336cde..b62dabf 100644
--- a/src/engine/SCons/SConf.py
+++ b/src/engine/SCons/SConf.py
@@ -47,6 +47,9 @@ import SCons.Warnings
# but it showed up that there are too many side effects in doing that.
SConfFS=SCons.Node.FS.default_fs
+# to be set, if we are in dry-run mode
+dryrun = 0
+
_ac_build_counter = 0
_ac_config_counter = 0
_activeSConfObjects = {}
@@ -159,6 +162,22 @@ class SConf:
def do_failed(self, status=2):
pass
+ class SConfDryRunTask(SConfBuildTask):
+ """Raise ConfiugreDryRunErrors whenever a target is to
+ be built. Pass these Errors to the main script."""
+ def execute(self):
+ target = self.targets[0]
+ if (target.get_state() != SCons.Node.up_to_date and
+ target.has_builder() and
+ not hasattr(target.builder, 'status')):
+
+ raise SCons.Errors.ConfigureDryRunError(target)
+
+ def failed(self):
+ if sys.exc_type == SCons.Errors.ConfigureDryRunError:
+ raise
+ SConfBuildTask.failed(self)
+
if self.logstream != None:
# override stdout / stderr to write in log file
oldStdout = sys.stdout
@@ -176,8 +195,12 @@ class SConf:
try:
# ToDo: use user options for calc
self.calc = SCons.Sig.Calculator(max_drift=0)
+ if dryrun:
+ buildTask = SConfDryRunTask
+ else:
+ buildTask = SConfBuildTask
tm = SCons.Taskmaster.Taskmaster( nodes,
- SConfBuildTask,
+ buildTask,
self.calc )
# we don't want to build tests in parallel
jobs = SCons.Job.Jobs(1, tm )
@@ -365,6 +388,8 @@ class SConf:
self.cache = {}
def _dumpCache(self):
+ if dryrun:
+ return
# try to dump build-error cache
try:
cacheDesc = {'scons_version' : SCons.__version__,
@@ -377,9 +402,13 @@ class SConf:
def _createDir( self, node ):
dirName = node.get_path()
- if not os.path.isdir( dirName ):
- os.makedirs( dirName )
- node._exists = 1
+ if dryrun:
+ if not os.path.isdir( dirName ):
+ raise SCons.Errors.ConfigureDryRunError(dirName)
+ else:
+ if not os.path.isdir( dirName ):
+ os.makedirs( dirName )
+ node._exists = 1
def _startup(self):
"""Private method. Set up logstream, and set the environment
@@ -394,7 +423,7 @@ class SConf:
self._createDir(self.confdir)
self.confdir.up().add_ignore( [self.confdir] )
- if self.logfile != None:
+ if self.logfile != None and not dryrun:
# truncate logfile, if SConf.Configure is called for the first time
# in a build
if _ac_config_counter == 0:
diff --git a/src/engine/SCons/Script/__init__.py b/src/engine/SCons/Script/__init__.py
index 1c773f0..139d296 100644
--- a/src/engine/SCons/Script/__init__.py
+++ b/src/engine/SCons/Script/__init__.py
@@ -723,8 +723,12 @@ def _main():
if options.warn:
_setup_warn(options.warn)
if options.noexec:
+ SCons.SConf.dryrun = 1
SCons.Action.execute_actions = None
CleanTask.execute = CleanTask.show
+ if options.question:
+ SCons.SConf.dryrun = 1
+
if options.no_progress or options.silent:
display.set_mode(0)
if options.silent:
@@ -977,6 +981,8 @@ def main():
_scons_syntax_error(e)
except SCons.Errors.UserError, e:
_scons_user_error(e)
+ except SCons.Errors.ConfigureDryRunError, e:
+ _scons_configure_dryrun_error(e)
except:
_scons_other_errors()