Skip to content

Commit

Permalink
Merge pull request #22 from titsuki/fix-buildpm
Browse files Browse the repository at this point in the history
Use CustomBuilder.pm6 instead of Builder.pm
  • Loading branch information
titsuki authored Dec 7, 2019
2 parents dac630e + 718cbb6 commit a98b0bd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ install:
- rakudobrew build-zef
- zef --debug --depsonly --/test install .
script:
- zef build .
- PERL6LIB=$PWD/lib zef build .
- PERL6LIB=$PWD/lib prove -e perl6 -vr t/
sudo: false
5 changes: 4 additions & 1 deletion META6.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
],
"build-depends" : [
"LibraryMake",
"Distribution::Builder::MakeFromJSON",
"Zef"
],
"builder" : "MeCab::CustomBuilder",
"depends" : [ ],
"description" : "A Perl 6 bindings for libmecab ( http://taku910.github.io/mecab/ )",
"license" : "Artistic-2.0",
Expand All @@ -17,7 +19,8 @@
"MeCab::DictionaryInfo" : "lib/MeCab/DictionaryInfo.pm6",
"MeCab::Lattice" : "lib/MeCab/Lattice.pm6",
"MeCab::Model" : "lib/MeCab/Model.pm6",
"MeCab::Tagger" : "lib/MeCab/Tagger.pm6"
"MeCab::Tagger" : "lib/MeCab/Tagger.pm6",
"MeCab::CustomBuilder" : "lib/MeCab/CustomBuilder.pm6"
},
"resources" : [
"libraries/mecab"
Expand Down
16 changes: 10 additions & 6 deletions Build.pm → lib/MeCab/CustomBuilder.pm6
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
use v6;
use LibraryMake;
use Zef;
use Zef::Fetch;
use Zef::Extract;
use Distribution::Builder::MakeFromJSON;

class Build {
method build($workdir) {
class MeCab::CustomBuilder:ver<0.0.13> is Distribution::Builder::MakeFromJSON {
method build(IO() $work-dir = $*CWD) {
my $workdir = ~$work-dir;
if $*DISTRO.is-win {
die "Sorry, this binding doesn't support windows";
}
Expand Down Expand Up @@ -36,14 +40,14 @@ class Build {
my $uri = 'https://drive.google.com/uc?export=download&id=0B4y35FiV1wh7cENtOXlicTFaRUE';
my $archive-file = "mecab-0.996.tar.gz".IO.e
?? "mecab-0.996.tar.gz"
!! $fetcher.fetch($uri, "mecab-0.996.tar.gz");
!! $fetcher.fetch(Candidate.new(:$uri), "mecab-0.996.tar.gz");

my @extract-backends = [
{ module => "Zef::Service::Shell::tar" },
{ module => "Zef::Service::Shell::p5tar" },
];
my $extractor = Zef::Extract.new(:backends(@extract-backends));
my $extract-dir = $extractor.extract($archive-file, $*CWD);
my $extract-dir = $extractor.extract(Candidate.new(:uri($archive-file)), $*CWD);
if "mecab-0.996".IO.d {
shell "patch -p1 mecab-0.996/src/mecab.h < $srcdir/mecab.h.patch";
shell "patch -p1 mecab-0.996/src/libmecab.cpp < $srcdir/libmecab.cpp.patch";
Expand All @@ -70,7 +74,7 @@ class Build {
my $uri = 'https://drive.google.com/uc?export=download&id=0B4y35FiV1wh7MWVlSDBCSXZMTXM';
my $archive-file = "mecab-ipadic-2.7.0-20070801.tar.gz".IO.e
?? "mecab-ipadic-2.7.0-20070801.tar.gz"
!! $fetcher.fetch($uri, "mecab-ipadic-2.7.0-20070801.tar.gz");
!! $fetcher.fetch(Candidate.new(:$uri), "mecab-ipadic-2.7.0-20070801.tar.gz");

my @extract-backends = [
{ module => "Zef::Service::Shell::tar" },
Expand All @@ -79,7 +83,7 @@ class Build {
my $extractor = Zef::Extract.new(:backends(@extract-backends));
my $extract-dir = $archive-file.IO.basename.subst(/\.tar\.gz/, '').IO.e
?? $archive-file.IO.basename.subst(/\.tar\.gz/, '').IO
!! $extractor.extract($archive-file, $*CWD);
!! $extractor.extract(Candidate.new(:uri($archive-file)), $*CWD);

chdir("mecab-ipadic-2.7.0-20070801");
shell("./configure --with-charset=utf8 --prefix=$prefix --with-mecab-config=$prefix/bin/mecab-config");
Expand Down

0 comments on commit a98b0bd

Please sign in to comment.