Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Cleaned up source tree, build process is now cleaner

  • Loading branch information...
commit 22fe27c90f13aa754d1f8b8a268a71f0aefb7477 1 parent bf5f786
@mnunberg mnunberg authored
View
35 MANIFEST
@@ -6,6 +6,7 @@ README.pod
PLCB_ConfUtil.pm
PLCB_Config.pm
+build_libraries.pl
lib/Couchbase/Client.pm
lib/Couchbase/Client/Return.pm
@@ -29,26 +30,26 @@ lib/Couchbase/Test/Settings.pm
lib/Couchbase/Test/Interop.pm
lib/Couchbase/Test/Netfail.pm
-Client.xs
-Client_multi.xs
-Async.xs
+xs/Client.xs
+xs/Client_multi.xs
+xs/Async.xs
-perl-couchbase.h
-perl-couchbase-async.h
-plcb-util.h
-plcb-return.h
+xs/perl-couchbase.h
+xs/perl-couchbase-async.h
+xs/plcb-util.h
+xs/plcb-return.h
-callbacks.c
-convert.c
-ctor.c
-async.c
-async_callbacks.c
-async_events.c
+xs/callbacks.c
+xs/convert.c
+xs/ctor.c
+xs/async_base.c
+xs/async_callbacks.c
+xs/async_events.c
-build_libraries.pl
-idx_constants.pl
-error_constants.pl
-print_constants.pl
+
+constants/idx_constants.pl
+constants/error_constants.pl
+constants/print_constants.pl
t/00-load.t
t/01-main.t
View
35 MANIFEST.in
@@ -6,6 +6,7 @@ README.pod
PLCB_ConfUtil.pm
PLCB_Config.pm
+build_libraries.pl
lib/Couchbase/Client.pm
lib/Couchbase/Client/Return.pm
@@ -29,26 +30,26 @@ lib/Couchbase/Test/Settings.pm
lib/Couchbase/Test/Interop.pm
lib/Couchbase/Test/Netfail.pm
-Client.xs
-Client_multi.xs
-Async.xs
+xs/Client.xs
+xs/Client_multi.xs
+xs/Async.xs
-perl-couchbase.h
-perl-couchbase-async.h
-plcb-util.h
-plcb-return.h
+xs/perl-couchbase.h
+xs/perl-couchbase-async.h
+xs/plcb-util.h
+xs/plcb-return.h
-callbacks.c
-convert.c
-ctor.c
-async.c
-async_callbacks.c
-async_events.c
+xs/callbacks.c
+xs/convert.c
+xs/ctor.c
+xs/async_base.c
+xs/async_callbacks.c
+xs/async_events.c
-build_libraries.pl
-idx_constants.pl
-error_constants.pl
-print_constants.pl
+
+constants/idx_constants.pl
+constants/error_constants.pl
+constants/print_constants.pl
t/00-load.t
t/01-main.t
View
152 Makefile.PL
@@ -1,55 +1,107 @@
#!/usr/bin/perl
use strict;
use warnings;
+
use ExtUtils::MakeMaker;
use Dir::Self;
use Getopt::Long;
use Config;
use File::Spec;
use Config;
-
use lib __DIR__;
use PLCB_ConfUtil;
-
GetOptions(
'dynamic' => \my $UseDynamic,
'include=s' => \my $ExtraInclude,
'ldpath=s' => \my $ExtraLDPath,
);
+my %MM_Options;
+################################################################################
+### Our C Source Files ###
+################################################################################
+{
+ my @C_Modules = qw(
+ callbacks convert ctor async_base async_callbacks async_events);
+ my @XS_Modules = qw(Client Client_multi);
+
+ foreach (@XS_Modules, @C_Modules) {
+ my $obj = $_ . $Config{obj_ext};
+ push @{ $MM_Options{OBJECT} }, File::Spec->catfile('xs', $obj);
+ }
+
+ $MM_Options{OBJECT} = join(' ', @{$MM_Options{OBJECT}});
+
+ foreach my $xs (@XS_Modules) {
+ $xs = File::Spec->catfile('xs', $xs);
+ my $c = "$xs.c";
+ $xs = "$xs.xs";
+ $MM_Options{XS}->{$xs} = $c;
+ }
+}
+################################################################################
+### These scripts generate constants ###
+################################################################################
+foreach ([qw(error Errors)], [qw(idx IDXConst)]) {
+ my ($script,$genpm) = @$_;
+ $script = "constants/$script" . "_constants.pl";
+ $genpm = '$(INST_LIB)/Couchbase/Client/' . "$genpm" . "_const.pm";
+ $MM_Options{PL_FILES}->{$script} = $genpm;
+}
-#We might want to figure out right now if we're linking against an existent
-#libcouchbase, using a user-provided custom dynamic link, or dynamic link
-my $myextlib;
+################################################################################
+### Check dependencies ###
+################################################################################
my $inc;
my $libs;
+################################################################################
+### Check build type and options ###
+################################################################################
+my $myextlib;
+
+my $inst_dir = PLCB_ConfUtil::get_inst_dir();
+my $inst_lib_dir = File::Spec->catfile($inst_dir, 'lib');
+my $inst_inc_dir = File::Spec->catfile($inst_dir, 'include');
+
my $buildscript_options = "";
+#my @extra_deps;
+#foreach my $dep (['sasl2', 'sasl'], ['event', 'event']) {
+# my ($installed,$new) = @$dep;
+# print STDERR "Checking if $installed is present...";
+# if(check_lib(lib => $installed,
+# LIBS => $ExtraLDPath, INC => $ExtraInclude)) {
+# print STDERR "OK\n";
+# push @extra_deps, "-l$installed";
+# } else {
+# print STDERR "NOT FOUND (will build embedded)\n";
+# push @extra_deps, File::Spec->catfile($inst_lib_dir,
+# "lib".$new.$Config{lib_ext});
+# $buildscript_options .= ' --build-'.$new;
+# }
+#}
+
if(!$UseDynamic) {
- my $inst_dir = PLCB_ConfUtil::get_inst_dir();
- $inc = '-I' . File::Spec->catfile($inst_dir, 'include');
-
- my $lib_dir = File::Spec->catfile($inst_dir, 'lib');
-
- $libs = "-L$lib_dir -lsasl2 -levent -ldl -lresolv";
+ $inc = '-I' . $inst_inc_dir;
+ $libs = "-L$inst_lib_dir -lsasl2 -levent -ldl -lresolv";
#Set path for linker and friends
$myextlib = join(' ',
- map(File::Spec->catfile($lib_dir, $_.'$(LIB_EXT)'),
+ map(File::Spec->catfile($inst_lib_dir, $_.'$(LIB_EXT)'),
qw(libcouchbase libvbucket)));
-
- {
- no warnings 'once';
- *MY::postamble = \&_static_my_postamble;
- }
} else {
$myextlib = "";
$libs = " -lcouchbase -lvbucket -lcouchbase_libevent";
}
+{
+ $inc .= " " . join(" ", map("-I$_", split(/\s+/, $Config{locincpth})));
+ $libs .= " " . join(" ", map("-L$_", split(/\s+/, $Config{libpth})));
+}
+
foreach ([\$inc, \$ExtraInclude], [\$libs, \$ExtraLDPath]) {
my ($defl,$extra) = @$_;
if($$extra) {
@@ -58,43 +110,24 @@ foreach ([\$inc, \$ExtraInclude], [\$libs, \$ExtraLDPath]) {
}
}
+$MM_Options{INC} = $inc;
+$MM_Options{LIBS} = $libs;
+$MM_Options{MYEXTLIB} = $myextlib;
+
#Write our temporary parameters
PLCB_ConfUtil::write_tmpflags($inc, $libs);
-# .c files
-my @source_modules = qw(
- callbacks
- convert
- ctor
- async
- async_callbacks
- async_events
-);
-
-# .xs files
-my @xs_modules = qw(
- Client
- Client_multi
-);
-my @objects = map {$_ . '.o' } (@source_modules, @xs_modules);
WriteMakefile(
NAME => 'Couchbase::Client',
AUTHOR => q{M. Nunberg <mnunberg@haskalah.org>},
VERSION_FROM => 'lib/Couchbase/Client.pm',
ABSTRACT_FROM => 'lib/Couchbase/Client.pm',
- OBJECT => join(" ", @objects),
-
+
($ExtUtils::MakeMaker::VERSION >= 6.3002
? ('LICENSE'=> 'perl')
- : ()),
-
- PL_FILES => {
- #Force them to build into blib
- "error_constants.pl" => '$(INST_LIB)/Couchbase/Client/Errors_const.pm',
- "idx_constants.pl" => '$(INST_LIB)/Couchbase/Client/IDXConst_const.pm'
- },
+ : ()),
CONFIGURE_REQUIRES => {
'Dir::Self' => 0,
@@ -119,19 +152,36 @@ WriteMakefile(
'POE::Sugar::Attributes' => 0.02,
'POE' => 1.312,
},
- 'MYEXTLIB' => $myextlib,
- NEEDS_LINKING => 1,
-
+
+ NEEDS_LINKING => 1,
OPTIMIZE =>
- ' -Wdeclaration-after-statement -Werror -std=gnu89 -fPIC',
+ ' -Wdeclaration-after-statement -Werror -std=gnu89',
- LIBS => $libs,
- INC => $inc,
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
clean => { FILES => 'Couchbase-Client-* COMPILER_FLAGS' },
+ %MM_Options,
);
-sub MY::libscan {
+
+package MY;
+use Config;
+use strict;
+use warnings;
+
+#thanks rafl!
+sub const_cccmd {
+ my $ret = shift->SUPER::const_cccmd(@_);
+ return q{} unless $ret;
+ if ($Config{cc} =~ /^cl\b/i) {
+ warn 'you are using MSVC... my condolences.';
+ $ret .= ' /Fo$@';
+ } else {
+ $ret .= ' -o $@';
+ }
+ return $ret;
+}
+
+sub libscan {
my ($self,$path) = @_;
if($path =~ /\.pl$/i) {
return "";
@@ -140,7 +190,9 @@ sub MY::libscan {
}
}
-sub _static_my_postamble {
+sub postamble {
+ return unless $myextlib;
+
my $make_text = <<'EOM';
$(MYEXTLIB):
$(PERLRUN) build_libraries.pl __BUILD_LIBRARIES_OPTIONS__
View
2  PLCB_ConfUtil.pm
@@ -74,7 +74,7 @@ sub write_tmpflags {
sub env_from_tmpflags {
my $confhash = do "$TEMPFILE";
$ENV{CFLAGS} .= ' ' . $confhash->{CFLAGS} . ' ' . $Config{ccflags};
- $ENV{CFLAGS} .= ' -I' . __DIR__;
+ $ENV{CFLAGS} .= ' -I' . File::Spec->catfile(__DIR__, 'xs');
$ENV{LDFLAGS}= "";
# $ENV{LDFLAGS} .= ' ' . $confhash->{LDFLAGS};
View
13 build_libraries.pl
@@ -63,6 +63,15 @@ sub tarball_2_dir {
runcmd("tar xf $MEMCACHED_H_TARBALL -C $INST_DIR");
$ENV{CPPFLAGS} .= ' -fPIC ';
+$ENV{CPPFLAGS} .= " -I".File::Spec->catfile($INST_DIR, "include");
+$ENV{LDFLAGS} .= " -lm -L".File::Spec->catfile($INST_DIR, "lib");
+
+$ENV{CPPFLAGS} .= " " . join(" ", map("-I$_", split(/\s+/, $Config{locincpth})));
+$ENV{LDFLAGS} .= " " . join(" ", map("-L$_", split(/\s+/, $Config{libpth})));
+
+log_info("CPPFLAGS:", $ENV{CPPFLAGS});
+log_info("LDFLAS:", $ENV{LDFLAGS});
+
#build libvbucket first:
{
chdir tarball_2_dir($LIBVBUCKET_TARBALL);
@@ -82,10 +91,6 @@ sub tarball_2_dir {
{
chdir $TOPLEVEL;
chdir tarball_2_dir($LIBCOUCHBASE_TARBALL);
- $ENV{CPPFLAGS} .= " -I".File::Spec->catfile($INST_DIR, "include");
- $ENV{LDFLAGS} .= " -lm -L".File::Spec->catfile($INST_DIR, "lib");
- log_info("CPPFLAGS:", $ENV{CPPFLAGS});
- log_info("LDFLAS:", $ENV{LDFLAGS});
my @libcouchbase_options = (
@COMMON_OPTIONS,
View
0  error_constants.pl → constants/error_constants.pl
File renamed without changes
View
0  idx_constants.pl → constants/idx_constants.pl
File renamed without changes
View
0  print_constants.pl → constants/print_constants.pl
File renamed without changes
View
2  lib/Couchbase/Client.pm
@@ -2,7 +2,7 @@ package Couchbase::Client;
BEGIN {
require XSLoader;
- our $VERSION = '0.11_0';
+ our $VERSION = '0.12_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.11_0';
+our $VERSION = '0.12_0';
require XSLoader;
XSLoader::load('Couchbase::Client', $VERSION);
use Couchbase::Client;
View
5 lib/Couchbase/MockServer.pm
@@ -37,15 +37,17 @@ sub _accept_harakiri {
my $begin_time = time();
my $max_wait = 5;
my $got_accept = 0;
+
while(time - $begin_time < $max_wait) {
my $sock = $self->harakiri_socket->accept();
if($sock) {
+ $sock->blocking(1);
$self->harakiri_socket($sock);
$got_accept = 1;
log_info("Got harakiri connection");
my $buf = "";
$self->harakiri_socket->recv($buf, 100, 0);
- if($buf) {
+ if(defined $buf) {
my ($port) = ($buf =~ /(\d+)/);
$self->port($port);
} else {
@@ -59,7 +61,6 @@ sub _accept_harakiri {
if(!$got_accept) {
die("Could not establish harakiri control connection");
}
- $self->harakiri_socket->blocking(1);
}
sub _do_run {
View
0  Async.xs → xs/Async.xs
File renamed without changes
View
0  Client.xs → xs/Client.xs
File renamed without changes
View
0  Client_multi.xs → xs/Client_multi.xs
File renamed without changes
View
0  async.c → xs/async_base.c
File renamed without changes
View
0  async_callbacks.c → xs/async_callbacks.c
File renamed without changes
View
0  async_events.c → xs/async_events.c
File renamed without changes
View
0  callbacks.c → xs/callbacks.c
File renamed without changes
View
0  convert.c → xs/convert.c
File renamed without changes
View
0  ctor.c → xs/ctor.c
File renamed without changes
View
0  perl-couchbase-async.h → xs/perl-couchbase-async.h
File renamed without changes
View
0  perl-couchbase.h → xs/perl-couchbase.h
File renamed without changes
View
0  plcb-return.h → xs/plcb-return.h
File renamed without changes
View
0  plcb-util.h → xs/plcb-util.h
File renamed without changes
Please sign in to comment.
Something went wrong with that request. Please try again.