Remove SQL::Translator::Schema::Graph as announced in 0.11011
[dbsrgits/SQL-Translator.git] / Makefile.PL
CommitLineData
860d3652 1use inc::Module::Install 1.06;
6e64adbe 2use strict;
3use warnings;
4
475a7db7 5# to deal wuth x.y.z versions properly
cc553312 6configure_requires 'ExtUtils::MakeMaker' => '6.54';
475a7db7 7
860d3652 8perl_version '5.008001';
9
6e64adbe 10my $deps = {
11 requires => {
cc553312 12 'Class::Base' => '0',
13 'Class::Data::Inheritable' => '0.02',
14 'Digest::SHA' => '0',
15 'Carp::Clan' => '0',
cc553312 16 'IO::Scalar' => '2.110',
7e666ece 17 'Parse::RecDescent' => '1.967009',
cc553312 18 'DBI' => '0',
19 'File::ShareDir' => '1.0',
20 'File::Spec' => '0',
cc553312 21 'XML::Writer' => '0.500',
a5bfeba8 22 'Moo' => '1.000003',
0fb58589 23 'Package::Variant' => '1.001001',
68d75205 24 'Sub::Quote' => '0',
45287c81 25 'Try::Tiny' => '0.04',
7c7966a1 26 'List::MoreUtils' => '0.09',
6e64adbe 27 },
28 recommends => {
cc553312 29 'Template' => '2.20',
30 'GD' => '0',
31 'GraphViz' => '0',
32 'Graph::Directed' => '0',
33 'Spreadsheet::ParseExcel' => '0.41',
34 'Text::ParseWords' => '0',
35 'Text::RecordParser' => '0.02',
36 'XML::LibXML' => '1.69',
6e64adbe 37 },
38 test_requires => {
cc553312 39 'YAML' => '0.66',
860d3652 40 'Test::More' => '0.88',
cc553312 41 'Test::Differences' => '0',
860d3652 42 'Test::Exception' => '0.31',
6e64adbe 43 },
44};
45
6e64adbe 46
47name 'SQL-Translator';
48author 'Ken Youens-Clark <kclark@cpan.org>';
49abstract 'SQL DDL transformations and more';
44659089 50license 'gpl';
3f5ee660 51repository 'git://git.shadowcat.co.uk/dbsrgits/SQL-Translator.git';
6e64adbe 52bugtracker 'http://rt.cpan.org/NoAuth/Bugs.html?Dist=SQL-Translator';
53
54resources Ratings => 'http://cpanratings.perl.org/d/SQL-Translator';
55
09d9cd5e 56Meta->{values}{x_authority} = 'cpan:JROBINSON';
57
6e64adbe 58all_from 'lib/SQL/Translator.pm';
59
60for my $type (qw/requires recommends test_requires/) {
61 no strict qw/refs/;
62 my $f = \&$type;
63 for my $mod (keys %{$deps->{$type} || {} }) {
64 $f->($mod, $deps->{$type}{$mod});
65 }
66}
67
6e64adbe 68install_script (qw|
467b7282 69 script/sqlt-diagram
70 script/sqlt-diff
71 script/sqlt-diff-old
72 script/sqlt-dumper
73 script/sqlt-graph
74 script/sqlt
6e64adbe 75|);
76
77install_share();
78
aee4b66e 79tests_recursive ();
80
81
82# temporary(?) until I get around to fix M::I wrt xt/
83# needs Module::Install::AuthorTests
84eval {
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/);
89 1;
90} || do {
91 if ($Module::Install::AUTHOR) {
92 my $err = $@;
93
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";
97
98 die $err;
99 }
100};
6e64adbe 101
102auto_install();
103
dc34f950 104if ($Module::Install::AUTHOR) {
105 _recompile_grammars();
106 _recreate_rt_source();
107}
108
6e64adbe 109WriteAll();
dc34f950 110
dc34f950 111sub _recompile_grammars {
0eb3b94a 112 return; # disabled until RT#74593 is resolved
113
bdf60588 114 require File::Spec;
115
116 my $compiled_parser_dir = File::Spec->catdir(qw/
117 share PrecompiledParsers Parse RecDescent DDL SQLT
118 /);
119
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 );
127
128 my ($type) = $parser_fn =~ /^\Q$parser_libdir\E\/(.+)\.pm$/i
129 or die "$parser_fn not named in expected format\n";
130
131 my $parser_source = do { local (@ARGV, $/) = $parser_fn; <> };
132 next unless $parser_source =~ /\$GRAMMAR.+?END_OF_GRAMMAR/s;
133
134
135 my $precomp_parser_fn = File::Spec->catfile($compiled_parser_dir, "$type.pm");
136
137 next if (
138 -f $precomp_parser_fn
139 and
140 (stat($parser_fn))[9] <= (stat($precomp_parser_fn))[9]
141 );
142
143
144 print "Precompiling parser for $type\n";
145
146 require $parser_fn;
147 require Parse::RecDescent;
148
149 Parse::RecDescent->Precompile(
150 do {
151 no strict 'refs';
152 ${"SQL::Translator::Parser::${type}::GRAMMAR"}
153 || die "No \$GRAMMAR global found in SQL::Translator::Parser::$type ($parser_fn)\n"
154 },
155 "Parse::RecDescent::DDL::SQLT::$type"
156 );
157
158 rename( "$type.pm", $precomp_parser_fn )
159 or die "Unable to move $type.pm to $compiled_parser_dir: $!\n";
160 }
161
dc34f950 162}
163
164sub _recreate_rt_source {
165 my $base_xml = "t/data/roundtrip.xml";
166 my $autogen_yaml = "t/data/roundtrip_autogen.yaml";
167
168 print "Updating $autogen_yaml\n";
169
170 unlink $autogen_yaml;
171
172 eval {
173
174 use lib 'lib';
175
176 require SQL::Translator;
177 require SQL::Translator::Parser::XML;
178
179 open (my $fh, '>', $autogen_yaml) or die "$autogen_yaml: $!\n";
180
181 my $tr = SQL::Translator->new;
182 my $yaml = $tr->translate (
183 parser => 'XML',
184 file => $base_xml,
185 producer => 'YAML',
186 ) or die sprintf ("Unable to translate %s to YAML: %s\n",
187 $base_xml,
188 $tr->error || 'error unknown'
189 );
190
191 print $fh $yaml;
192 close $fh;
193 };
194
195 if ($@) {
d53db6a7 196 warn <<EOE;
dc34f950 197
198=========================================================================
d53db6a7 199=============== WARNING !!! =================
dc34f950 200=========================================================================
201
202Unable to update the roundtrip schema (attempt triggered by AUTHOR mode).
d53db6a7 203We will still generate a Makefile, but be aware that if you build a dist
204this way, it *WILL* be broken.
dc34f950 205
d53db6a7 206-------------------------------------------------------------------------
dc34f950 207$@
208
d53db6a7 209Press Enter to continue.
dc34f950 210EOE
d53db6a7 211 <>;
dc34f950 212 }
213}