build_doc.pl 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/usr/bin/perl
  2. # building documentation using doxygen and updation versionning number
  3. use strict;
  4. use File::Basename;
  5. my $sDocFile = "doxyconf";
  6. my $outputdir = "doc/doxygen";
  7. my @line = ();
  8. my $repoversion;
  9. my $gitversion;
  10. my $doxyversion;
  11. my $chked;
  12. my($filename, $dir, $suffix) = fileparse($0);
  13. chdir "../$dir"; #put ourself like was called in tools
  14. #checking for doxygen
  15. open PIPE,"doxygen --version |" or die $!;
  16. @line = grep { /\d.\d.\d/ } <PIPE>;
  17. $doxyversion = $line[0];
  18. print "doxyversion = [ $doxyversion ]\n";
  19. if($doxyversion eq ""){
  20. die "Please install doxygen to proceed";
  21. }
  22. close PIPE;
  23. #cheking for git cli
  24. open PIPE,"git --version |" or die $!;
  25. @line = grep { /\d.\d.\d.\d/ } <PIPE>;
  26. $gitversion = $line[0];
  27. $gitversion =~ s/[^\d.\d.\d.\d]//g;
  28. print "doxyversion = [ $gitversion ]\n";
  29. if($gitversion eq ""){
  30. die "Please install git to proceed";
  31. }
  32. close PIPE;
  33. open PIPE,"git rev-parse --short HEAD |" or die $!;
  34. @line = grep { /\w/ } <PIPE>;
  35. $repoversion = $line[0];
  36. print "Git hash is : $repoversion";
  37. close PIPE;
  38. unless(-r "$outputdir"){
  39. mkdir "$outputdir" or die "Can't create output directory for documentation (outdir=$outputdir)\n";
  40. }
  41. die "$sDocFile doesn't seem to exist or coudldn't be read" unless(-r "$sDocFile");
  42. print "Updating doxygen file version (doxyconf=$sDocFile)\n";
  43. open FHIN,"$sDocFile" || die "couldn't openfile/create $sDocFile \n";
  44. open FHOUT,">doxyconf.tmp" || die "couldn't openfile/create doxyconf.tmp \n";
  45. while(<FHIN>){
  46. if(($chked&1)==0 && $_ =~ /^PROJECT_NUMBER/) {
  47. @line = split(" ",$_);
  48. print FHOUT "PROJECT_NUMBER = $repoversion";
  49. print "Updated project number\n";
  50. $chked &=1;
  51. }
  52. elsif(($chked&2)==0 && $_ =~ /^OUTPUT_DIRECTORY/){
  53. print FHOUT "OUTPUT_DIRECTORY = $outputdir";
  54. print "Updated output dir\n";
  55. $chked &=2;
  56. }
  57. else { print FHOUT $_; }
  58. }
  59. close FHIN;
  60. close FHOUT;
  61. unlink $sDocFile;
  62. rename "doxyconf.tmp", $sDocFile;
  63. print "Building doc\n";
  64. system("doxygen doxyconf");