generate svg of DBICTest::Schema in author mode
[dbsrgits/DBIx-Class.git] / maint / Makefile.PL.inc / 56_autogen_schema_files.pl
CommitLineData
a2c29633 1require File::Spec;
6635c6d2 2my $test_ddl_fn = File::Spec->catfile(qw( t lib sqlite.sql ));
3my @test_ddl_cmd = qw( -I lib -I t/lib -- maint/gen_sqlite_schema_files --schema-class DBICTest::Schema );
ad93ee36 4my $test_graph_fn = File::Spec->catfile(qw( examples DBICTest db-diagram.svg ));
5my @test_graph_cmd = qw( -I lib -I t/lib -- maint/gen_dbictest_schema_diagram --schema-class DBICTest::Schema );
6635c6d2 6
7my $example_ddl_fn = File::Spec->catfile(qw( examples Schema db example.sql ));
8my $example_db_fn = File::Spec->catfile(qw( examples Schema db example.db ));
9my @example_ddl_cmd = qw( -I lib -I examples/Schema -- maint/gen_sqlite_schema_files --schema-class MyApp::Schema );
10my @example_pop_cmd = qw( -I lib -I examples/Schema -- examples/Schema/insertdb.pl );
a2c29633 11
12# If the author doesn't have the prereqs, still generate a Makefile
13# The EUMM build-stage generation will run unconditionally and
14# errors will not be ignored unlike here
15require DBIx::Class::Optional::Dependencies;
16if ( DBIx::Class::Optional::Dependencies->req_ok_for ('deploy') ) {
17 print "Regenerating $test_ddl_fn\n";
18 system( $^X, @test_ddl_cmd, '--ddl-out' => $test_ddl_fn );
19
ad93ee36 20 print "Regenerating $test_graph_fn\n";
21 system( $^X, @test_graph_cmd, '--diagram-out' => $test_graph_fn );
22
6635c6d2 23 print "Regenerating $example_ddl_fn and $example_db_fn\n";
24 system( $^X, @example_ddl_cmd, '--ddl-out' => $example_ddl_fn, '--deploy-to' => $example_db_fn );
25
26 print "Populating $example_db_fn\n";
27 system( $^X, @example_pop_cmd );
28
a2c29633 29 # if we don't do it some git tools (e.g. gitk) get confused that the
30 # ddl file is modified, when it clearly isn't
31 system('git status --porcelain >' . File::Spec->devnull);
32}
33
34postamble <<"EOP";
35
36clonedir_generate_files : dbic_clonedir_regen_test_ddl
37
38dbic_clonedir_regen_test_ddl :
39\t\$(ABSPERLRUN) @test_ddl_cmd --ddl-out @{[ $mm_proto->quote_literal($test_ddl_fn) ]}
6635c6d2 40\t\$(ABSPERLRUN) @example_ddl_cmd --ddl-out @{[ $mm_proto->quote_literal($example_ddl_fn) ]} --deploy-to @{[ $mm_proto->quote_literal($example_db_fn) ]}
41\t\$(ABSPERLRUN) @example_pop_cmd
a2c29633 42EOP
43
44# keep the Makefile.PL eval happy
451;