Implemented Debug Tag functionality
[public/netxms.git] / build / updatetag.pl
1 #!/usr/bin/perl
2
3 my $file = shift || die "Usage : updatetag.pl <file>";
4
5 my $tag = `git describe`;
6 chomp $tag;
7 print "Git tag: $tag\n";
8
9 my $update = 1;
10
11 if (open(IN, "<$file"))
12 {
13 while(<IN>)
14 {
15 chomp;
16 my $in = $_;
17 if ($in =~ /\* BUILDTAG:(.*) \*/)
18 {
19 print "Build tag: $1\n";
20 if ($1 eq $tag)
21 {
22 $update = 0;
23 }
24 }
25 }
26 close IN;
27 }
28
29 if ($update == 1)
30 {
31 open(OUT, ">$file") or die "Cannot open output file: $!";
32 print OUT "/* BUILDTAG:$tag */\n";
33 print OUT "#ifndef _build_tag_h_\n";
34 print OUT "#define _build_tag_h_\n";
35 print OUT "#define NETXMS_BUILD_TAG _T(\"$tag\")\n";
36 print OUT "#define NETXMS_BUILD_TAG_A \"$tag\"\n";
37 print OUT "#endif\n";
38 close OUT;
39
40 print "Build tag updated\n";
41 }