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 third_party/waf:third_party/waf')
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',
40 'run-transaction-expand',
41 'run-traverse-in-transaction',
44 'run-marklock-deadlock',
45 'run-allrecord-traverse-deadlock',
46 'run-mutex-openflags2',
48 'run-mutex-allrecord-bench',
49 'run-mutex-allrecord-trylock',
50 'run-mutex-allrecord-block',
51 'run-mutex-transaction1',
57 opt
.BUILTIN_DEFAULT('replace')
58 opt
.PRIVATE_EXTENSION_DEFAULT('tdb', noextension
='tdb')
59 opt
.RECURSE('lib/replace')
60 opt
.add_option('--disable-tdb-mutex-locking',
61 help=("Disable the use of pthread robust mutexes"),
62 action
="store_true", dest
='disable_tdb_mutex_locking',
67 conf
.env
.disable_tdb_mutex_locking
= getattr(Options
.options
,
68 'disable_tdb_mutex_locking',
70 if not conf
.env
.disable_tdb_mutex_locking
:
71 conf
.env
.replace_add_global_pthread
= True
72 conf
.RECURSE('lib/replace')
74 conf
.env
.standalone_tdb
= conf
.IN_LAUNCH_DIR()
75 conf
.env
.building_tdb
= True
77 if not conf
.env
.standalone_tdb
:
78 if conf
.CHECK_BUNDLED_SYSTEM_PKG('tdb', minversion
=VERSION
,
79 implied_deps
='replace'):
80 conf
.define('USING_SYSTEM_TDB', 1)
81 conf
.env
.building_tdb
= False
82 if not conf
.env
.disable_python
and \
83 conf
.CHECK_BUNDLED_SYSTEM_PYTHON('pytdb', 'tdb', minversion
=VERSION
):
84 conf
.define('USING_SYSTEM_PYTDB', 1)
86 if (conf
.CONFIG_SET('HAVE_ROBUST_MUTEXES') and
87 conf
.env
.building_tdb
and
88 not conf
.env
.disable_tdb_mutex_locking
):
89 conf
.define('USE_TDB_MUTEX_LOCKING', 1)
91 conf
.CHECK_XSLTPROC_MANPAGES()
93 if not conf
.env
.disable_python
:
94 # also disable if we don't have the python libs installed
95 conf
.SAMBA_CHECK_PYTHON(mandatory
=False)
96 conf
.check_python_version((2,4,2))
97 conf
.SAMBA_CHECK_PYTHON_HEADERS(mandatory
=False)
98 if not conf
.env
.HAVE_PYTHON_H
:
99 Logs
.warn('Disabling pytdb as python devel libs not found')
100 conf
.env
.disable_python
= True
102 conf
.SAMBA_CONFIG_H()
104 conf
.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
107 bld
.RECURSE('lib/replace')
109 COMMON_FILES
='''check.c error.c tdb.c traverse.c
110 freelistcheck.c lock.c dump.c freelist.c
111 io.c open.c transaction.c hash.c summary.c rescue.c
114 COMMON_SRC
= bld
.SUBDIR('common', COMMON_FILES
)
116 if bld
.env
.standalone_tdb
:
117 bld
.env
.PKGCONFIGDIR
= '${LIBDIR}/pkgconfig'
118 private_library
= False
120 private_library
= True
122 if not bld
.CONFIG_SET('USING_SYSTEM_TDB'):
126 if bld
.CONFIG_SET('USE_TDB_MUTEX_LOCKING'):
127 tdb_deps
+= ' pthread'
129 bld
.SAMBA_LIBRARY('tdb',
137 public_headers
=('' if private_library
else 'include/tdb.h'),
138 public_headers_install
=not private_library
,
140 private_library
=private_library
)
142 bld
.SAMBA_BINARY('tdbtorture',
143 'tools/tdbtorture.c',
147 bld
.SAMBA_BINARY('tdbrestore',
148 'tools/tdbrestore.c',
149 'tdb', manpages
='man/tdbrestore.8')
151 bld
.SAMBA_BINARY('tdbdump',
153 'tdb', manpages
='man/tdbdump.8')
155 bld
.SAMBA_BINARY('tdbbackup',
158 manpages
='man/tdbbackup.8')
160 bld
.SAMBA_BINARY('tdbtool',
162 'tdb', manpages
='man/tdbtool.8')
164 if bld
.env
.standalone_tdb
:
165 # FIXME: This hardcoded list is stupid, stupid, stupid.
166 bld
.SAMBA_SUBSYSTEM('tdb-test-helpers',
167 'test/external-agent.c test/lock-tracking.c test/logging.c',
171 for t
in tdb1_unit_tests
:
173 s
= "test/" + t
+ ".c"
174 bld
.SAMBA_BINARY(b
, s
, 'replace tdb-test-helpers',
175 includes
='include', install
=False)
177 if not bld
.CONFIG_SET('USING_SYSTEM_PYTDB'):
178 for env
in bld
.gen_python_environments(['PKGCONFIGDIR']):
179 bld
.SAMBA_PYTHON('pytdb',
182 enabled
=not bld
.env
.disable_python
,
184 cflags
='-DPACKAGE_VERSION=\"%s\"' % VERSION
)
186 if not bld
.env
.disable_python
:
187 for env
in bld
.gen_python_environments(['PKGCONFIGDIR']):
188 bld
.SAMBA_SCRIPT('_tdb_text.py',
189 pattern
='_tdb_text.py',
192 bld
.INSTALL_FILES('${PYTHONARCHDIR}', '_tdb_text.py')
195 '''run tdb testsuite'''
196 import Utils
, samba_utils
, shutil
199 test_prefix
= "%s/st" % (Utils
.g_module
.blddir
)
200 shutil
.rmtree(test_prefix
, ignore_errors
=True)
201 os
.makedirs(test_prefix
)
202 os
.environ
['TEST_DATA_PREFIX'] = test_prefix
204 env
= samba_utils
.LOAD_ENVIRONMENT()
205 # FIXME: This is horrible :(
207 # Create scratch directory for tests.
208 testdir
= os
.path
.join(test_prefix
, 'tdb-tests')
209 samba_utils
.mkdir_p(testdir
)
210 # Symlink back to source dir so it can find tests in test/
211 link
= os
.path
.join(testdir
, 'test')
212 if not os
.path
.exists(link
):
213 os
.symlink(os
.path
.abspath(os
.path
.join(env
.cwd
, 'test')), link
)
215 for t
in tdb1_unit_tests
:
217 cmd
= "cd " + testdir
+ " && " + os
.path
.abspath(os
.path
.join(Utils
.g_module
.blddir
, f
)) + " > test-output 2>&1"
219 ret
= samba_utils
.RUN_COMMAND(cmd
)
221 print("%s failed:" % f
)
222 samba_utils
.RUN_COMMAND("cat " + os
.path
.join(testdir
, 'test-output'))
227 cmd
= os
.path
.join(Utils
.g_module
.blddir
, 'tdbtorture')
228 ret
= samba_utils
.RUN_COMMAND(cmd
)
229 print("testsuite returned %d" % ret
)
233 pyret
= samba_utils
.RUN_PYTHON_TESTS(['python/tests/simple.py'])
234 print("python testsuite returned %d" % pyret
)
235 sys
.exit(ecode
or pyret
)
237 # WAF doesn't build the unit tests for this, maybe because they don't link with tdb?
241 Scripting
.commands
.append('build')
242 Scripting
.commands
.append('testonly')
245 '''makes a tarball for distribution'''
248 def reconfigure(ctx
):
249 '''reconfigure if config scripts have changed'''
251 samba_utils
.reconfigure(ctx
)