BVB Source Codes

Gource Show build_win32.pl Source code

Return Download Gource: download build_win32.pl Source code - Download Gource Source code - Type:.pl
  1. #!/usr/bin/perl
  2. # windows archive + installer generator
  3.  
  4. use strict;
  5. use warnings;
  6. use FindBin;
  7.  
  8. my $base_dir   = "$FindBin::Bin/../..";
  9. my $dll_dir    = "$base_dir/dev/win32";
  10. my $builds_dir = "$base_dir/dev/builds";
  11.  
  12. sub gource_version {
  13.     my $version = `cat $base_dir/src/gource_settings.h | grep GOURCE_VERSION`;
  14.     $version =~ /"([^"]+)"/ or die("could not determine version\n");
  15.     $version = $1;
  16.     return $version;
  17. }
  18.  
  19. sub doit {
  20.     my $cmd = shift;
  21.    
  22.     if(system($cmd) != 0) {
  23.         die("command '$cmd' failed: $!");
  24.     }
  25. }
  26.  
  27. sub dosify {
  28.     my($src, $dest) = @_;
  29.    
  30.     my $content = `cat $src`;
  31.     $content =~ s/\r?\n/\r\n/g;
  32.    
  33.     open  OUTPUT, ">$dest" or die("$!");
  34.     print OUTPUT $content;
  35.     close OUTPUT;
  36. }
  37.  
  38. chdir("$base_dir") or die("chdir to $base_dir failed");
  39.  
  40. my $nsis_script = q[
  41. !define MULTIUSER_MUI
  42. !define MULTIUSER_EXECUTIONLEVEL Highest
  43. !define MULTIUSER_INSTALLMODE_COMMANDLINE
  44. !define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY "Software\Gource"
  45. !define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY "Software\Gource"
  46. !define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME "Install_Mode"
  47. !define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME "Install_Dir"
  48. !define MULTIUSER_INSTALLMODE_INSTDIR "Gource"
  49. !include "MultiUser.nsh"
  50.  
  51. !include "MUI2.nsh"
  52. !include "LogicLib.nsh"
  53. !include "SafeEnvVarUpdate.nsh"
  54.  
  55. Name "Gource GOURCE_VERSION"
  56.  
  57. OutFile "GOURCE_INSTALLER"
  58.  
  59. !define MUI_WELCOMEFINISHPAGE_BITMAP   "..\..\nsis\welcome.bmp"
  60. !define MUI_UNWELCOMEFINISHPAGE_BITMAP "..\..\nsis\welcome.bmp"
  61.  
  62. !define MUI_COMPONENTSPAGE_NODESC
  63.  
  64. !insertmacro MULTIUSER_PAGE_INSTALLMODE
  65. !insertmacro MUI_PAGE_WELCOME
  66. !insertmacro MUI_PAGE_COMPONENTS
  67. !insertmacro MUI_PAGE_DIRECTORY
  68. !insertmacro MUI_PAGE_INSTFILES
  69. !insertmacro MUI_PAGE_FINISH
  70.  
  71. !insertmacro MUI_LANGUAGE "English"
  72.  
  73. Function .onInit
  74.   !insertmacro MULTIUSER_INIT
  75.   ReadRegStr $R0 SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Gource" "UninstallString"
  76.   StrCmp $R0 "" done
  77.   MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
  78.   "Gource appears to already be installed. $\n$\nClick OK to remove the previous version and continue the installation." \
  79.   IDOK uninst
  80.   Abort
  81.  
  82.  uninst:
  83.   ClearErrors
  84.   ExecWait $R0
  85.  
  86.  done:
  87.  
  88. FunctionEnd
  89.  
  90. Function un.onInit
  91.   !insertmacro MULTIUSER_UNINIT
  92. FunctionEnd
  93.  
  94. Section "Gource" SecGource
  95.   SectionIn RO
  96.  
  97.   GOURCE_INSTALL_LIST
  98.  
  99.   writeUninstaller $INSTDIR\uninstall.exe
  100.  
  101.   WriteRegStr SHCTX "Software\Gource" ${MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME} "$INSTDIR"
  102.   WriteRegStr SHCTX "Software\Gource" ${MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME} "$MultiUser.InstallMode"
  103.  
  104.   WriteRegStr   SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Gource" "DisplayName"          "Gource"
  105.   WriteRegStr   SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Gource" "DisplayVersion"       "GOURCE_VERSION"
  106.   WriteRegStr   SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Gource" "UninstallString"      '"$INSTDIR\uninstall.exe"'
  107.   WriteRegStr   SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Gource" "QuietUninstallString" '"$INSTDIR\uninstall.exe" /S'
  108.   WriteRegDWORD SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Gource" "NoModify" 1
  109.   WriteRegDWORD SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Gource" "NoRepair" 1
  110.  
  111. SectionEnd
  112.  
  113. Section "Add to PATH" SecAddtoPath
  114.  
  115.   ${If} $MultiUser.InstallMode == "AllUsers"
  116.     ${EnvVarUpdate} $0 "PATH" "A" "HKLM" "$INSTDIR\cmd"
  117.   ${ElseIf} $MultiUser.InstallMode == "CurrentUser"
  118.     ${EnvVarUpdate} $0 "PATH" "A" "HKCU" "$INSTDIR\cmd"
  119.   ${EndIf}
  120.  
  121. SectionEnd
  122.  
  123. Section "Uninstall"
  124.  
  125.   ${If} $MultiUser.InstallMode == "AllUsers"
  126.     ${un.EnvVarUpdate} $0 "PATH" "R" "HKLM" "$INSTDIR\cmd"
  127.   ${ElseIf} $MultiUser.InstallMode == "CurrentUser"
  128.     ${un.EnvVarUpdate} $0 "PATH" "R" "HKCU" "$INSTDIR\cmd"
  129.   ${EndIf}
  130.  
  131.   DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Gource"
  132.   DeleteRegKey SHCTX "Software\Gource"
  133.  
  134.   GOURCE_UNINSTALL_LIST
  135.   GOURCE_UNINSTALL_DIRS
  136.  
  137.   Delete $INSTDIR\uninstall.exe
  138.   RMDir "$INSTDIR"
  139. SectionEnd
  140. ];
  141.  
  142. my @gource_files = qw(
  143.     gource.exe
  144.     data/beam.png
  145.     data/file.png
  146.     data/user.png
  147.     data/bloom.tga
  148.     data/bloom_alpha.tga
  149.     data/gource.style
  150.     data/fonts/FreeSans.ttf
  151.     data/shaders/bloom.frag
  152.     data/shaders/bloom.vert
  153.     data/shaders/shadow.frag
  154.     data/shaders/shadow.vert
  155.     data/shaders/text.frag
  156.     data/shaders/text.vert
  157.     cmd/gource.cmd
  158.     cmd/gource
  159. );
  160.  
  161. my @gource_txts = qw(
  162.     README
  163.     ChangeLog
  164.     data/fonts/README
  165.     COPYING
  166.     THANKS
  167. );
  168.  
  169. my @gource_dlls = qw(
  170.     SDL2.dll
  171.     SDL2_image.dll
  172.     libpcre-1.dll
  173.     libjpeg-9.dll
  174.     libpng16-16.dll
  175.     zlib1.dll
  176.     glew32.dll
  177.     libfreetype-6.dll
  178. );
  179.  
  180. my @gource_dirs = qw(
  181.     data
  182.     data/fonts
  183.     data/shaders
  184.     cmd
  185. );
  186.  
  187. my $tmp_dir = "$builds_dir/gource-build.$$";
  188.  
  189. doit("rm $tmp_dir") if -d $tmp_dir;
  190. mkdir($tmp_dir);
  191.  
  192. # create directories
  193. foreach my $dir (@gource_dirs) {
  194.     mkdir("$tmp_dir/$dir");
  195. }
  196.  
  197. my @gource_bundle;
  198.  
  199. # copy general files
  200. foreach my $file (@gource_files) {
  201.     doit("cp $file $tmp_dir/$file");
  202.     push @gource_bundle, $file;
  203. }
  204.  
  205. # copy dlls
  206. foreach my $file (@gource_dlls) {
  207.     doit("cp $dll_dir/$file $tmp_dir/$file");
  208.     push @gource_bundle, $file;
  209. }
  210.  
  211. # convert text files
  212. foreach my $file (@gource_txts) {
  213.     dosify("$file", "$tmp_dir/$file.txt");
  214.     push @gource_bundle, "$file.txt";
  215. }
  216.  
  217. my $version = gource_version();
  218.  
  219. my $installer_name = "gource-${version}-setup.exe";
  220. my $archive_name   = "gource-${version}.win32.zip";
  221.  
  222. my $install_list = '';
  223.  
  224. foreach my $dir ('', @gource_dirs) {
  225.  
  226.     my @dir_files = map  { my $f = $_; $f =~ s{/}{\\}g; $f; }
  227.                     grep { my $d = /^(.+)\// ? $1 : ''; $d eq $dir }
  228.                     @gource_bundle;
  229.  
  230.     (my $output_dir = $dir) =~ s{/}{\\}g;
  231.  
  232.     $install_list .= "\n" . '  SetOutPath "$INSTDIR' . ( $dir ? "\\$output_dir" : "" ) . "\"\n\n";
  233.  
  234.     foreach my $file (@dir_files) {
  235.         $install_list .= '  File '.$file."\n";
  236.     }
  237. }
  238.  
  239. my $uninstall_list = join("\n", map { my $f = $_; $f =~ s{/}{\\}g; '  Delete $INSTDIR\\'.$f } @gource_bundle);
  240. my $uninstall_dirs = join("\n", map { my $d = $_; $d =~ s{/}{\\}g; '  RMDir  $INSTDIR\\'.$d } reverse @gource_dirs);
  241.  
  242. $nsis_script =~ s/GOURCE_VERSION/$version/g;
  243. $nsis_script =~ s/GOURCE_INSTALLER/$installer_name/g;
  244. $nsis_script =~ s/GOURCE_INSTALL_LIST/$install_list/;
  245. $nsis_script =~ s/GOURCE_UNINSTALL_LIST/$uninstall_list/;
  246. $nsis_script =~ s/GOURCE_UNINSTALL_DIRS/$uninstall_dirs/;
  247. $nsis_script =~ s/\n/\r\n/g;
  248.  
  249. chdir($tmp_dir) or die("failed to change directory to '$tmp_dir'\n");
  250.  
  251. # remove existing copies of the version installer if they exist
  252.  
  253. doit("rm ../$installer_name") if -e "../$installer_name";
  254. doit("rm ../$archive_name")   if -e "../$archive_name";
  255.  
  256. my $output_file = "gource.nsi";
  257.  
  258. open my $NSIS_HANDLE, ">$output_file" or die("failed to open $output_file: $!");
  259. print $NSIS_HANDLE $nsis_script;
  260. close $NSIS_HANDLE;
  261.  
  262. # generate installer
  263.  
  264. # assert we have the long string build of NSIS
  265. doit("makensis -HDRINFO | grep -q NSIS_MAX_STRLEN=8192");
  266.  
  267. doit("makensis $output_file");
  268.  
  269. doit("rm $output_file");
  270. doit("mv $installer_name ..");
  271.  
  272. # also create zip archive
  273.  
  274. doit("zip -r $archive_name *");
  275. doit("mv $archive_name ..");
  276.  
  277. chdir("$tmp_dir/..");
  278. doit("rm -rf $tmp_dir");
  279.  
downloadbuild_win32.pl Source code - Download Gource Source code
Related Source Codes/Software:
FDFullscreenPopGesture - A UINavigationController's category to enable full... 2017-01-10
node-style-guide - A guide for styling your node.js / JavaScript code... 2017-01-09
ImageOptim - GUI image optimizer for Mac htt... 2017-01-09
falcon - Falcon is a low-level, high-performance Python fra... 2017-01-09
prerender - Node server that uses phantomjs to render a javasc... 2017-01-09
che - Eclipse Che: Next-generation Eclipse IDE. Open sou... 2017-01-10
notepad-plus-plus - Notepad++ official repository h... 2017-01-10
waterline - An adapter-based ORM for Node.js with support for ... 2017-01-10
Workerman - An asynchronous event driven PHP framework for eas... 2017-01-10
structor - An advanced visual editor for React components ... 2017-01-10
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top