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:
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
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.
25 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
28 Verify creation of a config.h file from a Configure context.
37 test = TestSCons.TestSCons(match = TestSCons.match_exact)
39 lib = test.Configure_lib
40 LIB = "LIB" + string.upper(lib)
42 test.write('SConstruct', """\
45 env.AppendENVPath('PATH', os.environ['PATH'])
46 conf = Configure(env, config_h = 'config.h')
47 r1 = conf.CheckFunc('printf')
48 r2 = conf.CheckFunc('noFunctionCall')
49 r3 = conf.CheckType('int')
50 r4 = conf.CheckType('noType')
51 r5 = conf.CheckCHeader('stdio.h', '<>')
52 r6 = conf.CheckCHeader('hopefullynoc-header.h')
53 r7 = conf.CheckCXXHeader('vector', '<>')
54 r8 = conf.CheckCXXHeader('hopefullynocxx-header.h')
56 conf = Configure(env, config_h = 'config.h')
57 r9 = conf.CheckLib('%(lib)s', 'sin')
58 r10 = conf.CheckLib('hopefullynolib', 'sin')
59 r11 = conf.CheckLibWithHeader('%(lib)s', 'math.h', 'c')
60 r12 = conf.CheckLibWithHeader('%(lib)s', 'hopefullynoheader2.h', 'c')
61 r13 = conf.CheckLibWithHeader('hopefullynolib2', 'math.h', 'c')
65 expected_read_str = """\
66 Checking for C function printf()... yes
67 Checking for C function noFunctionCall()... no
68 Checking for C type int... yes
69 Checking for C type noType... no
70 Checking for C header file stdio.h... yes
71 Checking for C header file hopefullynoc-header.h... no
72 Checking for C++ header file vector... yes
73 Checking for C++ header file hopefullynocxx-header.h... no
74 Checking for sin() in C library %(lib)s... yes
75 Checking for sin() in C library hopefullynolib... no
76 Checking for C library %(lib)s... yes
77 Checking for C library %(lib)s... no
78 Checking for C library hopefullynolib2... no
81 expected_build_str = """\
82 scons: Configure: creating config.h
85 expected_stdout = test.wrap_stdout(build_str=expected_build_str,
86 read_str=expected_read_str)
88 expected_config_h = string.replace("""\
93 /* Define to 1 if the system has the function `printf'. */
96 /* Define to 1 if the system has the function `noFunctionCall'. */
97 /* #undef HAVE_NOFUNCTIONCALL */
99 /* Define to 1 if the system has the type `int'. */
102 /* Define to 1 if the system has the type `noType'. */
103 /* #undef HAVE_NOTYPE */
105 /* Define to 1 if you have the <stdio.h> header file. */
106 #define HAVE_STDIO_H 1
108 /* Define to 1 if you have the <hopefullynoc-header.h> header file. */
109 /* #undef HAVE_HOPEFULLYNOC_HEADER_H */
111 /* Define to 1 if you have the <vector> header file. */
112 #define HAVE_VECTOR 1
114 /* Define to 1 if you have the <hopefullynocxx-header.h> header file. */
115 /* #undef HAVE_HOPEFULLYNOCXX_HEADER_H */
117 /* Define to 1 if you have the `%(lib)s' library. */
118 #define HAVE_%(LIB)s 1
120 /* Define to 1 if you have the `hopefullynolib' library. */
121 /* #undef HAVE_LIBHOPEFULLYNOLIB */
123 /* Define to 1 if you have the `%(lib)s' library. */
124 #define HAVE_%(LIB)s 1
126 /* Define to 1 if you have the `%(lib)s' library. */
127 /* #undef HAVE_%(LIB)s */
129 /* Define to 1 if you have the `hopefullynolib2' library. */
130 /* #undef HAVE_LIBHOPEFULLYNOLIB2 */
132 #endif /* CONFIG_H_SEEN */
133 """ % locals(), "\n", os.linesep)
135 test.run(stdout=expected_stdout)
137 config_h = test.read(test.workpath('config.h'))
138 if expected_config_h != config_h:
139 print "Unexpected config.h"
141 print "---------------------------------------------------------"
142 print repr(expected_config_h)
143 print "---------------------------------------------------------"
145 print "---------------------------------------------------------"
147 print "---------------------------------------------------------"
149 print "---------------------------------------------------------"
151 print "---------------------------------------------------------"
154 expected_read_str = re.sub(r'\b((yes)|(no))\b',
157 expected_build_str = "scons: `.' is up to date.\n"
158 expected_stdout = test.wrap_stdout(build_str=expected_build_str,
159 read_str=expected_read_str)
160 #expected_stdout = string.replace(expected_stdout, "\n", os.linesep)
162 test.run(stdout=expected_stdout)
164 config_h = test.read(test.workpath('config.h'))
165 if expected_config_h != config_h:
166 print "Unexpected config.h"
168 print "---------------------------------------------------------"
169 print repr(expected_config_h)
170 print "---------------------------------------------------------"
172 print "---------------------------------------------------------"
174 print "---------------------------------------------------------"
176 print "---------------------------------------------------------"
178 print "---------------------------------------------------------"
185 # indent-tabs-mode:nil
187 # vim: set expandtab tabstop=4 shiftwidth=4: