Commit | Line | Data |
e01862e4 |
1 | require File::Spec; |
7606fd62 |
2 | my $ddl_fn = { |
3 | sqlite => File::Spec->catfile(qw(t lib sqlite.sql)), |
4 | dbdfile => File::Spec->catfile(qw(t lib dbdfile.sql)), |
5 | }; |
e01862e4 |
6 | |
7 | # If the author doesn't have the prereqs, we will end up obliterating |
8 | # the ddl file, and all tests will fail, therefore don't do anything |
9 | # on error |
10 | # The EUMM build-stage generation will run unconditionally and |
11 | # errors will not be trapped |
4a51243f |
12 | require DBIx::Class::Optional::Dependencies; |
13 | if ( DBIx::Class::Optional::Dependencies->req_ok_for ('deploy') ) { |
7606fd62 |
14 | foreach my $type (qw(sqlite dbdfile)) { |
15 | print "Regenerating t/lib/$type.sql\n"; |
16 | if (my $out = ` "$^X" -Ilib maint/gen_schema_$type `) { |
17 | open (my $fh, '>:unix', $ddl_fn->{$type}) or die "Unable to open $ddl_fn->{$type}: $!"; |
18 | print $fh $out; |
19 | close $fh; |
9d622a1b |
20 | |
7606fd62 |
21 | # if we don't do it some git tools (e.g. gitk) get confused that the |
22 | # ddl file is modified, when it clearly isn't |
23 | system('git status --porcelain >' . File::Spec->devnull); |
24 | } |
4a51243f |
25 | } |
e01862e4 |
26 | } |
27 | |
7606fd62 |
28 | my $postamble = <<"EOP"; |
e01862e4 |
29 | |
30 | clonedir_generate_files : dbic_clonedir_regen_test_ddl |
31 | |
32 | dbic_clonedir_regen_test_ddl : |
e01862e4 |
33 | EOP |
7606fd62 |
34 | foreach my $type (qw(sqlite dbdfile)) { |
35 | $postamble .= <<"EOP"; |
36 | \t\$(ABSPERLRUN) -Ilib -- maint/gen_schema_$type > @{[ $mm_proto->quote_literal($ddl_fn->{$type}) ]} |
37 | @{[ $crlf_fixup->($ddl_fn->{$type}) ]} |
38 | EOP |
39 | } |
40 | |
41 | postamble $postamble; |
e01862e4 |
42 | |
43 | # keep the Makefile.PL eval happy |
44 | 1; |