Skip to content

Commit

Permalink
A whole bunch of changes, mainly build-related.. ugh
Browse files Browse the repository at this point in the history
  • Loading branch information
mnunberg committed Feb 14, 2012
1 parent 5025f61 commit 2aec41c
Show file tree
Hide file tree
Showing 19 changed files with 379 additions and 338 deletions.
218 changes: 108 additions & 110 deletions Client.xs

Large diffs are not rendered by default.

8 changes: 3 additions & 5 deletions MANIFEST
Expand Up @@ -14,8 +14,6 @@ lib/Couchbase/Client/IDXConst.pm


lib/Couchbase/Client/README.pod lib/Couchbase/Client/README.pod


lib/Couchbase/Client/Errors_const.pm
lib/Couchbase/Client/IDXConst_const.pm
lib/Couchbase/Client/Compat.pm lib/Couchbase/Client/Compat.pm


lib/Couchbase/Client/Async.pm lib/Couchbase/Client/Async.pm
Expand Down Expand Up @@ -54,8 +52,8 @@ print_constants.pl


t/00-load.t t/00-load.t
t/01-main.t t/01-main.t
t/tmp/CouchbaseMock.jar


src/memcached-headers.tar.gz src/memcached-headers.tar.gz

src/libcouchbase-1.0.0_50_g1a42d9e.tar.gz
src/libcouchbase-1.0.0_45_g58818c5.tar.gz src/libvbucket-1.8.0.1_5_ga4397f3.tar.gz
src/libvbucket-1.8.0.1_4_g677e403.tar.gz
2 changes: 2 additions & 0 deletions MANIFEST.SKIP
Expand Up @@ -3,3 +3,5 @@
^\. ^\.
^src/ ^src/
^inst_dir/ ^inst_dir/
.+_const\.pm
^author_utils
59 changes: 59 additions & 0 deletions MANIFEST.in
@@ -0,0 +1,59 @@
Changes
MANIFEST
MANIFEST.SKIP
Makefile.PL
README.pod

PLCB_ConfUtil.pm
PLCB_Config.pm

lib/Couchbase/Client.pm
lib/Couchbase/Client/Return.pm
lib/Couchbase/Client/Errors.pm
lib/Couchbase/Client/IDXConst.pm

lib/Couchbase/Client/README.pod

lib/Couchbase/Client/Compat.pm

lib/Couchbase/Client/Async.pm
lib/Couchbase/Client/Async/Event.pm
lib/Couchbase/Client/Async/Request.pm

lib/Couchbase/MockServer.pm
lib/Couchbase/Test/ClientSync.pm
lib/Couchbase/Test/Common.pm
lib/Couchbase/Test/Async.pm
lib/Couchbase/Test/Async/Loop.pm
lib/Couchbase/Test/Settings.pm
lib/Couchbase/Test/Interop.pm
lib/Couchbase/Test/Netfail.pm

Client.xs
Client_multi.xs
Async.xs

perl-couchbase.h
perl-couchbase-async.h
plcb-util.h
plcb-return.h

callbacks.c
convert.c
ctor.c
async.c
async_callbacks.c
async_events.c

build_libraries.pl
idx_constants.pl
error_constants.pl
print_constants.pl

t/00-load.t
t/01-main.t
t/tmp/CouchbaseMock.jar

src/memcached-headers.tar.gz
src/libcouchbase-__LIBCOUCHBASE_RELEASE__.tar.gz
src/libvbucket-__LIBVBUCKET_RELEASE__.tar.gz
39 changes: 30 additions & 9 deletions Makefile.PL
Expand Up @@ -9,6 +9,8 @@ use File::Spec;
use Config; use Config;


use lib __DIR__; use lib __DIR__;
use PLCB_ConfUtil;



GetOptions( GetOptions(
'dynamic' => \my $UseDynamic, 'dynamic' => \my $UseDynamic,
Expand All @@ -24,18 +26,21 @@ my $myextlib;
my $inc; my $inc;
my $libs; my $libs;


my $buildscript_options = "";

if(!$UseDynamic) { if(!$UseDynamic) {
my $inst_dir = File::Spec->catfile('src', 'inst'); 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'); my $lib_dir = File::Spec->catfile($inst_dir, 'lib');


$libs = "-L$lib_dir -lsasl2 -levent -ldl -lresolv";

#Set path for linker and friends #Set path for linker and friends
$myextlib = join(' ', $myextlib = join(' ',
map(File::Spec->catfile($lib_dir, $_.'$(LIB_EXT)'), map(File::Spec->catfile($lib_dir, $_.'$(LIB_EXT)'),
qw(libcouchbase libvbucket))); qw(libcouchbase libvbucket)));


#set include path
$inc = '-I' . File::Spec->catfile($inst_dir, 'include');
$libs = '-lsasl2 -levent -ldl -lresolv';
{ {
no warnings 'once'; no warnings 'once';
*MY::postamble = \&_static_my_postamble; *MY::postamble = \&_static_my_postamble;
Expand All @@ -48,10 +53,14 @@ if(!$UseDynamic) {
foreach ([\$inc, \$ExtraInclude], [\$libs, \$ExtraLDPath]) { foreach ([\$inc, \$ExtraInclude], [\$libs, \$ExtraLDPath]) {
my ($defl,$extra) = @$_; my ($defl,$extra) = @$_;
if($$extra) { if($$extra) {
$$defl ||= "";
$$defl = "$$extra $$defl"; $$defl = "$$extra $$defl";
} }
} }


#Write our temporary parameters
PLCB_ConfUtil::write_tmpflags($inc, $libs);

# .c files # .c files
my @source_modules = qw( my @source_modules = qw(
callbacks callbacks
Expand Down Expand Up @@ -82,8 +91,9 @@ WriteMakefile(
: ()), : ()),


PL_FILES => { PL_FILES => {
"error_constants.pl" => "lib/Couchbase/Client/Errors_const.pm", #Force them to build into blib
"idx_constants.pl" => "lib/Couchbase/Client/IDXConst_const.pm" "error_constants.pl" => '$(INST_LIB)/Couchbase/Client/Errors_const.pm',
"idx_constants.pl" => '$(INST_LIB)/Couchbase/Client/IDXConst_const.pm'
}, },


CONFIGURE_REQUIRES => { CONFIGURE_REQUIRES => {
Expand All @@ -96,12 +106,14 @@ WriteMakefile(
'Class::XSAccessor' => 1.11, 'Class::XSAccessor' => 1.11,
'Test::More' => 0, 'Test::More' => 0,


#We need libevent for whatever we're doing
'Alien::Libevent' => 0.001004,

#These modules are needed for tests, but not strictly required for #These modules are needed for tests, but not strictly required for
#functionality #functionality


'Log::Fu' => 0.25, 'Log::Fu' => 0.25,
'Test::Class' => 0.36, 'Test::Class' => 0.36,
'LWP::UserAgent' => 0,


#these are needed for asynchronous tests and modules #these are needed for asynchronous tests and modules
'POE::Sugar::Attributes' => 0.02, 'POE::Sugar::Attributes' => 0.02,
Expand All @@ -116,16 +128,25 @@ WriteMakefile(
LIBS => $libs, LIBS => $libs,
INC => $inc, INC => $inc,
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
clean => { FILES => 'Couchbase-Client-*' }, clean => { FILES => 'Couchbase-Client-* COMPILER_FLAGS' },
); );


sub MY::libscan {
my ($self,$path) = @_;
if($path =~ /\.pl$/i) {
return "";
} else {
return $path;
}
}


sub _static_my_postamble { sub _static_my_postamble {
my $make_text = <<'EOM'; my $make_text = <<'EOM';
$(MYEXTLIB): $(MYEXTLIB):
$(PERLRUN) build_libraries.pl $(PERLRUN) build_libraries.pl __BUILD_LIBRARIES_OPTIONS__
EOM EOM


$make_text =~ s/__BUILD_LIBRARIES_OPTIONS__/$buildscript_options/g;
$make_text =~ s/^\s+/\t/msg; $make_text =~ s/^\s+/\t/msg;
$make_text; $make_text;
} }
56 changes: 48 additions & 8 deletions PLCB_ConfUtil.pm
Expand Up @@ -2,6 +2,11 @@ package PLCB_ConfUtil;
use strict; use strict;
use warnings; use warnings;
use Dir::Self; use Dir::Self;
use File::Spec;
use File::Path qw(rmtree);
use Data::Dumper;
use Config;

use lib __DIR__; use lib __DIR__;


my $config = do 'PLCB_Config.pm'; my $config = do 'PLCB_Config.pm';
Expand All @@ -11,14 +16,7 @@ if(!$config) {
} }


sub set_gcc_env { sub set_gcc_env {
my $existing_env = $ENV{C_INCLUDE_PATH};
$existing_env ||= "";
my $new_env = $config->{COUCHBASE_INCLUDE_PATH};
if(!$new_env) {
return;
} else {
$ENV{C_INCLUDE_PATH} = "$new_env:$existing_env";
}
} }


sub get_gcc_linker_flags { sub get_gcc_linker_flags {
Expand All @@ -41,4 +39,46 @@ sub get_include_dir {
} }
} }


sub clean_cbc_sources {
my $dir_base = $config->{SRC_DIR};

foreach my $lib (qw(couchbase vbucket)) {
my $dir = sprintf("lib%s-%s", $lib,
$config->{ "LIB" . uc($lib) . "_RELEASE" });
$dir = File::Spec->catfile($dir_base, $dir);
rmtree($dir);
}
rmtree($config->{SRC_INST});
}

sub get_toplevel_dir {
$config->{SRC_DIR};
}

sub get_inst_dir {
$config->{SRC_INST};
}

my $TEMPFILE = File::Spec->catfile(__DIR__, "COMPILER_FLAGS");

sub write_tmpflags {
my ($cflags,$ldflags) = @_;
open my $fh, ">", $TEMPFILE or die "$TEMPFILE: $@";
my $h = {
CFLAGS => $cflags,
LDFLAGS => $ldflags
};
print $fh Dumper($h);
}

sub env_from_tmpflags {
my $confhash = do "$TEMPFILE";
$ENV{CFLAGS} .= ' ' . $confhash->{CFLAGS} . ' ' . $Config{ccflags};
$ENV{CFLAGS} .= ' -I' . __DIR__;
$ENV{LDFLAGS}= "";
# $ENV{LDFLAGS} .= ' ' . $confhash->{LDFLAGS};

# printf("CFLAGS: %s\nLDFLAGS=%s\n", $ENV{CFLAGS}, $ENV{LDFLAGS});
}

1; 1;
21 changes: 15 additions & 6 deletions PLCB_Config.pm
@@ -1,20 +1,29 @@
package PLCB_Config; package PLCB_Config;
use strict; use strict;
use warnings; use warnings;
use Dir::Self;
use File::Spec;
use Hash::Util qw(lock_keys);


#this perl 'hash' contains configuration information necessary #this perl 'hash' contains configuration information necessary
#to bootstrap and/or configure the perl couchbase client and run #to bootstrap and/or configure the perl couchbase client and run
#necessary tests. #necessary tests.


my $params = { my $params = {
#URL from which to download the mock JAR file for tests #URL from which to download the mock JAR file for tests
#COUCHBASE_MOCK_JARURL => COUCHBASE_MOCK_JARURL => 'https://github.com/downloads/mnunberg/' .
# "http://files.couchbase.com/maven2/org/couchbase/mock/". 'perl-Couchbase-Client/CouchbaseMock-0.5-SNAPSHOT.jar',
# "CouchbaseMock/0.5-SNAPSHOT/CouchbaseMock-0.5-20120202.071818-12.jar",
COUCHBASE_MOCK_JARURL => 'http://files.avsej.net/CouchbaseMock.jar', #version numbers for libcouchbase and libvbucket
LIBVBUCKET_RELEASE => '1.8.0.1_4_g677e403', LIBVBUCKET_RELEASE => '1.8.0.1_5_ga4397f3',
LIBCOUCHBASE_RELEASE => '1.0.0_45_g58818c5' LIBCOUCHBASE_RELEASE => '1.0.0_50_g1a42d9e'
}; };




#don't change these, or there may be bad consequences
$params->{SRC_DIR} = File::Spec->catfile(__DIR__, 'src');
$params->{SRC_INST} = File::Spec->catfile($params->{SRC_DIR}, 'inst');

lock_keys(%$params);

return $params; #return value return $params; #return value
File renamed without changes.
8 changes: 8 additions & 0 deletions author_utils/reset_sources.pl
@@ -0,0 +1,8 @@
#!/usr/bin/perl
use strict;
use warnings;
use Dir::Self;
use lib __DIR__ . "../";
use PLCB_ConfUtil;

PLCB_ConfUtil::clean_cbc_sources();

0 comments on commit 2aec41c

Please sign in to comment.