From eb69d884790500a7e5a8185b3fe29b23a84ed7ac Mon Sep 17 00:00:00 2001 From: Kenichi Ishigaki Date: Tue, 24 Nov 2015 21:23:05 +0900 Subject: [PATCH] moved the guts of api_history utility to SQLiteUtil --- util/SQLiteUtil.pm | 30 +++++++++++++++++++++++++++++- util/api_history.pl | 26 +------------------------- 2 files changed, 30 insertions(+), 26 deletions(-) diff --git a/util/SQLiteUtil.pm b/util/SQLiteUtil.pm index 66de420..5896e64 100644 --- a/util/SQLiteUtil.pm +++ b/util/SQLiteUtil.pm @@ -8,6 +8,7 @@ use File::Copy; our @EXPORT = qw/ extract_constants versions srcdir mirror copy_files + check_api_history /; our $ROOT = "$FindBin::Bin/.."; @@ -157,7 +158,6 @@ my %compat = map {$_ => 1} qw/ flags_for_file_open_operations /; - sub extract_constants { my $file = shift; $file ||= "$FindBin::Bin/../sqlite3.h"; @@ -274,6 +274,34 @@ sub copy_files { copy("$dir/fts3_tokenizer.h", $ROOT); } +sub check_api_history { + require Array::Diff; + my %current; + for my $version (versions()) { + print "checking $version...\n"; + my $dir = srcdir($version); + unless ($dir && -d $dir) { + $dir = mirror($version) or next; + } + my %constants = extract_constants("$dir/sqlite3.h"); + if (%current) { + for (sort keys %current) { + print "$version: deleted $_\n" if !exists $constants{$_}; + } + for (sort keys %constants) { + if (!exists $current{$_}) { + print "$version: added $_\n"; + next; + } + my $diff = Array::Diff->diff($current{$_}, $constants{$_}); + print "$version: added $_\n" for @{$diff->added || []}; + print "$version: deleted $_\n" for @{$diff->deleted || []}; + } + } + %current = %constants; + } +} + package SQLiteUtil::Version; use overload '""' => sub { diff --git a/util/api_history.pl b/util/api_history.pl index 275cbc1..0d869e7 100644 --- a/util/api_history.pl +++ b/util/api_history.pl @@ -5,29 +5,5 @@ use warnings; use FindBin; use lib "$FindBin::Bin"; use SQLiteUtil; -use Array::Diff; -my %current; -for my $version (versions()) { - print "checking $version...\n"; - my $dir = srcdir($version); - unless ($dir && -d $dir) { - $dir = mirror($version) or next; - } - my %constants = extract_constants("$dir/sqlite3.h"); - if (%current) { - for (sort keys %current) { - print "$version: deleted $_\n" if !exists $constants{$_}; - } - for (sort keys %constants) { - if (!exists $current{$_}) { - print "$version: added $_\n"; - next; - } - my $diff = Array::Diff->diff($current{$_}, $constants{$_}); - print "$version: added $_\n" for @{$diff->added || []}; - print "$version: deleted $_\n" for @{$diff->deleted || []}; - } - } - %current = %constants; -} +check_api_history();