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',
64 opt
.BUILTIN_DEFAULT('replace')
65 opt
.PRIVATE_EXTENSION_DEFAULT('tdb', noextension
='tdb')
66 opt
.RECURSE('lib/replace')
67 opt
.add_option('--disable-tdb-mutex-locking',
68 help=("Disable the use of pthread robust mutexes"),
69 action
="store_true", dest
='disable_tdb_mutex_locking',
74 conf
.env
.disable_tdb_mutex_locking
= getattr(Options
.options
,
75 'disable_tdb_mutex_locking',
77 if not conf
.env
.disable_tdb_mutex_locking
:
78 conf
.env
.replace_add_global_pthread
= True
79 conf
.RECURSE('lib/replace')
81 conf
.env
.standalone_tdb
= conf
.IN_LAUNCH_DIR()
82 conf
.env
.building_tdb
= True
84 if not conf
.env
.standalone_tdb
:
85 if conf
.CHECK_BUNDLED_SYSTEM_PKG('tdb', minversion
=VERSION
,
86 implied_deps
='replace'):
87 conf
.define('USING_SYSTEM_TDB', 1)
88 conf
.env
.building_tdb
= False
89 if not conf
.env
.disable_python
and \
90 conf
.CHECK_BUNDLED_SYSTEM_PYTHON('pytdb', 'tdb', minversion
=VERSION
):
91 conf
.define('USING_SYSTEM_PYTDB', 1)
93 if (conf
.CONFIG_SET('HAVE_ROBUST_MUTEXES') and
94 conf
.env
.building_tdb
and
95 not conf
.env
.disable_tdb_mutex_locking
):
96 conf
.define('USE_TDB_MUTEX_LOCKING', 1)
98 conf
.CHECK_XSLTPROC_MANPAGES()
100 conf
.SAMBA_CHECK_PYTHON()
101 conf
.SAMBA_CHECK_PYTHON_HEADERS()
103 conf
.SAMBA_CONFIG_H()
105 conf
.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
108 bld
.RECURSE('lib/replace')
110 COMMON_FILES
='''check.c error.c tdb.c traverse.c
111 freelistcheck.c lock.c dump.c freelist.c
112 io.c open.c transaction.c hash.c summary.c rescue.c
115 COMMON_SRC
= bld
.SUBDIR('common', COMMON_FILES
)
117 if bld
.env
.standalone_tdb
:
118 bld
.env
.PKGCONFIGDIR
= '${LIBDIR}/pkgconfig'
119 private_library
= False
121 private_library
= True
123 if not bld
.CONFIG_SET('USING_SYSTEM_TDB'):
127 if bld
.CONFIG_SET('USE_TDB_MUTEX_LOCKING'):
128 tdb_deps
+= ' pthread'
130 bld
.SAMBA_LIBRARY('tdb',
138 public_headers
=('' if private_library
else 'include/tdb.h'),
139 public_headers_install
=not private_library
,
141 private_library
=private_library
)
143 bld
.SAMBA_BINARY('tdbtorture',
144 'tools/tdbtorture.c',
148 bld
.SAMBA_BINARY('tdbrestore',
149 'tools/tdbrestore.c',
150 'tdb', manpages
='man/tdbrestore.8')
152 bld
.SAMBA_BINARY('tdbdump',
154 'tdb', manpages
='man/tdbdump.8')
156 bld
.SAMBA_BINARY('tdbbackup',
159 manpages
='man/tdbbackup.8')
161 bld
.SAMBA_BINARY('tdbtool',
163 'tdb', manpages
='man/tdbtool.8')
165 if bld
.env
.standalone_tdb
:
166 # FIXME: This hardcoded list is stupid, stupid, stupid.
167 bld
.SAMBA_SUBSYSTEM('tdb-test-helpers',
168 'test/external-agent.c test/lock-tracking.c test/logging.c',
172 for t
in tdb1_unit_tests
:
174 s
= "test/" + t
+ ".c"
175 bld
.SAMBA_BINARY(b
, s
, 'replace tdb-test-helpers',
176 includes
='include', install
=False)
178 if not bld
.CONFIG_SET('USING_SYSTEM_PYTDB'):
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 bld
.SAMBA_SCRIPT('_tdb_text.py',
188 pattern
='_tdb_text.py',
191 bld
.INSTALL_FILES('${PYTHONARCHDIR}', '_tdb_text.py')
194 '''run tdb testsuite'''
197 blddir
= Context
.g_module
.out
198 test_prefix
= "%s/st" % (blddir
)
199 shutil
.rmtree(test_prefix
, ignore_errors
=True)
200 os
.makedirs(test_prefix
)
201 os
.environ
['TEST_DATA_PREFIX'] = test_prefix
203 env
= samba_utils
.LOAD_ENVIRONMENT()
204 # FIXME: This is horrible :(
206 # Create scratch directory for tests.
207 testdir
= os
.path
.join(test_prefix
, 'tdb-tests')
208 samba_utils
.mkdir_p(testdir
)
209 # Symlink back to source dir so it can find tests in test/
210 link
= os
.path
.join(testdir
, 'test')
211 if not os
.path
.exists(link
):
212 os
.symlink(ctx
.path
.make_node('test').abspath(), link
)
214 sh_tests
= ["test/test_tdbbackup.sh test/jenkins-be-hash.tdb"]
216 for sh_test
in sh_tests
:
217 cmd
= "BINDIR=%s %s" % (blddir
, sh_test
)
218 print("shell test: " + cmd
)
219 ret
= samba_utils
.RUN_COMMAND(cmd
)
221 print("%s sh test failed" % cmd
)
225 for t
in tdb1_unit_tests
:
227 cmd
= "cd " + testdir
+ " && " + os
.path
.abspath(os
.path
.join(blddir
, f
)) + " > test-output 2>&1"
229 ret
= samba_utils
.RUN_COMMAND(cmd
)
231 print("%s failed:" % f
)
232 samba_utils
.RUN_COMMAND("cat " + os
.path
.join(testdir
, 'test-output'))
237 cmd
= os
.path
.join(blddir
, 'tdbtorture')
238 ret
= samba_utils
.RUN_COMMAND(cmd
)
239 print("testsuite returned %d" % ret
)
243 pyret
= samba_utils
.RUN_PYTHON_TESTS(['python/tests/simple.py'])
244 print("python testsuite returned %d" % pyret
)
245 sys
.exit(ecode
or pyret
)
247 # WAF doesn't build the unit tests for this, maybe because they don't link with tdb?
250 Options
.commands
.append('build')
251 Options
.commands
.append('testonly')
254 '''makes a tarball for distribution'''
257 def reconfigure(ctx
):
258 '''reconfigure if config scripts have changed'''
259 samba_utils
.reconfigure(ctx
)