From 1913e7fdf5c187e917ee57f6925286f9249c06b9 Mon Sep 17 00:00:00 2001 From: Gregory Burd Date: Tue, 16 Apr 2013 21:46:53 -0400 Subject: [PATCH] Continue to iterate on the build system to accomodate shared libs. --- c_src/async_nif.h | 1 - c_src/build_deps.sh | 40 +++++++++++++++++++++++------------- c_src/bzip2-build.patch | 11 ---------- c_src/wiredtiger-build.patch | 20 ++++++++++-------- src/wterl.erl | 6 ++++++ 5 files changed, 44 insertions(+), 34 deletions(-) delete mode 100644 c_src/bzip2-build.patch diff --git a/c_src/async_nif.h b/c_src/async_nif.h index d67bc37..5493dba 100644 --- a/c_src/async_nif.h +++ b/c_src/async_nif.h @@ -295,7 +295,6 @@ async_nif_worker_fn(void *arg) req->fn_work(req->env, req->ref, &req->pid, worker_id, req->args); req->fn_post(req->args); enif_free(req->args); - enif_free_env(req->env); enif_free(req); /* Continue working if more requests are in the queue, otherwise wait diff --git a/c_src/build_deps.sh b/c_src/build_deps.sh index 64821ab..6f69cc9 100755 --- a/c_src/build_deps.sh +++ b/c_src/build_deps.sh @@ -58,10 +58,11 @@ get_wt () ./autogen.sh || exit 1 cd ./build_posix || exit 1 [ -e Makefile ] && $MAKE distclean - ../configure --with-pic \ - --enable-snappy \ - --enable-bzip2 \ - --prefix=${BASEDIR}/system || exit 1 + LDFLAGS="-L$BASEDIR/system/lib" CFLAGS="-I$BASEDIR/system/include" \ + ../configure --with-pic \ + --enable-snappy \ + --enable-bzip2 \ + --prefix=${BASEDIR}/system || exit 1 ) } @@ -74,7 +75,6 @@ get_snappy () patch -p1 --forward < $BASEDIR/snappy-build.patch || exit 1) (cd $BASEDIR/$SNAPPY_DIR || exit 1 ./configure --with-pic \ - --disable-shared \ --prefix=$BASEDIR/system || exit 1 ) } @@ -125,14 +125,24 @@ build_snappy () build_bzip2 () { (cd $BASEDIR/$BZIP2_DIR && \ - $MAKE -j && \ - $MAKE install + $MAKE -j -f Makefile-libbz2_so && \ + mkdir -p $BASEDIR/system/lib && \ + cp -f bzlib.h $BASEDIR/system/include && \ + cp -f libbz2.so.1.0.6 $BASEDIR/system/lib && \ + ln -s $BASEDIR/system/lib/libbz2.so.1.0.6 $BASEDIR/system/lib/libbz2.so && \ + ln -s $BASEDIR/system/lib/libbz2.so.1.0.6 $BASEDIR/system/lib/libbz2-1.so && \ + ln -s $BASEDIR/system/lib/libbz2.so.1.0.6 $BASEDIR/system/lib/libbz2-1.0.so ) } case "$1" in clean) rm -rf system $WT_DIR $SNAPPY_DIR $BZIP2_DIR + rm -f ${BASEDIR}/../priv/wt + rm -f ${BASEDIR}/../priv/libwiredtiger-*.so + rm -f ${BASEDIR}/../priv/libwiredtiger_*.so + rm -f ${BASEDIR}/../priv/libbz2.so.* + rm -f ${BASEDIR}/../priv/libsnappy.so.* ;; test) @@ -154,21 +164,23 @@ case "$1" in # Build Snappy [ -d $BASEDIR/$SNAPPY_DIR ] || (echo "Missing Snappy source directory (did you first get-deps?)" && exit 1) - test -f system/lib/libsnappy.a || build_snappy; + test -f system/lib/libsnappy.so.[0-9].[0-9].[0-9] || build_snappy; # Build BZIP2 [ -d $BASEDIR/$BZIP2_DIR ] || (echo "Missing BZip2 source directory (did you first get-deps?)" && exit 1) - test -f system/lib/libbz2.a || build_bzip2; + test -f system/lib/libbz2.so.[0-9].[0-9].[0-9] || build_bzip2; # Build WiredTiger [ -d $BASEDIR/$WT_DIR ] || (echo "Missing WiredTiger source directory (did you first get-deps?)" && exit 1) - test -f system/lib/libwiredtiger.a -a \ - -f system/lib/libwiredtiger_snappy.a -a \ - -f system/lib/libwiredtiger_bzip2.a || build_wt; + test -f system/lib/libwiredtiger-[0-9].[0-9].[0-9].so -a \ + -f system/lib/libwiredtiger_snappy.so -a \ + -f system/lib/libwiredtiger_bzip2.so || build_wt; [ -d $BASEDIR/../priv ] || mkdir ${BASEDIR}/../priv cp $BASEDIR/system/bin/wt ${BASEDIR}/../priv - cp $BASEDIR/system/lib/libwiredtiger*.so ${BASEDIR}/../priv - + cp $BASEDIR/system/lib/libwiredtiger-[0-9].[0-9].[0-9].so ${BASEDIR}/../priv + cp $BASEDIR/system/lib/libwiredtiger_*.so ${BASEDIR}/../priv + cp $BASEDIR/system/lib/libbz2.so.[0-9].[0-9].[0-9] ${BASEDIR}/../priv + cp $BASEDIR/system/lib/libsnappy.so.[0-9].[0-9].[0-9] ${BASEDIR}/../priv ;; esac diff --git a/c_src/bzip2-build.patch b/c_src/bzip2-build.patch deleted file mode 100644 index 58a732d..0000000 --- a/c_src/bzip2-build.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- foo/Makefile.orig 2013-04-16 10:25:18.837249297 -0400 -+++ foo/Makefile 2013-04-16 10:28:32.113926986 -0400 -@@ -24,7 +24,7 @@ - CFLAGS=-Wall -Winline -O2 -g $(BIGFILES) - - # Where you want it installed when you do 'make install' --PREFIX=/usr/local -+PREFIX=$(BASEDIR)/system - - - OBJS= blocksort.o \ diff --git a/c_src/wiredtiger-build.patch b/c_src/wiredtiger-build.patch index aa78cc0..f689da0 100644 --- a/c_src/wiredtiger-build.patch +++ b/c_src/wiredtiger-build.patch @@ -1,20 +1,24 @@ diff --git a/ext/compressors/bzip2/Makefile.am b/ext/compressors/bzip2/Makefile.am -index 0aedc2e..9cd96e3 100644 +index 0aedc2e..2137b8c 100644 --- a/ext/compressors/bzip2/Makefile.am +++ b/ext/compressors/bzip2/Makefile.am -@@ -3,4 +3,4 @@ AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir)/src/include +@@ -2,5 +2,5 @@ AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir)/src/include + lib_LTLIBRARIES = libwiredtiger_bzip2.la libwiredtiger_bzip2_la_SOURCES = bzip2_compress.c - libwiredtiger_bzip2_la_LDFLAGS = -avoid-version -module +-libwiredtiger_bzip2_la_LDFLAGS = -avoid-version -module -libwiredtiger_bzip2_la_LIBADD = -lbz2 -+libwiredtiger_bzip2_la_LIBADD = -L$(BASEDIR)/system/lib/libbz2.a ++libwiredtiger_bzip2_la_LDFLAGS = -avoid-version -module -Wl,-rpath,.:lib/wterl-0.9.0/priv:lib/wterl/priv:priv ++libwiredtiger_bzip2_la_LIBADD = -lbz2 diff --git a/ext/compressors/snappy/Makefile.am b/ext/compressors/snappy/Makefile.am -index 6d78823..286dc55 100644 +index 6d78823..2f2567e 100644 --- a/ext/compressors/snappy/Makefile.am +++ b/ext/compressors/snappy/Makefile.am -@@ -3,4 +3,4 @@ AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir)/src/include +@@ -2,5 +2,5 @@ AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir)/src/include + lib_LTLIBRARIES = libwiredtiger_snappy.la libwiredtiger_snappy_la_SOURCES = snappy_compress.c - libwiredtiger_snappy_la_LDFLAGS = -avoid-version -module +-libwiredtiger_snappy_la_LDFLAGS = -avoid-version -module -libwiredtiger_snappy_la_LIBADD = -lsnappy -+libwiredtiger_snappy_la_LIBADD = -L$(BASEDIR)/system/lib/libsnappy.a ++libwiredtiger_snappy_la_LDFLAGS = -avoid-version -module -Wl,-rpath,.:lib/wterl-0.9.0/priv:lib/wterl/priv:priv ++libwiredtiger_snappy_la_LIBADD = -lsnappy diff --git a/src/wterl.erl b/src/wterl.erl index 28985c6..a3c7cc4 100644 --- a/src/wterl.erl +++ b/src/wterl.erl @@ -588,6 +588,12 @@ conn_test_() -> ConnRef = open_test_table(ConnRef, "table", [{block_compressor, "snappy"}]), ?assertMatch(ok, verify(ConnRef, "table:test")), ?assertMatch(ok, drop(ConnRef, "table:test")) + end}, + {"create, verify, drop a table(btree, bzip2)", + fun() -> + ConnRef = open_test_table(ConnRef, "table", [{block_compressor, "bzip2"}]), + ?assertMatch(ok, verify(ConnRef, "table:test")), + ?assertMatch(ok, drop(ConnRef, "table:test")) end}]} end}.