Link tests with the raw objects Fix the test building issues once for all; each test is linked with the raw objects of the library, not with any compiled version. That way we make sure the tests always run, and are always linked with the latest and most up-to-date version of the code. Signed-off-by: Vicent Marti <tanoku@gmail.com>
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
diff --git a/wscript b/wscript
index 41d3d30..6f89804 100644
--- a/wscript
+++ b/wscript
@@ -74,15 +74,15 @@ def build(bld):
# command '[build|clean|install|uninstall]-static'
if bld.variant == 'static':
- build_library(bld, 'cstlib')
+ build_library(bld, 'static')
# command '[build|clean|install|uninstall]-shared'
elif bld.variant == 'shared':
- build_library(bld, 'cshlib')
+ build_library(bld, 'shared')
# command '[build|clean]-tests'
elif bld.variant == 'tests':
- build_library(bld, 'cshlib')
+ build_library(bld, 'objects')
build_tests(bld)
# command 'build|clean|install|uninstall': by default, run
@@ -91,9 +91,15 @@ def build(bld):
from waflib import Options
Options.commands = [bld.cmd + '-shared', bld.cmd + '-static'] + Options.commands
-def build_library(bld, lib_str):
- directory = bld.path
+def build_library(bld, build_type):
+
+ BUILD = {
+ 'shared' : bld.shlib,
+ 'static' : bld.stlib,
+ 'objects' : bld.objects
+ }
+ directory = bld.path
sources = directory.ant_glob('src/*.c')
# Compile platform-dependant code
@@ -106,15 +112,12 @@ def build_library(bld, lib_str):
sources.append('src/ppc/sha1.c')
else:
sources.append('src/block-sha1/sha1.c')
-
- features = ['c', lib_str]
-
#------------------------------
# Build the main library
#------------------------------
# either as static or shared;
- bld(features=features,
+ BUILD[build_type](
source=sources,
target='git2',
includes='src',
@@ -123,7 +126,7 @@ def build_library(bld, lib_str):
)
# On Unix systems, build the Pkg-config entry file
- if bld.env.PLATFORM == 'unix':
+ if bld.env.PLATFORM == 'unix' and bld.is_install:
bld(rule="""sed -e 's#@prefix@#$(prefix)#' -e 's#@libdir@#$(libdir)#' < ${SRC} > ${TGT}""",
source='libgit2.pc.in',
target='libgit2.pc',
@@ -167,7 +170,6 @@ def build_tests(bld):
includes=['src', 'tests'],
defines=['TEST_TOC="%s.toc"' % test_name, 'TEST_RESOURCES="%s"' % resources_path],
install_path=None,
- shlibpath=[directory.find_node('build/tests/').abspath()],
use=['test_helper', 'git2'] + ALL_LIBS # link with all the libs we know
# libraries which are not enabled won't link
)
@@ -200,28 +202,14 @@ class _run_tests(Context):
fun = 'run_tests'
def run_tests(ctx):
- import shutil, tempfile, sys, os
+ import shutil, tempfile
failed = False
test_folder = tempfile.mkdtemp()
- build_folder = ctx.path.find_node('build/tests/')
test_glob = 'build/tests/t????-*'
- environ = os.environ.copy()
- environ_tail = ""
-
- if sys.platform == 'win32':
- test_glob += '.exe'
- environ_var, environ_separator = 'PATH', ';'
- else:
- environ_var, environ_separator = 'LD_LIBRARY_PATH', ':'
-
- if environ_var in environ:
- environ_tail = environ_separator + environ[environ_var]
-
- environ[environ_var] = build_folder.abspath() + environ_tail
for test in ctx.path.ant_glob(test_glob):
- if ctx.exec_command(test.abspath(), cwd=test_folder, env=environ) != 0:
+ if ctx.exec_command(test.abspath(), cwd=test_folder) != 0:
failed = True
break