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',
22 'Scalar::Util' => '0',
28 'Graph::Directed' => '0',
29 'Spreadsheet::ParseExcel' => '0.41',
30 'Text::RecordParser' => '0.02',
31 'XML::LibXML' => '1.69',
36 'XML::Writer' => '0.500',
37 'Test::More' => '0.88',
38 'Test::Differences' => '0',
39 'Test::Exception' => '0.31',
40 'Text::ParseWords' => '0',
45 name 'SQL-Translator';
46 author 'Ken Youens-Clark <kclark@cpan.org>';
47 abstract 'SQL DDL transformations and more';
50 resources repository => 'https://github.com/dbsrgits/sql-translator/';
51 resources bugtracker => 'https://rt.cpan.org/NoAuth/Bugs.html?Dist=SQL-Translator';
52 resources Ratings => 'http://cpanratings.perl.org/d/SQL-Translator';
53 resources IRC => 'irc://irc.perl.org/#sql-translator';
55 Meta->{values}{x_authority} = 'cpan:JROBINSON';
57 all_from 'lib/SQL/Translator.pm';
58 readme_from 'lib/SQL/Translator.pm';
60 for my $type (qw/requires recommends test_requires/) {
63 for my $mod (keys %{$deps->{$type} || {} }) {
64 $f->($mod, $deps->{$type}{$mod});
82 # temporary(?) until I get around to fix M::I wrt xt/
83 # needs Module::Install::AuthorTests
85 # this should not be necessary since the autoloader is supposed
86 # to work, but there were reports of it failing
87 require Module::Install::AuthorTests;
88 recursive_author_tests (qw/xt/);
91 if ($Module::Install::AUTHOR) {
94 # better error message in case of missing dep
95 eval { require Module::Install::AuthorTests }
96 || die "\nYou need Module::Install::AuthorTests installed to run this Makefile.PL in author mode:\n\n$@\n";
104 if ($Module::Install::AUTHOR) {
105 _recompile_grammars();
106 _recreate_rt_source();
111 sub _recompile_grammars {
112 return; # disabled until RT#74593 is resolved
116 my $compiled_parser_dir = File::Spec->catdir(qw/
117 share PrecompiledParsers Parse RecDescent DDL SQLT
120 # Currently consider only single-name parsers containing a grammar marker
121 # This is somewhat fragile, but better than loading all kinds of parsers
122 # to some of which we may not even have the deps
123 my $parser_libdir = 'lib/SQL/Translator/Parser';
124 for my $parser_fn (glob "$parser_libdir/*.pm") {
125 die "$parser_fn does not look like a readable file\n"
126 unless ( -f $parser_fn and -r $parser_fn );
128 my ($type) = $parser_fn =~ /^\Q$parser_libdir\E\/(.+)\.pm$/i
129 or die "$parser_fn not named in expected format\n";
131 my $parser_source = do { local (@ARGV, $/) = $parser_fn; <> };
132 next unless $parser_source =~ /\$GRAMMAR.+?END_OF_GRAMMAR/s;
135 my $precomp_parser_fn = File::Spec->catfile($compiled_parser_dir, "$type.pm");
138 -f $precomp_parser_fn
140 (stat($parser_fn))[9] <= (stat($precomp_parser_fn))[9]
144 print "Precompiling parser for $type\n";
147 require Parse::RecDescent;
149 Parse::RecDescent->Precompile(
152 ${"SQL::Translator::Parser::${type}::GRAMMAR"}
153 || die "No \$GRAMMAR global found in SQL::Translator::Parser::$type ($parser_fn)\n"
155 "Parse::RecDescent::DDL::SQLT::$type"
158 rename( "$type.pm", $precomp_parser_fn )
159 or die "Unable to move $type.pm to $compiled_parser_dir: $!\n";
164 sub _recreate_rt_source {
165 my $base_xml = "t/data/roundtrip.xml";
166 my $autogen_yaml = "t/data/roundtrip_autogen.yaml";
168 print "Updating $autogen_yaml\n";
170 unlink $autogen_yaml;
176 require SQL::Translator;
177 require SQL::Translator::Parser::XML;
179 open (my $fh, '>', $autogen_yaml) or die "$autogen_yaml: $!\n";
181 my $tr = SQL::Translator->new;
182 my $yaml = $tr->translate (
186 ) or die sprintf ("Unable to translate %s to YAML: %s\n",
188 $tr->error || 'error unknown'
198 =========================================================================
199 =============== WARNING !!! =================
200 =========================================================================
202 Unable to update the roundtrip schema (attempt triggered by AUTHOR mode).
203 Aborting Makefile generation, please fix the errors indicated below
204 (typically by installing the missing modules).
206 -------------------------------------------------------------------------