@@ -721,7 +721,7 @@ function Fetch-Dependencies {
721
721
DownloadAndVerify $WixURL " $BinaryCache \WiX-$WiXVersion .zip" $WiXHash
722
722
Extract- ZipFile WiX- $WiXVersion.zip $BinaryCache WiX- $WiXVersion
723
723
724
- if ($SkipBuild ) { return }
724
+ if ($SkipBuild -and -not $Test ) { return }
725
725
726
726
DownloadAndVerify $PinnedBuild " $BinaryCache \$PinnedToolchain .exe" $PinnedSHA256
727
727
@@ -791,6 +791,30 @@ function Fetch-Dependencies {
791
791
DownloadAndVerify $NDKURL " $BinaryCache \android-ndk-$AndroidNDKVersion -windows.zip" $NDKHash
792
792
793
793
Extract- ZipFile - ZipFileName " android-ndk-$AndroidNDKVersion -windows.zip" - BinaryCache $BinaryCache - ExtractPath " android-ndk-$AndroidNDKVersion " - CreateExtractPath $false
794
+
795
+ if ($Test -and -not (Test-Path " $NDKDir \licenses" )) {
796
+ $NDKDir = " $BinaryCache \android-ndk-r26b"
797
+ $CLToolsURL = " https://dl.google.com/android/repository/commandlinetools-win-11076708_latest.zip"
798
+ $CLToolsHash = " 4d6931209eebb1bfb7c7e8b240a6a3cb3ab24479ea294f3539429574b1eec862"
799
+ DownloadAndVerify $CLToolsURL " $BinaryCache \android-cmdline-tools.zip" $CLToolsHash
800
+
801
+ # Install cmdline-tools
802
+ New-Item - Type Directory - Path " $NDKDir \licenses" - ErrorAction Ignore | Out-Null
803
+ Set-Content - Path " $NDKDir \licenses\android-sdk-license" - Value " 24333f8a63b6825ea9c5514f83c2829b004d1fee"
804
+ Set-Content - Path " $NDKDir \licenses\android-sdk-preview-license" - Value " 84831b9409646a918e30573bab4c9c91346d8abd"
805
+ Extract- ZipFile - ZipFileName " android-cmdline-tools.zip" - BinaryCache $BinaryCache - ExtractPath " android-ndk-r26b\.temp"
806
+ Invoke-Program " $NDKDir \.temp\cmdline-tools\bin\sdkmanager.bat" -- sdk_root= " $NDKDir " " cmdline-tools;latest" " --channel=3"
807
+
808
+ # Install packages
809
+ $AndroidSdkMgr = " $NDKDir \cmdline-tools\latest\bin\sdkmanager.bat"
810
+ foreach ($Package in @ (" emulator" , " platforms;android-29" , " system-images;android-29;default;x86_64" , " platform-tools" )) {
811
+ Invoke-Program $AndroidSdkMgr $Package
812
+ }
813
+
814
+ # Create test device
815
+ $AndroidAvdMgr = " $NDKDir \cmdline-tools\latest\bin\avdmanager.bat"
816
+ Invoke-Program $AndroidAvdMgr create avd -- name " swift-test-device" -- package " system-images;android-29;default;x86_64"
817
+ }
794
818
}
795
819
796
820
if ($IncludeDS2 ) {
@@ -1868,6 +1892,33 @@ function Build-Dispatch([Platform]$Platform, $Arch, [switch]$Test = $false) {
1868
1892
}
1869
1893
}
1870
1894
1895
+ function Test-Dispatch ([Platform ]$Platform ) {
1896
+ # TODO: Make it global
1897
+ $NDKDir = " $BinaryCache \android-ndk-r26b"
1898
+
1899
+ # TODO: Start once for all tests and make it shuts down
1900
+ $emulator = " $NDKDir \emulator\emulator.exe"
1901
+ Start-Process - FilePath $emulator - ArgumentList " @swift-test-device" `
1902
+ - RedirectStandardOutput " $NDKDir \.temp\emulator.out" `
1903
+ - RedirectStandardError " $NDKDir \.temp\emulator.err"
1904
+
1905
+ # TODO: Find a better indicator than a upper-bound delay
1906
+ Start-Sleep - Seconds 5
1907
+
1908
+ # This is just a hack for now
1909
+ $LocalBin = (Get-TargetProjectBinaryCache $AndroidX64 Dispatch)
1910
+ $CacheName = Split-Path $LocalBin - Leaf
1911
+ $RemoteBin = " /data/local/tmp/$CacheName "
1912
+
1913
+ # TODO: On my local machine I have to grant network access once. How to do that in CI?
1914
+ $adb = " $NDKDir \platform-tools\adb.exe"
1915
+ Invoke-Program $adb " shell" " rm -rf $RemoteBin "
1916
+ Invoke-Program $adb " shell" " mkdir $RemoteBin "
1917
+ Invoke-Program $adb " push" " $LocalBin /." $RemoteBin
1918
+ Invoke-Program $adb " push" " S:/ctest_mock.sh" " /data/local/tmp"
1919
+ Invoke-Program $adb " shell" " sh /data/local/tmp/ctest_mock.sh $RemoteBin "
1920
+ }
1921
+
1871
1922
function Build-Foundation ([Platform ]$Platform , $Arch , [switch ]$Test = $false ) {
1872
1923
if ($Test ) {
1873
1924
# Foundation tests build via swiftpm rather than CMake
@@ -2923,6 +2974,10 @@ if (-not $IsCrossCompiling) {
2923
2974
2924
2975
if ($Test -contains " dispatch" ) {
2925
2976
Build-Dispatch Windows $HostArch - Test
2977
+ # TODO: This is a hack. We need different devices for different arches.
2978
+ if (AndroidSDKs -contains " x86_64" ) {
2979
+ Test-Dispatch Android
2980
+ }
2926
2981
}
2927
2982
if ($Test -contains " foundation" ) {
2928
2983
Build-Foundation Windows $HostArch - Test
0 commit comments