]> git.saurik.com Git - wxWidgets.git/blob - distrib/msw/tmake/lib/wxVersion.pm
get the version info directly from wx/version.h instead of hardcoding it here
[wxWidgets.git] / distrib / msw / tmake / lib / wxVersion.pm
1 package wxVersion;
2
3 =head1 NAME
4
5 wxVersion
6
7 =head1 SYNOPSIS
8
9 use wxVersion qw(GetVersion);
10
11 =head1 METHODS
12
13 =cut
14
15 use strict;
16
17 use base 'Exporter';
18 use vars qw(@EXPORT_OK);
19
20 @EXPORT_OK = qw(GetVersion);
21
22 sub GetVersion()
23 {
24 my $filename = $ENV{"WXWIN"} . "/include/wx/version.h";
25 open(VERSION_H, $filename) or die "Can't open $filename: $!\n";
26
27 my %versions;
28 my $numGot = 0;
29
30 while ( defined($_ = <VERSION_H>) ) {
31 chomp;
32
33 if ( /\s*#define\s+wxMAJOR_VERSION\s+(\d+)/ ) {
34 $versions{'MAJOR'} = $1;
35 $numGot++;
36 }
37 elsif ( /\s*#define\s+wxMINOR_VERSION\s+(\d+)/ ) {
38 $versions{'MINOR'} = $1;
39 $numGot++;
40 }
41 elsif ( /\s*#define\s+wxRELEASE_NUMBER\s+(\d+)/ ) {
42 $versions{'MICRO'} = $1;
43 $numGot++;
44 }
45
46 last if $numGot == 3 # we've got everything we wanted
47 }
48
49 $numGot == 3 or die "Failed to read the version from $filename.\n";
50
51 return %versions;
52 }
53