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',
45 'run-marklock-deadlock',
46 'run-allrecord-traverse-deadlock',
47 'run-mutex-openflags2',
49 'run-mutex-allrecord-bench',
50 'run-mutex-allrecord-trylock',
51 'run-mutex-allrecord-block',
52 'run-mutex-transaction1',
58 opt
.BUILTIN_DEFAULT('replace')
59 opt
.PRIVATE_EXTENSION_DEFAULT('tdb', noextension
='tdb')
60 opt
.RECURSE('lib/replace')
61 opt
.add_option('--disable-tdb-mutex-locking',
62 help=("Disable the use of pthread robust mutexes"),
63 action
="store_true", dest
='disable_tdb_mutex_locking',
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 not conf
.env
.disable_python
and \
84 conf
.CHECK_BUNDLED_SYSTEM_PYTHON('pytdb', 'tdb', minversion
=VERSION
):
85 conf
.define('USING_SYSTEM_PYTDB', 1)
87 if (conf
.CONFIG_SET('HAVE_ROBUST_MUTEXES') and
88 conf
.env
.building_tdb
and
89 not conf
.env
.disable_tdb_mutex_locking
):
90 conf
.define('USE_TDB_MUTEX_LOCKING', 1)
92 conf
.CHECK_XSLTPROC_MANPAGES()
94 if not conf
.env
.disable_python
:
95 # also disable if we don't have the python libs installed
96 conf
.SAMBA_CHECK_PYTHON(mandatory
=False)
97 conf
.check_python_version((2,4,2))
98 conf
.SAMBA_CHECK_PYTHON_HEADERS(mandatory
=False)
99 if not conf
.env
.HAVE_PYTHON_H
:
100 Logs
.warn('Disabling pytdb as python devel libs not found')
101 conf
.env
.disable_python
= True
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 for env
in bld
.gen_python_environments(['PKGCONFIGDIR']):
180 bld
.SAMBA_PYTHON('pytdb',
183 enabled
=not bld
.env
.disable_python
,
185 cflags
='-DPACKAGE_VERSION=\"%s\"' % VERSION
)
187 if not bld
.env
.disable_python
:
188 for env
in bld
.gen_python_environments(['PKGCONFIGDIR']):
189 bld
.SAMBA_SCRIPT('_tdb_text.py',
190 pattern
='_tdb_text.py',
193 bld
.INSTALL_FILES('${PYTHONARCHDIR}', '_tdb_text.py')
196 '''run tdb testsuite'''
197 import Utils
, samba_utils
, shutil
200 test_prefix
= "%s/st" % (Utils
.g_module
.blddir
)
201 shutil
.rmtree(test_prefix
, ignore_errors
=True)
202 os
.makedirs(test_prefix
)
203 os
.environ
['TEST_DATA_PREFIX'] = test_prefix
205 env
= samba_utils
.LOAD_ENVIRONMENT()
206 # FIXME: This is horrible :(
208 # Create scratch directory for tests.
209 testdir
= os
.path
.join(test_prefix
, 'tdb-tests')
210 samba_utils
.mkdir_p(testdir
)
211 # Symlink back to source dir so it can find tests in test/
212 link
= os
.path
.join(testdir
, 'test')
213 if not os
.path
.exists(link
):
214 os
.symlink(os
.path
.abspath(os
.path
.join(env
.cwd
, 'test')), link
)
216 for t
in tdb1_unit_tests
:
218 cmd
= "cd " + testdir
+ " && " + os
.path
.abspath(os
.path
.join(Utils
.g_module
.blddir
, f
)) + " > test-output 2>&1"
220 ret
= samba_utils
.RUN_COMMAND(cmd
)
222 print("%s failed:" % f
)
223 samba_utils
.RUN_COMMAND("cat " + os
.path
.join(testdir
, 'test-output'))
228 cmd
= os
.path
.join(Utils
.g_module
.blddir
, 'tdbtorture')
229 ret
= samba_utils
.RUN_COMMAND(cmd
)
230 print("testsuite returned %d" % ret
)
234 pyret
= samba_utils
.RUN_PYTHON_TESTS(['python/tests/simple.py'])
235 print("python testsuite returned %d" % pyret
)
236 sys
.exit(ecode
or pyret
)
238 # WAF doesn't build the unit tests for this, maybe because they don't link with tdb?
242 Scripting
.commands
.append('build')
243 Scripting
.commands
.append('testonly')
246 '''makes a tarball for distribution'''
249 def reconfigure(ctx
):
250 '''reconfigure if config scripts have changed'''
252 samba_utils
.reconfigure(ctx
)