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',
28 'Graph::Directed' => '0',
29 'Spreadsheet::ParseExcel' => '0.41',
30 'Text::ParseWords' => '0',
31 'Text::RecordParser' => '0.02',
32 'XML::LibXML' => '1.69',
36 'Test::More' => '0.88',
37 'Test::Differences' => '0',
38 'Test::Exception' => '0.31',
43 name 'SQL-Translator';
44 author 'Ken Youens-Clark <kclark@cpan.org>';
45 abstract 'SQL DDL transformations and more';
47 repository 'git://git.shadowcat.co.uk/dbsrgits/SQL-Translator.git';
48 bugtracker 'http://rt.cpan.org/NoAuth/Bugs.html?Dist=SQL-Translator';
50 resources Ratings => 'http://cpanratings.perl.org/d/SQL-Translator';
52 Meta->{values}{x_authority} = 'cpan:JROBINSON';
54 all_from 'lib/SQL/Translator.pm';
56 for my $type (qw/requires recommends test_requires/) {
59 for my $mod (keys %{$deps->{$type} || {} }) {
60 $f->($mod, $deps->{$type}{$mod});
64 no_index directory => $_ for (qw|
65 lib/SQL/Translator/Schema/Graph
67 no_index package => $_ for (qw|
68 SQL::Translator::Schema::Graph
85 # temporary(?) until I get around to fix M::I wrt xt/
86 # needs Module::Install::AuthorTests
88 # this should not be necessary since the autoloader is supposed
89 # to work, but there were reports of it failing
90 require Module::Install::AuthorTests;
91 recursive_author_tests (qw/xt/);
94 if ($Module::Install::AUTHOR) {
97 # better error message in case of missing dep
98 eval { require Module::Install::AuthorTests }
99 || die "\nYou need Module::Install::AuthorTests installed to run this Makefile.PL in author mode:\n\n$@\n";
107 if ($Module::Install::AUTHOR) {
108 _recompile_grammars();
109 _recreate_rt_source();
114 sub _recompile_grammars {
115 return; # disabled until RT#74593 is resolved
119 my $compiled_parser_dir = File::Spec->catdir(qw/
120 share PrecompiledParsers Parse RecDescent DDL SQLT
123 # Currently consider only single-name parsers containing a grammar marker
124 # This is somewhat fragile, but better than loading all kinds of parsers
125 # to some of which we may not even have the deps
126 my $parser_libdir = 'lib/SQL/Translator/Parser';
127 for my $parser_fn (glob "$parser_libdir/*.pm") {
128 die "$parser_fn does not look like a readable file\n"
129 unless ( -f $parser_fn and -r $parser_fn );
131 my ($type) = $parser_fn =~ /^\Q$parser_libdir\E\/(.+)\.pm$/i
132 or die "$parser_fn not named in expected format\n";
134 my $parser_source = do { local (@ARGV, $/) = $parser_fn; <> };
135 next unless $parser_source =~ /\$GRAMMAR.+?END_OF_GRAMMAR/s;
138 my $precomp_parser_fn = File::Spec->catfile($compiled_parser_dir, "$type.pm");
141 -f $precomp_parser_fn
143 (stat($parser_fn))[9] <= (stat($precomp_parser_fn))[9]
147 print "Precompiling parser for $type\n";
150 require Parse::RecDescent;
152 Parse::RecDescent->Precompile(
155 ${"SQL::Translator::Parser::${type}::GRAMMAR"}
156 || die "No \$GRAMMAR global found in SQL::Translator::Parser::$type ($parser_fn)\n"
158 "Parse::RecDescent::DDL::SQLT::$type"
161 rename( "$type.pm", $precomp_parser_fn )
162 or die "Unable to move $type.pm to $compiled_parser_dir: $!\n";
167 sub _recreate_rt_source {
168 my $base_xml = "t/data/roundtrip.xml";
169 my $autogen_yaml = "t/data/roundtrip_autogen.yaml";
171 print "Updating $autogen_yaml\n";
173 unlink $autogen_yaml;
179 require SQL::Translator;
180 require SQL::Translator::Parser::XML;
182 open (my $fh, '>', $autogen_yaml) or die "$autogen_yaml: $!\n";
184 my $tr = SQL::Translator->new;
185 my $yaml = $tr->translate (
189 ) or die sprintf ("Unable to translate %s to YAML: %s\n",
191 $tr->error || 'error unknown'
201 =========================================================================
202 =============== WARNING !!! =================
203 =========================================================================
205 Unable to update the roundtrip schema (attempt triggered by AUTHOR mode).
206 We will still generate a Makefile, but be aware that if you build a dist
207 this way, it *WILL* be broken.
209 -------------------------------------------------------------------------
212 Press Enter to continue.