From bd6eb23022e0f8d8bbd04d587f402731294f8a68 Mon Sep 17 00:00:00 2001 From: Marco Villegas Date: Wed, 22 Dec 2010 04:02:18 -0500 Subject: [PATCH 1/9] minor: Let waf write the right values for prefix and libdir at pkg-config file. --- wscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wscript b/wscript index 104de86a5..558163196 100644 --- a/wscript +++ b/wscript @@ -124,7 +124,7 @@ def build_library(bld, lib_str): # On Unix systems, build the Pkg-config entry file if bld.env.PLATFORM == 'unix': - bld(rule="""sed -e 's#@prefix@#$(prefix)#' -e 's#@libdir@#$(libdir)#' < ${SRC} > ${TGT}""", + bld(rule="""sed -e 's#@prefix@#${PREFIX}#' -e 's#@libdir@#${LIBDIR}#' < ${SRC} > ${TGT}""", source='libgit2.pc.in', target='libgit2.pc', install_path='${LIBDIR}/pkgconfig', From a58e6a5fc99929878377e97973ada46ee437ce0b Mon Sep 17 00:00:00 2001 From: Marco Villegas Date: Wed, 22 Dec 2010 13:39:13 -0500 Subject: [PATCH 2/9] Run ldconfig on install at unix platforms. --- wscript | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/wscript b/wscript index 104de86a5..627ae31da 100644 --- a/wscript +++ b/wscript @@ -134,6 +134,13 @@ def build_library(bld, lib_str): bld.install_files('${PREFIX}/include', directory.find_node('src/git2.h')) bld.install_files('${PREFIX}/include/git2', directory.ant_glob('src/git2/*.h')) + # On Unix systems, let them know about installation + if bld.env.PLATFORM == 'unix' and bld.cmd in ['install-static', 'install-shared']: + bld.add_post_fun(call_ldconfig) + +def call_ldconfig(bld): + bld.exec_command('/sbin/ldconfig') + def grep_test_header(text, test_file): return '\n'.join(l for l in test_file.read().splitlines() if text in l) From 0847dff5cd6522dbef29958cbafa7a56f409e82a Mon Sep 17 00:00:00 2001 From: Vicent Marti Date: Wed, 22 Dec 2010 21:57:48 +0200 Subject: [PATCH 3/9] Fix test builds in Win32 Use forward slashes for the TEST_RESOURCES definition. libgit2 uses only forward slashes. Signed-off-by: Vicent Marti --- wscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wscript b/wscript index 104de86a5..41d3d30ec 100644 --- a/wscript +++ b/wscript @@ -144,7 +144,7 @@ def build_tests(bld): return directory = bld.path - resources_path = directory.find_node('tests/resources/').abspath() + resources_path = directory.find_node('tests/resources/').abspath().replace('\\', '/') # Common object with the Test library methods bld.objects(source=['tests/test_helpers.c', 'tests/test_lib.c'], includes=['src', 'tests'], target='test_helper') From 2a18a792e3674b24f2d6312c039571c64f75dacd Mon Sep 17 00:00:00 2001 From: Vicent Marti Date: Wed, 22 Dec 2010 22:43:39 +0200 Subject: [PATCH 4/9] Properly export all external symbols in Win32 Some external functions were not being exported because they were using the 'extern' keyword instead of the generic GIT_EXTERN() macro. Signed-off-by: Vicent Marti --- src/delta-apply.h | 2 +- src/dir.h | 8 ++++---- src/fileops.h | 42 +++++++++++++++++++++--------------------- src/map.h | 4 ++-- src/thread-utils.h | 2 +- src/util.h | 18 +++++++++--------- 6 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/delta-apply.h b/src/delta-apply.h index 642442de0..fc5d8cd01 100644 --- a/src/delta-apply.h +++ b/src/delta-apply.h @@ -15,7 +15,7 @@ * - GIT_SUCCESS on a successful delta unpack. * - GIT_ERROR if the delta is corrupt or doesn't match the base. */ -extern int git__delta_apply( +GIT_EXTERN(int) git__delta_apply( git_rawobj *out, const unsigned char *base, size_t base_len, diff --git a/src/dir.h b/src/dir.h index c01c3fae7..bb77d3596 100644 --- a/src/dir.h +++ b/src/dir.h @@ -22,10 +22,10 @@ typedef struct { int first; } git__DIR; -extern git__DIR *git__opendir(const char *); -extern struct git__dirent *git__readdir(git__DIR *); -extern void git__rewinddir(git__DIR *); -extern int git__closedir(git__DIR *); +GIT_EXTERN(git__DIR *) git__opendir(const char *); +GIT_EXTERN(struct git__dirent *) git__readdir(git__DIR *); +GIT_EXTERN(void) git__rewinddir(git__DIR *); +GIT_EXTERN(int) git__closedir(git__DIR *); # ifndef GIT__WIN32_NO_WRAP_DIR # define dirent git__dirent diff --git a/src/fileops.h b/src/fileops.h index 6656cdf43..b90deddda 100644 --- a/src/fileops.h +++ b/src/fileops.h @@ -27,9 +27,9 @@ GIT_INLINE(int) git__mkdir(const char *path, int GIT_UNUSED(mode)) return mkdir(path); } -extern int git__unlink(const char *path); -extern int git__mkstemp(char *template); -extern int git__fsync(int fd); +GIT_EXTERN(int) git__unlink(const char *path); +GIT_EXTERN(int) git__mkstemp(char *template); +GIT_EXTERN(int) git__fsync(int fd); # ifndef GIT__WIN32_NO_HIDE_FILEOPS # define unlink(p) git__unlink(p) @@ -54,21 +54,21 @@ typedef struct { /* file io buffer */ size_t len; /* data length */ } gitfo_buf; -extern int gitfo_exists(const char *path); -extern int gitfo_open(const char *path, int flags); -extern int gitfo_creat(const char *path, int mode); -extern int gitfo_isdir(const char *path); -extern int gitfo_mkdir_recurs(const char *path, int mode); +GIT_EXTERN(int) gitfo_exists(const char *path); +GIT_EXTERN(int) gitfo_open(const char *path, int flags); +GIT_EXTERN(int) gitfo_creat(const char *path, int mode); +GIT_EXTERN(int) gitfo_isdir(const char *path); +GIT_EXTERN(int) gitfo_mkdir_recurs(const char *path, int mode); #define gitfo_close(fd) close(fd) -extern int gitfo_read(git_file fd, void *buf, size_t cnt); -extern int gitfo_write(git_file fd, void *buf, size_t cnt); +GIT_EXTERN(int) gitfo_read(git_file fd, void *buf, size_t cnt); +GIT_EXTERN(int) gitfo_write(git_file fd, void *buf, size_t cnt); #define gitfo_lseek(f,n,w) lseek(f, n, w) -extern off_t gitfo_size(git_file fd); +GIT_EXTERN(off_t) gitfo_size(git_file fd); -extern int gitfo_read_file(gitfo_buf *obj, const char *path); -extern void gitfo_free_buf(gitfo_buf *obj); -extern int gitfo_move_file(char *from, char *to); +GIT_EXTERN(int) gitfo_read_file(gitfo_buf *obj, const char *path); +GIT_EXTERN(void) gitfo_free_buf(gitfo_buf *obj); +GIT_EXTERN(int) gitfo_move_file(char *from, char *to); #define gitfo_stat(p,b) stat(p, b) #define gitfo_fstat(f,b) fstat(f, b) @@ -97,7 +97,7 @@ extern int gitfo_move_file(char *from, char *to); * - GIT_SUCCESS on success; * - GIT_EOSERR on an unspecified OS related error. */ -extern int gitfo_map_ro( +GIT_EXTERN(int) gitfo_map_ro( git_map *out, git_file fd, off_t begin, @@ -107,7 +107,7 @@ extern int gitfo_map_ro( * Release the memory associated with a previous memory mapping. * @param map the mapping description previously configured. */ -extern void gitfo_free_map(git_map *map); +GIT_EXTERN(void) gitfo_free_map(git_map *map); /** * Walk each directory entry, except '.' and '..', calling fn(state). @@ -120,15 +120,15 @@ extern void gitfo_free_map(git_map *map); * may modify the pathbuf, but only by appending new text. * @param state to pass to fn as the first arg. */ -extern int gitfo_dirent( +GIT_EXTERN(int) gitfo_dirent( char *pathbuf, size_t pathmax, int (*fn)(void *, char *), void *state); -extern gitfo_cache *gitfo_enable_caching(git_file fd, size_t cache_size); -extern int gitfo_write_cached(gitfo_cache *ioc, void *buf, size_t len); -extern int gitfo_flush_cached(gitfo_cache *ioc); -extern int gitfo_close_cached(gitfo_cache *ioc); +GIT_EXTERN(gitfo_cache *) gitfo_enable_caching(git_file fd, size_t cache_size); +GIT_EXTERN(int) gitfo_write_cached(gitfo_cache *ioc, void *buf, size_t len); +GIT_EXTERN(int) gitfo_flush_cached(gitfo_cache *ioc); +GIT_EXTERN(int) gitfo_close_cached(gitfo_cache *ioc); #endif /* INCLUDE_fileops_h__ */ diff --git a/src/map.h b/src/map.h index 3188ffdbb..2388bb345 100644 --- a/src/map.h +++ b/src/map.h @@ -25,7 +25,7 @@ typedef struct { /* memory mapped buffer */ #endif } git_map; -extern int git__mmap(git_map *out, size_t len, int prot, int flags, int fd, off_t offset); -extern int git__munmap(git_map *map); +GIT_EXTERN(int) git__mmap(git_map *out, size_t len, int prot, int flags, int fd, off_t offset); +GIT_EXTERN(int) git__munmap(git_map *map); #endif /* INCLUDE_map_h__ */ diff --git a/src/thread-utils.h b/src/thread-utils.h index 0395b97d1..864ecb7b1 100644 --- a/src/thread-utils.h +++ b/src/thread-utils.h @@ -84,6 +84,6 @@ typedef struct { int counter; } git_refcnt; #endif -extern int git_online_cpus(void); +GIT_EXTERN(int) git_online_cpus(void); #endif /* INCLUDE_thread_utils_h__ */ diff --git a/src/util.h b/src/util.h index 5f647253c..05f5a3443 100644 --- a/src/util.h +++ b/src/util.h @@ -3,9 +3,9 @@ #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) -extern void *git__malloc(size_t); -extern void *git__calloc(size_t, size_t); -extern char *git__strdup(const char *); +GIT_EXTERN(void *) git__malloc(size_t); +GIT_EXTERN(void *) git__calloc(size_t, size_t); +GIT_EXTERN(char *) git__strdup(const char *); #ifndef GIT__NO_HIDE_MALLOC # define GIT__FORBID_MALLOC do_not_use_malloc_directly @@ -26,15 +26,15 @@ extern char *git__strdup(const char *); # define strdup(a) GIT__FORBID_MALLOC #endif -extern int git__fmt(char *, size_t, const char *, ...) +GIT_EXTERN(int) git__fmt(char *, size_t, const char *, ...) GIT_FORMAT_PRINTF(3, 4); -extern int git__prefixcmp(const char *str, const char *prefix); -extern int git__suffixcmp(const char *str, const char *suffix); +GIT_EXTERN(int) git__prefixcmp(const char *str, const char *prefix); +GIT_EXTERN(int) git__suffixcmp(const char *str, const char *suffix); -extern int git__dirname(char *dir, size_t n, char *path); -extern int git__basename(char *base, size_t n, char *path); +GIT_EXTERN(int) git__dirname(char *dir, size_t n, char *path); +GIT_EXTERN(int) git__basename(char *base, size_t n, char *path); -extern void git__hexdump(const char *buffer, size_t n); +GIT_EXTERN(void) git__hexdump(const char *buffer, size_t n); /** @return true if p fits into the range of a size_t */ GIT_INLINE(int) git__is_sizet(off_t p) From 11f6646f032c669170453e8e359ac337fa9abbb7 Mon Sep 17 00:00:00 2001 From: Vicent Marti Date: Wed, 22 Dec 2010 22:51:24 +0200 Subject: [PATCH 5/9] Export TLS symbols properly in Win32 There was no export definition for GIT_EXTERN_TLS() under MSVC. Signed-off-by: Vicent Marti --- src/git2/common.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/git2/common.h b/src/git2/common.h index 9d014c038..bbeec4128 100644 --- a/src/git2/common.h +++ b/src/git2/common.h @@ -55,6 +55,8 @@ __attribute__((visibility("default"))) \ GIT_TLS \ type +#elif defined(_MSC_VER) +# define GIT_EXTERN_TLS(type) __declspec(dllexport) GIT_TLS type #else # define GIT_EXTERN_TLS(type) extern GIT_TLS type #endif From 9f54fe482dd369ebbae67b0b33f7efde206ba249 Mon Sep 17 00:00:00 2001 From: Vicent Marti Date: Thu, 23 Dec 2010 00:15:09 +0200 Subject: [PATCH 6/9] Remove git_errno It was not being used by any methods (only by malloc and calloc), and since it needs to be TLS, it cannot be exported on DLLs on Windows. Burn it with fire. The API always returns error codes! Signed-off-by: Vicent Marti --- src/common.h | 1 - src/errors.c | 28 ---------------------------- src/errors.h | 24 ------------------------ src/fileops.c | 20 ++++++++++---------- src/git2/errors.h | 10 ---------- src/unix/map.c | 2 +- src/util.c | 24 ------------------------ src/util.h | 32 ++++++++++---------------------- tests/t0001-errno.c | 12 ------------ 9 files changed, 21 insertions(+), 132 deletions(-) delete mode 100644 src/errors.h delete mode 100644 tests/t0001-errno.c diff --git a/src/common.h b/src/common.h index 821ee8844..287df60e2 100644 --- a/src/common.h +++ b/src/common.h @@ -49,7 +49,6 @@ typedef SSIZE_T ssize_t; #include "git2/common.h" #include "util.h" #include "thread-utils.h" -#include "errors.h" #include "bswap.h" #define GIT_PATH_MAX 4096 diff --git a/src/errors.c b/src/errors.c index ac73402ee..df8b82200 100644 --- a/src/errors.c +++ b/src/errors.c @@ -1,34 +1,6 @@ #include "common.h" #include "thread-utils.h" /* for GIT_TLS */ -#if defined(GIT_TLS) -/* compile-time constant initialization required */ -GIT_TLS int git_errno = 0; - -#elif defined(GIT_HAS_PTHREAD) - -static pthread_key_t errno_key; - -static void init_errno(void) __attribute__((constructor)); -static void init_errno(void) -{ - pthread_key_create(&errno_key, free); -} - -int *git__errno_storage(void) -{ - int *e = pthread_getspecific(errno_key); - if (!e) { -#undef calloc - e = calloc(1, sizeof(*e)); -#define calloc(a,b) GIT__FORBID_MALLOC - pthread_setspecific(errno_key, e); - } - return e; -} - -#endif - static struct { int num; const char *str; diff --git a/src/errors.h b/src/errors.h deleted file mode 100644 index d22a03b33..000000000 --- a/src/errors.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef INCLUDE_errors_h__ -#define INCLUDE_errors_h__ - -#include "git2/errors.h" - -/* convenience functions */ -GIT_INLINE(int) git_int_error(int code) -{ - git_errno = code; - return code; -} - -GIT_INLINE(int) git_os_error(void) -{ - return git_int_error(GIT_EOSERR); -} - -GIT_INLINE(void) *git_ptr_error(int code) -{ - git_errno = code; - return NULL; -} - -#endif diff --git a/src/fileops.c b/src/fileops.c index a25796a7b..5d7e92978 100644 --- a/src/fileops.c +++ b/src/fileops.c @@ -4,13 +4,13 @@ int gitfo_open(const char *path, int flags) { int fd = open(path, flags | O_BINARY); - return fd >= 0 ? fd : git_os_error(); + return fd >= 0 ? fd : GIT_EOSERR; } int gitfo_creat(const char *path, int mode) { int fd = open(path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, mode); - return fd >= 0 ? fd : git_os_error(); + return fd >= 0 ? fd : GIT_EOSERR; } int gitfo_read(git_file fd, void *buf, size_t cnt) @@ -21,11 +21,11 @@ int gitfo_read(git_file fd, void *buf, size_t cnt) if (r < 0) { if (errno == EINTR || errno == EAGAIN) continue; - return git_os_error(); + return GIT_EOSERR; } if (!r) { errno = EPIPE; - return git_os_error(); + return GIT_EOSERR; } cnt -= r; b += r; @@ -41,11 +41,11 @@ int gitfo_write(git_file fd, void *buf, size_t cnt) if (r < 0) { if (errno == EINTR || errno == EAGAIN) continue; - return git_os_error(); + return GIT_EOSERR; } if (!r) { errno = EPIPE; - return git_os_error(); + return GIT_EOSERR; } cnt -= r; b += r; @@ -92,7 +92,7 @@ off_t gitfo_size(git_file fd) { struct stat sb; if (gitfo_fstat(fd, &sb)) - return git_os_error(); + return GIT_EOSERR; return sb.st_size; } @@ -151,13 +151,13 @@ int gitfo_move_file(char *from, char *to) if (!rename(from, to)) return GIT_SUCCESS; - return git_os_error(); + return GIT_EOSERR; } int gitfo_map_ro(git_map *out, git_file fd, off_t begin, size_t len) { if (git__mmap(out, len, GIT_PROT_READ, GIT_MAP_SHARED, fd, begin) < GIT_SUCCESS) - return git_os_error(); + return GIT_EOSERR; return GIT_SUCCESS; } @@ -275,7 +275,7 @@ int gitfo_dirent( dir = opendir(path); if (!dir) - return git_os_error(); + return GIT_EOSERR; while ((de = readdir(dir)) != NULL) { size_t de_len; diff --git a/src/git2/errors.h b/src/git2/errors.h index 98bce4857..627e67c70 100644 --- a/src/git2/errors.h +++ b/src/git2/errors.h @@ -33,16 +33,6 @@ */ GIT_BEGIN_DECL -/** The git errno. */ -#if defined(GIT_TLS) -GIT_EXTERN_TLS(int) git_errno; - -#elif defined(GIT_HAS_PTHREAD) -# define git_errno (*git__errno_storage()) -GIT_EXTERN(int *) git__errno_storage(void); - -#endif - /** * strerror() for the Git library * @param num The error code to explain diff --git a/src/unix/map.c b/src/unix/map.c index a41bae0b8..3008008a6 100644 --- a/src/unix/map.c +++ b/src/unix/map.c @@ -40,7 +40,7 @@ int git__mmap(git_map *out, size_t len, int prot, int flags, int fd, off_t offse out->data = mmap(NULL, len, mprot, mflag, fd, offset); if (!out->data || out->data == MAP_FAILED) - return git_os_error(); + return GIT_EOSERR; out->len = len; return GIT_SUCCESS; diff --git a/src/util.c b/src/util.c index debf526d2..a3b62effa 100644 --- a/src/util.c +++ b/src/util.c @@ -3,30 +3,6 @@ #include #include -void *git__malloc(size_t n) -{ - void *r = malloc(n); - if (!r) - return git_ptr_error(GIT_ENOMEM); - return r; -} - -void *git__calloc(size_t a, size_t b) -{ - void *r = calloc(a, b); - if (!r) - return git_ptr_error(GIT_ENOMEM); - return r; -} - -char *git__strdup(const char *s) -{ - char *r = strdup(s); - if (!r) - return git_ptr_error(GIT_ENOMEM); - return r; -} - int git__fmt(char *buf, size_t buf_sz, const char *fmt, ...) { va_list va; diff --git a/src/util.h b/src/util.h index 05f5a3443..5204185b9 100644 --- a/src/util.h +++ b/src/util.h @@ -3,28 +3,16 @@ #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) -GIT_EXTERN(void *) git__malloc(size_t); -GIT_EXTERN(void *) git__calloc(size_t, size_t); -GIT_EXTERN(char *) git__strdup(const char *); - -#ifndef GIT__NO_HIDE_MALLOC -# define GIT__FORBID_MALLOC do_not_use_malloc_directly - -# ifdef malloc -# undef malloc -# endif -# define malloc(a) GIT__FORBID_MALLOC - -# ifdef calloc -# undef calloc -# endif -# define calloc(a,b) GIT__FORBID_MALLOC - -# ifdef strdup -# undef strdup -# endif -# define strdup(a) GIT__FORBID_MALLOC -#endif +/* + * Don't wrap malloc/calloc. + * Use the default versions in glibc, and make + * sure that any methods that allocate memory + * return a GIT_ENOMEM error when allocation + * fails. + */ +#define git__malloc malloc +#define git__calloc calloc +#define git__strdup strdup GIT_EXTERN(int) git__fmt(char *, size_t, const char *, ...) GIT_FORMAT_PRINTF(3, 4); diff --git a/tests/t0001-errno.c b/tests/t0001-errno.c deleted file mode 100644 index acb12d3a5..000000000 --- a/tests/t0001-errno.c +++ /dev/null @@ -1,12 +0,0 @@ -#include "test_lib.h" -#include "errors.h" - -BEGIN_TEST(errno_zero_on_init) - must_be_true(git_errno == 0); -END_TEST - -BEGIN_TEST(set_ENOTOID) - must_be_true(GIT_ENOTOID != 0); - git_errno = GIT_ENOTOID; - must_be_true(git_errno == GIT_ENOTOID); -END_TEST From e7379f338474fad9318faffe5d0b6000ff3e1b30 Mon Sep 17 00:00:00 2001 From: Vicent Marti Date: Thu, 23 Dec 2010 00:43:07 +0200 Subject: [PATCH 7/9] 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 --- wscript | 42 +++++++++++++++--------------------------- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/wscript b/wscript index 41d3d30ec..6f898047c 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 From e035685f272579a8620741aaad521540712c0725 Mon Sep 17 00:00:00 2001 From: Vicent Marti Date: Thu, 23 Dec 2010 00:44:41 +0200 Subject: [PATCH 8/9] Revert "Properly export all external symbols in Win32" It is not a good idea to export these internal symbols now that they are not required to run the unit tests. Signed-off-by: Vicent Marti --- src/delta-apply.h | 2 +- src/dir.h | 8 ++++---- src/fileops.h | 42 +++++++++++++++++++++--------------------- src/map.h | 4 ++-- src/thread-utils.h | 2 +- src/util.h | 12 ++++++------ 6 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/delta-apply.h b/src/delta-apply.h index fc5d8cd01..642442de0 100644 --- a/src/delta-apply.h +++ b/src/delta-apply.h @@ -15,7 +15,7 @@ * - GIT_SUCCESS on a successful delta unpack. * - GIT_ERROR if the delta is corrupt or doesn't match the base. */ -GIT_EXTERN(int) git__delta_apply( +extern int git__delta_apply( git_rawobj *out, const unsigned char *base, size_t base_len, diff --git a/src/dir.h b/src/dir.h index bb77d3596..c01c3fae7 100644 --- a/src/dir.h +++ b/src/dir.h @@ -22,10 +22,10 @@ typedef struct { int first; } git__DIR; -GIT_EXTERN(git__DIR *) git__opendir(const char *); -GIT_EXTERN(struct git__dirent *) git__readdir(git__DIR *); -GIT_EXTERN(void) git__rewinddir(git__DIR *); -GIT_EXTERN(int) git__closedir(git__DIR *); +extern git__DIR *git__opendir(const char *); +extern struct git__dirent *git__readdir(git__DIR *); +extern void git__rewinddir(git__DIR *); +extern int git__closedir(git__DIR *); # ifndef GIT__WIN32_NO_WRAP_DIR # define dirent git__dirent diff --git a/src/fileops.h b/src/fileops.h index b90deddda..6656cdf43 100644 --- a/src/fileops.h +++ b/src/fileops.h @@ -27,9 +27,9 @@ GIT_INLINE(int) git__mkdir(const char *path, int GIT_UNUSED(mode)) return mkdir(path); } -GIT_EXTERN(int) git__unlink(const char *path); -GIT_EXTERN(int) git__mkstemp(char *template); -GIT_EXTERN(int) git__fsync(int fd); +extern int git__unlink(const char *path); +extern int git__mkstemp(char *template); +extern int git__fsync(int fd); # ifndef GIT__WIN32_NO_HIDE_FILEOPS # define unlink(p) git__unlink(p) @@ -54,21 +54,21 @@ typedef struct { /* file io buffer */ size_t len; /* data length */ } gitfo_buf; -GIT_EXTERN(int) gitfo_exists(const char *path); -GIT_EXTERN(int) gitfo_open(const char *path, int flags); -GIT_EXTERN(int) gitfo_creat(const char *path, int mode); -GIT_EXTERN(int) gitfo_isdir(const char *path); -GIT_EXTERN(int) gitfo_mkdir_recurs(const char *path, int mode); +extern int gitfo_exists(const char *path); +extern int gitfo_open(const char *path, int flags); +extern int gitfo_creat(const char *path, int mode); +extern int gitfo_isdir(const char *path); +extern int gitfo_mkdir_recurs(const char *path, int mode); #define gitfo_close(fd) close(fd) -GIT_EXTERN(int) gitfo_read(git_file fd, void *buf, size_t cnt); -GIT_EXTERN(int) gitfo_write(git_file fd, void *buf, size_t cnt); +extern int gitfo_read(git_file fd, void *buf, size_t cnt); +extern int gitfo_write(git_file fd, void *buf, size_t cnt); #define gitfo_lseek(f,n,w) lseek(f, n, w) -GIT_EXTERN(off_t) gitfo_size(git_file fd); +extern off_t gitfo_size(git_file fd); -GIT_EXTERN(int) gitfo_read_file(gitfo_buf *obj, const char *path); -GIT_EXTERN(void) gitfo_free_buf(gitfo_buf *obj); -GIT_EXTERN(int) gitfo_move_file(char *from, char *to); +extern int gitfo_read_file(gitfo_buf *obj, const char *path); +extern void gitfo_free_buf(gitfo_buf *obj); +extern int gitfo_move_file(char *from, char *to); #define gitfo_stat(p,b) stat(p, b) #define gitfo_fstat(f,b) fstat(f, b) @@ -97,7 +97,7 @@ GIT_EXTERN(int) gitfo_move_file(char *from, char *to); * - GIT_SUCCESS on success; * - GIT_EOSERR on an unspecified OS related error. */ -GIT_EXTERN(int) gitfo_map_ro( +extern int gitfo_map_ro( git_map *out, git_file fd, off_t begin, @@ -107,7 +107,7 @@ GIT_EXTERN(int) gitfo_map_ro( * Release the memory associated with a previous memory mapping. * @param map the mapping description previously configured. */ -GIT_EXTERN(void) gitfo_free_map(git_map *map); +extern void gitfo_free_map(git_map *map); /** * Walk each directory entry, except '.' and '..', calling fn(state). @@ -120,15 +120,15 @@ GIT_EXTERN(void) gitfo_free_map(git_map *map); * may modify the pathbuf, but only by appending new text. * @param state to pass to fn as the first arg. */ -GIT_EXTERN(int) gitfo_dirent( +extern int gitfo_dirent( char *pathbuf, size_t pathmax, int (*fn)(void *, char *), void *state); -GIT_EXTERN(gitfo_cache *) gitfo_enable_caching(git_file fd, size_t cache_size); -GIT_EXTERN(int) gitfo_write_cached(gitfo_cache *ioc, void *buf, size_t len); -GIT_EXTERN(int) gitfo_flush_cached(gitfo_cache *ioc); -GIT_EXTERN(int) gitfo_close_cached(gitfo_cache *ioc); +extern gitfo_cache *gitfo_enable_caching(git_file fd, size_t cache_size); +extern int gitfo_write_cached(gitfo_cache *ioc, void *buf, size_t len); +extern int gitfo_flush_cached(gitfo_cache *ioc); +extern int gitfo_close_cached(gitfo_cache *ioc); #endif /* INCLUDE_fileops_h__ */ diff --git a/src/map.h b/src/map.h index 2388bb345..3188ffdbb 100644 --- a/src/map.h +++ b/src/map.h @@ -25,7 +25,7 @@ typedef struct { /* memory mapped buffer */ #endif } git_map; -GIT_EXTERN(int) git__mmap(git_map *out, size_t len, int prot, int flags, int fd, off_t offset); -GIT_EXTERN(int) git__munmap(git_map *map); +extern int git__mmap(git_map *out, size_t len, int prot, int flags, int fd, off_t offset); +extern int git__munmap(git_map *map); #endif /* INCLUDE_map_h__ */ diff --git a/src/thread-utils.h b/src/thread-utils.h index 864ecb7b1..0395b97d1 100644 --- a/src/thread-utils.h +++ b/src/thread-utils.h @@ -84,6 +84,6 @@ typedef struct { int counter; } git_refcnt; #endif -GIT_EXTERN(int) git_online_cpus(void); +extern int git_online_cpus(void); #endif /* INCLUDE_thread_utils_h__ */ diff --git a/src/util.h b/src/util.h index 5204185b9..808b20da4 100644 --- a/src/util.h +++ b/src/util.h @@ -14,15 +14,15 @@ #define git__calloc calloc #define git__strdup strdup -GIT_EXTERN(int) git__fmt(char *, size_t, const char *, ...) +extern int git__fmt(char *, size_t, const char *, ...) GIT_FORMAT_PRINTF(3, 4); -GIT_EXTERN(int) git__prefixcmp(const char *str, const char *prefix); -GIT_EXTERN(int) git__suffixcmp(const char *str, const char *suffix); +extern int git__prefixcmp(const char *str, const char *prefix); +extern int git__suffixcmp(const char *str, const char *suffix); -GIT_EXTERN(int) git__dirname(char *dir, size_t n, char *path); -GIT_EXTERN(int) git__basename(char *base, size_t n, char *path); +extern int git__dirname(char *dir, size_t n, char *path); +extern int git__basename(char *base, size_t n, char *path); -GIT_EXTERN(void) git__hexdump(const char *buffer, size_t n); +extern void git__hexdump(const char *buffer, size_t n); /** @return true if p fits into the range of a size_t */ GIT_INLINE(int) git__is_sizet(off_t p) From 51035184ddcc7f5a4437f57e04474b4bb98d8a49 Mon Sep 17 00:00:00 2001 From: Vicent Marti Date: Thu, 23 Dec 2010 01:00:40 +0200 Subject: [PATCH 9/9] Prevent test manifests from being run The test runner was running the manifest and other crap files. Now it filters out to just the executables. Signed-off-by: Vicent Marti --- wscript | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/wscript b/wscript index b02856862..85f7385b2 100644 --- a/wscript +++ b/wscript @@ -209,12 +209,15 @@ class _run_tests(Context): fun = 'run_tests' def run_tests(ctx): - import shutil, tempfile + import shutil, tempfile, sys failed = False test_folder = tempfile.mkdtemp() test_glob = 'build/tests/t????-*' + if sys.platform == 'win32': + test_glob += '.exe' + for test in ctx.path.ant_glob(test_glob): if ctx.exec_command(test.abspath(), cwd=test_folder) != 0: failed = True