You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

151 lines
3.3KB

  1. # Script that builds libpff
  2. #
  3. # Version: 20180728
  4. Param (
  5. [string]$Configuration = ${Env:Configuration},
  6. [string]$MSVSCppConvertOptions = "--extend-with-x64",
  7. [string]$Platform = ${Env:Platform},
  8. [string]$PythonPath = "C:\Python27",
  9. [string]$VSToolsPath = "..\vstools"
  10. )
  11. $ExitSuccess = 0
  12. $ExitFailure = 1
  13. $Python = "${PythonPath}\python.exe"
  14. $Git = "git"
  15. $GitUrl = "https://github.com/libyal/vstools.git"
  16. $MSVSCppConvert = "${VSToolsPath}\scripts\msvscpp-convert.py"
  17. If (-Not (Test-Path $Python))
  18. {
  19. Write-Host "Missing Python: ${Python}" -foreground Red
  20. Exit ${ExitFailure}
  21. }
  22. If (-Not (Test-Path ${VSToolsPath}))
  23. {
  24. # PowerShell will raise NativeCommandError if git writes to stdout or stderr
  25. # therefore 2>&1 is added and the output is stored in a variable.
  26. $Output = Invoke-Expression -Command "${Git} clone ${GitUrl} ${VSToolsPath} 2>&1"
  27. }
  28. Else
  29. {
  30. Push-Location "${VSToolsPath}"
  31. Try
  32. {
  33. # Make sure vstools are up to date.
  34. $Output = Invoke-Expression -Command "${Git} pull 2>&1"
  35. }
  36. Finally
  37. {
  38. Pop-Location
  39. }
  40. }
  41. If (-Not (Test-Path ${MSVSCppConvert}))
  42. {
  43. Write-Host "Missing msvscpp-convert.py: ${MSVSCppConvert}" -foreground Red
  44. Exit ${ExitFailure}
  45. }
  46. ElseIf (-Not ${Env:VisualStudioVersion})
  47. {
  48. Write-Host "Unknown Visual Studio version make sure to set %VisualStudioVersion%" -foreground Red
  49. Exit ${ExitFailure}
  50. }
  51. $OutputFormat = ""
  52. If (${Env:VisualStudioVersion} -eq "15.0")
  53. {
  54. $OutputFormat = "2017"
  55. }
  56. ElseIf (${Env:VisualStudioVersion} -eq "14.0")
  57. {
  58. $OutputFormat = "2015"
  59. }
  60. ElseIf (${Env:VisualStudioVersion} -eq "12.0")
  61. {
  62. $OutputFormat = "2013"
  63. }
  64. ElseIf (${Env:VisualStudioVersion} -eq "11.0")
  65. {
  66. $OutputFormat = "2012"
  67. }
  68. ElseIf (${Env:VisualStudioVersion} -eq "10.0")
  69. {
  70. $OutputFormat = "2010"
  71. }
  72. ElseIf (${Env:VisualStudioVersion} -eq "9.0")
  73. {
  74. $OutputFormat = "2008"
  75. }
  76. Else
  77. {
  78. Write-Host "Unsupported Visual Studio version: %VisualStudioVersion% = ${Env:VisualStudioVersion}" -foreground Red
  79. Exit ${ExitFailure}
  80. }
  81. If (${OutputFormat} -eq "2017")
  82. {
  83. $MSBuild = "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\amd64\MSBuild.exe"
  84. }
  85. ElseIf (${OutputFormat} -eq "2008")
  86. {
  87. $MSBuild = "C:\\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe"
  88. }
  89. Else
  90. {
  91. $MSBuild = "C:\\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe"
  92. }
  93. If (-Not (Test-Path ${MSBuild}))
  94. {
  95. Write-Host "Missing msbuild.exe: ${MSBuild}" -foreground Red
  96. Exit ${ExitFailure}
  97. }
  98. If (${OutputFormat} -eq "2008")
  99. {
  100. $VSSolutionPath = "msvscpp"
  101. }
  102. Else
  103. {
  104. $VSSolutionPath = "vs${OutputFormat}"
  105. If (-Not (Test-Path "${VSSolutionPath}"))
  106. {
  107. ${Env:PYTHONPATH} = ${VSToolsPath}
  108. Invoke-Expression -Command "& '${Python}' ${MSVSCppConvert} --output-format ${OutputFormat} ${MSVSCppConvertOptions} msvscpp\libpff.sln"
  109. }
  110. }
  111. $VSSolutionFile = "${VSSolutionPath}\libpff.sln"
  112. If (-Not (Test-Path "${VSSolutionFile}"))
  113. {
  114. Write-Host "Missing Visual Studio ${OutputFormat} solution file: ${VSSolutionFile}" -foreground Red
  115. Exit ${ExitFailure}
  116. }
  117. If (-Not ${Configuration})
  118. {
  119. $Configuration = "Release"
  120. }
  121. If (-Not ${Platform})
  122. {
  123. $Platform = "Win32"
  124. }
  125. $MSBuildOptions = "/verbosity:quiet /target:Build /property:Configuration=${Configuration},Platform=${Platform}"
  126. If (${Env:VisualStudioVersion} -eq "15.0")
  127. {
  128. $MSBuildOptions = "${MSBuildOptions} /property:PlatformToolset=v141"
  129. }
  130. Invoke-Expression -Command "& '${MSBuild}' ${MSBuildOptions} ${VSSolutionFile}"
  131. Exit ${ExitSuccess}