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.964001',
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});
78 # temporary(?) until I get around to fix M::I wrt xt/
79 # needs Module::Install::AuthorTests
81 # this should not be necessary since the autoloader is supposed
82 # to work, but there were reports of it failing
83 require Module::Install::AuthorTests;
84 recursive_author_tests (qw/xt/);
87 if ($Module::Install::AUTHOR) {
90 # better error message in case of missing dep
91 eval { require Module::Install::AuthorTests }
92 || die "\nYou need Module::Install::AuthorTests installed to run this Makefile.PL in author mode:\n\n$@\n";
100 if ($Module::Install::AUTHOR) {
101 _recompile_grammars();
102 _recreate_rt_source();
107 sub _recompile_grammars {
108 return; # disabled until RT#74593 is resolved
112 my $compiled_parser_dir = File::Spec->catdir(qw/
113 share PrecompiledParsers Parse RecDescent DDL SQLT
116 # Currently consider only single-name parsers containing a grammar marker
117 # This is somewhat fragile, but better than loading all kinds of parsers
118 # to some of which we may not even have the deps
119 my $parser_libdir = 'lib/SQL/Translator/Parser';
120 for my $parser_fn (glob "$parser_libdir/*.pm") {
121 die "$parser_fn does not look like a readable file\n"
122 unless ( -f $parser_fn and -r $parser_fn );
124 my ($type) = $parser_fn =~ /^\Q$parser_libdir\E\/(.+)\.pm$/i
125 or die "$parser_fn not named in expected format\n";
127 my $parser_source = do { local (@ARGV, $/) = $parser_fn; <> };
128 next unless $parser_source =~ /\$GRAMMAR.+?END_OF_GRAMMAR/s;
131 my $precomp_parser_fn = File::Spec->catfile($compiled_parser_dir, "$type.pm");
134 -f $precomp_parser_fn
136 (stat($parser_fn))[9] <= (stat($precomp_parser_fn))[9]
140 print "Precompiling parser for $type\n";
143 require Parse::RecDescent;
145 Parse::RecDescent->Precompile(
148 ${"SQL::Translator::Parser::${type}::GRAMMAR"}
149 || die "No \$GRAMMAR global found in SQL::Translator::Parser::$type ($parser_fn)\n"
151 "Parse::RecDescent::DDL::SQLT::$type"
154 rename( "$type.pm", $precomp_parser_fn )
155 or die "Unable to move $type.pm to $compiled_parser_dir: $!\n";
160 sub _recreate_rt_source {
161 my $base_xml = "t/data/roundtrip.xml";
162 my $autogen_yaml = "t/data/roundtrip_autogen.yaml";
164 print "Updating $autogen_yaml\n";
166 unlink $autogen_yaml;
172 require SQL::Translator;
173 require SQL::Translator::Parser::XML;
175 open (my $fh, '>', $autogen_yaml) or die "$autogen_yaml: $!\n";
177 my $tr = SQL::Translator->new;
178 my $yaml = $tr->translate (
182 ) or die sprintf ("Unable to translate %s to YAML: %s\n",
184 $tr->error || 'error unknown'
194 =========================================================================
195 =============== WARNING !!! =================
196 =========================================================================
198 Unable to update the roundtrip schema (attempt triggered by AUTHOR mode).
199 We will still generate a Makefile, but be aware that if you build a dist
200 this way, it *WILL* be broken.
202 -------------------------------------------------------------------------
205 Press Enter to continue.