forked from lestrrat-p5/ZMQ
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.TRAVIS.PL
168 lines (153 loc) · 4.58 KB
/
.TRAVIS.PL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#!perl
use strict;
use Cwd ();
use File::Spec;
my $ROOT = Cwd::abs_path( Cwd::cwd() );
my $EXTDIR = File::Spec->catdir($ROOT, "ext");
my $target = $ENV{PERL_ZMQ_TEST_TARGET} || 'ZMQ-LibZMQ2';
sub myguard::DESTROY {
if ($_[0]->{code}) {
$_[0]->{code}->();
}
}
sub myguard(&) {
bless { code => $_[0] }, 'myguard';
}
if (! -d $target) {
die "$target does not exist";
}
sub mysystem(@) {
print STDERR "===> @_\n";
system(@_) == 0 or die "Failed to execute @_: $!";
}
sub install_libzmq(@) {
my ($basename, $opts) = @_;
mysystem("sudo", "apt-get", "install", "uuid-dev");
my $tail = $opts->{tail} || '';
my $prefix = File::Spec->catdir($EXTDIR, $basename);
my $file = "$basename$tail.tar.gz";
if (! -e $file) {
mysystem("curl", "-LO", "http://download.zeromq.org/$file");
}
if (! -e $basename) {
mysystem("tar", "xzf", $file);
}
my $cwd = Cwd::abs_path();
my $guard = myguard { chdir $cwd };
chdir $basename;
mysystem("./configure", "--prefix", $prefix, @{$opts->{extra_configure_args} ||[]});
mysystem("make");
mysystem("make", "install");
return $prefix;
}
sub cpanm (@) {
eval {
mysystem("cpanm", "--notest", @_);
};
if (my $e = $@) {
my $cpanm_log = "/home/travis/.cpanm/build.log";
open my $fh, '<', $cpanm_log;
while (<$fh>) {
print;
}
die $e;
}
}
sub test_binding {
my $subdir = shift;
my $cwd = Cwd::abs_path();
my $guard = myguard { chdir $cwd };
chdir File::Spec->catdir($ROOT, $subdir);
cpanm("--installdeps", ".");
mysystem("perl", "Makefile.PL");
mysystem("make", "test");
}
sub install_libczmq {
my $zmq_version = shift;
print STDERR "===> Installing libczmq against zeromq-$zmq_version\n";
$ENV{ZMQ_HOME} = install_libzmq("zeromq-$zmq_version");
install_libzmq("czmq-1.3.2", {
extra_configure_args => [
sprintf('--with-libzmq=%s', File::Spec->catdir($EXTDIR, "zeromq-$zmq_version")),
]
});
}
if ( $target eq 'ZMQ-Constants' ) {
cpanm(qw(
inc::Module::Install
Test::Requires
));
test_binding("ZMQ-Constants");
} elsif ( $target eq 'ZMQ-CZMQ' ) {
cpanm(qw(
inc::Module::Install
Module::Install::XSUtil
Module::Install::CheckLib
Test::Requires
Test::TCP
));
foreach my $zmq_version( qw(2.2.0 3.2.2) ) {
$ENV{CZMQ_HOME} = install_libczmq($zmq_version);
cpanm(File::Spec->catdir($ROOT, "ZMQ-LibCZMQ1"));
test_binding("ZMQ-CZMQ");
if ($ENV{ZMQ_HOME} && -d $ENV{ZMQ_HOME}) {
mysystem("rm", "-rf", $ENV{ZMQ_HOME});
}
}
} elsif ( $target eq 'ZMQ-LibCZMQ1' ) {
cpanm(qw(
inc::Module::Install
Module::Install::XSUtil
Module::Install::CheckLib
Test::Requires
Test::TCP
));
foreach my $zmq_version ( qw(2.2.0 3.2.2) ) {
$ENV{CZMQ_HOME} = install_libczmq($zmq_version);
test_binding("ZMQ-LibCZMQ1");
if ($ENV{ZMQ_HOME} && -d $ENV{ZMQ_HOME}) {
mysystem("rm", "-rf", $ENV{ZMQ_HOME});
}
}
} elsif ( $target eq 'ZMQ-LibZMQ2' ) {
$ENV{ZMQ_HOME} = install_libzmq("zeromq-2.2.0");
cpanm(qw(
inc::Module::Install
Module::Install::AuthorTests
Module::Install::CheckLib
Module::Install::XSUtil
));
test_binding("ZMQ-LibZMQ2");
cpanm(qw(AnyEvent Proc::Guard));
test_binding("ZMQ-LibZMQ2");
} elsif ( $target eq 'ZMQ-LibZMQ3' ) {
$ENV{ZMQ_HOME} = install_libzmq("zeromq-3.2.2");
cpanm(qw(
inc::Module::Install
Module::Install::AuthorTests
Module::Install::CheckLib
Module::Install::XSUtil
));
print STDERR "===\n\nTesting $target w/o optional dependencies...\n\n===\n";
test_binding("ZMQ-LibZMQ3");
print STDERR "===\n\nTesting $target with optional dependencies...\n\n===\n";
cpanm(qw(AnyEvent Test::TCP Proc::Guard));
test_binding("ZMQ-LibZMQ3");
} elsif ( $target eq 'ZMQ' ) {
cpanm(qw(
inc::Module::Install
Module::Install::AuthorTests
Module::Install::CheckLib
Module::Install::XSUtil
));
foreach my $zmq_version(qw(2.2.0 3.2.2)) {
my $backend = sprintf 'LibZMQ%d', substr($zmq_version, 0, 1);
$ENV{ZMQ_HOME} = install_libzmq("zeromq-$zmq_version");
cpanm(File::Spec->catdir($ROOT, "ZMQ-$backend"));
$ENV{PERL_ZMQ_BACKEND} = "ZMQ::$backend";
test_binding("ZMQ");
if ($ENV{ZMQ_HOME} && -d $ENV{ZMQ_HOME}) {
mysystem("rm", "-rf", $ENV{ZMQ_HOME});
}
}
}