Changelog update
[public/netxms.git] / build / updatetag.pl
1 #!/usr/bin/perl
2
3 my $file_prefix = shift || "netxms";
4 my $define_prefix = shift || "NETXMS";
5 my $file = shift || $file_prefix . "-build-tag.h";
6
7 my $tag = `git describe --always`;
8 chomp $tag;
9 if ($tag =~ /^Release-(.*)/)
10 {
11 $tag = $1;
12 }
13 print "Git tag: $tag\n";
14
15 my $update = 1;
16
17 if (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
35 if ($update == 1)
36 {
37 open(OUT, ">$file") or die "Cannot open output file: $!";
38 print OUT "/* BUILDTAG:$tag */\n";
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";
43 print OUT "#endif\n";
44 close OUT;
45
46 print "Build tag updated\n";
47 }