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';
14 'Parse::RecDescent' => '1.967009',
16 'File::ShareDir' => '1.0',
18 'Package::Variant' => '1.001001',
20 'Try::Tiny' => '0.04',
21 'List::MoreUtils' => '0.09',
27 'Graph::Directed' => '0',
28 'Spreadsheet::ParseExcel' => '0.41',
29 'Text::RecordParser' => '0.02',
30 'XML::LibXML' => '1.69',
35 'XML::Writer' => '0.500',
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';
55 readme_from 'lib/SQL/Translator.pm';
57 for my $type (qw/requires recommends test_requires/) {
60 for my $mod (keys %{$deps->{$type} || {} }) {
61 $f->($mod, $deps->{$type}{$mod});
79 # temporary(?) until I get around to fix M::I wrt xt/
80 # needs Module::Install::AuthorTests
82 # this should not be necessary since the autoloader is supposed
83 # to work, but there were reports of it failing
84 require Module::Install::AuthorTests;
85 recursive_author_tests (qw/xt/);
88 if ($Module::Install::AUTHOR) {
91 # better error message in case of missing dep
92 eval { require Module::Install::AuthorTests }
93 || die "\nYou need Module::Install::AuthorTests installed to run this Makefile.PL in author mode:\n\n$@\n";
101 if ($Module::Install::AUTHOR) {
102 _recompile_grammars();
103 _recreate_rt_source();
108 sub _recompile_grammars {
109 return; # disabled until RT#74593 is resolved
113 my $compiled_parser_dir = File::Spec->catdir(qw/
114 share PrecompiledParsers Parse RecDescent DDL SQLT
117 # Currently consider only single-name parsers containing a grammar marker
118 # This is somewhat fragile, but better than loading all kinds of parsers
119 # to some of which we may not even have the deps
120 my $parser_libdir = 'lib/SQL/Translator/Parser';
121 for my $parser_fn (glob "$parser_libdir/*.pm") {
122 die "$parser_fn does not look like a readable file\n"
123 unless ( -f $parser_fn and -r $parser_fn );
125 my ($type) = $parser_fn =~ /^\Q$parser_libdir\E\/(.+)\.pm$/i
126 or die "$parser_fn not named in expected format\n";
128 my $parser_source = do { local (@ARGV, $/) = $parser_fn; <> };
129 next unless $parser_source =~ /\$GRAMMAR.+?END_OF_GRAMMAR/s;
132 my $precomp_parser_fn = File::Spec->catfile($compiled_parser_dir, "$type.pm");
135 -f $precomp_parser_fn
137 (stat($parser_fn))[9] <= (stat($precomp_parser_fn))[9]
141 print "Precompiling parser for $type\n";
144 require Parse::RecDescent;
146 Parse::RecDescent->Precompile(
149 ${"SQL::Translator::Parser::${type}::GRAMMAR"}
150 || die "No \$GRAMMAR global found in SQL::Translator::Parser::$type ($parser_fn)\n"
152 "Parse::RecDescent::DDL::SQLT::$type"
155 rename( "$type.pm", $precomp_parser_fn )
156 or die "Unable to move $type.pm to $compiled_parser_dir: $!\n";
161 sub _recreate_rt_source {
162 my $base_xml = "t/data/roundtrip.xml";
163 my $autogen_yaml = "t/data/roundtrip_autogen.yaml";
165 print "Updating $autogen_yaml\n";
167 unlink $autogen_yaml;
173 require SQL::Translator;
174 require SQL::Translator::Parser::XML;
176 open (my $fh, '>', $autogen_yaml) or die "$autogen_yaml: $!\n";
178 my $tr = SQL::Translator->new;
179 my $yaml = $tr->translate (
183 ) or die sprintf ("Unable to translate %s to YAML: %s\n",
185 $tr->error || 'error unknown'
195 =========================================================================
196 =============== WARNING !!! =================
197 =========================================================================
199 Unable to update the roundtrip schema (attempt triggered by AUTHOR mode).
200 We will still generate a Makefile, but be aware that if you build a dist
201 this way, it *WILL* be broken.
203 -------------------------------------------------------------------------
206 Press Enter to continue.