8 # find the buildtools directory
10 while not os.path.exists(top+'/buildtools') and len(top.split('/')) < 5:
12 sys.path.insert(0, top + '/buildtools/wafsamba')
17 from wafsamba import samba_dist, samba_utils
18 from waflib import Options, Logs, Context
21 samba_dist.DIST_DIRS('lib/tdb:. lib/replace:lib/replace buildtools:buildtools third_party/waf:third_party/waf')
29 'run-die-during-transaction',
32 'run-nested-transactions',
33 'run-nested-traverse',
34 'run-no-lock-during-traverse',
36 'run-open-during-transaction',
39 'run-rescue-find_entry',
43 'run-transaction-expand',
44 'run-traverse-in-transaction',
48 'run-marklock-deadlock',
49 'run-allrecord-traverse-deadlock',
50 'run-mutex-openflags2',
52 'run-mutex-allrecord-bench',
53 'run-mutex-allrecord-trylock',
54 'run-mutex-allrecord-block',
55 'run-mutex-transaction1',
59 'run-circular-freelist',
63 opt.BUILTIN_DEFAULT('replace')
64 opt.PRIVATE_EXTENSION_DEFAULT('tdb', noextension='tdb')
65 opt.RECURSE('lib/replace')
66 opt.add_option('--disable-tdb-mutex-locking',
67 help=("Disable the use of pthread robust mutexes"),
68 action="store_true", dest='disable_tdb_mutex_locking',
73 conf.env.disable_tdb_mutex_locking = getattr(Options.options,
74 'disable_tdb_mutex_locking',
76 if not conf.env.disable_tdb_mutex_locking:
77 conf.env.replace_add_global_pthread = True
78 conf.RECURSE('lib/replace')
80 conf.env.standalone_tdb = conf.IN_LAUNCH_DIR()
81 conf.env.building_tdb = True
83 if not conf.env.standalone_tdb:
84 if conf.CHECK_BUNDLED_SYSTEM_PKG('tdb', minversion=VERSION,
85 implied_deps='replace'):
86 conf.define('USING_SYSTEM_TDB', 1)
87 conf.env.building_tdb = False
88 if not conf.env.disable_python and \
89 conf.CHECK_BUNDLED_SYSTEM_PYTHON('pytdb', 'tdb', minversion=VERSION):
90 conf.define('USING_SYSTEM_PYTDB', 1)
92 if (conf.CONFIG_SET('HAVE_ROBUST_MUTEXES') and
93 conf.env.building_tdb and
94 not conf.env.disable_tdb_mutex_locking):
95 conf.define('USE_TDB_MUTEX_LOCKING', 1)
97 conf.CHECK_XSLTPROC_MANPAGES()
99 if not conf.env.disable_python:
100 # also disable if we don't have the python libs installed
101 conf.SAMBA_CHECK_PYTHON(mandatory=False)
102 conf.check_python_version((2,4,2))
103 conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=False)
104 if not conf.env.HAVE_PYTHON_H:
105 Logs.warn('Disabling pytdb as python devel libs not found')
106 conf.env.disable_python = True
108 conf.SAMBA_CONFIG_H()
110 conf.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
113 bld.RECURSE('lib/replace')
115 COMMON_FILES='''check.c error.c tdb.c traverse.c
116 freelistcheck.c lock.c dump.c freelist.c
117 io.c open.c transaction.c hash.c summary.c rescue.c
120 COMMON_SRC = bld.SUBDIR('common', COMMON_FILES)
122 if bld.env.standalone_tdb:
123 bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
124 private_library = False
126 private_library = True
128 if not bld.CONFIG_SET('USING_SYSTEM_TDB'):
132 if bld.CONFIG_SET('USE_TDB_MUTEX_LOCKING'):
133 tdb_deps += ' pthread'
135 bld.SAMBA_LIBRARY('tdb',
143 public_headers=('' if private_library else 'include/tdb.h'),
144 public_headers_install=not private_library,
146 private_library=private_library)
148 bld.SAMBA_BINARY('tdbtorture',
149 'tools/tdbtorture.c',
153 bld.SAMBA_BINARY('tdbrestore',
154 'tools/tdbrestore.c',
155 'tdb', manpages='man/tdbrestore.8')
157 bld.SAMBA_BINARY('tdbdump',
159 'tdb', manpages='man/tdbdump.8')
161 bld.SAMBA_BINARY('tdbbackup',
164 manpages='man/tdbbackup.8')
166 bld.SAMBA_BINARY('tdbtool',
168 'tdb', manpages='man/tdbtool.8')
170 if bld.env.standalone_tdb:
171 # FIXME: This hardcoded list is stupid, stupid, stupid.
172 bld.SAMBA_SUBSYSTEM('tdb-test-helpers',
173 'test/external-agent.c test/lock-tracking.c test/logging.c',
177 for t in tdb1_unit_tests:
179 s = "test/" + t + ".c"
180 bld.SAMBA_BINARY(b, s, 'replace tdb-test-helpers',
181 includes='include', install=False)
183 if not bld.CONFIG_SET('USING_SYSTEM_PYTDB'):
184 for env in bld.gen_python_environments(['PKGCONFIGDIR']):
185 bld.SAMBA_PYTHON('pytdb',
188 enabled=not bld.env.disable_python,
190 cflags='-DPACKAGE_VERSION=\"%s\"' % VERSION)
192 if not bld.env.disable_python:
193 for env in bld.gen_python_environments(['PKGCONFIGDIR']):
194 bld.SAMBA_SCRIPT('_tdb_text.py',
195 pattern='_tdb_text.py',
198 bld.INSTALL_FILES('${PYTHONARCHDIR}', '_tdb_text.py')
201 '''run tdb testsuite'''
204 blddir = Context.g_module.out
205 test_prefix = "%s/st" % (blddir)
206 shutil.rmtree(test_prefix, ignore_errors=True)
207 os.makedirs(test_prefix)
208 os.environ['TEST_DATA_PREFIX'] = test_prefix
210 env = samba_utils.LOAD_ENVIRONMENT()
211 # FIXME: This is horrible :(
213 # Create scratch directory for tests.
214 testdir = os.path.join(test_prefix, 'tdb-tests')
215 samba_utils.mkdir_p(testdir)
216 # Symlink back to source dir so it can find tests in test/
217 link = os.path.join(testdir, 'test')
218 if not os.path.exists(link):
219 os.symlink(ctx.path.make_node('test').abspath(), link)
221 sh_tests = ["test/test_tdbbackup.sh test/jenkins-be-hash.tdb"]
223 for sh_test in sh_tests:
224 cmd = "BINDIR={} {}".format(blddir, sh_test)
225 print("shell test: " + cmd)
226 ret = samba_utils.RUN_COMMAND(cmd)
228 print("%s sh test failed" % cmd)
232 for t in tdb1_unit_tests:
234 cmd = "cd " + testdir + " && " + os.path.abspath(os.path.join(blddir, f)) + " > test-output 2>&1"
236 ret = samba_utils.RUN_COMMAND(cmd)
238 print("%s failed:" % f)
239 samba_utils.RUN_COMMAND("cat " + os.path.join(testdir, 'test-output'))
244 cmd = os.path.join(blddir, 'tdbtorture')
245 ret = samba_utils.RUN_COMMAND(cmd)
246 print("testsuite returned %d" % ret)
250 pyret = samba_utils.RUN_PYTHON_TESTS(['python/tests/simple.py'])
251 print("python testsuite returned %d" % pyret)
252 sys.exit(ecode or pyret)
254 # WAF doesn't build the unit tests for this, maybe because they don't link with tdb?
257 Options.commands.append('build')
258 Options.commands.append('testonly')
261 '''makes a tarball for distribution'''
264 def reconfigure(ctx):
265 '''reconfigure if config scripts have changed'''
266 samba_utils.reconfigure(ctx)