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';
13 'Class::Data::Inheritable' => '0.02',
16 'IO::Scalar' => '2.110',
17 'Parse::RecDescent' => '1.967009',
19 'File::ShareDir' => '1.0',
21 'XML::Writer' => '0.500',
23 'Package::Variant' => '1.001001',
25 'Try::Tiny' => '0.04',
26 'List::MoreUtils' => '0.09',
32 'Graph::Directed' => '0',
33 'Spreadsheet::ParseExcel' => '0.41',
34 'Text::ParseWords' => '0',
35 'Text::RecordParser' => '0.02',
36 'XML::LibXML' => '1.69',
40 'Test::More' => '0.88',
41 'Test::Differences' => '0',
42 'Test::Exception' => '0.31',
47 name 'SQL-Translator';
48 author 'Ken Youens-Clark <kclark@cpan.org>';
49 abstract 'SQL DDL transformations and more';
51 repository 'git://git.shadowcat.co.uk/dbsrgits/SQL-Translator.git';
52 bugtracker 'http://rt.cpan.org/NoAuth/Bugs.html?Dist=SQL-Translator';
54 resources Ratings => 'http://cpanratings.perl.org/d/SQL-Translator';
56 Meta->{values}{x_authority} = 'cpan:JROBINSON';
58 all_from 'lib/SQL/Translator.pm';
60 for my $type (qw/requires recommends test_requires/) {
63 for my $mod (keys %{$deps->{$type} || {} }) {
64 $f->($mod, $deps->{$type}{$mod});
68 no_index directory => $_ for (qw|
69 lib/SQL/Translator/Schema/Graph
71 no_index package => $_ for (qw|
72 SQL::Translator::Schema::Graph
89 # temporary(?) until I get around to fix M::I wrt xt/
90 # needs Module::Install::AuthorTests
92 # this should not be necessary since the autoloader is supposed
93 # to work, but there were reports of it failing
94 require Module::Install::AuthorTests;
95 recursive_author_tests (qw/xt/);
98 if ($Module::Install::AUTHOR) {
101 # better error message in case of missing dep
102 eval { require Module::Install::AuthorTests }
103 || die "\nYou need Module::Install::AuthorTests installed to run this Makefile.PL in author mode:\n\n$@\n";
111 if ($Module::Install::AUTHOR) {
112 _recompile_grammars();
113 _recreate_rt_source();
118 sub _recompile_grammars {
119 return; # disabled until RT#74593 is resolved
123 my $compiled_parser_dir = File::Spec->catdir(qw/
124 share PrecompiledParsers Parse RecDescent DDL SQLT
127 # Currently consider only single-name parsers containing a grammar marker
128 # This is somewhat fragile, but better than loading all kinds of parsers
129 # to some of which we may not even have the deps
130 my $parser_libdir = 'lib/SQL/Translator/Parser';
131 for my $parser_fn (glob "$parser_libdir/*.pm") {
132 die "$parser_fn does not look like a readable file\n"
133 unless ( -f $parser_fn and -r $parser_fn );
135 my ($type) = $parser_fn =~ /^\Q$parser_libdir\E\/(.+)\.pm$/i
136 or die "$parser_fn not named in expected format\n";
138 my $parser_source = do { local (@ARGV, $/) = $parser_fn; <> };
139 next unless $parser_source =~ /\$GRAMMAR.+?END_OF_GRAMMAR/s;
142 my $precomp_parser_fn = File::Spec->catfile($compiled_parser_dir, "$type.pm");
145 -f $precomp_parser_fn
147 (stat($parser_fn))[9] <= (stat($precomp_parser_fn))[9]
151 print "Precompiling parser for $type\n";
154 require Parse::RecDescent;
156 Parse::RecDescent->Precompile(
159 ${"SQL::Translator::Parser::${type}::GRAMMAR"}
160 || die "No \$GRAMMAR global found in SQL::Translator::Parser::$type ($parser_fn)\n"
162 "Parse::RecDescent::DDL::SQLT::$type"
165 rename( "$type.pm", $precomp_parser_fn )
166 or die "Unable to move $type.pm to $compiled_parser_dir: $!\n";
171 sub _recreate_rt_source {
172 my $base_xml = "t/data/roundtrip.xml";
173 my $autogen_yaml = "t/data/roundtrip_autogen.yaml";
175 print "Updating $autogen_yaml\n";
177 unlink $autogen_yaml;
183 require SQL::Translator;
184 require SQL::Translator::Parser::XML;
186 open (my $fh, '>', $autogen_yaml) or die "$autogen_yaml: $!\n";
188 my $tr = SQL::Translator->new;
189 my $yaml = $tr->translate (
193 ) or die sprintf ("Unable to translate %s to YAML: %s\n",
195 $tr->error || 'error unknown'
205 =========================================================================
206 =============== WARNING !!! =================
207 =========================================================================
209 Unable to update the roundtrip schema (attempt triggered by AUTHOR mode).
210 We will still generate a Makefile, but be aware that if you build a dist
211 this way, it *WILL* be broken.
213 -------------------------------------------------------------------------
216 Press Enter to continue.