Advertisement
yumetodo

DxLibEx_CI_AppVeyor_Install_Script

Sep 27th, 2016
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if ($PSVersionTable.PSVersion.Major -lt 5) {
  2.     Write-Error "Powershell version 5 or later is required."
  3.     exit 1
  4. }
  5. function Compare-With-Current-Dxlib-Version ($dxlib_txt, $dxlib_expect_version) {
  6.     return (Test-Path $dxlib_txt) -And ($dxlib_expect_version -eq ([regex]"Ver ([0-9]+\.[0-9a-z]+)").Matches((Get-Content $dxlib_txt))[0].Groups[1].value.Replace(".", "_"));
  7. }
  8. $first_dir = (Get-Location).Path
  9. [System.Console]::Write("fetch DxLib...")
  10. $dlhtml = Invoke-WebRequest -Uri "http://dxlib.o.oo7.jp/dxdload.html"
  11. try {
  12.     $dst = $dlhtml -match '<A HREF="(http[s]*:\/\/[^/]+\/DxLib\/DxLib_VC[\d\w_/.:]+\.(exe|zip))">'
  13. } catch {
  14.     exit 1
  15. }
  16. $dllink = $matches[1];
  17. $dlext = $matches[2];
  18. $dst = $dllink -match "DxLib_VC([\d\w_/.:]+)\.$dlext"
  19. $dxlib_version = $matches[1];
  20. Write-Output "done."
  21. $dxlib_txt = "DxLib_VC\DxLib.txt"
  22. if ((Test-Path "DxLib_VC") -And (Compare-With-Current-Dxlib-Version $dxlib_txt $dxlib_version)){
  23.     Write-Output "DxLib version $dxlib_version detect. skip install."
  24. } else {
  25.     if (!(Test-Path "DxLib_VC$dxlib_version.$dlext")) {
  26.         Write-Output "Downloading DxLib($dxlib_version) from: $dllink"
  27.         Invoke-WebRequest -Uri $dllink -OutFile "DxLib_VC$dxlib_version.$dlext"
  28.         Write-Output "done."
  29.     } else {
  30.         Write-Output "DxLib_VC$dxlib_version.$dlext found. Download skip."
  31.     }
  32.     [System.Console]::Write("Extracting...")
  33.     Rename-Item -path "DxLib_VC" -newName "DxLib_VC_old"
  34.     if ($dlext -eq "zip") {
  35.         $zip_path = "DxLib_VC$dxlib_version.zip";
  36.         $zip = Get-Item $zip_path
  37.         $dirname = $zip.Basename
  38.         New-Item -Force -ItemType directory -Path $dirname
  39.         if (0 -eq $PSVersionTable.PSVersion.Minor) {
  40.             Expand-Archive $zip_path -OutputPath $dirname
  41.         } else {
  42.             Expand-Archive -Path $zip_path -DestinationPath $dirname
  43.         }
  44.         Move-Item -Path "$dirname/DxLib_VC" -Destination "DxLib_VC"
  45.         Remove-Item -path $dirname -recurse -force
  46.     } else {
  47.         Start-Process -FilePath "DxLib_VC$dxlib_version.exe" -Wait
  48.     }
  49.     if ((Test-Path "DxLib_VC") -And (Compare-With-Current-Dxlib-Version $dxlib_txt $dxlib_version)) {
  50.         Write-Output "done."
  51.         [System.Console]::Write("Delete old DxLib_VC and temporary file...")
  52.         Remove-Item -path "DxLib_VC_old" -recurse -force
  53.         Remove-Item -path "DxLib_VC$dxlib_version.$dlext" -ErrorAction Ignore
  54.         Write-Output "done."
  55.     } else {
  56.         Rename-Item -path "DxLib_VC_old" -newName "DxLib_VC"
  57.         Write-Output "failed."
  58.         exit 1
  59.     }
  60. }
  61.  
  62. Set-Location "DxLib_VC\プロジェクトに追加すべきファイル_VC用"
  63. $cu_dir = (Get-Location).Path
  64. Write-Output "$cu_dir exist."
  65.  
  66. [System.Console]::Write("setting to environment variable...")
  67. Set-Location $first_dir
  68. $env:DXLIB_ROOT=$cu_dir
  69. Write-Output "done."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement