buildRelease.pl 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/usr/bin/perl
  2. #
  3. # Copyright (c) 2013 No Face Press, LLC
  4. # License http://opensource.org/licenses/mit-license.php MIT License
  5. #
  6. # This script builds and packages a Windows release.
  7. # It requires ActiveState Perl to use and is intended
  8. # to be run from the its directory under the
  9. # VS Developer Command Prompt.
  10. # Create a Zip file
  11. use Archive::Zip qw( :ERROR_CODES :CONSTANTS );
  12. my $zip = Archive::Zip->new();
  13. my $src = "..";
  14. sub getCivetwebVersion {
  15. print "Fetching CivetWeb version...\n";
  16. open HEADER, "${src}/include/civetweb.h";
  17. while (<HEADER>) {
  18. if (m/define\s+CIVETWEB_VERSION\s+"(.+)"/) {
  19. close HEADER;
  20. return $1;
  21. }
  22. }
  23. close HEADER;
  24. return "UNKNOWN_VERSION";
  25. }
  26. my $CIVETWEB_VERSION = getCivetwebVersion();
  27. my $basename = "civetweb-$CIVETWEB_VERSION";
  28. my $dir = "${basename}";
  29. sub build32() {
  30. print "\nBuilding Win32 Release version...\n";
  31. system("msbuild /p:Configuration=Release /p:Platform=Win32 civetweb.sln");
  32. }
  33. sub build64() {
  34. print "\nBuilding x64 Release version...\n";
  35. system("msbuild /p:Configuration=Release /p:Platform=x64 civetweb.sln");
  36. }
  37. sub writeArchive() {
  38. my $archive = "${basename}-win.zip";
  39. print "Creating archive $archive ...\n";
  40. $zip->addDirectory("${dir}/");
  41. $zip->addFile( "${src}/LICENSE.md", "${dir}/LICENSE.md" );
  42. $zip->addFile( "${src}/README.md", "${dir}/README.md" );
  43. $zip->addFile( "${src}/resources/systray.ico", "${dir}/systray.ico" );
  44. $zip->addFile( "${src}/resources/civetweb_64x64.png",
  45. "${dir}/civetweb_64x64.png" );
  46. $zip->addFile( "${src}/resources/itworks.html", "${dir}/index.html" );
  47. $zip->addFile( "${src}/VS2012/Release/Win32/civetweb_lua.exe",
  48. "${dir}/civetweb32.exe" );
  49. $zip->addFile( "${src}/VS2012/Release/x64/civetweb_lua.exe",
  50. "${dir}/civetweb64.exe" );
  51. unless ( $zip->writeToFileNamed($archive) == AZ_OK ) {
  52. die 'write error';
  53. }
  54. }
  55. build32();
  56. build64();
  57. writeArchive();
  58. exit 0;