1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
import os
import glob
import subprocess
import sys
from scripts import version
from scripts import config
from scripts import tests
from scripts import pkgconfig
from scripts.builder import Builder
DOIT_CONFIG = {
'default_tasks': [
'libxmlbird',
'libxmlbird_pkgconfig'
],
}
all_tests = tests.all_tests ();
def soname(target_binary):
if "darwin" in sys.platform or "msys" in sys.platform:
return ''
return '-Wl,-soname,' + target_binary
def make_libxmlbird(target_binary):
valac_command = config.VALAC + """\
-C \
--pkg posix \
--vapidir=./ \
--basedir build/libxmlbird/ \
""" + config.NON_NULL + """ \
""" + config.VALACFLAGS.get("xmlbird", "") + """ \
--enable-experimental \
--library libxmlbird \
--vapi=./build/xmlbird.vapi \
-H build/xmlbird/xmlbird.h \
libxmlbird/*.vala \
"""
cc_command = config.CC + " " + config.CFLAGS.get("xmlbird", "") + """ \
-c C_SOURCE \
-I ./build/xmlbird \
-fPIC \
$(pkg-config --cflags glib-2.0) \
-o OBJECT_FILE"""
linker_command = config.CC + " " + config.LDFLAGS.get("xmlbird", "") + """ \
-shared \
""" + soname(target_binary) + """ \
build/libxmlbird/*.o \
$(pkg-config --libs glib-2.0) \
$(pkg-config --libs gobject-2.0) \
-o ./build/bin/""" + target_binary
libxmlbird = Builder('libxmlbird',
valac_command,
cc_command,
linker_command,
target_binary,
'libxmlbird.so')
yield libxmlbird.build()
def task_libxmlbird():
if "kfreebsd" in sys.platform:
LIBXMLBIRD_SO_VERSION=version.LIBXMLBIRD_SO_VERSION
elif "openbsd" in sys.platform:
LIBXMLBIRD_SO_VERSION='${LIBxmlbird_VERSION}'
else:
LIBXMLBIRD_SO_VERSION=version.LIBXMLBIRD_SO_VERSION
yield make_libxmlbird('libxmlbird.so.' + LIBXMLBIRD_SO_VERSION)
def make_libxmlbird_pkgconfig():
pkgconfig.generate_pkg_config_file ()
def task_libxmlbird_pkgconfig():
"""build tests"""
return {
'actions': [make_libxmlbird_pkgconfig],
'task_dep': ['libxmlbird'],
}
def task_distclean ():
return {
'actions': ['rm -rf .doit.db build scripts/config.py scripts/*.pyc *.pyc'],
}
def task_build_tests():
"""build tests"""
return {
'actions': [tests.build_tests],
'task_dep': ['libxmlbird'],
}
def task_fuzz():
"""run fuzz test"""
return {
'actions': ['./tests/fuzz.py'],
'task_dep': ['build_tests'],
}
def task_test():
"""run tests"""
def run_tests():
print('Running tests')
failed = 0
passed = 0
for t in all_tests:
process = subprocess.Popen ("./run_test.sh ./build/bin/" + t, shell=True)
process.communicate()[0]
if not process.returncode == 0:
print(t + ' Failed')
failed = failed + 1
else:
passed = passed + 1
print(str(passed) + ' tests passed and ' + str(failed) + ' failed.')
return {
'actions': [run_tests],
'task_dep': ['build_tests'],
'verbosity': 2
}
|