package_win32.ps1 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. # Written by Joseph Lenox
  2. # Licensed under the same license as the rest of Slic3r.
  3. # ------------------------
  4. # You need to have Strawberry Perl 5.24.0.1 (or slic3r-perl) installed for this to work,
  5. Param
  6. (
  7. # Perl version major/minor number. Slic3r perl uses 524
  8. [string]$perlVersion = "524",
  9. # Override the output file name.
  10. [string]$outputFile = "",
  11. [string]$currentDate = "$(Get-Date -UFormat '%Y.%m.%d')",
  12. # Override the branch name used in the output. Otherwise autodetect based on git.
  13. [string]$branch = "",
  14. #This is "32bit" or "64bit". It will detect based on presence of libglut.
  15. [string]$arch = $env:ARCH,
  16. # Change this to where you have Strawberry Perl installed.
  17. [string]$STRAWBERRY_PATH = "C:\Strawberry",
  18. [switch]$skipInstallPAR
  19. )
  20. function Get-ScriptDirectory
  21. {
  22. $Invocation = (Get-Variable MyInvocation -Scope 1).Value
  23. Split-Path $Invocation.MyCommand.Path
  24. }
  25. $scriptDir = Get-ScriptDirectory
  26. echo "Make this is run from the perl command window."
  27. echo "Requires PAR."
  28. $perldll = "perl$perlVersion"
  29. if ($branch -eq "") {
  30. git branch | foreach {
  31. if ($env:APPVEYOR) {
  32. if ($_ -match "` (.*)") {
  33. $branch += $matches[1]
  34. }
  35. } else {
  36. if ($_ -match "\*` (.*)"){
  37. $branch += $matches[1]
  38. }
  39. }
  40. }
  41. }
  42. if ($outputFile -eq "") {
  43. $outputFile = $output_zip
  44. }
  45. if (!($arch -eq "64bit" -Or $arch -eq "32bit")) {
  46. # detect current version through libglut
  47. if (Test-Path "${STRAWBERRY_PATH}\c\bin\libglut-0__.dll") {
  48. $arch = "64bit"
  49. } else {
  50. $arch = "32bit"
  51. }
  52. echo "Arch: $arch"
  53. }
  54. if ($env:APPVEYOR) {
  55. if ($env:APPVEYOR_PULL_REQUEST_NUMBER -eq "") {
  56. $output_zip = "${scriptDir}\..\..\Slic3r-${branch}.${currentDate}.${env:APPVEYOR_BUILD_NUMBER}.$(git rev-parse --short HEAD).${arch}.zip"
  57. } else {
  58. $output_zip = "${scriptDir}\..\..\Slic3r-${branch}.${currentDate}.${env:APPVEYOR_BUILD_NUMBER}.$(git rev-parse --short HEAD).${arch}-PR${APPVEYOR_PULL_REQUEST_NUMBER}.zip"
  59. }
  60. } else {
  61. $output_zip = "${scriptDir}\..\..\Slic3r-${branch}.${currentDate}.$(git rev-parse --short HEAD).${arch}.zip"
  62. }
  63. if ($outputFile -eq "") {
  64. $outputFile = $output_zip
  65. }
  66. if (-Not $skipInstallPAR) {
  67. cpanm "PAR::Packer"
  68. }
  69. # Some file names change based on 64bit/32bit. Set them here.
  70. if ($arch -eq "32bit") {
  71. $perlarch = "sjlj"
  72. $glut = "libglut-0_.dll"
  73. $pthread= "pthreadGC2-w32.dll"
  74. } else {
  75. $perlarch = "seh"
  76. $glut = "libglut-0__.dll"
  77. $pthread= "pthreadGC2-w64.dll"
  78. }
  79. if (!( (Test-Path -Path "${scriptDir}\slic3r.exe") -And (Test-Path -Path "${scriptDir}\slic3r-console.exe") -And (Test-Path -Path "${scriptDir}\slic3r-debug-console.exe") ) ) {
  80. echo "Compiling Slic3r binaries"
  81. & ${scriptDir}\compile_wrapper.ps1 -perlVersion=$perlVersion -STRAWBERRY_PATH=$STRAWBERRY_PATH
  82. }
  83. # remove all static libraries, they just take up space.
  84. if ($env:APPVEYOR) {
  85. gci ${scriptDir}\..\..\ -recurse | ? {$_.Name -match ".*\.a$"} | ri
  86. gci -recurse ${scriptDir}\..\..\local-lib | ? {$_.PSIsContainer -And $_.Name -match "DocView|IPC|DataView|Media|Ribbon|Calendar|STC|PerlTest|WebView"} | ri
  87. gci -recurse ${scriptDir}\..\..\local-lib| ? {$_.Name -match ".*(webview|ribbon|stc).*\.dll"} | ri
  88. gci -recurse ${scriptDir}\..\..\local-lib| ? {$_.Name -match ".*(webview|ribbon|stc).*\.dll"} | ri
  89. gci -recurse ${scriptDir}\..\..\local-lib| ? {$_.Name -match "^ExtUtils$"} | ri
  90. gci -recurse ${scriptDir}\..\..\local-lib\lib\perl5\Module ? {$_.Name -match "^Build"} | ri
  91. gci -recurse ${scriptDir}\..\..\local-lib ? {$_.Name -match "\.pod$"} | ri
  92. gci -recurse ${scriptDir}\..\..\local-lib ? {$_.Name -match "\.h$"} | ri
  93. }
  94. pp `
  95. -a "${scriptDir}/slic3r.exe;Slic3r.exe" `
  96. -a "${scriptDir}/slic3r-console.exe;Slic3r-console.exe" `
  97. -a "${scriptDir}/slic3r-debug-console.exe;Slic3r-debug-console.exe" `
  98. -a "${scriptDir}/../../lib;lib" `
  99. -a "${scriptDir}/../../local-lib;local-lib" `
  100. -a "${scriptDir}/../../slic3r.pl;slic3r.pl" `
  101. -a "${scriptDir}/../../var;var" `
  102. -a "${scriptDir}/../../FreeGLUT/freeglut.dll;freeglut.dll" `
  103. -a "${STRAWBERRY_PATH}\perl\bin\perl${perlVersion}.dll;perl${perlVersion}.dll" `
  104. -a "${STRAWBERRY_PATH}\perl\bin\libstdc++-6.dll;libstdc++-6.dll" `
  105. -a "${STRAWBERRY_PATH}\perl\bin\libgcc_s_${perlarch}-1.dll;libgcc_s_${perlarch}-1.dll" `
  106. -a "${STRAWBERRY_PATH}\perl\bin\libwinpthread-1.dll;libwinpthread-1.dll" `
  107. -a "${STRAWBERRY_PATH}\c\bin\${pthread};${pthread}" `
  108. -a "${STRAWBERRY_PATH}\c\bin\${glut};${glut}" `
  109. -M AutoLoader `
  110. -M B `
  111. -M Carp `
  112. -M Class::Accessor `
  113. -M Config `
  114. -M Crypt::CBC `
  115. -M Cwd `
  116. -M Devel::GlobalDestruction `
  117. -M Digest `
  118. -M Digest::MD5 `
  119. -M Digest::SHA `
  120. -M Digest::base `
  121. -M DynaLoader `
  122. -M Errno `
  123. -M Exporter `
  124. -M Exporter::Heavy `
  125. -M Fcntl `
  126. -M File::Basename `
  127. -M File::Glob `
  128. -M File::Spec `
  129. -M File::Spec::Unix `
  130. -M File::Spec::Win32 `
  131. -M FindBin `
  132. -M HTTP::Config `
  133. -M HTTP::Date `
  134. -M HTTP::Headers `
  135. -M HTTP::Headers::Util `
  136. -M HTTP::Message `
  137. -M HTTP::Request `
  138. -M HTTP::Request::Common `
  139. -M HTTP::Response `
  140. -M HTTP::Status `
  141. -M IO `
  142. -M IO::Handle `
  143. -M IO::Select `
  144. -M IO::Socket `
  145. -M LWP `
  146. -M LWP::MediaTypes `
  147. -M LWP::MemberMixin `
  148. -M LWP::Protocol `
  149. -M LWP::Protocol::http `
  150. -M LWP::UserAgent `
  151. -M List::Util `
  152. -M Math::Trig `
  153. -M Method::Generate::Accessor `
  154. -M Method::Generate::BuildAll `
  155. -M Method::Generate::Constructor `
  156. -M Module::Runtime `
  157. -M POSIX `
  158. -M Pod::Escapes `
  159. -M Pod::Text `
  160. -M Pod::Usage `
  161. -M SelectSaver `
  162. -M Socket `
  163. -M Socket6 `
  164. -M Storable `
  165. -M Sub::Exporter `
  166. -M Sub::Exporter::Progressive `
  167. -M Symbol `
  168. -M Term::Cap `
  169. -M Text::ParseWords `
  170. -M Thread `
  171. -M Thread::Queue `
  172. -M Thread::Semaphore `
  173. -M Tie::Handle `
  174. -M Tie::Hash `
  175. -M Tie::StdHandle `
  176. -M Time::Local `
  177. -M URI `
  178. -M URI::Escape `
  179. -M URI::http `
  180. -M Unicode::Normalize `
  181. -M Win32 `
  182. -M Win32::API `
  183. -M Win32::TieRegistry `
  184. -M Win32::WinError `
  185. -M Win32API::Registry `
  186. -M XSLoader `
  187. -B `
  188. -M lib `
  189. -p ${scriptDir}\..\..\slic3r.pl -o ${scriptDir}\..\..\slic3r.par
  190. # switch renaming based on whether or not using packaged exe or zip
  191. # make this more useful for not being on the appveyor server
  192. copy ${scriptDir}\..\..\slic3r.par ${outputFile}
  193. echo "Package saved as ${outputFile}"
  194. del ${scriptDir}\..\..\slic3r.par