Commit | Line | Data |
860d3652 |
1 | use inc::Module::Install 1.06; |
6e64adbe |
2 | use strict; |
3 | use warnings; |
4 | |
475a7db7 |
5 | # to deal wuth x.y.z versions properly |
cc553312 |
6 | configure_requires 'ExtUtils::MakeMaker' => '6.54'; |
475a7db7 |
7 | |
860d3652 |
8 | perl_version '5.008001'; |
9 | |
6e64adbe |
10 | my $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 | |
47 | name 'SQL-Translator'; |
48 | author 'Ken Youens-Clark <kclark@cpan.org>'; |
49 | abstract 'SQL DDL transformations and more'; |
44659089 |
50 | license 'gpl'; |
3f5ee660 |
51 | repository 'git://git.shadowcat.co.uk/dbsrgits/SQL-Translator.git'; |
6e64adbe |
52 | bugtracker 'http://rt.cpan.org/NoAuth/Bugs.html?Dist=SQL-Translator'; |
53 | |
54 | resources Ratings => 'http://cpanratings.perl.org/d/SQL-Translator'; |
55 | |
09d9cd5e |
56 | Meta->{values}{x_authority} = 'cpan:JROBINSON'; |
57 | |
6e64adbe |
58 | all_from 'lib/SQL/Translator.pm'; |
59 | |
60 | for 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 | |
e3fc8761 |
68 | no_index directory => $_ for (qw| |
69 | lib/SQL/Translator/Schema/Graph |
70 | |); |
71 | no_index package => $_ for (qw| |
72 | SQL::Translator::Schema::Graph |
73 | |); |
74 | |
6e64adbe |
75 | install_script (qw| |
467b7282 |
76 | script/sqlt-diagram |
77 | script/sqlt-diff |
78 | script/sqlt-diff-old |
79 | script/sqlt-dumper |
80 | script/sqlt-graph |
81 | script/sqlt |
6e64adbe |
82 | |); |
83 | |
84 | install_share(); |
85 | |
aee4b66e |
86 | tests_recursive (); |
87 | |
88 | |
89 | # temporary(?) until I get around to fix M::I wrt xt/ |
90 | # needs Module::Install::AuthorTests |
91 | eval { |
92 | # this should not be necessary since the autoloader is supposed |
93 | # to work, but there were reports of it failing |
94 | require Module::Install::AuthorTests; |
95 | recursive_author_tests (qw/xt/); |
96 | 1; |
97 | } || do { |
98 | if ($Module::Install::AUTHOR) { |
99 | my $err = $@; |
100 | |
101 | # better error message in case of missing dep |
102 | eval { require Module::Install::AuthorTests } |
103 | || die "\nYou need Module::Install::AuthorTests installed to run this Makefile.PL in author mode:\n\n$@\n"; |
104 | |
105 | die $err; |
106 | } |
107 | }; |
6e64adbe |
108 | |
109 | auto_install(); |
110 | |
dc34f950 |
111 | if ($Module::Install::AUTHOR) { |
112 | _recompile_grammars(); |
113 | _recreate_rt_source(); |
114 | } |
115 | |
6e64adbe |
116 | WriteAll(); |
dc34f950 |
117 | |
dc34f950 |
118 | sub _recompile_grammars { |
0eb3b94a |
119 | return; # disabled until RT#74593 is resolved |
120 | |
bdf60588 |
121 | require File::Spec; |
122 | |
123 | my $compiled_parser_dir = File::Spec->catdir(qw/ |
124 | share PrecompiledParsers Parse RecDescent DDL SQLT |
125 | /); |
126 | |
127 | # Currently consider only single-name parsers containing a grammar marker |
128 | # This is somewhat fragile, but better than loading all kinds of parsers |
129 | # to some of which we may not even have the deps |
130 | my $parser_libdir = 'lib/SQL/Translator/Parser'; |
131 | for my $parser_fn (glob "$parser_libdir/*.pm") { |
132 | die "$parser_fn does not look like a readable file\n" |
133 | unless ( -f $parser_fn and -r $parser_fn ); |
134 | |
135 | my ($type) = $parser_fn =~ /^\Q$parser_libdir\E\/(.+)\.pm$/i |
136 | or die "$parser_fn not named in expected format\n"; |
137 | |
138 | my $parser_source = do { local (@ARGV, $/) = $parser_fn; <> }; |
139 | next unless $parser_source =~ /\$GRAMMAR.+?END_OF_GRAMMAR/s; |
140 | |
141 | |
142 | my $precomp_parser_fn = File::Spec->catfile($compiled_parser_dir, "$type.pm"); |
143 | |
144 | next if ( |
145 | -f $precomp_parser_fn |
146 | and |
147 | (stat($parser_fn))[9] <= (stat($precomp_parser_fn))[9] |
148 | ); |
149 | |
150 | |
151 | print "Precompiling parser for $type\n"; |
152 | |
153 | require $parser_fn; |
154 | require Parse::RecDescent; |
155 | |
156 | Parse::RecDescent->Precompile( |
157 | do { |
158 | no strict 'refs'; |
159 | ${"SQL::Translator::Parser::${type}::GRAMMAR"} |
160 | || die "No \$GRAMMAR global found in SQL::Translator::Parser::$type ($parser_fn)\n" |
161 | }, |
162 | "Parse::RecDescent::DDL::SQLT::$type" |
163 | ); |
164 | |
165 | rename( "$type.pm", $precomp_parser_fn ) |
166 | or die "Unable to move $type.pm to $compiled_parser_dir: $!\n"; |
167 | } |
168 | |
dc34f950 |
169 | } |
170 | |
171 | sub _recreate_rt_source { |
172 | my $base_xml = "t/data/roundtrip.xml"; |
173 | my $autogen_yaml = "t/data/roundtrip_autogen.yaml"; |
174 | |
175 | print "Updating $autogen_yaml\n"; |
176 | |
177 | unlink $autogen_yaml; |
178 | |
179 | eval { |
180 | |
181 | use lib 'lib'; |
182 | |
183 | require SQL::Translator; |
184 | require SQL::Translator::Parser::XML; |
185 | |
186 | open (my $fh, '>', $autogen_yaml) or die "$autogen_yaml: $!\n"; |
187 | |
188 | my $tr = SQL::Translator->new; |
189 | my $yaml = $tr->translate ( |
190 | parser => 'XML', |
191 | file => $base_xml, |
192 | producer => 'YAML', |
193 | ) or die sprintf ("Unable to translate %s to YAML: %s\n", |
194 | $base_xml, |
195 | $tr->error || 'error unknown' |
196 | ); |
197 | |
198 | print $fh $yaml; |
199 | close $fh; |
200 | }; |
201 | |
202 | if ($@) { |
d53db6a7 |
203 | warn <<EOE; |
dc34f950 |
204 | |
205 | ========================================================================= |
d53db6a7 |
206 | =============== WARNING !!! ================= |
dc34f950 |
207 | ========================================================================= |
208 | |
209 | Unable to update the roundtrip schema (attempt triggered by AUTHOR mode). |
d53db6a7 |
210 | We will still generate a Makefile, but be aware that if you build a dist |
211 | this way, it *WILL* be broken. |
dc34f950 |
212 | |
d53db6a7 |
213 | ------------------------------------------------------------------------- |
dc34f950 |
214 | $@ |
215 | |
d53db6a7 |
216 | Press Enter to continue. |
dc34f950 |
217 | EOE |
d53db6a7 |
218 | <>; |
dc34f950 |
219 | } |
220 | } |