install-windows-android.ps1 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <#
  2. Copyright (c) Contributors to the Open 3D Engine Project.
  3. For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. SPDX-License-Identifier: Apache-2.0 OR MIT
  5. #>
  6. Import-Module C:\ProgramData\chocolatey\helpers\chocolateyInstaller.psm1
  7. #Android SDK Command line tools needs a custom installer due the latest command like version not being available in the Chocolatey repository
  8. $androidSdkPackageName = 'androidsdk'
  9. $androidSdkVersion = '11076708_latest'
  10. $androidSdkUrl = "https://dl.google.com/android/repository/commandlinetools-win-$androidSdkVersion.zip"
  11. $androidSdkChecksum = '4d6931209eebb1bfb7c7e8b240a6a3cb3ab24479ea294f3539429574b1eec862'
  12. $androidSdkInstallDir = "C:\AndroidSdk\cmdline-tools"
  13. $androidSdkLatestDir = "$androidSdkInstallDir\latest"
  14. Install-ChocolateyZipPackage $androidSdkPackageName $androidSdkUrl $androidSdkInstallDir -Checksum $androidSdkChecksum -ChecksumType 'sha256'
  15. Install-ChocolateyEnvironmentVariable "ANDROID_SDK_ROOT" "C:\AndroidSdk" -VariableType 'Machine'
  16. # Rename the Android SDK folder 'cmdline-tools' to match what the command line tools looks like normally in a full AndroidSDK install
  17. Rename-Item -Path "$androidSdkInstallDir\cmdline-tools" "$androidSdkLatestDir"
  18. # Set package versions
  19. $android_packages = '"platforms;android-28" "platforms;android-29" "platforms;android-30"'
  20. $googleplay_packages = '"extras;google;market_apk_expansion" "extras;google;market_licensing"'
  21. $build_tools = '"build-tools;30.0.2" "build-tools;34.0.0" "tools"'
  22. $ndk = '"ndk;21.4.7075529" "ndk;23.1.7779620" "ndk;25.1.8937393" "ndk;25.2.9519653"'
  23. Write-Host "Installing Android SDK packages..."
  24. $sdkmanager = "$androidSdkLatestDir\bin\sdkmanager.bat"
  25. Write-Host "Installing Android platform packages: $android_packages"
  26. Start-Process -FilePath $sdkmanager -ArgumentList $android_packages -RedirectStandardOutput "NUL" -RedirectStandardError "$host.Streams.Error" -NoNewWindow -Wait
  27. Write-Host "Installing Google Play packages: $googleplay_packages"
  28. Start-Process -FilePath $sdkmanager -ArgumentList $googleplay_packages -RedirectStandardOutput "NUL" -RedirectStandardError "$host.Streams.Error" -NoNewWindow -Wait
  29. Write-Host "Installing Build Tools: $build_tools"
  30. Start-Process -FilePath $sdkmanager -ArgumentList $build_tools -RedirectStandardOutput "NUL" -RedirectStandardError "$host.Streams.Error" -NoNewWindow -Wait
  31. Write-Host "Installing Android NDK packages: $ndk"
  32. Start-Process -FilePath $sdkmanager -ArgumentList $ndk -NoNewWindow -Wait
  33. # Set the NDK environment
  34. Install-ChocolateyEnvironmentVariable "LY_NDK_DIR" "C:\AndroidSdk\ndk\25.1.8937393" -VariableType 'Machine'
  35. $gradle_version = '8.7'
  36. $gradle_checksum = '194717442575a6f96e1c1befa2c30e9a4fc90f701d7aee33eb879b79e7ff05c0'
  37. Write-Host "Installing Gradle $gradle_version"
  38. #Gradle needs a custom installer due to being hardcoded to C:\Programdata in Chocolatey
  39. Import-Module C:\ProgramData\chocolatey\helpers\chocolateyInstaller.psm1
  40. $packageName = 'gradle'
  41. $url = "https://services.gradle.org/distributions/gradle-$gradle_version-all.zip"
  42. $installDir = "C:\Gradle"
  43. Install-ChocolateyZipPackage $packageName $url $installDir -Checksum $gradle_checksum -ChecksumType 'sha256'
  44. $gradle_home = Join-Path $installDir "$packageName-$gradle_version"
  45. $gradle_bat = Join-Path $gradle_home 'bin\gradle.bat'
  46. Install-ChocolateyEnvironmentVariable "GRADLE_HOME" $gradle_home -VariableType 'Machine'
  47. Install-ChocolateyEnvironmentVariable "GRADLE_BUILD_HOME" $gradle_home -VariableType 'Machine'
  48. Install-ChocolateyPath "$gradle_home\bin" -PathType 'Machine'
  49. Install-BinFile -Name 'gradle' -Path $gradle_bat
  50. $ninja_version = 1.10.0
  51. Write-Host "Installing Ninja $ninja_version"
  52. choco install -y ninja --version=$ninja_version --package-parameters="/installDir:C:\Ninja"
  53. Install-ChocolateyPath "C:\Ninja" -PathType 'Machine'
  54. refreshenv