From f5f078d795c2c9074e03a8a2b1d809287a622a05 Mon Sep 17 00:00:00 2001 From: stevenknight Date: Thu, 17 Mar 2005 13:05:36 +0000 Subject: [PATCH] Restore (some) old SCons.Script.* names, some released SConscript files are using them. git-svn-id: http://scons.tigris.org/svn/scons/trunk@1256 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- src/engine/SCons/Script/SConscript.py | 10 +++++ src/engine/SCons/Script/__init__.py | 53 ++++++++++++++++++++++++++- test/Script-import.py | 42 ++++++++++++++++++++- 3 files changed, 102 insertions(+), 3 deletions(-) diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py index d0df6a38..07dfd559 100644 --- a/src/engine/SCons/Script/SConscript.py +++ b/src/engine/SCons/Script/SConscript.py @@ -55,6 +55,16 @@ import traceback import types import UserList +# The following variables used to live in this module. Some +# SConscript files out there may have referred to them directly as +# SCons.Script.SConscript.*. This is now supported by some special +# handling towards the bottom of the SConscript.__init__.py module. +#Arguments = {} +#ArgList = [] +#BuildTargets = TargetList() +#CommandLineTargets = [] +#DefaultTargets = [] + launch_dir = os.path.abspath(os.curdir) GlobalDict = None diff --git a/src/engine/SCons/Script/__init__.py b/src/engine/SCons/Script/__init__.py index 9de951b3..4327ac2c 100644 --- a/src/engine/SCons/Script/__init__.py +++ b/src/engine/SCons/Script/__init__.py @@ -77,6 +77,41 @@ import Main main = Main.main +# The following are global class definitions and variables that used to +# live directly in this module back before 0.96.90, when it contained +# a lot of code. Some SConscript files in widely-distributed packages +# (Blender is the specific example) actually reached into SCons.Script +# directly to use some of these. Rather than break those SConscript +# files, we're going to propagate these names into the SCons.Script +# namespace here. +# +# Some of these are commented out because it's *really* unlikely anyone +# used them, but we're going to leave the comment here to try to make +# it obvious what to do if the situation arises. +BuildTask = Main.BuildTask +CleanTask = Main.CleanTask +QuestionTask = Main.QuestionTask +#PrintHelp = Main.PrintHelp +OptParser = Main.OptParser +SConscriptSettableOptions = Main.SConscriptSettableOptions + +keep_going_on_error = Main.keep_going_on_error +print_dtree = Main.print_dtree +print_explanations = Main.print_explanations +print_includes = Main.print_includes +print_objects = Main.print_objects +print_time = Main.print_time +print_tree = Main.print_tree +memory_stats = Main.memory_stats +ignore_errors = Main.ignore_errors +#sconscript_time = Main.sconscript_time +#command_time = Main.command_time +#exit_status = Main.exit_status +#profiling = Main.profiling +repositories = Main.repositories +#num_jobs = Main.num_jobs # settable by SConscript.SetJobs() + +# import SConscript _SConscript = SConscript @@ -206,7 +241,7 @@ GlobalDefaultEnvironmentFunctions = [ 'GetOption', 'Help', 'Import', - 'SConscript', + #'SConscript', is handled separately, below. 'SConscriptChdir', 'SetOption', @@ -274,6 +309,22 @@ GlobalDefaultBuilders = [ for name in GlobalDefaultEnvironmentFunctions + GlobalDefaultBuilders: exec "%s = _SConscript.DefaultEnvironmentCall(%s)" % (name, repr(name)) +# There are a handful of variables that used to live in the +# Script/SConscript.py module that some SConscript files out there were +# accessing directly as SCons.Script.SConscript.*. The problem is that +# "SConscript" in this namespace is no longer a module, it's a global +# function call--or more precisely, an object that implements a global +# function call through the default Environment. Nevertheless, we can +# aintain backwards compatibility for SConscripts that were reaching in +# this way by hanging some attributes off the "SConscript" object here. +SConscript = _SConscript.DefaultEnvironmentCall('SConscript') + +SConscript.Arguments = ARGUMENTS +SConscript.ArgList = ARGLIST +SConscript.BuildTargets = BUILD_TARGETS +SConscript.CommandLineTargets = COMMAND_LINE_TARGETS +SConscript.DefaultTargets = DEFAULT_TARGETS + # The global Command() function must be handled differently than the # global functions for other construction environment methods because # we want people to be able to use Actions that must expand $TARGET diff --git a/test/Script-import.py b/test/Script-import.py index 90052a5f..4dd8d914 100644 --- a/test/Script-import.py +++ b/test/Script-import.py @@ -25,8 +25,9 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" """ -Test that a module that we import into an SConscript file -can itself easily import the global SCons variables. +Test that a module that we import into an SConscript file can itself +easily import the global SCons variables, and a handful of other variables +directly from SCons.Script modules. """ import TestSCons @@ -44,6 +45,8 @@ SConscript('SConscript') test.write('SConscript', """\ import m2 +import m3 +import m4 """) test.write("m2.py", """\ @@ -51,6 +54,41 @@ from SCons.Script import * Command("file.out", "file.in", Copy("$TARGET", "$SOURCE")) """) +test.write("m3.py", """\ +import SCons.Script + +SCons.Script.BuildTask +SCons.Script.CleanTask +SCons.Script.QuestionTask +#SCons.Script.PrintHelp +SCons.Script.OptParser +SCons.Script.SConscriptSettableOptions + +SCons.Script.keep_going_on_error +SCons.Script.print_dtree +SCons.Script.print_explanations +SCons.Script.print_includes +SCons.Script.print_objects +SCons.Script.print_time +SCons.Script.print_tree +SCons.Script.memory_stats +SCons.Script.ignore_errors +#SCons.Script.sconscript_time +#SCons.Script.command_time +#SCons.Script.exit_status +#SCons.Script.profiling +SCons.Script.repositories +""") + +test.write("m4.py", """\ +import SCons.Script.SConscript +SCons.Script.SConscript.Arguments +SCons.Script.SConscript.ArgList +SCons.Script.SConscript.BuildTargets +SCons.Script.SConscript.CommandLineTargets +SCons.Script.SConscript.DefaultTargets +""") + test.write("file.in", "file.in\n") test.run(arguments = '.') -- 2.26.2