1 use inc::Module::Install 1.00;
5 # to deal wuth x.y.z versions properly
6 configure_requires 'ExtUtils::MakeMaker' => 6.54;
11 'Class::Data::Inheritable' => 0.02,
12 'Class::MakeMethods' => 0,
16 'IO::Scalar' => 2.110,
17 'Parse::RecDescent' => 1.964001,
20 'File::ShareDir' => 1.0,
23 'XML::Writer' => 0.500,
30 'Graph::Directed' => 0,
31 'Spreadsheet::ParseExcel' => 0.41,
32 'Text::ParseWords' => 0,
33 'Text::RecordParser' => 0.02,
34 'XML::LibXML' => 1.69,
38 'File::Basename' => 0,
40 'Test::Differences' => 0,
41 'Test::Exception' => 0,
47 name 'SQL-Translator';
48 author 'Ken Youens-Clark <kclark@cpan.org>';
49 abstract 'SQL DDL transformations and more';
51 repository 'git://git.shadowcat.co.uk/dbsrgits/SQL-Translator.git';
52 bugtracker 'http://rt.cpan.org/NoAuth/Bugs.html?Dist=SQL-Translator';
54 resources Ratings => 'http://cpanratings.perl.org/d/SQL-Translator';
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});
83 if ($Module::Install::AUTHOR) {
84 _recompile_grammars();
85 _recreate_rt_source();
90 sub _recompile_grammars {
93 my $compiled_parser_dir = File::Spec->catdir(qw/
94 share PrecompiledParsers Parse RecDescent DDL SQLT
97 # Currently consider only single-name parsers containing a grammar marker
98 # This is somewhat fragile, but better than loading all kinds of parsers
99 # to some of which we may not even have the deps
100 my $parser_libdir = 'lib/SQL/Translator/Parser';
101 for my $parser_fn (glob "$parser_libdir/*.pm") {
102 die "$parser_fn does not look like a readable file\n"
103 unless ( -f $parser_fn and -r $parser_fn );
105 my ($type) = $parser_fn =~ /^\Q$parser_libdir\E\/(.+)\.pm$/i
106 or die "$parser_fn not named in expected format\n";
108 my $parser_source = do { local (@ARGV, $/) = $parser_fn; <> };
109 next unless $parser_source =~ /\$GRAMMAR.+?END_OF_GRAMMAR/s;
112 my $precomp_parser_fn = File::Spec->catfile($compiled_parser_dir, "$type.pm");
115 -f $precomp_parser_fn
117 (stat($parser_fn))[9] <= (stat($precomp_parser_fn))[9]
121 print "Precompiling parser for $type\n";
124 require Parse::RecDescent;
126 Parse::RecDescent->Precompile(
129 ${"SQL::Translator::Parser::${type}::GRAMMAR"}
130 || die "No \$GRAMMAR global found in SQL::Translator::Parser::$type ($parser_fn)\n"
132 "Parse::RecDescent::DDL::SQLT::$type"
135 rename( "$type.pm", $precomp_parser_fn )
136 or die "Unable to move $type.pm to $compiled_parser_dir: $!\n";
141 sub _recreate_rt_source {
142 my $base_xml = "t/data/roundtrip.xml";
143 my $autogen_yaml = "t/data/roundtrip_autogen.yaml";
145 print "Updating $autogen_yaml\n";
147 unlink $autogen_yaml;
153 require SQL::Translator;
154 require SQL::Translator::Parser::XML;
156 open (my $fh, '>', $autogen_yaml) or die "$autogen_yaml: $!\n";
158 my $tr = SQL::Translator->new;
159 my $yaml = $tr->translate (
163 ) or die sprintf ("Unable to translate %s to YAML: %s\n",
165 $tr->error || 'error unknown'
175 =========================================================================
176 =============== WARNING !!! =================
177 =========================================================================
179 Unable to update the roundtrip schema (attempt triggered by AUTHOR mode).
180 We will still generate a Makefile, but be aware that if you build a dist
181 this way, it *WILL* be broken.
183 -------------------------------------------------------------------------
186 Press Enter to continue.