-
Notifications
You must be signed in to change notification settings - Fork 7
/
.TRAVIS.PL
71 lines (60 loc) · 1.79 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
#!perl
use strict;
use Cwd ();
sub mysystem(@) {
print STDERR "---> @_\n";
system(@_) == 0 or die "Failed to execute @_: $!";
}
sub mychdir::DESTROY {
chdir $_[0]->{o_dir};
}
sub mychdir(@) {
my $guard = bless { o_dir => Cwd::abs_path() }, "mychdir";
chdir $_[0];
return $guard;
}
sub cpanm (@) {
@_ = ("cpanm", "--notest", @_);
goto &mysystem;
}
sub main {
if ($ARGV[0] eq 'install') {
run_install();
} else {
run_test();
}
}
sub run_install {
# download latest mecab and mecab-ipadic
my $mecab_version = "0.994";
my $ipadic_version = "2.7.0-20070801";
mysystem("curl", "-LO", "http://mecab.googlecode.com/files/mecab-$mecab_version.tar.gz");
mysystem("curl", "-LO", "http://downloads.sourceforge.net/project/mecab/mecab-ipadic/$ipadic_version/mecab-ipadic-$ipadic_version.tar.gz");
my $cwd = Cwd::abs_path();
mysystem("tar", "-xvzf", "mecab-$mecab_version.tar.gz");
{
my $guard = mychdir("mecab-$mecab_version");
mysystem("./configure", "--prefix=$cwd/mecab");
mysystem("make", "install");
}
mysystem("tar", "-xvzf", "mecab-ipadic-$ipadic_version.tar.gz");
{
my $guard = mychdir("mecab-ipadic-$ipadic_version");
mysystem("./configure", "--with-charset=utf8", "--with-mecab-config=$cwd/mecab/bin/mecab-config");
mysystem("make", "install");
}
cpanm(qw(
Module::Install
Module::Install::AuthorTests
Module::Install::CheckLib
Module::Install::Repository
Module::Install::XSUtil
));
local $ENV{TRAVIS_TEST} = 1;
mysystem("perl", "Makefile.PL", "--encoding=utf-8", "--mecab-config=$cwd/mecab/bin/mecab-config");
cpanm(qw(--installdeps .));
}
sub run_test {
mysystem("make", "test");
}
main unless caller();