"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "SCons/Variables/PackageVariable.py" between
scons-4.2.0.tar.gz and SCons-4.3.0.tar.gz

About: SCons is a software construction tool (a Python script and a set of modules as a superior alternative to the classic "Make" build tool).

PackageVariable.py  (scons-4.2.0):PackageVariable.py  (SCons-4.3.0)
skipping to change at line 24 skipping to change at line 24
# in all copies or substantial portions of the Software. # in all copies or substantial portions of the Software.
# #
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""Option type for package Variables. """Variable type for package Variables.
This file defines the option type for SCons implementing 'package activation'.
To be used whenever a 'package' may be enabled/disabled and the To be used whenever a 'package' may be enabled/disabled and the
package path may be specified. package path may be specified.
Usage example: Given these options ::
Examples: x11=no (disables X11 support)
x11=no (disables X11 support) x11=yes (will search for the package installation dir)
x11=yes (will search for the package installation dir) x11=/usr/local/X11 (will check this path for existence)
x11=/usr/local/X11 (will check this path for existence)
Can be used as a replacement for autoconf's ``--with-xxx=yyy`` ::
To replace autoconf's --with-xxx=yyy ::
opts = Variables()
opts = Variables() opts.Add(
opts.Add(PackageVariable('x11', PackageVariable(
'use X11 installed here (yes = search some places', key='x11',
'yes')) help='use X11 installed here (yes = search some places)',
... default='yes'
if env['x11'] == True: )
dir = ... search X11 in some standard places ... )
env['x11'] = dir ...
if env['x11']: if env['x11'] == True:
... build with x11 ... dir = ... # search X11 in some standard places ...
env['x11'] = dir
if env['x11']:
... # build with x11 ...
""" """
__all__ = ['PackageVariable',] from typing import Tuple, Callable
import SCons.Errors import SCons.Errors
__enable_strings = ('1', 'yes', 'true', 'on', 'enable', 'search') __all__ = ['PackageVariable',]
__disable_strings = ('0', 'no', 'false', 'off', 'disable')
ENABLE_STRINGS = ('1', 'yes', 'true', 'on', 'enable', 'search')
DISABLE_STRINGS = ('0', 'no', 'false', 'off', 'disable')
def _converter(val): def _converter(val):
""" """ """
"""
lval = val.lower() lval = val.lower()
if lval in __enable_strings: return True if lval in ENABLE_STRINGS:
if lval in __disable_strings: return False return True
#raise ValueError("Invalid value for boolean option: %s" % val) if lval in DISABLE_STRINGS:
return False
return val return val
def _validator(key, val, env, searchfunc): def _validator(key, val, env, searchfunc) -> None:
""" """
# NB: searchfunc is currently undocumented and unsupported # NB: searchfunc is currently undocumented and unsupported
"""
"""
# TODO write validator, check for path # TODO write validator, check for path
import os import os
if env[key] is True: if env[key] is True:
if searchfunc: if searchfunc:
env[key] = searchfunc(key, val) env[key] = searchfunc(key, val)
elif env[key] and not os.path.exists(val): elif env[key] and not os.path.exists(val):
raise SCons.Errors.UserError( raise SCons.Errors.UserError(
'Path does not exist for option %s: %s' % (key, val)) 'Path does not exist for option %s: %s' % (key, val))
def PackageVariable(key, help, default, searchfunc=None): def PackageVariable(key, help, default, searchfunc=None) -> Tuple[str, str, str,
# NB: searchfunc is currently undocumented and unsupported Callable, Callable]:
""" """Return a tuple describing a package list SCons Variable.
The input parameters describe a 'package list' option, thus they
are returned with the correct converter and validator appended. The The input parameters describe a 'package list' option. Returns
result is usable for input to opts.Add() . a tuple including the correct converter and validator appended.
The result is usable as input to :meth:`Add` .
A 'package list' option may either be 'all', 'none' or a list of A 'package list' option may either be 'all', 'none' or a pathname
package names (separated by space). string. This information is appended to *help*.
""" """
# NB: searchfunc is currently undocumented and unsupported
help = '\n '.join( help = '\n '.join(
(help, '( yes | no | /path/to/%s )' % key)) (help, '( yes | no | /path/to/%s )' % key))
return (key, help, default, return (key, help, default,
lambda k, v, e: _validator(k,v,e,searchfunc), lambda k, v, e: _validator(k, v, e, searchfunc),
_converter) _converter)
# Local Variables: # Local Variables:
# tab-width:4 # tab-width:4
# indent-tabs-mode:nil # indent-tabs-mode:nil
# End: # End:
# vim: set expandtab tabstop=4 shiftwidth=4: # vim: set expandtab tabstop=4 shiftwidth=4:
 End of changes. 14 change blocks. 
41 lines changed or deleted 46 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)