Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: scons-2.0.1/engine/SCons/Variables/PackageVariable.py

Issue 6711079: Added an unmodified copy of SCons to third_party. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/third_party/
Patch Set: '' Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 """engine.SCons.Variables.PackageVariable
2
3 This file defines the option type for SCons implementing 'package
4 activation'.
5
6 To be used whenever a 'package' may be enabled/disabled and the
7 package path may be specified.
8
9 Usage example:
10
11 Examples:
12 x11=no (disables X11 support)
13 x11=yes (will search for the package installation dir)
14 x11=/usr/local/X11 (will check this path for existance)
15
16 To replace autoconf's --with-xxx=yyy
17
18 opts = Variables()
19 opts.Add(PackageVariable('x11',
20 'use X11 installed here (yes = search some places',
21 'yes'))
22 ...
23 if env['x11'] == True:
24 dir = ... search X11 in some standard places ...
25 env['x11'] = dir
26 if env['x11']:
27 ... build with x11 ...
28 """
29
30 #
31 # Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 The S Cons Foundation
32 #
33 # Permission is hereby granted, free of charge, to any person obtaining
34 # a copy of this software and associated documentation files (the
35 # "Software"), to deal in the Software without restriction, including
36 # without limitation the rights to use, copy, modify, merge, publish,
37 # distribute, sublicense, and/or sell copies of the Software, and to
38 # permit persons to whom the Software is furnished to do so, subject to
39 # the following conditions:
40 #
41 # The above copyright notice and this permission notice shall be included
42 # in all copies or substantial portions of the Software.
43 #
44 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
45 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
46 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
47 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
48 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
49 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
50 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
51 #
52
53 __revision__ = "src/engine/SCons/Variables/PackageVariable.py 5134 2010/08/16 23 :02:40 bdeegan"
54
55 __all__ = ['PackageVariable',]
56
57 import SCons.Errors
58
59 __enable_strings = ('1', 'yes', 'true', 'on', 'enable', 'search')
60 __disable_strings = ('0', 'no', 'false', 'off', 'disable')
61
62 def _converter(val):
63 """
64 """
65 lval = val.lower()
66 if lval in __enable_strings: return True
67 if lval in __disable_strings: return False
68 #raise ValueError("Invalid value for boolean option: %s" % val)
69 return val
70
71
72 def _validator(key, val, env, searchfunc):
73 # NB: searchfunc is currenty undocumented and unsupported
74 """
75 """
76 # todo: write validator, check for path
77 import os
78 if env[key] is True:
79 if searchfunc:
80 env[key] = searchfunc(key, val)
81 elif env[key] and not os.path.exists(val):
82 raise SCons.Errors.UserError(
83 'Path does not exist for option %s: %s' % (key, val))
84
85
86 def PackageVariable(key, help, default, searchfunc=None):
87 # NB: searchfunc is currenty undocumented and unsupported
88 """
89 The input parameters describe a 'package list' option, thus they
90 are returned with the correct converter and validator appended. The
91 result is usable for input to opts.Add() .
92
93 A 'package list' option may either be 'all', 'none' or a list of
94 package names (seperated by space).
95 """
96 help = '\n '.join(
97 (help, '( yes | no | /path/to/%s )' % key))
98 return (key, help, default,
99 lambda k, v, e: _validator(k,v,e,searchfunc),
100 _converter)
101
102 # Local Variables:
103 # tab-width:4
104 # indent-tabs-mode:nil
105 # End:
106 # vim: set expandtab tabstop=4 shiftwidth=4:
OLDNEW
« no previous file with comments | « scons-2.0.1/engine/SCons/Variables/ListVariable.py ('k') | scons-2.0.1/engine/SCons/Variables/PathVariable.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698