autorid: introduce idmap_autorid_domsid_is_for_alloc()
[Samba.git] / lib / tdb / wscript
blob70196938ed2e9c6c8fc7645c9f224b6a0676b741
1 #!/usr/bin/env python
3 APPNAME = 'tdb'
4 VERSION = '1.2.13'
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'
45 def set_options(opt):
46 opt.BUILTIN_DEFAULT('replace')
47 opt.PRIVATE_EXTENSION_DEFAULT('tdb', noextension='tdb')
48 opt.RECURSE('lib/replace')
49 if opt.IN_LAUNCH_DIR():
50 opt.add_option('--disable-python',
51 help=("disable the pytdb module"),
52 action="store_true", dest='disable_python', default=False)
55 def configure(conf):
56 conf.RECURSE('lib/replace')
58 conf.env.standalone_tdb = conf.IN_LAUNCH_DIR()
59 conf.env.building_tdb = True
61 if not conf.env.standalone_tdb:
62 if conf.CHECK_BUNDLED_SYSTEM_PKG('tdb', minversion=VERSION,
63 implied_deps='replace'):
64 conf.define('USING_SYSTEM_TDB', 1)
65 conf.env.building_tdb = False
66 if conf.CHECK_BUNDLED_SYSTEM_PYTHON('pytdb', 'tdb', minversion=VERSION):
67 conf.define('USING_SYSTEM_PYTDB', 1)
69 conf.env.disable_python = getattr(Options.options, 'disable_python', False)
71 conf.CHECK_XSLTPROC_MANPAGES()
73 if not conf.env.disable_python:
74 # also disable if we don't have the python libs installed
75 conf.find_program('python', var='PYTHON')
76 conf.check_tool('python')
77 conf.check_python_version((2,4,2))
78 conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=False)
79 if not conf.env.HAVE_PYTHON_H:
80 Logs.warn('Disabling pytdb as python devel libs not found')
81 conf.env.disable_python = True
83 conf.SAMBA_CONFIG_H()
85 conf.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
87 def build(bld):
88 bld.RECURSE('lib/replace')
90 COMMON_SRC = bld.SUBDIR('common',
91 '''check.c error.c tdb.c traverse.c
92 freelistcheck.c lock.c dump.c freelist.c
93 io.c open.c transaction.c hash.c summary.c rescue.c''')
95 if bld.env.standalone_tdb:
96 bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
97 private_library = False
98 else:
99 private_library = True
101 if not bld.CONFIG_SET('USING_SYSTEM_TDB'):
102 bld.SAMBA_LIBRARY('tdb',
103 COMMON_SRC,
104 deps='replace',
105 includes='include',
106 abi_directory='ABI',
107 abi_match='tdb_*',
108 hide_symbols=True,
109 vnum=VERSION,
110 public_headers='include/tdb.h',
111 public_headers_install=not private_library,
112 pc_files='tdb.pc',
113 private_library=private_library)
115 bld.SAMBA_BINARY('tdbtorture',
116 'tools/tdbtorture.c',
117 'tdb',
118 install=False)
120 bld.SAMBA_BINARY('tdbrestore',
121 'tools/tdbrestore.c',
122 'tdb', manpages='man/tdbrestore.8')
124 bld.SAMBA_BINARY('tdbdump',
125 'tools/tdbdump.c',
126 'tdb', manpages='man/tdbdump.8')
128 bld.SAMBA_BINARY('tdbbackup',
129 'tools/tdbbackup.c',
130 'tdb',
131 manpages='man/tdbbackup.8')
133 bld.SAMBA_BINARY('tdbtool',
134 'tools/tdbtool.c',
135 'tdb', manpages='man/tdbtool.8')
137 # FIXME: This hardcoded list is stupid, stupid, stupid.
138 bld.SAMBA_SUBSYSTEM('tdb-test-helpers',
139 'test/external-agent.c test/lock-tracking.c test/logging.c',
140 'replace',
141 includes='include')
143 for t in tdb1_unit_tests:
144 b = "tdb1-" + t
145 s = "test/" + t + ".c"
146 bld.SAMBA_BINARY(b, s, 'replace tdb-test-helpers',
147 includes='include', install=False)
149 if not bld.CONFIG_SET('USING_SYSTEM_PYTDB'):
150 bld.SAMBA_PYTHON('pytdb',
151 'pytdb.c',
152 deps='tdb',
153 enabled=not bld.env.disable_python,
154 realname='tdb.so',
155 cflags='-DPACKAGE_VERSION=\"%s\"' % VERSION)
157 def testonly(ctx):
158 '''run tdb testsuite'''
159 import Utils, samba_utils, shutil
160 ecode = 0
162 test_prefix = "%s/st" % (Utils.g_module.blddir)
163 shutil.rmtree(test_prefix, ignore_errors=True)
164 os.makedirs(test_prefix)
165 os.environ['TEST_DATA_PREFIX'] = test_prefix
167 env = samba_utils.LOAD_ENVIRONMENT()
168 # FIXME: This is horrible :(
169 if env.building_tdb:
170 # Create scratch directory for tests.
171 testdir = os.path.join(test_prefix, 'tdb-tests')
172 samba_utils.mkdir_p(testdir)
173 # Symlink back to source dir so it can find tests in test/
174 link = os.path.join(testdir, 'test')
175 if not os.path.exists(link):
176 os.symlink(os.path.abspath(os.path.join(env.cwd, 'test')), link)
178 for t in tdb1_unit_tests:
179 f = "tdb1-" + t
180 cmd = "cd " + testdir + " && " + os.path.abspath(os.path.join(Utils.g_module.blddir, f)) + " > test-output 2>&1"
181 print("..." + f)
182 ret = samba_utils.RUN_COMMAND(cmd)
183 if ret != 0:
184 print("%s failed:" % f)
185 samba_utils.RUN_COMMAND("cat " + os.path.join(testdir, 'test-output'))
186 ecode = ret
187 break
189 if ecode == 0:
190 cmd = os.path.join(Utils.g_module.blddir, 'tdbtorture')
191 ret = samba_utils.RUN_COMMAND(cmd)
192 print("testsuite returned %d" % ret)
193 if ret != 0:
194 ecode = ret
195 sys.exit(ecode)
197 # WAF doesn't build the unit tests for this, maybe because they don't link with tdb?
198 # This forces it
199 def test(ctx):
200 import Scripting
201 Scripting.commands.append('build')
202 Scripting.commands.append('testonly')
204 def dist():
205 '''makes a tarball for distribution'''
206 samba_dist.dist()
208 def reconfigure(ctx):
209 '''reconfigure if config scripts have changed'''
210 import samba_utils
211 samba_utils.reconfigure(ctx)