Merged revisions 2725-2865 via svnmerge from
[scons.git] / test / Deprecated / Options / help.py
1 #!/usr/bin/env python
2 #
3 # __COPYRIGHT__
4 #
5 # Permission is hereby granted, free of charge, to any person obtaining
6 # a copy of this software and associated documentation files (the
7 # "Software"), to deal in the Software without restriction, including
8 # without limitation the rights to use, copy, modify, merge, publish,
9 # distribute, sublicense, and/or sell copies of the Software, and to
10 # permit persons to whom the Software is furnished to do so, subject to
11 # the following conditions:
12 #
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
15 #
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
17 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 #
24
25 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
26
27 """
28 Test the Options help messages.
29 """
30
31 import os.path
32 import string
33
34 try:
35     True, False
36 except NameError:
37     True = (0 == 0)
38     False = (0 != 0)
39
40 str_True = str(True)
41 str_False = str(False)
42
43 import TestSCons
44
45 test = TestSCons.TestSCons()
46
47
48
49 workpath = test.workpath()
50 qtpath  = os.path.join(workpath, 'qt')
51 libpath = os.path.join(qtpath, 'lib')
52 libdirvar = os.path.join('$qtdir', 'lib')
53
54 test.subdir(qtpath)
55 test.subdir(libpath)
56          
57 test.write('SConstruct', """
58 from SCons.Options import BoolOption, EnumOption, ListOption, \
59    PackageOption, PathOption
60
61 list_of_libs = Split('x11 gl qt ical')
62 qtdir = r'%(qtpath)s'
63
64 opts = Options(args=ARGUMENTS)
65 opts.AddOptions(
66     BoolOption('warnings', 'compilation with -Wall and similiar', 1),
67     BoolOption('profile', 'create profiling informations', 0),
68     EnumOption('debug', 'debug output and symbols', 'no',
69                allowed_values=('yes', 'no', 'full'),
70                map={}, ignorecase=0),  # case sensitive
71     EnumOption('guilib', 'gui lib to use', 'gtk',
72                allowed_values=('motif', 'gtk', 'kde'),
73                map={}, ignorecase=1), # case insensitive
74     EnumOption('some', 'some option', 'xaver',
75                allowed_values=('xaver', 'eins'),
76                map={}, ignorecase=2), # make lowercase
77     ListOption('shared',
78                'libraries to build as shared libraries',
79                'all',
80                names = list_of_libs),
81     PackageOption('x11',
82                   'use X11 installed here (yes = search some places)',
83                   'yes'),
84     PathOption('qtdir', 'where the root of Qt is installed', qtdir),
85     PathOption('qt_libraries',
86                'where the Qt library is installed',
87                r'%(libdirvar)s'),
88     )
89
90 env = Environment(options=opts)
91 Help(opts.GenerateHelpText(env))
92
93 print env['warnings']
94 print env['profile']
95
96 Default(env.Alias('dummy', None))
97 """ % locals())
98
99
100 test.run(arguments='-h',
101          stdout = """\
102 scons: Reading SConscript files ...
103 %(str_True)s
104 %(str_False)s
105 scons: done reading SConscript files.
106
107 warnings: compilation with -Wall and similiar (yes|no)
108     default: 1
109     actual: %(str_True)s
110
111 profile: create profiling informations (yes|no)
112     default: 0
113     actual: %(str_False)s
114
115 debug: debug output and symbols (yes|no|full)
116     default: no
117     actual: no
118
119 guilib: gui lib to use (motif|gtk|kde)
120     default: gtk
121     actual: gtk
122
123 some: some option (xaver|eins)
124     default: xaver
125     actual: xaver
126
127 shared: libraries to build as shared libraries
128     (all|none|comma-separated list of names)
129     allowed names: x11 gl qt ical
130     default: all
131     actual: x11 gl qt ical
132
133 x11: use X11 installed here (yes = search some places)
134     ( yes | no | /path/to/x11 )
135     default: yes
136     actual: %(str_True)s
137
138 qtdir: where the root of Qt is installed ( /path/to/qtdir )
139     default: %(qtpath)s
140     actual: %(qtpath)s
141
142 qt_libraries: where the Qt library is installed ( /path/to/qt_libraries )
143     default: %(libdirvar)s
144     actual: %(libpath)s
145
146 Use scons -H for help about command-line options.
147 """ % locals())
148
149
150
151 test.pass_test()