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',
24 'Try::Tiny' => '0.04',
30 'Graph::Directed' => '0',
31 'Spreadsheet::ParseExcel' => '0.41',
32 'Text::ParseWords' => '0',
33 'Text::RecordParser' => '0.02',
34 'XML::LibXML' => '1.69',
38 'Test::More' => '0.88',
39 'Test::Differences' => '0',
40 'Test::Exception' => '0.31',
45 name 'SQL-Translator';
46 author 'Ken Youens-Clark <kclark@cpan.org>';
47 abstract 'SQL DDL transformations and more';
49 repository 'git://git.shadowcat.co.uk/dbsrgits/SQL-Translator.git';
50 bugtracker 'http://rt.cpan.org/NoAuth/Bugs.html?Dist=SQL-Translator';
52 resources Ratings => 'http://cpanratings.perl.org/d/SQL-Translator';
54 Meta->{values}{x_authority} = 'cpan:JROBINSON';
56 all_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});
66 no_index directory => $_ for (qw|
67 lib/SQL/Translator/Schema/Graph
69 no_index package => $_ for (qw|
70 SQL::Translator::Schema::Graph
87 # temporary(?) until I get around to fix M::I wrt xt/
88 # needs Module::Install::AuthorTests
90 # this should not be necessary since the autoloader is supposed
91 # to work, but there were reports of it failing
92 require Module::Install::AuthorTests;
93 recursive_author_tests (qw/xt/);
96 if ($Module::Install::AUTHOR) {
99 # better error message in case of missing dep
100 eval { require Module::Install::AuthorTests }
101 || die "\nYou need Module::Install::AuthorTests installed to run this Makefile.PL in author mode:\n\n$@\n";
109 if ($Module::Install::AUTHOR) {
110 _recompile_grammars();
111 _recreate_rt_source();
116 sub _recompile_grammars {
117 return; # disabled until RT#74593 is resolved
121 my $compiled_parser_dir = File::Spec->catdir(qw/
122 share PrecompiledParsers Parse RecDescent DDL SQLT
125 # Currently consider only single-name parsers containing a grammar marker
126 # This is somewhat fragile, but better than loading all kinds of parsers
127 # to some of which we may not even have the deps
128 my $parser_libdir = 'lib/SQL/Translator/Parser';
129 for my $parser_fn (glob "$parser_libdir/*.pm") {
130 die "$parser_fn does not look like a readable file\n"
131 unless ( -f $parser_fn and -r $parser_fn );
133 my ($type) = $parser_fn =~ /^\Q$parser_libdir\E\/(.+)\.pm$/i
134 or die "$parser_fn not named in expected format\n";
136 my $parser_source = do { local (@ARGV, $/) = $parser_fn; <> };
137 next unless $parser_source =~ /\$GRAMMAR.+?END_OF_GRAMMAR/s;
140 my $precomp_parser_fn = File::Spec->catfile($compiled_parser_dir, "$type.pm");
143 -f $precomp_parser_fn
145 (stat($parser_fn))[9] <= (stat($precomp_parser_fn))[9]
149 print "Precompiling parser for $type\n";
152 require Parse::RecDescent;
154 Parse::RecDescent->Precompile(
157 ${"SQL::Translator::Parser::${type}::GRAMMAR"}
158 || die "No \$GRAMMAR global found in SQL::Translator::Parser::$type ($parser_fn)\n"
160 "Parse::RecDescent::DDL::SQLT::$type"
163 rename( "$type.pm", $precomp_parser_fn )
164 or die "Unable to move $type.pm to $compiled_parser_dir: $!\n";
169 sub _recreate_rt_source {
170 my $base_xml = "t/data/roundtrip.xml";
171 my $autogen_yaml = "t/data/roundtrip_autogen.yaml";
173 print "Updating $autogen_yaml\n";
175 unlink $autogen_yaml;
181 require SQL::Translator;
182 require SQL::Translator::Parser::XML;
184 open (my $fh, '>', $autogen_yaml) or die "$autogen_yaml: $!\n";
186 my $tr = SQL::Translator->new;
187 my $yaml = $tr->translate (
191 ) or die sprintf ("Unable to translate %s to YAML: %s\n",
193 $tr->error || 'error unknown'
203 =========================================================================
204 =============== WARNING !!! =================
205 =========================================================================
207 Unable to update the roundtrip schema (attempt triggered by AUTHOR mode).
208 We will still generate a Makefile, but be aware that if you build a dist
209 this way, it *WILL* be broken.
211 -------------------------------------------------------------------------
214 Press Enter to continue.