Skip to content

Commit 417e483

Browse files
committed
Swift Androd build
1 parent a441618 commit 417e483

File tree

2 files changed

+30
-43
lines changed

2 files changed

+30
-43
lines changed

.github/workflows/pull_request.yml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
- name: Build Android SDK
4949
working-directory: swift-ci/sdks/android
5050
run: |
51-
sudo apt install -q ninja-build
51+
sudo apt install -q ninja-build patchelf
5252
# build all architectures
5353
#./build
5454
@@ -60,6 +60,7 @@ jobs:
6060
- name: Get artifact info
6161
id: paths
6262
run: |
63+
echo "swift-root=$(dirname ${{ runner.temp }}/swift-android-sdk/host-toolchain/*/usr)" >> $GITHUB_OUTPUT
6364
echo "swift-path=$(ls ${{ runner.temp }}/swift-android-sdk/host-toolchain/*/usr/bin/swift)" >> $GITHUB_OUTPUT
6465
echo "artifact-name=$(basename ${{ runner.temp }}/swift-android-sdk/products/*.artifactbundle.tar.gz)" >> $GITHUB_OUTPUT
6566
echo "artifact-path=$(realpath ${{ runner.temp }}/swift-android-sdk/products/*.artifactbundle.tar.gz)" >> $GITHUB_OUTPUT
@@ -73,7 +74,21 @@ jobs:
7374
run: |
7475
${{ steps.paths.outputs.swift-path }} sdk install ${{ steps.paths.outputs.artifact-path }}
7576
${{ steps.paths.outputs.swift-path }} sdk configure --show-configuration $(${{ steps.paths.outputs.swift-path }} sdk list | head -n 1) x86_64-unknown-linux-android
77+
- name: Build swift-algorithms
78+
run: |
79+
cd ${{ runner.temp }}
80+
git clone https://github.com/apple/swift-algorithms.git
81+
cd swift-algorithms
82+
${{ steps.paths.outputs.swift-path }} build --build-tests --swift-sdk x86_64-unknown-linux-android
83+
- name: Test swift-algorithms on Android
84+
uses: skiptools/swift-android-action@main
85+
with:
86+
#package-path: ${{ runner.temp }}/DemoProject
87+
package-path: ${{ runner.temp }}/swift-algorithms
88+
installed-sdk: x86_64-unknown-linux-android
89+
installed-swift: ${{ steps.paths.outputs.swift-root }}
7690
- name: Build Demo Project
91+
if: false
7792
run: |
7893
cd ${{ runner.temp }}
7994
mkdir DemoProject
@@ -87,18 +102,3 @@ jobs:
87102
echo 'import Dispatch' >> Sources/DemoProject/DemoProject.swift
88103
echo 'import Android' >> Sources/DemoProject/DemoProject.swift
89104
${{ steps.paths.outputs.swift-path }} build --build-tests --swift-sdk x86_64-unknown-linux-android
90-
- name: Build swift-algorithms
91-
run: |
92-
cd ${{ runner.temp }}
93-
git clone https://github.com/apple/swift-algorithms.git
94-
cd swift-algorithms
95-
${{ steps.paths.outputs.swift-path }} build --build-tests --swift-sdk x86_64-unknown-linux-android
96-
- name: Test Swift Package on Android
97-
# TODO: need to implement installed-sdk option in swift-android-action
98-
if: false
99-
uses: skiptools/swift-android-action@main
100-
with:
101-
package-path: ${{ runner.temp }}/DemoProject
102-
installed-sdk: x86_64-unknown-linux-android
103-
installed-swift: ${{ steps.paths.outputs.swift-path }}
104-

swift-ci/sdks/android/scripts/build.sh

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -444,23 +444,10 @@ cat > $ndk_sysroot_path/SDKSettings.json <<EOF
444444
}
445445
EOF
446446

447-
448-
#quiet_pushd ndk-sysroot/usr/lib
449-
# FIXME: need to merge the multiple x86_64 archs
450-
#ln -s ../../../swift-android.sdk/x86_64/usr/lib/swift
451-
#quiet_popd
452-
453-
#mkdir "${sdk_root}"
454-
#quiet_pushd "${sdk_root}"
455-
#cp -R ${build_dir}/sdk_root/* .
456-
#quiet_popd
457-
458447
cp -a ${build_dir}/sdk_root sdk_root
459448
# Copy necessary headers and libraries from the toolchain and NDK clang resource directories
460-
SYSROOT=${ndk_sysroot_path}
461-
TOOLCHAIN=$host_toolchain
462-
mkdir -pv $SYSROOT/usr/lib/swift/clang/lib
463-
cp -rv $TOOLCHAIN/lib/clang/*/include $SYSROOT/usr/lib/swift/clang
449+
mkdir -pv $ndk_sysroot_path/usr/lib/swift/clang/lib
450+
cp -rv $host_toolchain/lib/clang/*/include $ndk_sysroot_path/usr/lib/swift/clang
464451

465452
for arch in $archs; do
466453
quiet_pushd sdk_root/${arch}/usr
@@ -473,14 +460,14 @@ for arch in $archs; do
473460
arch_triple="arm-linux-androideabi"
474461
fi
475462

476-
sdk_root_arch=../../../sdk_root/$arch/usr
477-
478463
mkdir lib/${arch_triple}
479-
mv $sdk_root_arch/lib/pkgconfig $sdk_root_arch/lib/swift/android/lib*.{a,so} lib/${arch_triple}
464+
mv lib/pkgconfig lib/swift/android/lib*.{a,so} lib/${arch_triple}
480465

481466
mv lib/swift_static lib/swift_static-$arch
482467
mv lib/lib*.a lib/swift_static-$arch/android
468+
483469
rm -r lib/swift{,_static-$arch}/clang
470+
484471
mkdir -p lib/swift/clang/lib
485472
cp -a ${ndk_toolchain}/lib/clang/*/lib/linux lib/swift/clang/lib
486473
ln -s ../swift/clang lib/swift_static-$arch/clang
@@ -494,21 +481,21 @@ rm -r ${ndk_sysroot_path}/usr/share/{doc,man}
494481
rm -r ${ndk_sysroot_path}/usr/{include,lib}/{i686,riscv64}-linux-android
495482
rm -r sdk_root
496483

497-
# validate that some expected paths exists
484+
# validate that some expected paths exist
498485
quiet_pushd ${ndk_sysroot_path}/usr
499486
ls lib/swift/android
500-
ls lib/swift/android/x86_64
501-
ls lib/swift/android/x86_64/swiftrt.o
487+
ls lib/swift/android/*
488+
ls lib/swift/android/*/swiftrt.o
502489

503-
ls lib/swift_static-x86_64
504-
ls lib/swift_static-x86_64/android
505-
ls lib/swift_static-x86_64/android/libFoundationEssentials.a
490+
ls lib/swift_static-*
491+
ls lib/swift_static-*/android
492+
ls lib/swift_static-*/android/libFoundationEssentials.a
506493

507494
ls lib/swift/clang/lib
508495
ls lib/swift/clang/lib/linux
509-
ls lib/swift/clang/lib/linux/x86_64
510-
ls lib/swift/clang/lib/linux/x86_64/libunwind.a
511-
ls lib/x86_64-linux-android/28/crtbegin_dynamic.o
496+
ls lib/swift/clang/lib/linux/*
497+
ls lib/swift/clang/lib/linux/*/libunwind.a
498+
ls lib/*-linux-android/*/crtbegin_dynamic.o
512499
quiet_popd
513500

514501
cat > swift-sdk.json <<EOF

0 commit comments

Comments
 (0)