diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /graphics/sketch/makever.pl |
Initial commit
Diffstat (limited to 'graphics/sketch/makever.pl')
-rw-r--r-- | graphics/sketch/makever.pl | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/graphics/sketch/makever.pl b/graphics/sketch/makever.pl new file mode 100644 index 0000000000..430f0d42e9 --- /dev/null +++ b/graphics/sketch/makever.pl @@ -0,0 +1,76 @@ +use strict; +use POSIX qw(strftime); + +sub run { + local $/ = undef; + local *F; + + # get raw data + open(F, "version.dat") || die "can't open version.dat for input"; + my $x = <F>; + close F; + + # put data pairs in a hash + my %pairs = $x =~ /([a-z]+)\s*=\s*(\S+)\s*/g; + die "syntax error in version.dat\n" unless + defined $pairs{major} && + defined $pairs{minor} && + defined $pairs{build}; + + # update the build number + $pairs{build}++ unless $pairs{dist} or $ARGV[0] eq 'noinc'; + + # get the current time/date + my $t = time; + $pairs{time} = $t; + my $slt = scalar(localtime($t)); + my $nicelt = strftime("%A, %B %d, %Y", localtime($t)); + + # print the header + open(F, "> version.h") || die "can't open version.h for output"; + print F "// Produced by makever.pl. Don't edit.\n"; + print F "#define VER_MAJOR $pairs{major}\n"; + print F "#define VER_MINOR $pairs{minor}\n"; + print F "#define VER_BUILD $pairs{build}\n"; + print F "#define VER_BUILD_TIME $t\n"; + print F "#ifndef STRINGIFY\n"; + print F "#define ___S(X) #X\n"; + print F "#define STRINGIFY(X) ___S(X)\n"; + print F "#endif\n"; + print F "#define VER_BUILD_TIME_STRING STRINGIFY($slt)\n"; + my $d = $pairs{dist} ? "d" : ""; + print F qq|#define VER_STRING STRINGIFY(VER_MAJOR) "." STRINGIFY(VER_MINOR) " (build " STRINGIFY(VER_BUILD) "$d, " VER_BUILD_TIME_STRING ")"\n|; + close F; + + # print doc version information + open(F, "> Doc/version.texi") || die "can't open version.texi"; + print F "\@comment Produced by makever.pl. Don't edit.\n"; + print F "\@set VER_MAJOR $pairs{major}\n"; + print F "\@set VER_MINOR $pairs{minor}\n"; + print F "\@set VER_BUILD $pairs{build}\n"; + print F "\@set UPDATED $nicelt\n"; + print F "\@set VERSION \@value{VER_MAJOR}.\@value{VER_MINOR} (build \@value{VER_BUILD})\n"; + close F; + + if ( open(F, "index-tmp.htm") ) { + my $html = <F>; + close F; + my $version = "$pairs{major}.$pairs{minor} (build $pairs{build}), $nicelt"; + $html =~ s/VERSION/$version/g; + my $ver = "$pairs{major}.$pairs{minor}.$pairs{build}"; + $html =~ s/VER/$ver/g; + open(F, "> index.htm") || die "can't open index.htm for output"; + print F $html; + close F; + } + else { + warn "not generating web page\n"; + } + + # update the version header + open(F, "> version.dat") || die "can't open version.dat for output"; + print F join('', map { "$_ = $pairs{$_}\n" } keys %pairs); + close F; +} + +run; |