swrap: Add swrap_msghdr_add_cmsghdr().
[Samba.git] / lib / tdb / wscript
blob885548d7262dec0175b690567058b461a6d3bb62
1 #!/usr/bin/env python
3 APPNAME = 'tdb'
4 VERSION = '1.3.0'
6 blddir = 'bin'
8 import sys, os
10 # find the buildtools directory
11 srcdir = '.'
12 while not os.path.exists(srcdir+'/buildtools') and len(srcdir.split('/')) < 5:
13 srcdir = '../' + srcdir
14 sys.path.insert(0, srcdir + '/buildtools/wafsamba')
16 import wafsamba, samba_dist, Options, Logs
18 samba_dist.DIST_DIRS('lib/tdb:. lib/replace:lib/replace buildtools:buildtools')
20 tdb1_unit_tests = [
21 'run-3G-file',
22 'run-bad-tdb-header',
23 'run',
24 'run-check',
25 'run-corrupt',
26 'run-die-during-transaction',
27 'run-endian',
28 'run-incompatible',
29 'run-nested-transactions',
30 'run-nested-traverse',
31 'run-no-lock-during-traverse',
32 'run-oldhash',
33 'run-open-during-transaction',
34 'run-readonly-check',
35 'run-rescue',
36 'run-rescue-find_entry',
37 'run-rwlock-check',
38 'run-summary',
39 'run-transaction-expand',
40 'run-traverse-in-transaction',
41 'run-wronghash-fail',
42 'run-zero-append',
43 'run-marklock-deadlock',
44 'run-mutex-openflags2',
45 'run-mutex-trylock',
46 'run-mutex-allrecord-bench',
47 'run-mutex-allrecord-trylock',
48 'run-mutex-allrecord-block',
49 'run-mutex-die',
50 'run-mutex1',
53 def set_options(opt):
54 opt.BUILTIN_DEFAULT('replace')
55 opt.PRIVATE_EXTENSION_DEFAULT('tdb', noextension='tdb')
56 opt.RECURSE('lib/replace')
57 opt.add_option('--disable-tdb-mutex-locking',
58 help=("Disable the use of pthread robust mutexes"),
59 action="store_true", dest='disable_tdb_mutex_locking',
60 default=False)
61 if opt.IN_LAUNCH_DIR():
62 opt.add_option('--disable-python',
63 help=("disable the pytdb module"),
64 action="store_true", dest='disable_python', default=False)
67 def configure(conf):
68 conf.env.disable_tdb_mutex_locking = getattr(Options.options,
69 'disable_tdb_mutex_locking',
70 False)
71 if not conf.env.disable_tdb_mutex_locking:
72 conf.env.replace_add_global_pthread = True
73 conf.RECURSE('lib/replace')
75 conf.env.standalone_tdb = conf.IN_LAUNCH_DIR()
76 conf.env.building_tdb = True
78 if not conf.env.standalone_tdb:
79 if conf.CHECK_BUNDLED_SYSTEM_PKG('tdb', minversion=VERSION,
80 implied_deps='replace'):
81 conf.define('USING_SYSTEM_TDB', 1)
82 conf.env.building_tdb = False
83 if conf.CHECK_BUNDLED_SYSTEM_PYTHON('pytdb', 'tdb', minversion=VERSION):
84 conf.define('USING_SYSTEM_PYTDB', 1)
86 conf.env.disable_python = getattr(Options.options, 'disable_python', False)
88 if (conf.CONFIG_SET('HAVE_ROBUST_MUTEXES') and
89 conf.env.building_tdb and
90 not conf.env.disable_tdb_mutex_locking):
91 conf.define('USE_TDB_MUTEX_LOCKING', 1)
93 conf.CHECK_XSLTPROC_MANPAGES()
95 if not conf.env.disable_python:
96 # also disable if we don't have the python libs installed
97 conf.find_program('python', var='PYTHON')
98 conf.check_tool('python')
99 conf.check_python_version((2,4,2))
100 conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=False)
101 if not conf.env.HAVE_PYTHON_H:
102 Logs.warn('Disabling pytdb as python devel libs not found')
103 conf.env.disable_python = True
105 conf.SAMBA_CONFIG_H()
107 conf.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
109 def build(bld):
110 bld.RECURSE('lib/replace')
112 COMMON_FILES='''check.c error.c tdb.c traverse.c
113 freelistcheck.c lock.c dump.c freelist.c
114 io.c open.c transaction.c hash.c summary.c rescue.c
115 mutex.c'''
117 COMMON_SRC = bld.SUBDIR('common', COMMON_FILES)
119 if bld.env.standalone_tdb:
120 bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
121 private_library = False
122 else:
123 private_library = True
125 if not bld.CONFIG_SET('USING_SYSTEM_TDB'):
127 tdb_deps = 'replace'
129 if bld.CONFIG_SET('USE_TDB_MUTEX_LOCKING'):
130 tdb_deps += ' pthread'
132 bld.SAMBA_LIBRARY('tdb',
133 COMMON_SRC,
134 deps=tdb_deps,
135 includes='include',
136 abi_directory='ABI',
137 abi_match='tdb_*',
138 hide_symbols=True,
139 vnum=VERSION,
140 public_headers='include/tdb.h',
141 public_headers_install=not private_library,
142 pc_files='tdb.pc',
143 private_library=private_library)
145 bld.SAMBA_BINARY('tdbtorture',
146 'tools/tdbtorture.c',
147 'tdb',
148 install=False)
150 bld.SAMBA_BINARY('tdbrestore',
151 'tools/tdbrestore.c',
152 'tdb', manpages='man/tdbrestore.8')
154 bld.SAMBA_BINARY('tdbdump',
155 'tools/tdbdump.c',
156 'tdb', manpages='man/tdbdump.8')
158 bld.SAMBA_BINARY('tdbbackup',
159 'tools/tdbbackup.c',
160 'tdb',
161 manpages='man/tdbbackup.8')
163 bld.SAMBA_BINARY('tdbtool',
164 'tools/tdbtool.c',
165 'tdb', manpages='man/tdbtool.8')
167 # FIXME: This hardcoded list is stupid, stupid, stupid.
168 bld.SAMBA_SUBSYSTEM('tdb-test-helpers',
169 'test/external-agent.c test/lock-tracking.c test/logging.c',
170 tdb_deps,
171 includes='include')
173 for t in tdb1_unit_tests:
174 b = "tdb1-" + t
175 s = "test/" + t + ".c"
176 bld.SAMBA_BINARY(b, s, 'replace tdb-test-helpers',
177 includes='include', install=False)
179 if not bld.CONFIG_SET('USING_SYSTEM_PYTDB'):
180 bld.SAMBA_PYTHON('pytdb',
181 'pytdb.c',
182 deps='tdb',
183 enabled=not bld.env.disable_python,
184 realname='tdb.so',
185 cflags='-DPACKAGE_VERSION=\"%s\"' % VERSION)
187 def testonly(ctx):
188 '''run tdb testsuite'''
189 import Utils, samba_utils, shutil
190 ecode = 0
192 test_prefix = "%s/st" % (Utils.g_module.blddir)
193 shutil.rmtree(test_prefix, ignore_errors=True)
194 os.makedirs(test_prefix)
195 os.environ['TEST_DATA_PREFIX'] = test_prefix
197 env = samba_utils.LOAD_ENVIRONMENT()
198 # FIXME: This is horrible :(
199 if env.building_tdb:
200 # Create scratch directory for tests.
201 testdir = os.path.join(test_prefix, 'tdb-tests')
202 samba_utils.mkdir_p(testdir)
203 # Symlink back to source dir so it can find tests in test/
204 link = os.path.join(testdir, 'test')
205 if not os.path.exists(link):
206 os.symlink(os.path.abspath(os.path.join(env.cwd, 'test')), link)
208 for t in tdb1_unit_tests:
209 f = "tdb1-" + t
210 cmd = "cd " + testdir + " && " + os.path.abspath(os.path.join(Utils.g_module.blddir, f)) + " > test-output 2>&1"
211 print("..." + f)
212 ret = samba_utils.RUN_COMMAND(cmd)
213 if ret != 0:
214 print("%s failed:" % f)
215 samba_utils.RUN_COMMAND("cat " + os.path.join(testdir, 'test-output'))
216 ecode = ret
217 break
219 if ecode == 0:
220 cmd = os.path.join(Utils.g_module.blddir, 'tdbtorture')
221 ret = samba_utils.RUN_COMMAND(cmd)
222 print("testsuite returned %d" % ret)
223 if ret != 0:
224 ecode = ret
225 sys.exit(ecode)
227 # WAF doesn't build the unit tests for this, maybe because they don't link with tdb?
228 # This forces it
229 def test(ctx):
230 import Scripting
231 Scripting.commands.append('build')
232 Scripting.commands.append('testonly')
234 def dist():
235 '''makes a tarball for distribution'''
236 samba_dist.dist()
238 def reconfigure(ctx):
239 '''reconfigure if config scripts have changed'''
240 import samba_utils
241 samba_utils.reconfigure(ctx)