Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Build script and test enhancements

Bundled libcouchbase version with consistent error reporting

Tests now more consistent with connection errors

Removed sasl dependency in favor of libcouchbase embedded isasl

Prompt for Java and whether to build dependencies

Fixed Makefile target for libcouchbase.so/EU::MM for non-gmake make
variants

Added dependency for proper version of ExtUtils::CBuilder which includes
env CFLAGS

Removed Log::Fu from src/Makefile.PL, one way to our step of removing
un-needed deps

Include Perl's @Config{qw(cflags ldflags} for ultimate target, stripping
defines, optimization and other compiler/linker directives
  • Loading branch information...
commit c25036baca3a3888173b77da11f0c0fc719b6014 1 parent fdc0e6a
@mnunberg authored
View
3  MANIFEST
@@ -61,7 +61,6 @@ src/Makefile.PL
src/libcouchbase.pm
src/memcached-headers.tar.gz
-src/libcouchbase-1.0.0_70_ge8ad2ee.tar.gz
+src/libcouchbase-1.0.0_75_g5622928.tar.gz
src/libvbucket-1.8.0.2.tar.gz
src/libevent-2.0.17-stable.tar.gz
-src/libisasl-1.0.0_3_g35e33e3.tar.gz
View
1  MANIFEST.in
@@ -64,4 +64,3 @@ src/memcached-headers.tar.gz
src/libcouchbase-__LIBCOUCHBASE_RELEASE__.tar.gz
src/libvbucket-__LIBVBUCKET_RELEASE__.tar.gz
src/libevent-__LIBEVENT_RELEASE__.tar.gz
-src/libisasl-__LIBISASL_RELEASE__.tar.gz
View
26 Makefile.PL
@@ -14,7 +14,6 @@ use lib 'inc';
use Devel::CheckLib;
use Data::Dumper;
-log_err(__DIR__ . "/Makefile.PL");
$ENV{LD_RUN_PATH} ||= "";
#$Verbose = 99;
@@ -35,6 +34,7 @@ EOD
our (@LIBS,$INC);
our $MM_TopLevel;
our $Constants_INC = "";
+our $HaveJava = 0;
push @LIBS, $U_LibPath if $U_LibPath;
$INC = $U_IncPath || "";
@@ -95,6 +95,26 @@ if($ENV{PLCB_BUILD_AUTHOR}) {
$MM_Options{OPTIMIZE} = '-Wdeclaration-after-statement -Werror -std=gnu89';
}
+################################################################################
+### Check for Java ###
+################################################################################
+print STDERR "Checking for working Java (for tests)\n. Running java -version\n";
+$HaveJava = (system("java -version") == 0);
+if(!$HaveJava) {
+ my $promptval = prompt(
+ "java was not found in your path. You must have java to properly\n".
+ "test Couchbase::Client. Java is not a runtime dependency and this\n".
+ "module will likely function properly without it, but will be untested\n".
+ "on your specific installation.\n\n".
+ "Abort installation?", "n");
+
+ if($promptval =~ /^y/i) {
+ print STDERR "You have request to abort the installation.\n".
+ "Makefile.PL will now exit\n";
+ exit(0);
+ }
+}
+
use Log::Fu;
$MM_Options{NEEDS_LINKING} = 1;
@@ -117,6 +137,10 @@ WriteMakefile(
BUILD_REQUIRES => {
'ExtUtils::H2PM' => 0.08,
+
+ #This is really a dependency of ExtUtils::H2PM, but we need a
+ #version which honors the CFLAGS environment variable.
+ 'ExtUtils::CBuilder' => 0.280203
},
PREREQ_PM => {
View
4 PLCB_Config.pm
@@ -16,9 +16,9 @@ my $params = {
#version numbers for libcouchbase and libvbucket
LIBVBUCKET_RELEASE => '1.8.0.2',
- LIBCOUCHBASE_RELEASE => '1.0.0_70_ge8ad2ee',
+ LIBCOUCHBASE_RELEASE => '1.0.0_75_g5622928',
- LIBISASL_RELEASE => '1.0.0_3_g35e33e3',
+ #LIBISASL_RELEASE => '1.0.0_3_g35e33e3',
LIBEVENT_RELEASE => '2.0.17-stable',
};
View
25 build_libraries.pl
@@ -17,6 +17,7 @@
'env-ldflags=s' => \my $ENV_LDFLAGS,
'env-libs=s' => \my $ENV_LIBS,
'rpath=s' => \my $RPATH,
+ 'have-java' => \my $HAVE_JAVA,
);
use lib __DIR__;
@@ -44,7 +45,7 @@
sub runcmd {
my $cmd = join(" ", @_);
- print STDERR "Running $cmd\n";
+ print STDERR "[EXECUTING]:\n\t$cmd\n";
unless(system($cmd . " $BUILD_SILENT") == 0) {
print STDERR "Command $cmd failed\n";
printf STDERR ("CPPFLAGS=%s\nLDFLAGS=%s\n", $ENV{CPPFLAGS}, $ENV{LDFLAGS});
@@ -74,7 +75,6 @@ sub tarball_2_dir {
################################################################################
my $LIBVBUCKET_TARBALL = lib_2_tarball('libvbucket');
my $LIBCOUCHBASE_TARBALL = lib_2_tarball('libcouchbase');
-my $LIBISASL_TARBALL = lib_2_tarball('libisasl');
my $LIBEVENT_TARBALL = lib_2_tarball('libevent');
my $MEMCACHED_H_TARBALL = "memcached-headers.tar.gz";
@@ -148,14 +148,16 @@ sub lib_is_built {
################################################################################
### ISASL ###
################################################################################
-if(should_build('ISASL')) {
- chdir $TOPLEVEL;
- chdir tarball_2_dir($LIBISASL_TARBALL);
- runcmd("./configure", @COMMON_OPTIONS) unless -e 'Makefile';
- log_info("Configuring libisasl");
- runcmd("$MAKEPROG install");
- log_info("Installed libisasl");
-}
+#my $LIBISASL_TARBALL = lib_2_tarball('libisasl');
+#disabled because we now bundle it with libcouchbase itself.
+#if(should_build('ISASL')) {
+# chdir $TOPLEVEL;
+# chdir tarball_2_dir($LIBISASL_TARBALL);
+# runcmd("./configure", @COMMON_OPTIONS) unless -e 'Makefile';
+# log_info("Configuring libisasl");
+# runcmd("$MAKEPROG install");
+# log_info("Installed libisasl");
+#}
################################################################################
### libevent ###
@@ -216,14 +218,13 @@ sub lib_is_built {
push @libcouchbase_options, '--disable-tools';
}
- my $have_java = eval { runcmd("java", "-version"); 1; };
my $mockpath = File::Spec->catfile(
__DIR__, 't', 'tmp', 'CouchbaseMock.jar');
if(!-e $mockpath) {
die("Can't find mock in $mockpath");
}
- if($have_java && -e $mockpath) {
+ if($HAVE_JAVA && -e $mockpath) {
push @libcouchbase_options, '--with-couchbasemock='.$mockpath;
} else {
push @libcouchbase_options, '--disable-couchbasemock';
View
12 couchbase-client.kpf
@@ -2,9 +2,21 @@
<!-- Komodo Project File - DO NOT EDIT -->
<project id="32a0fd74-e11a-3743-94a7-9bb2f44a5377" kpf_version="4" name="couchbase-client.kpf">
<preference-set idref="32a0fd74-e11a-3743-94a7-9bb2f44a5377">
+ <string id="import_exclude_matches">*.*~;*.bak;*.tmp;CVS;.#*;*.pyo;*.pyc;.svn;*%*;tmp*.html;.DS_Store;*.o;*.swp*;*.json;Makefile;pm_to_blib;*.tar.gz;*.bs;*.xsc;log*</string>
+ <string id="import_include_matches"></string>
<boolean id="import_live">1</boolean>
+ <boolean id="import_recursive">0</boolean>
+ <string id="import_type">makeFlat</string>
+ <string id="lastTestPlanName_pref">New test plan #1</string>
<string relative="path" id="perlExtraPaths">lib:/home/mordy/src/Couchbase-Client/blib</string>
<boolean id="perl_lintOption_includeCurrentDirForLinter">1</boolean>
<string id="phpExtraPaths"></string>
+<preference-set id="testPlans">
+<preference-set id="New test plan #1">
+ <string id="command_line"></string>
+ <string relative="url" id="directory"></string>
+ <string id="language">Perl - TAP (*.t)</string>
+</preference-set>
+</preference-set>
</preference-set>
</project>
View
2  lib/Couchbase/Client.pm
@@ -2,7 +2,7 @@ package Couchbase::Client;
BEGIN {
require XSLoader;
- our $VERSION = '0.16_0';
+ our $VERSION = '0.17_0';
XSLoader::load(__PACKAGE__, $VERSION);
}
View
2  lib/Couchbase/Client/Async.pm
@@ -1,7 +1,7 @@
package Couchbase::Client::Async;
use strict;
use warnings;
-our $VERSION = '0.16_0';
+our $VERSION = '0.17_0';
use Couchbase::Client;
use Couchbase::Client::IDXConst;
use Log::Fu;
View
17 lib/Couchbase/Test/Settings.pm
@@ -89,7 +89,7 @@ sub T20_settings_connect :Test(no_plan)
ok(!$client->connect, "Failure to connect to nonexistent host");
my $errors = $client->get_errors;
ok(scalar @$errors, "Have error");
- is($errors->[0]->[0], COUCHBASE_NETWORK_ERROR, "Got NETWORK_ERROR");
+ is($errors->[0]->[0], COUCHBASE_CONNECT_ERROR, "Got CONNECT_ERROR");
$client = Couchbase::Client->new({
%{$self->common_options},
@@ -245,7 +245,10 @@ sub T24_timeout_settings :Test(no_plan)
sub T25_multi_server_list :Test(no_plan)
{
my $self = shift;
- my $server_list = ['localhost:0'];
+ # We can't use null for a port here because it might fail on GAI for
+ # SOCK_STREAM
+
+ my $server_list = ['localhost:1'];
my %options = %{$self->common_options};
my $bucket = $options{bucket};
my ($username,$password) = @options{qw(username password)};
@@ -259,10 +262,16 @@ sub T25_multi_server_list :Test(no_plan)
$cbo = Couchbase::Client->new({%options});
note "Connecting with bucket $bucket";
isa_ok($cbo, 'Couchbase::Client');
- is(scalar @{$cbo->get_errors}, 1, "have single error");
- is($cbo->get_errors->[0]->[0], COUCHBASE_NETWORK_ERROR,
+ ok(scalar @{$cbo->get_errors}, "have error(s)");
+ is($cbo->get_errors->[0]->[0], COUCHBASE_CONNECT_ERROR,
"Got network error for nonexistent host");
+ # If we have more than a single error, print them out (via dumper);
+ if(@{$cbo->get_errors()} > 1) {
+ diag "We really expected a single error. Extra info:";
+ diag Dumper($cbo->get_errors());
+ }
+
$ret = $cbo->set("foo", "fooval");
ok($ret->is_ok, "connected and can set value (retry ok)");
if(!$ret->is_ok){
View
97 src/Makefile.PL
@@ -6,7 +6,6 @@ use warnings;
use ExtUtils::MakeMaker;
use Dir::Self;
use Devel::CheckLib;
-use Log::Fu { level => 'debug' };
use Dir::Self;
use Data::Dumper;
use File::Spec;
@@ -84,16 +83,17 @@ EOC
sub check_dependency {
my ($names,$fn,%extra) = @_;
$names = ref $names ? $names : [ $names ];
- log_info("Checking for", @$names);
- local $ENV;
-
+
+ print STDERR "\nChecking for @{$names}...\n";
+ local %ENV = %ENV;
+
foreach my $libname (@$names) {
my (undef,undef,$ldargs,$runpath,$sofile) =
ExtUtils::Liblist->ext("$SEARCHPATH_S -l$libname", 0, 1);
next unless ($sofile && ($sofile = $sofile->[0]) );
-
- log_info("Have:", $sofile);
+
+ print STDERR "\tfound shared object: $sofile \n";
my %cl_opts = (
%CHECKLIB_OPTIONS,
lib => $libname,
@@ -108,12 +108,14 @@ sub check_dependency {
if($fn) {
$cl_opts{function} = $fn;
}
+ print STDERR "\tCompiling test program\n";
if(check_lib(%cl_opts, %extra)) {
- log_info("have $libname");
+ print STDERR "\tOK ($libname)\n";
return 1;
}
}
- log_warn("Couldn't find anything for", @$names);
+ print STDERR "\tNOT FOUND\n";
+ return 0;
}
@@ -135,7 +137,30 @@ sub create_buildscript_invocation {
my ($mm,$build,$install,$deps) = @_;
#mm is the parent Makefile, here
-
+
+ # we need to make sure our flags match whatever Devel::CheckLib might have
+ # used to determine an available dependency:
+
+ my $script_cppflags = $mm->{INC};
+ my $config_ccflags = $Config{ccflags};
+
+ # Strip any -D's, -f's, -g, and -O from the flags. and remove -pthread
+
+ $config_ccflags =~ s/-(?:D|f|O|M|g)\S+//g;
+
+ #string excessive whitespace:
+ $config_ccflags =~ s/\s+/ /g;
+
+ $script_cppflags .= ' ' . $config_ccflags;
+
+
+ $PLCBTopLevel::U_LibPath ||= "";
+
+ my $script_ldflags = $mm->{LDLOADLIBS} . ' ' . $PLCBTopLevel::U_LibPath .
+ ' ' . $Config{ldflags};
+
+ my $java_arg = $PLCBTopLevel::HaveJava ? "--have-java" : "";
+
my @lines = (
#begin long commandline invocation:
@@ -144,22 +169,20 @@ sub create_buildscript_invocation {
#'$(NOECHO) $(ECHO) '.
'$(PERLRUN) ' .
File::Spec->catfile('..', 'build_libraries.pl') . "\\",
- "\t\t".sprintf(" --build-prefix=%s \\\n\t\t--install-prefix=%s",
+ "\t".sprintf(" --build-prefix=%s \\\n\t\t--install-prefix=%s $java_arg",
$mm->quote_literal($build),
$mm->quote_literal($install)) . "\\",
- "\t\t".sprintf(" --env-cppflags=%s",
- $mm->quote_literal($mm->{INC})) . "\\",
+ "\t".sprintf(" --env-cppflags=%s",
+ $mm->quote_literal($script_cppflags)) . "\\",
- "\t\t".sprintf(" --env-libs=%s",
- $mm->quote_literal($mm->{LDLOADLIBS}. ' ' .
- $PLCBTopLevel::U_LibPath)) . "\\",
+ "\t".sprintf(" --env-libs=%s",
+ $mm->quote_literal($script_ldflags)) . "\\",
-
- "\t\t".sprintf(" --rpath=%s",
+ "\t".sprintf(" --rpath=%s",
$mm->quote_literal($mm->{LD_RUN_PATH})) . "\\",
- "\t\t".join(" ", @$deps)
+ "\t".join(" ", @$deps),
);
@@ -181,14 +204,15 @@ sub ldrunpath2rpath {
my $existing_flags = $parent->{LDDLFLAGS};
my @components = map { "$prefix$_" } split($Config{path_sep}, $ld_run_path);
$parent->{LDDLFLAGS} = join(" ", @components) . " " . $Config{lddlflags};
- log_warn("Mangled compiler line now is: ", $parent->{LDDLFLAGS});
+ printf STDERR ("\nFound RPATH directive in perl's linker flags.\n".
+ "Mangled compiler line now is: %s", $parent->{LDDLFLAGS});
}
sub mangle_parent_makefile {
my ($parent,$deps) = @_;
no strict 'refs';
- log_warn("Mangling parent MM methods for extra dependencies");
+ print STDERR ("Mangling parent MM methods for extra dependencies\n");
my $libpath = File::Spec->catfile($Sharepath, 'lib');
@@ -207,7 +231,7 @@ sub mangle_parent_makefile {
my $ret = $old_meth->($mm,@args, INST_DYNAMIC_DEP => $dep);
$ret = join("\n",
"\$(MYEXTLIB) ::",
- "\t\$(NOOP)",
+ "\t\ " . $mm->cd("src", '$(MAKE)'),
) . $ret;
return $ret;
@@ -276,7 +300,10 @@ sub MM_Configure {
@to_build = qw(VBUCKET COUCHBASE EVENT ISASL);
goto GT_MANGLE;
}
-
+
+ printf STDERR ("\nWill run a few test programs to see ".
+ "if depencies are required\n");
+
my $have_libcouchbase =
check_dependency('couchbase',$LIBCOUCHBASE_CFUNC,
header => ['sys/types.h', 'libcouchbase/couchbase.h'] );
@@ -288,17 +315,37 @@ sub MM_Configure {
}
if(!check_dependency(
- 'event', $LIBEVENT_CFUNC, header => ['event.h'] )) {
+ 'event', $LIBEVENT_CFUNC, header => ['event.h', 'stdio.h'] )) {
push @to_build, 'EVENT';
}
- if(!check_dependency(
+
+
+ if(0 && !check_dependency(
['sasl2', 'sasl'], $LIBSASL_CFUNC,
header => [ 'stdlib.h', 'sasl/sasl.h'] )) {
push @to_build, 'ISASL';
}
GT_MANGLE:
- log_err("We need to build the following dependencies:", @to_build);
+ my $errmsg = "\n".
+ "Couchbase::Client needs to build the following dependencies:\n".
+ "\t@to_build\n\n".
+ "You may want to install dependencies from your package manager\n".
+ "or install the bundled version.\n".
+ "\n".
+ "Installing the bundled version will (for better or worse) NOT\n".
+ "affect applications which depend on those libraries\n".
+ "\n".
+ "Install bundled libraries?";
+ my $promptval = prompt($errmsg, "y");
+
+ if($promptval !~ /^y/i) {
+ print STDERR "You have selected not to build and install the bundled\n".
+ "dependencies. Couchbase::Client will not be built\n";
+ exit(0);
+ }
+
+ print STDERR "Will build: @to_build\n\n...";
mangle_parent_makefile($parent, \@to_build);
Please sign in to comment.
Something went wrong with that request. Please try again.