From: Ed J Date: Tue, 14 Aug 2018 02:19:10 +0000 (+0100) Subject: Port Makefile.PL from Module::Install to Distar X-Git-Tag: v1.59_01~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Fmohawk2-eumm;p=dbsrgits%2FSQL-Translator.git Port Makefile.PL from Module::Install to Distar --- diff --git a/.gitignore b/.gitignore index d7737f8..915cedc 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ Build Build.bat MANIFEST MANIFEST.bak +MANIFEST.SKIP META.* MYMETA.* Makefile @@ -9,7 +10,7 @@ Makefile.old README _build/ blib/ -inc/ +Distar/ cover_db/ pm_to_blib t/data/roundtrip_autogen.yaml diff --git a/.travis.yml b/.travis.yml index acf1df2..50ba152 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,16 +25,23 @@ env: - COVERAGE="coveralls codecov" - DBICTEST_PG_DSN=dbi:Pg:dbname=sqlt_test - DBICTEST_PG_USER=postgres + - SPLIT_BUILD=0 matrix: allow_failures: - perl: "blead" - perl: "dev" before_install: - - eval $(curl https://travis-perl.github.io/init) --auto + - eval $(curl https://travis-perl.github.io/init) --perl + - cpan-install File::ShareDir::Install # absolute minimum for Makefile.PL + - perl Makefile.PL # generate deps + - cpan-install --deps # so can regen t/data/roundtrip_autogen.yaml install: + - build-dist + - cd $BUILD_DIR - $HELPERS_ROOT/bin/cpan-config - cpan-install --deps CGI DBD::SQLite XML::Parser DBD::Pg # Optional test deps - - cpan-install Test::EOL Test::NoTabs # Author test deps - cpan-install --coverage before_script: - psql -U postgres -c 'create database sqlt_test;' +script: + - perl Makefile.PL && make test diff --git a/Changes b/Changes index b022e5b..701c027 100644 --- a/Changes +++ b/Changes @@ -3,6 +3,7 @@ Changes for SQL::Translator * Add support for parsing PostgreSQL dollar-quoted strings * Add support for materialized views in Oracle producer * switched JSON backend from JSON.pm to JSON::MaybeXS + * Port Makefile.PL from Module::Install to Distar 0.11024 2018-01-09 diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP deleted file mode 100644 index 83e699f..0000000 --- a/MANIFEST.SKIP +++ /dev/null @@ -1,64 +0,0 @@ -^(?!script/|lib/|inc/|t/|xt/|share/|Makefile.PL$|README$|MANIFEST$|Changes$|AUTHORS$|META.(?:json|yml)$) - -.*CVS.* -.#.* -.*\.bak -.*\.swp -.*\.old -.*\.tar\.gz -^_build/ -_blib$ -Build$ -(^|/)\. - -# Version control files and dirs. -\bRCS\b -\bCVS\b -\bSCCS\b -,v$ -\B\.svn\b -\B\.git\b -\B\.gitignore\b -\b_darcs\b - -# Module::Build generated files and dirs. -^Build$ -^_build/ - -# Makemaker generated files and dirs. -\bMANIFEST\.bak -\bMakefile$ -\bblib/ -\bMakeMaker-\d -\bpm_to_blib\.ts$ -\bpm_to_blib$ -\bblibdirs\.ts$ # 6.18 through 6.25 generated this - -# Temp, old and emacs backup files. -~$ -\.old$ -\#$ -\b\.# -\.bak$ - -# Devel::Cover files. -\bcover_db\b - -# Test::Kwalitee cache files. -^Debian_CPANTS\.txt - -# Old tarballs etc -^SQL-Translator - -# patch and diff files -\.diff -\.patch -\.orig$ -\.rej$ - -# junk -\.log$ -\.tmp$ - -# temporary -\.sqlt_refactor_placeholder$ \ No newline at end of file diff --git a/Makefile.PL b/Makefile.PL index 9cc1156..70080cb 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -1,15 +1,31 @@ -BEGIN { push @INC, '.' unless $INC[-1] eq '.' } -use inc::Module::Install 1.06; use strict; use warnings; - -# to deal wuth x.y.z versions properly -configure_requires 'ExtUtils::MakeMaker' => '6.54'; - -perl_version '5.008001'; - -my $deps = { - requires => { +use ExtUtils::MakeMaker; +use File::ShareDir::Install; +do './maint/Makefile.PL.include' or die $@ + unless -f 'META.yml'; +my $eumm_version = eval $ExtUtils::MakeMaker::VERSION; + +my %eumm_args = ( + NAME => 'SQL::Translator', + ABSTRACT => 'SQL DDL transformations and more', + VERSION_FROM => 'lib/SQL/Translator.pm', + LICENSE => 'perl', + MIN_PERL_VERSION => '5.008001', + CONFIGURE_REQUIRES => { + 'ExtUtils::MakeMaker' => '6.54', # to deal with x.y.z versions properly + 'File::ShareDir::Install' => '0', + }, + TEST_REQUIRES => { + 'JSON::MaybeXS' => '1.003003', + 'YAML' => '0.66', + 'XML::Writer' => '0.500', + 'Test::More' => '0.88', + 'Test::Differences' => '0', + 'Test::Exception' => '0.31', + 'Text::ParseWords' => '0', + }, + PREREQ_PM => { 'Digest::SHA' => '0', 'Carp::Clan' => '0', 'Parse::RecDescent' => '1.967009', @@ -21,186 +37,87 @@ my $deps = { 'Try::Tiny' => '0.04', 'Scalar::Util' => '0', }, - recommends => { - 'Template' => '2.20', - 'GD' => '0', - 'GraphViz' => '0', - 'Graph::Directed' => '0', - 'Spreadsheet::ParseExcel' => '0.41', - 'Text::RecordParser' => '0.02', - 'XML::LibXML' => '1.69', + realclean => { + FILES => 't/data/roundtrip_autogen.yaml' }, - test_requires => { - 'JSON::MaybeXS' => '1.003003', - 'YAML' => '0.66', - 'XML::Writer' => '0.500', - 'Test::More' => '0.88', - 'Test::Differences' => '0', - 'Test::Exception' => '0.31', - 'Text::ParseWords' => '0', - }, -}; - - -name 'SQL-Translator'; -author 'Ken Youens-Clark '; -abstract 'SQL DDL transformations and more'; -license 'perl'; - -resources repository => 'https://github.com/dbsrgits/sql-translator/'; -resources bugtracker => 'https://rt.cpan.org/NoAuth/Bugs.html?Dist=SQL-Translator'; -resources Ratings => 'http://cpanratings.perl.org/d/SQL-Translator'; -resources IRC => 'irc://irc.perl.org/#sql-translator'; - -Meta->{values}{x_authority} = 'cpan:JROBINSON'; - -all_from 'lib/SQL/Translator.pm'; - -for my $type (qw/requires recommends test_requires/) { - no strict qw/refs/; - my $f = \&$type; - for my $mod (sort keys %{$deps->{$type} || {} }) { - $f->($mod, $deps->{$type}{$mod}); - } -} - -install_script (qw| - script/sqlt-diagram - script/sqlt-diff - script/sqlt-diff-old - script/sqlt-dumper - script/sqlt-graph - script/sqlt -|); - -install_share(); - -tests_recursive (); - -if ($Module::Install::AUTHOR) { - my @missing_plugins; - for my $plugin (qw(AuthorTests ReadmeFromPod)) { - unless (eval "require Module::Install::$plugin; 1") { - push @missing_plugins, "Module::Install::$plugin"; - chomp(my $err = $@); - $missing_plugins[-1] .= " ($err)" - unless $err =~ m{^Can't locate Module/Install/$plugin\.pm in \@INC}; - } - } - die "\nYou need to install the following modules to run this Makefile.PL in author mode:\n\n", join("\n", @missing_plugins), "\n\n" - if @missing_plugins; - - recursive_author_tests (qw/xt/); - readme_from('lib/SQL/Translator.pm'); -} - -auto_install(); - -if ($Module::Install::AUTHOR) { - _recompile_grammars(); - _recreate_rt_source(); -} - -WriteAll(); - -sub _recompile_grammars { - return; # disabled until RT#74593 is resolved - - require File::Spec; - - my $compiled_parser_dir = File::Spec->catdir(qw/ - share PrecompiledParsers Parse RecDescent DDL SQLT - /); - - # Currently consider only single-name parsers containing a grammar marker - # This is somewhat fragile, but better than loading all kinds of parsers - # to some of which we may not even have the deps - my $parser_libdir = 'lib/SQL/Translator/Parser'; - for my $parser_fn (glob "$parser_libdir/*.pm") { - die "$parser_fn does not look like a readable file\n" - unless ( -f $parser_fn and -r $parser_fn ); - - my ($type) = $parser_fn =~ /^\Q$parser_libdir\E\/(.+)\.pm$/i - or die "$parser_fn not named in expected format\n"; - - my $parser_source = do { local (@ARGV, $/) = $parser_fn; <> }; - next unless $parser_source =~ /\$GRAMMAR.+?END_OF_GRAMMAR/s; - - - my $precomp_parser_fn = File::Spec->catfile($compiled_parser_dir, "$type.pm"); - - next if ( - -f $precomp_parser_fn - and - (stat($parser_fn))[9] <= (stat($precomp_parser_fn))[9] - ); - - - print "Precompiling parser for $type\n"; - - require $parser_fn; - require Parse::RecDescent; - - Parse::RecDescent->Precompile( - do { - no strict 'refs'; - ${"SQL::Translator::Parser::${type}::GRAMMAR"} - || die "No \$GRAMMAR global found in SQL::Translator::Parser::$type ($parser_fn)\n" + EXE_FILES => [ qw| + script/sqlt-diagram + script/sqlt-diff + script/sqlt-diff-old + script/sqlt-dumper + script/sqlt-graph + script/sqlt + | ], + META_MERGE => { + "meta-spec" => { version => 2 }, + dynamic_config => 0, + resources => { + bugtracker => { + web => 'https://rt.cpan.org/NoAuth/Bugs.html?Dist=SQL-Translator', + mailto => 'bug-SQL-Translator@rt.cpan.org', }, - "Parse::RecDescent::DDL::SQLT::$type" - ); - - rename( "$type.pm", $precomp_parser_fn ) - or die "Unable to move $type.pm to $compiled_parser_dir: $!\n"; - } - -} - -sub _recreate_rt_source { - my $base_xml = "t/data/roundtrip.xml"; - my $autogen_yaml = "t/data/roundtrip_autogen.yaml"; - - print "Updating $autogen_yaml\n"; - - unlink $autogen_yaml; - - eval { - - use lib 'lib'; - - require SQL::Translator; - require SQL::Translator::Parser::XML; - - open (my $fh, '>', $autogen_yaml) or die "$autogen_yaml: $!\n"; + repository => { + type => 'git', + url => 'git@github.com/dbsrgits/sql-translator.git', + web => 'https://github.com/dbsrgits/sql-translator/', + }, + license => [ 'http://dev.perl.org/licenses/' ], + x_IRC => 'irc://irc.perl.org/#sql-translator', + x_Ratings => 'http://cpanratings.perl.org/d/SQL-Translator', + }, + x_authority => 'cpan:JROBINSON', + no_index => { + directory => [qw(maint share xt)], + }, + prereqs => { + runtime => { + recommends => { + 'Template' => '2.20', + 'GD' => '0', + 'GraphViz' => '0', + 'Graph::Directed' => '0', + 'Spreadsheet::ParseExcel' => '0.41', + 'Text::RecordParser' => '0.02', + 'XML::LibXML' => '1.69', + }, + }, + develop => { + requires => { + 'Template' => '2.20', + 'GD' => '0', + 'GraphViz' => '0', + 'Graph::Directed' => '0', + 'Spreadsheet::ParseExcel' => '0.41', + 'Text::RecordParser' => '0.02', + 'XML::LibXML' => '1.69', + 'Test::EOL' => '1.1', + 'Test::NoTabs' => '1.1', + 'Software::LicenseUtils' => '0', # for Distar + }, + }, + }, + }, +); - my $tr = SQL::Translator->new; - my $yaml = $tr->translate ( - parser => 'XML', - file => $base_xml, - producer => 'YAML', - ) or die sprintf ("Unable to translate %s to YAML: %s\n", - $base_xml, - $tr->error || 'error unknown' - ); +install_share 'share'; - print $fh $yaml; - close $fh; +sub _move_to { + my ($hash, $fromkey, $tokey) = @_; + $hash->{$tokey} = { + %{ $hash->{$tokey} || {} }, + %{ delete($hash->{$fromkey}) || {} }, }; - - if ($@) { - die <= 6.57_02 and $eumm_version < 6.57_07; +WriteMakefile(%eumm_args); + +package MY; +use File::ShareDir::Install qw(postamble); diff --git a/maint/Makefile.PL.include b/maint/Makefile.PL.include new file mode 100644 index 0000000..c78f9ab --- /dev/null +++ b/maint/Makefile.PL.include @@ -0,0 +1,122 @@ +BEGIN { -e 'Distar' or system("git clone git://git.shadowcat.co.uk/p5sagit/Distar.git") } +use lib 'Distar/lib'; +use Distar 0.001; + +author 'Ken Youens-Clark '; +manifest_include 'script' => qr/.+/; +manifest_include 't/data' => qr/.+/; +manifest_include 'share' => qr/.+/; +manifest_include '' => qr/\A(?:AUTHORS)\z/; + +# eval so can generate deps for cpanm --installdeps . +eval { + _recompile_grammars(); + _recreate_rt_source(); +}; +print "Got errors:\n\n$@" if $@; + +sub _recompile_grammars { + return; # disabled until RT#74593 is resolved + + require File::Spec; + + my $compiled_parser_dir = File::Spec->catdir(qw/ + share PrecompiledParsers Parse RecDescent DDL SQLT + /); + + # Currently consider only single-name parsers containing a grammar marker + # This is somewhat fragile, but better than loading all kinds of parsers + # to some of which we may not even have the deps + my $parser_libdir = 'lib/SQL/Translator/Parser'; + for my $parser_fn (glob "$parser_libdir/*.pm") { + die "$parser_fn does not look like a readable file\n" + unless ( -f $parser_fn and -r $parser_fn ); + + my ($type) = $parser_fn =~ /^\Q$parser_libdir\E\/(.+)\.pm$/i + or die "$parser_fn not named in expected format\n"; + + my $parser_source = do { local (@ARGV, $/) = $parser_fn; <> }; + next unless $parser_source =~ /\$GRAMMAR.+?END_OF_GRAMMAR/s; + + + my $precomp_parser_fn = File::Spec->catfile($compiled_parser_dir, "$type.pm"); + + next if ( + -f $precomp_parser_fn + and + (stat($parser_fn))[9] <= (stat($precomp_parser_fn))[9] + ); + + + print "Precompiling parser for $type\n"; + + require $parser_fn; + require Parse::RecDescent; + + Parse::RecDescent->Precompile( + do { + no strict 'refs'; + ${"SQL::Translator::Parser::${type}::GRAMMAR"} + || die "No \$GRAMMAR global found in SQL::Translator::Parser::$type ($parser_fn)\n" + }, + "Parse::RecDescent::DDL::SQLT::$type" + ); + + rename( "$type.pm", $precomp_parser_fn ) + or die "Unable to move $type.pm to $compiled_parser_dir: $!\n"; + } + +} + +sub _recreate_rt_source { + my $base_xml = "t/data/roundtrip.xml"; + my $autogen_yaml = "t/data/roundtrip_autogen.yaml"; + + print "Updating $autogen_yaml\n"; + + unlink $autogen_yaml; + + eval { + + use lib 'lib'; + + require SQL::Translator; + require SQL::Translator::Parser::XML; + + open (my $fh, '>', $autogen_yaml) or die "$autogen_yaml: $!\n"; + + my $tr = SQL::Translator->new; + my $yaml = $tr->translate ( + parser => 'XML', + file => $base_xml, + producer => 'YAML', + ) or die sprintf ("Unable to translate %s to YAML: %s\n", + $base_xml, + $tr->error || 'error unknown' + ); + + print $fh $yaml; + close $fh; + }; + + if ($@) { + die <