2
0

make_distrib.pl 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #!/usr/bin/perl
  2. my $curDir = `cd`;
  3. my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
  4. $year += 1900;
  5. # Get libcds version
  6. my $Version = get_version();
  7. print "Make libcds-$Version distributive\n";
  8. my $DistrDir = get_distrib_dir();
  9. print "Distrib dir: $DistrDir\n";
  10. # Git clone
  11. my $GitBranch = 'master';
  12. my $GitRepo = get_git_repo();
  13. print "Clone git: repo=$GitRepo, branch=$GitBranch\n";
  14. `git clone -b $GitBranch $GitRepo $DistrDir`; # or die "Error cloning branch $GitBranch to $DistrDir\n";
  15. print "Remove $DistrDir/.git directory\n";
  16. `rm -fr $DistrDir/.git`;
  17. `rm -f $DistrDir/.gitignore $DistrDir/tools/brush_cds.pl $DistrDir/tools/make_distrib.pl $DistrDir/tools/make_distrib.bat $DistrDir/doxygen/images.odp`;
  18. print "patch files...\n";
  19. patch_file("$DistrDir/CMakeList.txt", 'PROJECT_VERSION \d+\.\d+\.\d+', "PROJECT_VERSION $Version" );
  20. patch_file("$DistrDir/doxygen/cds.doxy", 'PROJECT_NUMBER\s*=\s*\d+\.\d+\.\d+', "PROJECT_NUMBER = $Version" ) ;
  21. print "Make docs\n";
  22. `cd $DistrDir/tools && make_docs.bat && rm doxygen.log && cd $curDir`;
  23. print "make zip...\n" ;
  24. `rm -f $DistrDir/../cds-$Version.zip` ;
  25. `cd $DistrDir/.. && 7za a cds-$Version.zip cds-$Version` ;
  26. print "Done\n" ;
  27. exit ;
  28. sub get_version()
  29. {
  30. my $version;
  31. open( my $fh, 'cds/version.h' ) or die "ERROR: Cannot find ../cds/version.h file";
  32. binmode $fh ;
  33. while (<$fh>) {
  34. if ( /CDS_VERSION_STRING.+(\d+\.\d+\.\d+)/ ) {
  35. $version = $1 ;
  36. last ;
  37. }
  38. }
  39. close $fh ;
  40. die "ERROR: cannot find version in ../cds/version.h" unless $version ;
  41. }
  42. sub get_distrib_dir()
  43. {
  44. my $dir = "../cds-distrib/cds-$Version";
  45. `rm -fr $dir` if -d $dir;
  46. mkdir $dir;
  47. return $dir;
  48. }
  49. sub get_git_repo()
  50. {
  51. return 'https://github.com/khizmax/libcds.git';
  52. }
  53. sub patch_file(@) {
  54. my $file = shift ;
  55. my $seek = shift ;
  56. my $repl = shift ;
  57. if ( open( my $fh, $file )) {
  58. binmode $fh ;
  59. my $str = '' ;
  60. $str .= $_ while <$fh> ;
  61. close $fh ;
  62. $str =~ s/$seek/$repl/g ;
  63. if ( open( my $fh, ">$file" )) {
  64. binmode $fh ;
  65. print $fh $str ;
  66. close $fh ;
  67. }
  68. }
  69. }