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',
31 'Graph::Directed' => '0',
32 'Spreadsheet::ParseExcel' => '0.41',
33 'Text::ParseWords' => '0',
34 'Text::RecordParser' => '0.02',
35 'XML::LibXML' => '1.69',
39 'Test::More' => '0.88',
40 'Test::Differences' => '0',
41 'Test::Exception' => '0.31',
46 name 'SQL-Translator';
47 author 'Ken Youens-Clark <kclark@cpan.org>';
48 abstract 'SQL DDL transformations and more';
50 repository 'git://git.shadowcat.co.uk/dbsrgits/SQL-Translator.git';
51 bugtracker 'http://rt.cpan.org/NoAuth/Bugs.html?Dist=SQL-Translator';
53 resources Ratings => 'http://cpanratings.perl.org/d/SQL-Translator';
55 Meta->{values}{x_authority} = 'cpan:JROBINSON';
57 all_from 'lib/SQL/Translator.pm';
59 for my $type (qw/requires recommends test_requires/) {
62 for my $mod (keys %{$deps->{$type} || {} }) {
63 $f->($mod, $deps->{$type}{$mod});
67 no_index directory => $_ for (qw|
68 lib/SQL/Translator/Schema/Graph
70 no_index package => $_ for (qw|
71 SQL::Translator::Schema::Graph
88 # temporary(?) until I get around to fix M::I wrt xt/
89 # needs Module::Install::AuthorTests
91 # this should not be necessary since the autoloader is supposed
92 # to work, but there were reports of it failing
93 require Module::Install::AuthorTests;
94 recursive_author_tests (qw/xt/);
97 if ($Module::Install::AUTHOR) {
100 # better error message in case of missing dep
101 eval { require Module::Install::AuthorTests }
102 || die "\nYou need Module::Install::AuthorTests installed to run this Makefile.PL in author mode:\n\n$@\n";
110 if ($Module::Install::AUTHOR) {
111 _recompile_grammars();
112 _recreate_rt_source();
117 sub _recompile_grammars {
118 return; # disabled until RT#74593 is resolved
122 my $compiled_parser_dir = File::Spec->catdir(qw/
123 share PrecompiledParsers Parse RecDescent DDL SQLT
126 # Currently consider only single-name parsers containing a grammar marker
127 # This is somewhat fragile, but better than loading all kinds of parsers
128 # to some of which we may not even have the deps
129 my $parser_libdir = 'lib/SQL/Translator/Parser';
130 for my $parser_fn (glob "$parser_libdir/*.pm") {
131 die "$parser_fn does not look like a readable file\n"
132 unless ( -f $parser_fn and -r $parser_fn );
134 my ($type) = $parser_fn =~ /^\Q$parser_libdir\E\/(.+)\.pm$/i
135 or die "$parser_fn not named in expected format\n";
137 my $parser_source = do { local (@ARGV, $/) = $parser_fn; <> };
138 next unless $parser_source =~ /\$GRAMMAR.+?END_OF_GRAMMAR/s;
141 my $precomp_parser_fn = File::Spec->catfile($compiled_parser_dir, "$type.pm");
144 -f $precomp_parser_fn
146 (stat($parser_fn))[9] <= (stat($precomp_parser_fn))[9]
150 print "Precompiling parser for $type\n";
153 require Parse::RecDescent;
155 Parse::RecDescent->Precompile(
158 ${"SQL::Translator::Parser::${type}::GRAMMAR"}
159 || die "No \$GRAMMAR global found in SQL::Translator::Parser::$type ($parser_fn)\n"
161 "Parse::RecDescent::DDL::SQLT::$type"
164 rename( "$type.pm", $precomp_parser_fn )
165 or die "Unable to move $type.pm to $compiled_parser_dir: $!\n";
170 sub _recreate_rt_source {
171 my $base_xml = "t/data/roundtrip.xml";
172 my $autogen_yaml = "t/data/roundtrip_autogen.yaml";
174 print "Updating $autogen_yaml\n";
176 unlink $autogen_yaml;
182 require SQL::Translator;
183 require SQL::Translator::Parser::XML;
185 open (my $fh, '>', $autogen_yaml) or die "$autogen_yaml: $!\n";
187 my $tr = SQL::Translator->new;
188 my $yaml = $tr->translate (
192 ) or die sprintf ("Unable to translate %s to YAML: %s\n",
194 $tr->error || 'error unknown'
204 =========================================================================
205 =============== WARNING !!! =================
206 =========================================================================
208 Unable to update the roundtrip schema (attempt triggered by AUTHOR mode).
209 We will still generate a Makefile, but be aware that if you build a dist
210 this way, it *WILL* be broken.
212 -------------------------------------------------------------------------
215 Press Enter to continue.