Android: set nightly targets for older NDK versions

This change makes provisioning also install older NDKs for Android,
which will be used in nightly targets.

Task-number: QTQAINFRA-7069
Change-Id: Ia8695383e94df282822da9019c33f1004a879bf6
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit 687b73cde0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Elias Toivola
2025-03-27 11:22:31 +02:00
committed by Qt Cherry-pick Bot
parent 30a92ce1f2
commit ac22ffaf57
10 changed files with 274 additions and 109 deletions

View File

@@ -1,4 +1,4 @@
# Copyright (C) 2023 The Qt Company Ltd.
# Copyright (C) 2025 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
# Requires: 7z, perl and msys
@@ -15,26 +15,38 @@ if (Is64BitWinHost) {
# Msys need to be installed to target machine
# More info and building instructions can be found from http://doc.qt.io/qt-5/opensslsupport.html
$openssl_version = "3.0.7"
$openssl_version_latest = "3.0.7"
$ndk_version_latest = "r27c"
$ndk_version_default = "$ndk_version_latest"
$openssl_compressed = Get-DownloadLocation ("openssl-${openssl_version}.tar.gz")
$openssl_sha1 = "f20736d6aae36bcbfa9aba0d358c71601833bf27"
$prebuilt_sha1_ndk_latest = "733cff853b6ee7738e78b90f46b5f028c8490e1e"
$prebuilt_sha1_ndk_default = "$prebuilt_sha1_ndk_latest"
$destination_prefix = "C:\Utils\prebuilt-openssl-${openssl_version}-for-android-ndk"
$prebuilt_ssl_sha1_latest = "733cff853b6ee7738e78b90f46b5f028c8490e1e"
$openssl_sha1_latest = "f20736d6aae36bcbfa9aba0d358c71601833bf27"
function Install($1, $2) {
$ndk_version = $1
$prebuilt_sha1 = $2
$openssl_version_nightly1 = $openssl_version_latest
$ndk_version_nightly1 = $ndk_version_latest
$prebuilt_ssl_sha1_nightly1 = $prebuilt_ssl_sha1_latest
$openssl_sha1_nightly1 = $openssl_sha1_latest
# msys unix style paths
$openssl_path = "/c/Utils/openssl-android-master"
$ndk_path = "/c/Utils/Android/android-ndk-${ndk_version}"
$cc_path = "$ndk_path/toolchains/llvm/prebuilt/windows-x86_64/bin"
$openssl_version_nightly2 = $openssl_version_latest
$ndk_version_nightly2 = $ndk_version_latest
$prebuilt_ssl_sha1_nightly2 = $prebuilt_ssl_sha1_latest
$openssl_sha1_nightly2 = $openssl_sha1_latest
$prebuilt_url_openssl = "\\ci-files01-hki.ci.qt.io\provisioning\openssl\prebuilt-openssl-${openssl_version}-for-android-ndk-${ndk_version}.zip"
$prebuilt_zip_openssl = Get-DownloadLocation ("prebuilt-openssl-${openssl_version}-for-android-ndk-${ndk_version}.zip")
function Install($1, $2, $3, $4) {
$openssl_version = $1
$ndk_version = $2
$prebuilt_sha1 = $3
$openssl_sha1 = $4
Write-Host "Installing OpenSSL ${openssl_version} for Android NDK ${ndk_version}"
$openssl_compressed = Get-DownloadLocation ("openssl-${openssl_version}.tar.gz")
# msys unix style paths
$openssl_path = "/c/Utils/openssl-android-master"
$ndk_path = "/c/Utils/Android/android-ndk-${ndk_version}"
$cc_path = "$ndk_path/toolchains/llvm/prebuilt/windows-x86_64/bin"
$prebuilt_url_openssl = "\\ci-files01-hki.ci.qt.io\provisioning\openssl\prebuilt-openssl-${openssl_version}-for-android-ndk-${ndk_version}.zip"
$prebuilt_zip_openssl = Get-DownloadLocation ("prebuilt-openssl-${openssl_version}-for-android-ndk-${ndk_version}.zip")
if ((Test-Path $prebuilt_url_openssl)) {
Write-Host "Install prebuilt OpenSSL for Android"
@@ -69,34 +81,36 @@ function Install($1, $2) {
}
}
# ANDROID_NDK_ROOT needs to be in environment variables before running this script
# Set-EnvironmentVariable "ANDROID_NDK_ROOT" "C:\Utils\Android\android-ndk-r27c"
$make_install = Start-Process -NoNewWindow -Wait -PassThru -ErrorAction Stop -FilePath "$msys_bash" -ArgumentList ("-lc", "`"yes | pacman -S make`"")
CheckExitCode $make_install
$make_install = Start-Process -NoNewWindow -Wait -PassThru -ErrorAction Stop -FilePath "$msys_bash" -ArgumentList ("-lc", "`"yes | pacman -S make`"")
CheckExitCode $make_install
$configure = Start-Process -NoNewWindow -Wait -PassThru -ErrorAction Stop -FilePath "$msys_bash" -ArgumentList ("-lc", "`"pushd $openssl_path; ANDROID_NDK_ROOT=$ndk_path PATH=${cc_path}:`$PATH CC=clang $openssl_path/Configure shared android-arm`"")
CheckExitCode $configure
$configure = Start-Process -NoNewWindow -Wait -PassThru -ErrorAction Stop -FilePath "$msys_bash" -ArgumentList ("-lc", "`"pushd $openssl_path; ANDROID_NDK_ROOT=$ndk_path PATH=${cc_path}:`$PATH CC=clang $openssl_path/Configure shared android-arm`"")
CheckExitCode $configure
$make = Start-Process -NoNewWindow -Wait -PassThru -ErrorAction Stop -FilePath "$msys_bash" -ArgumentList ("-lc", "`"pushd $openssl_path; ANDROID_NDK_ROOT=$ndk_path PATH=${cc_path}:`$PATH CC=clang make -f $openssl_path/Makefile build_generated`"")
CheckExitCode $make
$make = Start-Process -NoNewWindow -Wait -PassThru -ErrorAction Stop -FilePath "$msys_bash" -ArgumentList ("-lc", "`"pushd $openssl_path; ANDROID_NDK_ROOT=$ndk_path PATH=${cc_path}:`$PATH CC=clang make -f $openssl_path/Makefile build_generated`"")
CheckExitCode $make
Pop-Location
Remove-item C:\Utils\tmp -Recurse -Confirm:$false
Pop-Location
Remove-item C:\Utils\tmp -Recurse -Confirm:$false
}
return "C:\Utils\prebuilt-openssl-${openssl_version}-for-android-ndk-${ndk_version}"
}
# Install NDK Default version
Install $ndk_version_default $prebuilt_sha1_ndk_default
$ndk_ssl_path = Install $openssl_version_latest $ndk_version_latest $prebuilt_ssl_sha1_latest $openssl_sha1_latest
Set-EnvironmentVariable "OPENSSL_ANDROID_HOME_LATEST" "$ndk_ssl_path"
Write-Output "Android OpenSSL $openssl_version_latest for NDK $ndk_version_latest" >> ~/versions.txt
if (Test-Path -Path ${destination_prefix}-${ndk_version_latest}) {
Write-Host "OpenSSL for Android Latest version is the same than Default. Installation done."
} else {
# Install NDK Latest version
Install $ndk_version_latest $prebuilt_sha1_ndk_latest
if ($ndk_version_nightly1 -ne $ndk_version_latest) {
$ndk_ssl_path = Install $openssl_version_nightly1 $ndk_version_nightly1 $prebuilt_ssl_sha1_nightly1 $openssl_sha1_nightly1
Set-EnvironmentVariable "OPENSSL_ANDROID_HOME_NIGHTLY1" "$ndk_ssl_path"
Write-Output "Android OpenSSL $openssl_version_nightly1 for NDK $ndk_version_nightly1" >> ~/versions.txt
}
Set-EnvironmentVariable "OPENSSL_ANDROID_HOME_DEFAULT" "${destination_prefix}-${ndk_version_default}"
Set-EnvironmentVariable "OPENSSL_ANDROID_HOME_LATEST" "${destination_prefix}-${ndk_version_latest}"
Write-Output "Android OpenSSL = $openssl_version" >> ~/versions.txt
if ($ndk_version_nightly2 -ne $ndk_version_latest) {
$ndk_ssl_path = Install $openssl_version_nightly2 $ndk_version_nightly2 $prebuilt_ssl_sha1_nightly2 $openssl_sha1_nightly2
Set-EnvironmentVariable "OPENSSL_ANDROID_HOME_NIGHTLY2" "$ndk_ssl_path"
Write-Output "Android OpenSSL $openssl_version_nightly2 for NDK $ndk_version_nightly2" >> ~/versions.txt
}

View File

@@ -1,4 +1,4 @@
# Copyright (C) 2022 The Qt Company Ltd.
# Copyright (C) 2025 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
. "$PSScriptRoot\helpers.ps1"
@@ -10,15 +10,25 @@
# That's why we need to use Andoid-21 API version in Qt 5.9.
# NDK
$ndkZip = "C:\Windows\Temp\android_ndk.zip"
$ndkVersionLatest = "r27c"
$ndkVersionDefault = $ndkVersionLatest
$ndkChecksumLatest = "ac5f7762764b1f15341094e148ad4f847d050c38"
$ndkChecksumDefault = $ndkChecksumLatest
$ndkCachedUrlLatest = "\\ci-files01-hki.ci.qt.io\provisioning\android\android-ndk-$ndkVersionLatest-windows.zip"
$ndkOfficialUrlLatest = "https://dl.google.com/android/repository/android-ndk-$ndkVersionLatest-windows.zip"
$ndkCachedUrlDefault = "\\ci-files01-hki.ci.qt.io\provisioning\android\android-ndk-$ndkVersionDefault-windows.zip"
$ndkOfficialUrlDefault = "https://dl.google.com/android/repository/android-ndk-$ndkVersionDefault-windows.zip"
$ndkZip = "C:\Windows\Temp\android_ndk.zip"
# Non-latest (but still supported by the qt/qt5 branch) NDKs are installed for nightly targets in:
# coin/platform_configs/nightly_android.yaml
$ndkVersionNightly1 = $ndkVersionLatest # Same version = skip NDK install for nightly
$ndkChecksumNightly1 = $ndkChecksumLatest
$ndkCachedUrlNightly1 = "\\ci-files01-hki.ci.qt.io\provisioning\android\android-ndk-$ndkVersionNightly1-windows.zip"
$ndkOfficialUrlNightly1 = "https://dl.google.com/android/repository/android-ndk-$ndkVersionNightly1-windows.zip"
$ndkVersionNightly2 = $ndkVersionLatest
$ndkChecksumNightly2 = $ndkChecksumLatest
$ndkCachedUrlNightly2 = "\\ci-files01-hki.ci.qt.io\provisioning\android\android-ndk-$ndkVersionNightly2-windows.zip"
$ndkOfficialUrlNightly2 = "https://dl.google.com/android/repository/android-ndk-$ndkVersionNightly2-windows.zip"
# SDK
$toolsVersion = "2.1"
@@ -32,6 +42,8 @@ $toolsChecksum = "e2e19c2ff584efa87ef0cfdd1987f92881323208"
$cmdFolder = "c:\Utils\Android\cmdline-tools"
$sdkZip = "c:\Windows\Temp\$toolsFile"
New-Item -ItemType Directory -Path C:\Utils\Android\
New-Item -ItemType Directory -Path C:\Windows\Temp\android_extract
function Install($1, $2, $3, $4) {
$cacheUrl = $1
@@ -50,20 +62,24 @@ function Install($1, $2, $3, $4) {
return "C:\Utils\Android\$baseDirectory"
}
New-Item -ItemType Directory -Path C:\Utils\Android\
New-Item -ItemType Directory -Path C:\Windows\Temp\android_extract
Write-Host "Installing Android NDK $ndkVersionDefault"
$ndkFolderDefault = Install $ndkCachedUrlDefault $ndkZip $ndkChecksumDefault $ndkOfficialUrlDefault
Set-EnvironmentVariable "ANDROID_NDK_ROOT_DEFAULT" $ndkFolderDefault
Write-Host "Installing Android NDK $nkdVersionLatest"
$ndkFolderLatest = Install $ndkCachedUrlLatest $ndkZip $ndkChecksumLatest $ndkOfficialUrlLatest
Set-EnvironmentVariable "ANDROID_NDK_ROOT_LATEST" $ndkFolderLatest
# To be used by vcpkg
Set-EnvironmentVariable "ANDROID_NDK_HOME" $ndkFolderDefault
Set-EnvironmentVariable "ANDROID_NDK_HOME" $ndkFolderLatest
if ($ndkVersionDefault -eq $ndkVersionLatest) {
Write-Host "Android Latest version is the same than Default. NDK installation done."
} else {
Write-Host "Installing Android NDK $nkdVersionLatest"
$ndkFolderLatest = Install $ndkCachedUrlLatest $ndkZip $ndkChecksumLatest $ndkOfficialUrlLatest
Set-EnvironmentVariable "ANDROID_NDK_ROOT_LATEST" $ndkFolderLatest
if ($ndkVersionNightly1 -ne $ndkVersionLatest) {
Write-Host "Installing Android NDK $ndkVersionNightly1"
$ndkFolderNightly = Install $ndkCachedUrlNightly1 $ndkZip $ndkChecksumNightly1 $ndkOfficialUrlNightly1
Set-EnvironmentVariable "ANDROID_NDK_ROOT_NIGHTLY1" $ndkFolderNightly
Write-Output "Android NDK = $ndkVersionNightly1" >> ~/versions.txt
}
if ($ndkVersionNightly2 -ne $ndkVersionLatest) {
Write-Host "Installing Android NDK $ndkVersionNightly2"
$ndkFolderNightly = Install $ndkCachedUrlNightly2 $ndkZip $ndkChecksumNightly2 $ndkOfficialUrlNightly2
Set-EnvironmentVariable "ANDROID_NDK_ROOT_NIGHTLY2" $ndkFolderNightly
Write-Output "Android NDK = $ndkVersionNightly2" >> ~/versions.txt
}
$toolsFolder = Install $toolsCachedUrl $sdkZip $toolsChecksum $toolsOfficialUrl
@@ -102,4 +118,4 @@ cmd /c "dir C:\Utils\android"
Write-Output "Android SDK tools= $toolsVersion" >> ~/versions.txt
Write-Output "Android SDK Build Tools = $sdkBuildToolsVersion" >> ~/versions.txt
Write-Output "Android SDK Api Level = $sdkApiLevel" >> ~/versions.txt
Write-Output "Android NDK = $ndkVersionDefault" >> ~/versions.txt
Write-Output "Android NDK = $ndkVersionLatest" >> ~/versions.txt

View File

@@ -157,7 +157,7 @@ function InstallAndroidArmv7 {
$ranlib="${toolchain_bin}/llvm-ranlib.exe"
$nm="${toolchain_bin}/llvm-nm.exe"
$strip="${toolchain_bin}/llvm-strip.exe"
$openssl_path = [System.Environment]::GetEnvironmentVariable("OPENSSL_ANDROID_HOME_DEFAULT", [System.EnvironmentVariableTarget]::Machine)
$openssl_path = [System.Environment]::GetEnvironmentVariable("OPENSSL_ANDROID_HOME_LATEST", [System.EnvironmentVariableTarget]::Machine)
$openssl_path = $openssl_path.Replace("\", "/")
New-Item -ItemType SymbolicLink -Path ${openssl_path}/armeabi-v7a/libcrypto.so -Target ${openssl_path}/armeabi-v7a/libcrypto_3.so
@@ -167,7 +167,7 @@ function InstallAndroidArmv7 {
$config += " --enable-cross-compile --target-os=android --enable-jni --enable-mediacodec --enable-openssl --enable-pthreads --enable-neon --disable-asm --disable-indev=android_camera"
$config += " --arch=$target_arch --cpu=${target_cpu} --sysroot=${sysroot} --sysinclude=${sysroot}/usr/include/"
$config += " --cc=${cc} --cxx=${cxx} --ar=${ar} --ranlib=${ranlib}"
$config += " --extra-cflags=-I$envOPENSSL_ANDROID_HOME_DEFAULT/include --extra-ldflags=-L$env:OPENSSL_ANDROID_HOME_DEFAULT/armeabi-v7a"
$config += " --extra-cflags=-I$envOPENSSL_ANDROID_HOME_LATEST/include --extra-ldflags=-L$env:OPENSSL_ANDROID_HOME_LATEST/armeabi-v7a"
$config += " --extra-cflags=-I${openssl_path}/include --extra-ldflags=-L${openssl_path}/armeabi-v7a"
$config += " --strip=$strip"