10 # find the buildtools directory
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')
26 'run-die-during-transaction',
29 'run-nested-transactions',
30 'run-nested-traverse',
31 'run-no-lock-during-traverse',
33 'run-open-during-transaction',
36 'run-rescue-find_entry',
39 'run-transaction-expand',
40 'run-traverse-in-transaction',
43 'run-marklock-deadlock',
44 'run-mutex-openflags2',
46 'run-mutex-allrecord-bench',
47 'run-mutex-allrecord-trylock',
48 'run-mutex-allrecord-block',
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',
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)
68 conf
.env
.disable_tdb_mutex_locking
= getattr(Options
.options
,
69 'disable_tdb_mutex_locking',
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()
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
117 COMMON_SRC
= bld
.SUBDIR('common', COMMON_FILES
)
119 if bld
.env
.standalone_tdb
:
120 bld
.env
.PKGCONFIGDIR
= '${LIBDIR}/pkgconfig'
121 private_library
= False
123 private_library
= True
125 if not bld
.CONFIG_SET('USING_SYSTEM_TDB'):
129 if bld
.CONFIG_SET('USE_TDB_MUTEX_LOCKING'):
130 tdb_deps
+= ' pthread'
132 bld
.SAMBA_LIBRARY('tdb',
140 public_headers
='include/tdb.h',
141 public_headers_install
=not private_library
,
143 private_library
=private_library
)
145 bld
.SAMBA_BINARY('tdbtorture',
146 'tools/tdbtorture.c',
150 bld
.SAMBA_BINARY('tdbrestore',
151 'tools/tdbrestore.c',
152 'tdb', manpages
='man/tdbrestore.8')
154 bld
.SAMBA_BINARY('tdbdump',
156 'tdb', manpages
='man/tdbdump.8')
158 bld
.SAMBA_BINARY('tdbbackup',
161 manpages
='man/tdbbackup.8')
163 bld
.SAMBA_BINARY('tdbtool',
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',
173 for t
in tdb1_unit_tests
:
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',
183 enabled
=not bld
.env
.disable_python
,
185 cflags
='-DPACKAGE_VERSION=\"%s\"' % VERSION
)
188 '''run tdb testsuite'''
189 import Utils
, samba_utils
, shutil
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 :(
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
:
210 cmd
= "cd " + testdir
+ " && " + os
.path
.abspath(os
.path
.join(Utils
.g_module
.blddir
, f
)) + " > test-output 2>&1"
212 ret
= samba_utils
.RUN_COMMAND(cmd
)
214 print("%s failed:" % f
)
215 samba_utils
.RUN_COMMAND("cat " + os
.path
.join(testdir
, 'test-output'))
220 cmd
= os
.path
.join(Utils
.g_module
.blddir
, 'tdbtorture')
221 ret
= samba_utils
.RUN_COMMAND(cmd
)
222 print("testsuite returned %d" % ret
)
227 # WAF doesn't build the unit tests for this, maybe because they don't link with tdb?
231 Scripting
.commands
.append('build')
232 Scripting
.commands
.append('testonly')
235 '''makes a tarball for distribution'''
238 def reconfigure(ctx
):
239 '''reconfigure if config scripts have changed'''
241 samba_utils
.reconfigure(ctx
)