Changelog update
[public/netxms.git] / build / updatetag.pl
CommitLineData
7fabd388
VK
1#!/usr/bin/perl
2
77f87f93
VK
3my $file_prefix = shift || "netxms";
4my $define_prefix = shift || "NETXMS";
5my $file = shift || $file_prefix . "-build-tag.h";
7fabd388 6
0516e67d 7my $tag = `git describe --always`;
7fabd388 8chomp $tag;
0516e67d
VK
9if ($tag =~ /^Release-(.*)/)
10{
11 $tag = $1;
12}
7fabd388
VK
13print "Git tag: $tag\n";
14
15my $update = 1;
16
17if (open(IN, "<$file"))
18{
19 while(<IN>)
20 {
21 chomp;
22 my $in = $_;
23 if ($in =~ /\* BUILDTAG:(.*) \*/)
24 {
25 print "Build tag: $1\n";
26 if ($1 eq $tag)
27 {
28 $update = 0;
29 }
30 }
31 }
32 close IN;
33}
34
35if ($update == 1)
36{
37 open(OUT, ">$file") or die "Cannot open output file: $!";
38 print OUT "/* BUILDTAG:$tag */\n";
77f87f93
VK
39 print OUT "#ifndef _" . $file_prefix . "_build_tag_h_\n";
40 print OUT "#define _" . $file_prefix . "_build_tag_h_\n";
41 print OUT "#define " . $define_prefix . "_BUILD_TAG _T(\"$tag\")\n";
42 print OUT "#define " . $define_prefix . "_BUILD_TAG_A \"$tag\"\n";
7fabd388
VK
43 print OUT "#endif\n";
44 close OUT;
45
46 print "Build tag updated\n";
47}