1 BEGIN { -e 'Distar' or system("git clone git://git.shadowcat.co.uk/p5sagit/Distar.git") }
5 author 'Ken Youens-Clark <kclark@cpan.org>';
6 manifest_include 'script' => qr/.+/;
7 manifest_include 't/data' => qr/.+/;
8 manifest_include 'share' => qr/.+/;
9 manifest_include '' => qr/\A(?:AUTHORS)\z/;
11 # eval so can generate deps for cpanm --installdeps .
13 _recompile_grammars();
14 _recreate_rt_source();
16 print "Got errors:\n\n$@" if $@;
18 sub _recompile_grammars {
19 return; # disabled until RT#74593 is resolved
23 my $compiled_parser_dir = File::Spec->catdir(qw/
24 share PrecompiledParsers Parse RecDescent DDL SQLT
27 # Currently consider only single-name parsers containing a grammar marker
28 # This is somewhat fragile, but better than loading all kinds of parsers
29 # to some of which we may not even have the deps
30 my $parser_libdir = 'lib/SQL/Translator/Parser';
31 for my $parser_fn (glob "$parser_libdir/*.pm") {
32 die "$parser_fn does not look like a readable file\n"
33 unless ( -f $parser_fn and -r $parser_fn );
35 my ($type) = $parser_fn =~ /^\Q$parser_libdir\E\/(.+)\.pm$/i
36 or die "$parser_fn not named in expected format\n";
38 my $parser_source = do { local (@ARGV, $/) = $parser_fn; <> };
39 next unless $parser_source =~ /\$GRAMMAR.+?END_OF_GRAMMAR/s;
42 my $precomp_parser_fn = File::Spec->catfile($compiled_parser_dir, "$type.pm");
47 (stat($parser_fn))[9] <= (stat($precomp_parser_fn))[9]
51 print "Precompiling parser for $type\n";
54 require Parse::RecDescent;
56 Parse::RecDescent->Precompile(
59 ${"SQL::Translator::Parser::${type}::GRAMMAR"}
60 || die "No \$GRAMMAR global found in SQL::Translator::Parser::$type ($parser_fn)\n"
62 "Parse::RecDescent::DDL::SQLT::$type"
65 rename( "$type.pm", $precomp_parser_fn )
66 or die "Unable to move $type.pm to $compiled_parser_dir: $!\n";
71 sub _recreate_rt_source {
72 my $base_xml = "t/data/roundtrip.xml";
73 my $autogen_yaml = "t/data/roundtrip_autogen.yaml";
75 print "Updating $autogen_yaml\n";
83 require SQL::Translator;
84 require SQL::Translator::Parser::XML;
86 open (my $fh, '>', $autogen_yaml) or die "$autogen_yaml: $!\n";
88 my $tr = SQL::Translator->new;
89 my $yaml = $tr->translate (
93 ) or die sprintf ("Unable to translate %s to YAML: %s\n",
95 $tr->error || 'error unknown'
105 =========================================================================
106 =============== WARNING !!! =================
107 =========================================================================
109 Unable to update the roundtrip schema (attempt triggered by AUTHOR mode).
110 Continuing Makefile generation, but please fix the errors indicated below
111 (typically by installing the missing modules).
113 -------------------------------------------------------------------------
120 # vim: ft=perl et sts=2 sw=2 tw=0: