Commit | Line | Data |
---|---|---|
0c96388f MHM |
1 | #!/usr/bin/perl -w |
2 | ################################################################################ | |
3 | # | |
4 | # regenerate -- regenerate baseline and todo files | |
5 | # | |
6 | ################################################################################ | |
7 | # | |
b2049988 | 8 | # Version 3.x, Copyright (C) 2004-2013, Marcus Holland-Moritz. |
0c96388f MHM |
9 | # Version 2.x, Copyright (C) 2001, Paul Marquess. |
10 | # Version 1.x, Copyright (C) 1999, Kenneth Albanowski. | |
11 | # | |
12 | # This program is free software; you can redistribute it and/or | |
13 | # modify it under the same terms as Perl itself. | |
14 | # | |
15 | ################################################################################ | |
16 | ||
17 | use strict; | |
18 | use File::Path; | |
19 | use File::Copy; | |
20 | use Getopt::Long; | |
21 | use Pod::Usage; | |
22 | ||
3d7c117d | 23 | require './devel/devtools.pl'; |
0c96388f MHM |
24 | |
25 | our %opt = ( | |
ba120f6f | 26 | check => 1, |
337a666a | 27 | debug => 0, |
ba120f6f | 28 | verbose => 0, |
0c96388f MHM |
29 | ); |
30 | ||
a58fa8f3 | 31 | GetOptions(\%opt, qw( check! verbose install=s blead=s blead-version=s |
337a666a | 32 | debug debug-start=s)) or die pod2usage(); |
0c96388f MHM |
33 | |
34 | identify(); | |
35 | ||
36 | unless (-e 'parts/embed.fnc' and -e 'parts/apidoc.fnc') { | |
37 | print "\nOooops, $0 must be run from the Devel::PPPort root directory.\n"; | |
38 | quit_now(); | |
39 | } | |
40 | ||
41 | ask_or_quit("Are you sure you have updated parts/embed.fnc and parts/apidoc.fnc?"); | |
42 | ||
43 | my %files = map { ($_ => [glob "parts/$_/5*"]) } qw( base todo ); | |
44 | ||
45 | my(@notwr, @wr); | |
46 | for my $f (map @$_, values %files) { | |
47 | push @{-w $f ? \@wr : \@notwr}, $f; | |
48 | } | |
49 | ||
50 | if (@notwr) { | |
51 | if (@wr) { | |
52 | print "\nThe following files are not writable:\n\n"; | |
53 | print " $_\n" for @notwr; | |
54 | print "\nAre you sure you have checked out these files?\n"; | |
55 | } | |
56 | else { | |
57 | print "\nAll baseline / todo file are not writable.\n"; | |
58 | ask_or_quit("Do you want to try to check out these files?"); | |
59 | unless (runtool("wco", "-l", "-t", "locked by $0", @notwr)) { | |
60 | print "\nSomething went wrong while checking out the files.\n"; | |
61 | quit_now(); | |
62 | } | |
63 | } | |
64 | } | |
65 | ||
66 | for my $dir (qw( base todo )) { | |
67 | my $cur = "parts/$dir"; | |
68 | my $old = "$cur-old"; | |
69 | if (-e $old) { | |
70 | ask_or_quit("Do you want me to remove the old $old directory?"); | |
71 | rmtree($old); | |
72 | } | |
73 | mkdir $old; | |
74 | print "\nBacking up $cur in $old.\n"; | |
75 | for my $src (@{$files{$dir}}) { | |
76 | my $dst = $src; | |
744ef08f | 77 | $dst =~ s/\Q$cur/$old/ or die "Ooops!"; |
0c96388f MHM |
78 | move($src, $dst) or die "Moving $src to $dst failed: $!\n"; |
79 | } | |
80 | } | |
81 | ||
49ef49fe | 82 | my @perlargs; |
337a666a | 83 | push @perlargs, "--debug" if $opt{debug}; |
49ef49fe CBW |
84 | push @perlargs, "--install=$opt{install}" if exists $opt{install}; |
85 | push @perlargs, "--blead=$opt{blead}" if exists $opt{blead}; | |
a58fa8f3 | 86 | push @perlargs, "--debug-start=$opt{'debug-start'}" if $opt{'debug-start'}; |
49ef49fe | 87 | |
0c96388f | 88 | my $T0 = time; |
ba120f6f MHM |
89 | my @args = ddverbose(); |
90 | push @args, '--nocheck' unless $opt{check}; | |
49ef49fe CBW |
91 | push @args, "--blead-version=$opt{'blead-version'}" if exists $opt{'blead-version'}; |
92 | push @args, @perlargs; | |
0c96388f MHM |
93 | |
94 | print "\nBuilding baseline files...\n\n"; | |
95 | ||
ba120f6f | 96 | unless (runperl('devel/mktodo', '--base', @args)) { |
0c96388f MHM |
97 | print "\nSomething went wrong while building the baseline files.\n"; |
98 | quit_now(); | |
99 | } | |
100 | ||
101 | print "\nMoving baseline files...\n\n"; | |
102 | ||
103 | for my $src (glob 'parts/todo/5*') { | |
104 | my $dst = $src; | |
105 | $dst =~ s/todo/base/ or die "Ooops!"; | |
106 | move($src, $dst) or die "Moving $src to $dst failed: $!\n"; | |
107 | } | |
108 | ||
109 | print "\nBuilding todo files...\n\n"; | |
110 | ||
ba120f6f | 111 | unless (runperl('devel/mktodo', @args)) { |
635ff94c | 112 | print "\nSomething went wrong while building the todo files.\n"; |
0c96388f MHM |
113 | quit_now(); |
114 | } | |
115 | ||
116 | print "\nAdding remaining baseline info...\n\n"; | |
117 | ||
118 | unless (runperl('Makefile.PL') and | |
119 | runtool('make') and | |
49ef49fe | 120 | runperl('devel/scanprov', '--mode=write', @perlargs)) { |
0c96388f MHM |
121 | print "\nSomething went wrong while adding the baseline info.\n"; |
122 | quit_now(); | |
123 | } | |
124 | ||
125 | my($wall, $usr, $sys, $cusr, $csys) = (time - $T0, times); | |
126 | my $cpu = sprintf "%.2f", $usr + $sys + $cusr + $csys; | |
127 | $usr = sprintf "%.2f", $usr + $cusr; | |
128 | $sys = sprintf "%.2f", $sys + $csys; | |
129 | ||
130 | print <<END; | |
131 | ||
132 | API info regenerated successfully. | |
133 | ||
134 | Finished in $wall wallclock secs ($usr usr + $sys sys = $cpu CPU) | |
135 | ||
136 | Don't forget to check in the files in parts/base and parts/todo. | |
137 | ||
138 | END | |
139 | ||
ba120f6f MHM |
140 | __END__ |
141 | ||
142 | =head1 NAME | |
143 | ||
c4a2ac43 | 144 | regenerate - Automatically regenerate Devel::PPPort's API information |
ba120f6f MHM |
145 | |
146 | =head1 SYNOPSIS | |
147 | ||
148 | regenerate [options] | |
149 | ||
150 | --nocheck don't recheck symbols that caused an error | |
151 | --verbose show verbose output | |
152 | ||
153 | =head1 COPYRIGHT | |
154 | ||
b2049988 | 155 | Copyright (c) 2006-2013, Marcus Holland-Moritz. |
ba120f6f MHM |
156 | |
157 | This program is free software; you can redistribute it and/or | |
158 | modify it under the same terms as Perl itself. | |
159 | ||
160 | =head1 SEE ALSO | |
161 | ||
162 | See L<Devel::PPPort> and L<HACKERS>. | |
163 | ||
164 | =cut |