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',
46 opt
.BUILTIN_DEFAULT('replace')
47 opt
.PRIVATE_EXTENSION_DEFAULT('tdb', noextension
='tdb')
48 opt
.RECURSE('lib/replace')
49 if opt
.IN_LAUNCH_DIR():
50 opt
.add_option('--disable-python',
51 help=("disable the pytdb module"),
52 action
="store_true", dest
='disable_python', default
=False)
56 conf
.RECURSE('lib/replace')
58 conf
.env
.standalone_tdb
= conf
.IN_LAUNCH_DIR()
59 conf
.env
.building_tdb
= True
61 if not conf
.env
.standalone_tdb
:
62 if conf
.CHECK_BUNDLED_SYSTEM_PKG('tdb', minversion
=VERSION
,
63 implied_deps
='replace'):
64 conf
.define('USING_SYSTEM_TDB', 1)
65 conf
.env
.building_tdb
= False
66 if conf
.CHECK_BUNDLED_SYSTEM_PYTHON('pytdb', 'tdb', minversion
=VERSION
):
67 conf
.define('USING_SYSTEM_PYTDB', 1)
69 conf
.env
.disable_python
= getattr(Options
.options
, 'disable_python', False)
71 conf
.CHECK_XSLTPROC_MANPAGES()
73 if not conf
.env
.disable_python
:
74 # also disable if we don't have the python libs installed
75 conf
.find_program('python', var
='PYTHON')
76 conf
.check_tool('python')
77 conf
.check_python_version((2,4,2))
78 conf
.SAMBA_CHECK_PYTHON_HEADERS(mandatory
=False)
79 if not conf
.env
.HAVE_PYTHON_H
:
80 Logs
.warn('Disabling pytdb as python devel libs not found')
81 conf
.env
.disable_python
= True
85 conf
.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
88 bld
.RECURSE('lib/replace')
90 COMMON_SRC
= bld
.SUBDIR('common',
91 '''check.c error.c tdb.c traverse.c
92 freelistcheck.c lock.c dump.c freelist.c
93 io.c open.c transaction.c hash.c summary.c rescue.c''')
95 if bld
.env
.standalone_tdb
:
96 bld
.env
.PKGCONFIGDIR
= '${LIBDIR}/pkgconfig'
97 private_library
= False
99 private_library
= True
101 if not bld
.CONFIG_SET('USING_SYSTEM_TDB'):
102 bld
.SAMBA_LIBRARY('tdb',
110 public_headers
='include/tdb.h',
111 public_headers_install
=not private_library
,
113 private_library
=private_library
)
115 bld
.SAMBA_BINARY('tdbtorture',
116 'tools/tdbtorture.c',
120 bld
.SAMBA_BINARY('tdbrestore',
121 'tools/tdbrestore.c',
122 'tdb', manpages
='man/tdbrestore.8')
124 bld
.SAMBA_BINARY('tdbdump',
126 'tdb', manpages
='man/tdbdump.8')
128 bld
.SAMBA_BINARY('tdbbackup',
131 manpages
='man/tdbbackup.8')
133 bld
.SAMBA_BINARY('tdbtool',
135 'tdb', manpages
='man/tdbtool.8')
137 # FIXME: This hardcoded list is stupid, stupid, stupid.
138 bld
.SAMBA_SUBSYSTEM('tdb-test-helpers',
139 'test/external-agent.c test/lock-tracking.c test/logging.c',
143 for t
in tdb1_unit_tests
:
145 s
= "test/" + t
+ ".c"
146 bld
.SAMBA_BINARY(b
, s
, 'replace tdb-test-helpers',
147 includes
='include', install
=False)
149 if not bld
.CONFIG_SET('USING_SYSTEM_PYTDB'):
150 bld
.SAMBA_PYTHON('pytdb',
153 enabled
=not bld
.env
.disable_python
,
155 cflags
='-DPACKAGE_VERSION=\"%s\"' % VERSION
)
158 '''run tdb testsuite'''
159 import Utils
, samba_utils
, shutil
162 test_prefix
= "%s/st" % (Utils
.g_module
.blddir
)
163 shutil
.rmtree(test_prefix
, ignore_errors
=True)
164 os
.makedirs(test_prefix
)
165 os
.environ
['TEST_DATA_PREFIX'] = test_prefix
167 env
= samba_utils
.LOAD_ENVIRONMENT()
168 # FIXME: This is horrible :(
170 # Create scratch directory for tests.
171 testdir
= os
.path
.join(test_prefix
, 'tdb-tests')
172 samba_utils
.mkdir_p(testdir
)
173 # Symlink back to source dir so it can find tests in test/
174 link
= os
.path
.join(testdir
, 'test')
175 if not os
.path
.exists(link
):
176 os
.symlink(os
.path
.abspath(os
.path
.join(env
.cwd
, 'test')), link
)
178 for t
in tdb1_unit_tests
:
180 cmd
= "cd " + testdir
+ " && " + os
.path
.abspath(os
.path
.join(Utils
.g_module
.blddir
, f
)) + " > test-output 2>&1"
182 ret
= samba_utils
.RUN_COMMAND(cmd
)
184 print("%s failed:" % f
)
185 samba_utils
.RUN_COMMAND("cat " + os
.path
.join(testdir
, 'test-output'))
190 cmd
= os
.path
.join(Utils
.g_module
.blddir
, 'tdbtorture')
191 ret
= samba_utils
.RUN_COMMAND(cmd
)
192 print("testsuite returned %d" % ret
)
197 # WAF doesn't build the unit tests for this, maybe because they don't link with tdb?
201 Scripting
.commands
.append('build')
202 Scripting
.commands
.append('testonly')
205 '''makes a tarball for distribution'''
208 def reconfigure(ctx
):
209 '''reconfigure if config scripts have changed'''
211 samba_utils
.reconfigure(ctx
)