Build.PL: don't use -w flag when we already use warnings pragma
[bioperl-db.git] / Build.PL
blob6ec0ab13531ae5d253a61656e0f85d325e2484f3
1 #!/usr/bin/perl
3 # This is a Module::Build script for BioPerl-DB installation.
4 # See http://search.cpan.org/~kwilliams/Module-Build/lib/Module/Build.pm
6 use strict;
7 use warnings;
8 use Module::Build;
9 use File::Spec;
10 use File::Basename;
12 # add any supported drivers here
13 my @supported = qw(mysql Pg Oracle);
15 my $build = Module::Build->new(
16 module_name => 'Bio::DB::BioDB',
17 dist_name => 'BioPerl-DB',
18 dist_version => '1.006900',
19 dist_author => 'BioPerl Team <bioperl-l@bioperl.org>',
20 dist_abstract => 'BioPerl-DB - package for biological databases',
21 license => 'perl',
22 requires => {
23 'perl' => '5.6.1',
24 'Bio::Root::Version' => '1.006900',
25 'DBI' => 0
27 recommends => {
28 'Graph::Directed' => 0
30 auto_features => {
31 Pg_support => {
32 description => "Postgres databases",
33 requires => { 'DBD::Pg' => 0},
35 mysql_support => {
36 description => "MySQL databases",
37 requires => { 'DBD::mysql' => 0},
39 Oracle_support => {
40 description => "Oracle databases",
41 requires => { 'DBD::Oracle' => 0},
44 dynamic_config => 1,
45 create_makefile_pl => 'passthrough'
48 my $accept = $build->args->{accept};
50 # Ask questions for db configuration (Harness file)
51 biosql_conf();
53 # Optionally have script files installed.
54 if ($accept ? 0 : $build->y_n("Install scripts? y/n", 'n')) {
55 my $files = $build->_find_file_by_type('pl', 'scripts');
57 my $script_build = File::Spec->catdir($build->blib, 'script');
59 my @tobp;
60 while (my ($file, $dest) = each %$files) {
61 $dest = 'bp_'.File::Basename::basename($dest);
62 $dest = File::Spec->catfile($script_build, $dest);
63 $build->copy_if_modified(from => $file, to => $dest);
64 push @tobp, $dest;
67 $build->script_files(\@tobp);
70 # Create the build script and exit
71 $build->create_build_script;
73 exit;
75 # setup t/DBHarness.biosql.conf
76 sub biosql_conf {
77 my $continue = $accept ||
78 $build->y_n("Have you already installed BioSQL? y/n", 'y');
79 $continue ||
80 die "\nBioSQL must be installed prior to installation of bioperl-db; ".
81 "see the INSTALL file\n";
83 my @drivers = grep {$build->features($_.'_support')}
84 qw(mysql Pg Oracle);
86 die "You must install a supported database driver\n" unless @drivers;
88 my $config_file = File::Spec->catfile('t', 'DBHarness.biosql.conf');
89 if (-e $config_file) {
90 ($accept || $build->y_n(
91 "Do you want to use the existing '$config_file' config file? y/n",
92 'y')) && return;
93 unlink($config_file);
96 open(my $out, ">", $config_file)
97 or die "Error: could not write to config file '$config_file'\n";
99 my %config = (driver => $drivers[0],
100 host => '127.0.0.1',
101 user => 'root',
102 port => 3306,
103 password => '',
104 dbname => 'bioseqdb',
105 database => 'biosql',
106 schema_sql => '../biosql-schema/sql/biosqldb-mysql.sql');
108 $config{driver} = $build->prompt("DBD driver to use (mandatory)?",
109 $config{driver});
110 $config{host} = $build->prompt("Machine to connect to (mandatory)?",
111 $config{host});
112 $config{user} = $build->prompt("User to connect to server as (mandatory)?",
113 $config{user});
115 $config{port} = $build->prompt("Port the server is running on (optional, ".
116 "'' for undef/none)?", $config{port});
117 $config{port} = undef if $config{port} eq "''";
119 $config{password} = $build->prompt("Password (optional)?",
120 $config{password} || 'undef');
121 $config{password} = '' if $config{password} eq 'undef';
123 $build->log_info(<<COMMENT);
124 # The next answer will be used to identify the database name in
125 # the connect string, e.g., using database=, dbname=, or sid=,
126 # depending on the driver.
128 # If this is not set the test scripts will build a temporary
129 # database from scratch at the beginning and destroy it at the
130 # end. Conversely, if you do set it then the database must exist,
131 # or else the tests will fail.
133 # Generally, it is preferred to pre-build the database, simply for
134 # efficiency reasons, and it will also enable debugging your
135 # schema content if some test acts up.\n
136 COMMENT
137 $config{dbname} = $build->prompt("Name of your existing Biosql database, ".
138 "as it is known to your RDBMS ".
139 "(optional, '' for none)?",
140 $config{dbname});
141 $config{dbname} = '' if $config{dbname} eq "''";
143 unless ($config{dbname}) {
144 $config{schema_sql} = $build->prompt("Set schema_sql to use the ".
145 "version appropriate for your ".
146 "RDBMS (mandatory)",
147 $config{schema_sql});
149 # don't know why it is stored as an array ref, is this correct?
150 $config{schema_sql} = "['$config{schema_sql}']";
152 $build->log_info(<<COMMENT);
153 # The next answer does not refer to the schema or RDBMS; it only
154 # identifies which of the databases supported in bioperl-db you
155 # want to be using. Since at present bioperl-db only supports biosql,
156 # this must be biosql.
157 COMMENT
158 $config{database} = $build->prompt("The name of the database within ".
159 "bioperl-db?", $config{database});
161 print $out "{\n";
162 while (my ($key, $val) = each %config) {
163 # no empty strings, undefined conf setting should be undef (w/o quotes)
164 $val = "'$val'" unless $key eq 'schema_sql' || !defined($val);
165 if (!defined($val)) {
166 $val = 'undef';
168 print $out "\t'$key' => $val,\n";
170 print $out "}\n";
171 close($out);
173 # maybe add the capability of using a temporary (test) database, and
174 # load the SQL on the fly? A little trickier (SQL is in a different
175 # repo and is driver-dependent)
177 # probably should add a database ping here and die gracefully otherwise.
179 # we deliberately don't add the config file to cleanup, but it shouldn't
180 # cause problems because it is in MANIFEST.SKIP