mirror of
https://github.com/DBD-SQLite/DBD-SQLite
synced 2025-06-07 14:19:10 -04:00
DBD::SQLite: added preamble to generate modules to provide bundled c source/header (for other extensions)
This commit is contained in:
parent
d0dbdf132c
commit
97ff3be75c
2 changed files with 63 additions and 0 deletions
40
Makefile.PL
40
Makefile.PL
|
@ -323,6 +323,46 @@ package MY;
|
|||
use Config;
|
||||
|
||||
sub postamble {
|
||||
foreach my $file (qw/sqlite3.h sqlite3.c/) {
|
||||
(my $pm = $file) =~ tr/./_/;
|
||||
print "generating lib/DBD/SQLite/$pm.pm\n";
|
||||
open my $fh, '>', "lib/DBD/SQLite/$pm.pm" or die $!;
|
||||
print $fh <<"EOT";
|
||||
package DBD::SQLite::$pm;
|
||||
|
||||
use strict;
|
||||
our \$CODE = do { local \$/; <DATA> };
|
||||
|
||||
sub get {
|
||||
my (\$class, \$file, \$out) = \@_;
|
||||
my \$got;
|
||||
if (\$file) {
|
||||
(\$got) = \$CODE =~ m{(
|
||||
/\\*+[ ]Begin[ ]file[ ]\$file[ ]\\*+
|
||||
.+?
|
||||
/\\*+[ ]End[ ]of[ ]\$file[ ]\\*+/
|
||||
)}sx;
|
||||
}
|
||||
else {
|
||||
\$got = \$CODE;
|
||||
}
|
||||
if (\$got && \$out) {
|
||||
open my \$fh, '>', \$out or die \$!;
|
||||
print \$fh \$got;
|
||||
}
|
||||
return \$got ? \$got : '';
|
||||
}
|
||||
|
||||
1;
|
||||
\__DATA__
|
||||
EOT
|
||||
print $fh do {
|
||||
local $/;
|
||||
open my $in, '<', $file or die $!;
|
||||
<$in>;
|
||||
};
|
||||
}
|
||||
|
||||
require DBI;
|
||||
require DBI::DBD;
|
||||
eval {
|
||||
|
|
23
t/43_source_files.t
Normal file
23
t/43_source_files.t
Normal file
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
BEGIN {
|
||||
$| = 1;
|
||||
$^W = 1;
|
||||
}
|
||||
|
||||
use t::lib::Test qw/connect_ok @CALL_FUNCS/;
|
||||
use Test::More;
|
||||
use Test::NoWarnings;
|
||||
|
||||
plan tests => 6;
|
||||
|
||||
use_ok('DBD::SQLite::sqlite3_h');
|
||||
use_ok('DBD::SQLite::sqlite3_c');
|
||||
|
||||
my $header = DBD::SQLite::sqlite3_h->get;
|
||||
like $header => qr/define _SQLITE3_H_/, 'got whole file';
|
||||
|
||||
my $hwtime_h = DBD::SQLite::sqlite3_c->get('hwtime.h');
|
||||
like $hwtime_h => qr/Begin file hwtime.h/, 'has Begin file';
|
||||
unlike $hwtime_h => qr/Begin file [^h][^w]/, 'has no other Begin file';
|
Loading…
Add table
Reference in a new issue