-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathver_info.pl
executable file
·87 lines (67 loc) · 1.56 KB
/
ver_info.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/perl
use strict;
my @tmp_string;
my $svn_status;
my $svn_filename;
my $svn_version;
my $svn_root = ".";
my $svn_root_version;
my $svn_root_url;
my @header_defines = (
"#ifndef _SSV_VERSION_H_",
"#define _SSV_VERSION_H_",
"",
);
sub get_version {
foreach (@_) {
if($_ =~ m/^Last Changed Rev: (\d*)/) {
return $1;
}
}
# file doesn't exist on svn
return -1;
}
sub get_url {
foreach (@_) {
if($_ =~ m/^URL: (.*)/) {
return $1;
}
}
# file doesn't exist on svn
return -1;
}
printf("## script to generate version infomation header ##\n");
# step-0: get root svn number
$svn_root_version = get_version(qx(svn info $svn_root));
if ($svn_root_version == -1) {
exit 0;
}
# step-1: get root svn url
$svn_root_url = get_url(qx(svn info $svn_root));
OUTPUT_HEADER:
# step-3: output header files
if (defined($ARGV[0])) {
open HEADER, ">", $ARGV[0];
select HEADER;
}
else {
print "Error! Please specify header file\n";
}
foreach (@header_defines) {
printf("%s\n", $_);
}
##
printf("static u32 ssv_root_version = %d;\n\n", $svn_root_version);
printf("#define SSV_ROOT_URl \"$svn_root_url\"\n");
use Sys::Hostname;
my $host = hostname();
printf("#define COMPILERHOST \"$host\"\n");
use POSIX qw(strftime);
my $date = strftime "%m-%d-%Y-%H:%M:%S", localtime;
printf("#define COMPILERDATE \"$date\"\n");
##
use Config;
printf("#define COMPILEROS \"$Config{osname}\"\n");
printf("#define COMPILEROSARCH \"$Config{archname}\"\n");
printf("\n#endif\n\n");
exit 1;