s3:smbd: add a fsp_persistent_id() function
[Samba.git] / lib / tdb2 / wscript
blobb925893cb4c857e7706ddca15384808b36d0a779
1 #!/usr/bin/env python
3 APPNAME = 'tdb'
4 VERSION = '2.0.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, glob
18 samba_dist.DIST_DIRS('lib/tdb2:. lib/replace:lib/replace lib/ccan:lib/ccan buildtools:buildtools')
20 def set_options(opt):
21 opt.BUILTIN_DEFAULT('replace,ccan')
22 opt.PRIVATE_EXTENSION_DEFAULT('tdb2', noextension='tdb2')
23 opt.RECURSE('lib/replace')
24 opt.add_option('--enable-developer',
25 help=("Turn on developer warnings and debugging"),
26 action="store_true", dest='developer', default=False)
27 opt.add_option('--enable-tdb2',
28 help=("Use tdb2 API instead of tdb1 [True]"),
29 action="store_true", dest='BUILD_TDB2', default=True)
30 opt.add_option('--disable-tdb2',
31 help=("Use old tdb1 API instead of tdb2"),
32 action="store_false", dest='BUILD_TDB2')
33 opt.add_option('--valgrind',
34 help=("use valgrind on tests programs"),
35 action="store_true", dest='VALGRIND', default=False)
36 opt.add_option('--valgrind-log',
37 help=("where to put the valgrind log"),
38 action="store", dest='VALGRINDLOG', default=None)
39 if opt.IN_LAUNCH_DIR():
40 opt.add_option('--disable-python',
41 help=("disable the pytdb module"),
42 action="store_true", dest='disable_python', default=False)
44 def configure(conf):
45 if Options.options.developer:
46 conf.env.DEVELOPER_MODE = True
48 conf.env.TEST_RUN_SRC=['test/run-001-encode.c',
49 'test/run-001-fls.c',
50 'test/run-01-new_database.c',
51 'test/run-02-expand.c',
52 'test/run-03-coalesce.c',
53 'test/run-04-basichash.c',
54 'test/run-05-readonly-open.c',
55 'test/run-10-simple-store.c',
56 'test/run-11-simple-fetch.c',
57 'test/run-12-check.c',
58 'test/run-15-append.c',
59 'test/run-20-growhash.c',
60 'test/run-25-hashoverload.c',
61 'test/run-30-exhaust-before-expand.c',
62 'test/run-35-convert.c',
63 'test/run-50-multiple-freelists.c',
64 'test/run-56-open-during-transaction.c',
65 'test/run-57-die-during-transaction.c',
66 'test/run-64-bit-tdb.c',
67 'test/run-90-get-set-attributes.c',
68 'test/run-capabilities.c',
69 'test/run-expand-in-transaction.c',
70 'test/run-features.c',
71 'test/run-lockall.c',
72 'test/run-remap-in-read_traverse.c',
73 'test/run-seed.c',
74 'test/run-tdb1-3G-file.c',
75 'test/run-tdb1-bad-tdb-header.c',
76 'test/run-tdb1.c',
77 'test/run-tdb1-check.c',
78 'test/run-tdb1-corrupt.c',
79 'test/run-tdb1-endian.c',
80 'test/run-tdb1-hashsize.c',
81 'test/run-tdb1-incompatible.c',
82 'test/run-tdb1-nested-transactions.c',
83 'test/run-tdb1-nested-traverse.c',
84 'test/run-tdb1-no-lock-during-traverse.c',
85 'test/run-tdb1-oldhash.c',
86 'test/run-tdb1-readonly-check.c',
87 'test/run-tdb1-rwlock-check.c',
88 'test/run-tdb1-seqnum-wrap.c',
89 'test/run-tdb1-summary.c',
90 'test/run-tdb1-traverse-in-transaction.c',
91 'test/run-tdb1-wronghash-fail.c',
92 'test/run-tdb1-zero-append.c',
93 'test/run-tdb_errorstr.c',
94 'test/run-tdb_foreach.c',
95 'test/run-traverse.c']
96 conf.env.TEST_API_SRC=['test/api-12-store.c',
97 'test/api-13-delete.c',
98 'test/api-14-exists.c',
99 'test/api-16-wipe_all.c',
100 'test/api-21-parse_record.c',
101 'test/api-55-transaction.c',
102 'test/api-80-tdb_fd.c',
103 'test/api-81-seqnum.c',
104 'test/api-82-lockattr.c',
105 'test/api-83-openhook.c',
106 'test/api-91-get-stats.c',
107 'test/api-92-get-set-readonly.c',
108 'test/api-93-repack.c',
109 'test/api-add-remove-flags.c',
110 'test/api-check-callback.c',
111 'test/api-firstkey-nextkey.c',
112 'test/api-fork-test.c',
113 'test/api-locktimeout.c',
114 'test/api-missing-entries.c',
115 'test/api-open-multiple-times.c',
116 'test/api-record-expand.c',
117 'test/api-simple-delete.c',
118 'test/api-summary.c',
119 'test/api-tdb1-flag-removal.c']
120 conf.env.TEST_API_HELPER_SRC=['test/helpapi-external-agent.c']
121 conf.env.TEST_RUN_HELPER_SRC=['test/helprun-external-agent.c',
122 'test/helprun-layout.c']
123 conf.env.TEST_HELPER_SRC=['test/external-agent.c',
124 'test/failtest_helper.c',
125 'test/lock-tracking.c',
126 'test/logging.c',
127 'test/tap-interface.c',
128 'test/tdb1-external-agent.c',
129 'test/tdb1-lock-tracking.c']
131 if Options.options.BUILD_TDB2:
132 conf.DEFINE('BUILD_TDB2', 1)
133 conf.RECURSE('lib/replace')
134 conf.RECURSE('lib/ccan')
136 conf.env.standalone_tdb2 = conf.IN_LAUNCH_DIR()
137 conf.env.disable_python = getattr(Options.options, 'disable_python', False)
139 if not conf.env.standalone_tdb2:
140 if conf.CHECK_BUNDLED_SYSTEM('tdb', minversion=VERSION,
141 implied_deps='replace'):
142 conf.define('USING_SYSTEM_TDB2', 1)
143 if conf.CHECK_BUNDLED_SYSTEM_PYTHON('pytdb', 'tdb', minversion=VERSION):
144 conf.define('USING_SYSTEM_PYTDB', 1)
146 if not conf.env.disable_python:
147 # also disable if we don't have the python libs installed
148 conf.find_program('python', var='PYTHON')
149 conf.check_tool('python')
150 conf.check_python_version((2,4,2))
151 conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=False)
152 if not conf.env.HAVE_PYTHON_H:
153 Logs.warn('Disabling pytdb as python devel libs not found')
154 conf.env.disable_python = True
156 # This make #include <ccan/...> work.
157 conf.ADD_EXTRA_INCLUDES('''#lib''')
159 conf.SAMBA_CONFIG_H()
161 def build(bld):
162 if bld.env.BUILD_TDB2:
163 bld.RECURSE('lib/replace')
164 bld.RECURSE('lib/ccan')
166 if bld.env.standalone_tdb2:
167 bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
168 private_library = False
169 else:
170 private_library = True
172 SRC = '''check.c free.c hash.c io.c lock.c open.c
173 summary.c tdb.c transaction.c traverse.c
174 tdb1_check.c tdb1_freelist.c tdb1_hash.c
175 tdb1_io.c tdb1_lock.c tdb1_open.c
176 tdb1_summary.c tdb1_tdb.c tdb1_transaction.c
177 tdb1_traverse.c'''
179 if not bld.CONFIG_SET('USING_SYSTEM_TDB2'):
180 bld.SAMBA_LIBRARY('tdb',
181 SRC,
182 deps='replace ccan',
183 includes='.',
184 abi_directory='ABI',
185 abi_match='tdb_* tdb1_incompatible_hash',
186 hide_symbols=True,
187 vnum=VERSION,
188 public_headers='tdb2.h',
189 public_headers_install=not private_library,
190 pc_files='tdb.pc',
191 private_library=private_library)
193 bld.SAMBA_BINARY('tdbtorture',
194 'tools/tdb2torture.c',
195 deps='tdb',
196 install=False)
198 bld.SAMBA_BINARY('tdbtool',
199 'tools/tdb2tool.c',
200 deps='tdb')
202 bld.SAMBA_BINARY('tdbdump',
203 'tools/tdb2dump.c',
204 deps='tdb')
206 bld.SAMBA_BINARY('tdbrestore',
207 'tools/tdb2restore.c',
208 deps='tdb')
210 bld.SAMBA_BINARY('tdbbackup',
211 'tools/tdb2backup.c',
212 deps='tdb')
214 if not bld.CONFIG_SET('USING_SYSTEM_PYTDB'):
215 bld.SAMBA_PYTHON('pytdb',
216 source='pytdb.c',
217 deps='tdb',
218 enabled=not bld.env.disable_python,
219 realname='tdb.so',
220 cflags='-DPACKAGE_VERSION=\"%s\"' % VERSION)
222 if bld.env.DEVELOPER_MODE:
223 # FIXME: We need CCAN for some API tests, but waf thinks it's
224 # already available via tdb2. It is, but not publicly.
225 # Workaround is to build a private, non-hiding version.
226 bld.SAMBA_SUBSYSTEM('tdb2-testing',
227 SRC,
228 deps='replace ccan',
229 includes='.')
231 bld.SAMBA_SUBSYSTEM('tdb2-test-helpers', bld.env.TEST_HELPER_SRC,
232 deps='replace')
233 bld.SAMBA_SUBSYSTEM('tdb2-run-helpers', bld.env.TEST_RUN_HELPER_SRC,
234 deps='replace')
235 bld.SAMBA_SUBSYSTEM('tdb2-api-helpers', bld.env.TEST_API_HELPER_SRC,
236 deps='replace tdb2-testing')
238 for f in bld.env.TEST_RUN_SRC:
239 base = os.path.splitext(os.path.basename(f))[0]
240 bld.SAMBA_BINARY('tdb2-' + base, f,
241 deps='ccan replace tdb2-test-helpers tdb2-run-helpers ccan-failtest',
242 install=False)
244 for f in bld.env.TEST_API_SRC:
245 base = os.path.splitext(os.path.basename(f))[0]
246 bld.SAMBA_BINARY('tdb2-' + base, f,
247 deps='ccan replace tdb2-test-helpers tdb2-api-helpers',
248 install=False)
250 def testonly(ctx):
251 '''run tdb2 testsuite'''
252 import Utils, samba_utils, shutil
253 ecode = 0;
255 env = samba_utils.LOAD_ENVIRONMENT()
257 if env.BUILD_TDB2 and env.standalone_tdb2 and env.DEVELOPER_MODE:
259 # FIXME: This is horrible :(
260 test_prefix = "%s/st" % (Utils.g_module.blddir)
261 shutil.rmtree(test_prefix, ignore_errors=True)
262 os.makedirs(test_prefix)
264 # Create scratch directory for tests.
265 testdir = os.path.join(test_prefix, 'tdb2-tests')
266 samba_utils.mkdir_p(testdir)
267 # Symlink back to source dir so it can find tests in test/
268 link = os.path.join(testdir, 'test')
269 if not os.path.exists(link):
270 os.symlink(os.path.abspath(os.path.join(env.cwd, 'test')), link)
272 if Options.options.VALGRIND:
273 os.environ['VALGRIND'] = 'valgrind -q --num-callers=30'
274 if Options.options.VALGRINDLOG is not None:
275 os.environ['VALGRIND'] += ' --log-file=%s' % Options.options.VALGRINDLOG
277 for f in env.TEST_RUN_SRC + env.TEST_API_SRC:
278 name = "tdb2-" + os.path.splitext(os.path.basename(f))[0]
279 cmd = "cd " + testdir + " && $VALGRIND " + os.path.abspath(os.path.join(Utils.g_module.blddir, name)) + " > test-output 2>&1"
280 print("..." + f)
281 ret = samba_utils.RUN_COMMAND(cmd)
282 if ret != 0:
283 print("%s (%s) failed:" % (name, f))
284 samba_utils.RUN_COMMAND("cat " + os.path.join(testdir, 'test-output'))
285 ecode = ret;
286 break;
288 sys.exit(ecode)
290 # WAF doesn't build the unit tests for this, maybe because they don't link with tdb?
291 # This forces it
292 def test(ctx):
293 import Scripting
294 Scripting.commands.append('build')
295 Scripting.commands.append('testonly')
297 def dist():
298 '''makes a tarball for distribution'''
299 samba_dist.dist()
301 def reconfigure(ctx):
302 '''reconfigure if config scripts have changed'''
303 import samba_utils
304 samba_utils.reconfigure(ctx)