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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53 __revision__ = "src/engine/SCons/Variables/PackageVariable.py 5110 2010/07/25 16:14:38 bdeegan"
54
55 __all__ = ['PackageVariable',]
56
57 import string
58
59 import SCons.Errors
60
61 __enable_strings = ('1', 'yes', 'true', 'on', 'enable', 'search')
62 __disable_strings = ('0', 'no', 'false', 'off', 'disable')
63
72
73
75
76 """
77 """
78
79 import os
80 if env[key] is True:
81 if searchfunc:
82 env[key] = searchfunc(key, val)
83 elif env[key] and not os.path.exists(val):
84 raise SCons.Errors.UserError(
85 'Path does not exist for option %s: %s' % (key, val))
86
87
89
90 """
91 The input parameters describe a 'package list' option, thus they
92 are returned with the correct converter and validator appended. The
93 result is usable for input to opts.Add() .
94
95 A 'package list' option may either be 'all', 'none' or a list of
96 package names (seperated by space).
97 """
98 help = string.join(
99 (help, '( yes | no | /path/to/%s )' % key),
100 '\n ')
101 return (key, help, default,
102 lambda k, v, e, f=searchfunc: _validator(k,v,e,f),
103 _converter)
104
105
106
107
108
109
110