1 use inc::Module::Install 1.06;
5 # to deal wuth x.y.z versions properly
6 configure_requires 'ExtUtils::MakeMaker' => '6.54';
8 perl_version '5.008001';
14 'Parse::RecDescent' => '1.967009',
16 'File::ShareDir' => '1.0',
18 'Package::Variant' => '1.001001',
20 'Try::Tiny' => '0.04',
21 'List::MoreUtils' => '0.09',
22 'Scalar::Util' => '0',
28 'Graph::Directed' => '0',
29 'Spreadsheet::ParseExcel' => '0.41',
30 'Text::RecordParser' => '0.02',
31 'XML::LibXML' => '1.69',
36 'XML::Writer' => '0.500',
37 'Test::More' => '0.88',
38 'Test::Differences' => '0',
39 'Test::Exception' => '0.31',
44 name 'SQL-Translator';
45 author 'Ken Youens-Clark <kclark@cpan.org>';
46 abstract 'SQL DDL transformations and more';
48 repository 'git://git.shadowcat.co.uk/dbsrgits/SQL-Translator.git';
49 bugtracker 'http://rt.cpan.org/NoAuth/Bugs.html?Dist=SQL-Translator';
51 resources Ratings => 'http://cpanratings.perl.org/d/SQL-Translator';
53 Meta->{values}{x_authority} = 'cpan:JROBINSON';
55 all_from 'lib/SQL/Translator.pm';
56 readme_from 'lib/SQL/Translator.pm';
58 for my $type (qw/requires recommends test_requires/) {
61 for my $mod (keys %{$deps->{$type} || {} }) {
62 $f->($mod, $deps->{$type}{$mod});
80 # temporary(?) until I get around to fix M::I wrt xt/
81 # needs Module::Install::AuthorTests
83 # this should not be necessary since the autoloader is supposed
84 # to work, but there were reports of it failing
85 require Module::Install::AuthorTests;
86 recursive_author_tests (qw/xt/);
89 if ($Module::Install::AUTHOR) {
92 # better error message in case of missing dep
93 eval { require Module::Install::AuthorTests }
94 || die "\nYou need Module::Install::AuthorTests installed to run this Makefile.PL in author mode:\n\n$@\n";
102 if ($Module::Install::AUTHOR) {
103 _recompile_grammars();
104 _recreate_rt_source();
109 sub _recompile_grammars {
110 return; # disabled until RT#74593 is resolved
114 my $compiled_parser_dir = File::Spec->catdir(qw/
115 share PrecompiledParsers Parse RecDescent DDL SQLT
118 # Currently consider only single-name parsers containing a grammar marker
119 # This is somewhat fragile, but better than loading all kinds of parsers
120 # to some of which we may not even have the deps
121 my $parser_libdir = 'lib/SQL/Translator/Parser';
122 for my $parser_fn (glob "$parser_libdir/*.pm") {
123 die "$parser_fn does not look like a readable file\n"
124 unless ( -f $parser_fn and -r $parser_fn );
126 my ($type) = $parser_fn =~ /^\Q$parser_libdir\E\/(.+)\.pm$/i
127 or die "$parser_fn not named in expected format\n";
129 my $parser_source = do { local (@ARGV, $/) = $parser_fn; <> };
130 next unless $parser_source =~ /\$GRAMMAR.+?END_OF_GRAMMAR/s;
133 my $precomp_parser_fn = File::Spec->catfile($compiled_parser_dir, "$type.pm");
136 -f $precomp_parser_fn
138 (stat($parser_fn))[9] <= (stat($precomp_parser_fn))[9]
142 print "Precompiling parser for $type\n";
145 require Parse::RecDescent;
147 Parse::RecDescent->Precompile(
150 ${"SQL::Translator::Parser::${type}::GRAMMAR"}
151 || die "No \$GRAMMAR global found in SQL::Translator::Parser::$type ($parser_fn)\n"
153 "Parse::RecDescent::DDL::SQLT::$type"
156 rename( "$type.pm", $precomp_parser_fn )
157 or die "Unable to move $type.pm to $compiled_parser_dir: $!\n";
162 sub _recreate_rt_source {
163 my $base_xml = "t/data/roundtrip.xml";
164 my $autogen_yaml = "t/data/roundtrip_autogen.yaml";
166 print "Updating $autogen_yaml\n";
168 unlink $autogen_yaml;
174 require SQL::Translator;
175 require SQL::Translator::Parser::XML;
177 open (my $fh, '>', $autogen_yaml) or die "$autogen_yaml: $!\n";
179 my $tr = SQL::Translator->new;
180 my $yaml = $tr->translate (
184 ) or die sprintf ("Unable to translate %s to YAML: %s\n",
186 $tr->error || 'error unknown'
196 =========================================================================
197 =============== WARNING !!! =================
198 =========================================================================
200 Unable to update the roundtrip schema (attempt triggered by AUTHOR mode).
201 Aborting Makefile generation, please fix the errors indicated below
202 (typically by installing the missing modules).
204 -------------------------------------------------------------------------