Skip to content

Commit d0ef38e

Browse files
committed
Android SDK build
1 parent 7a59154 commit d0ef38e

File tree

3 files changed

+113
-13
lines changed

3 files changed

+113
-13
lines changed

.github/workflows/pull_request.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ jobs:
3535
run: ./build
3636

3737
android-build:
38-
#name: Build Android ${{ matrix.arch }}
39-
#strategy:
40-
#fail-fast: false
41-
#matrix:
42-
#arch: [armv7,aarch64,x86_64]
43-
name: Build Android SDK
38+
name: Build Android ${{ matrix.arch }} SDK
39+
strategy:
40+
fail-fast: false
41+
matrix:
42+
arch: [armv7,aarch64,x86_64]
43+
#name: Build Android SDK
4444
runs-on: ubuntu-24.04
4545
steps:
4646
- name: Checkout repository
@@ -49,6 +49,6 @@ jobs:
4949
working-directory: swift-ci/sdks/android
5050
run: |
5151
sudo apt install ninja-build
52-
#TARGET_ARCHS=${{ matrix.arch }} ./build
53-
./build
52+
TARGET_ARCHS=${{ matrix.arch }} ./build
53+
#./build
5454

swift-ci/sdks/android/build

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ pushd ${SDKROOT}/src/swift-project
7777
#perl -pi -e 's%canImport\(Darwin\) \|\| os\(Android\) \|\| os\(OpenBSD\)%canImport\(Darwin\) || os\(AndroidXXX\) || os\(OpenBSD\)%g' swift-corelibs-foundation/Sources/Foundation/Process.swift
7878

7979
git apply $PATCHDIR/swift-android.patch || true
80-
git apply -C1 $PATCHDIR/swift-android-ci.patch || true
80+
# swift-android-ci.patch is not needed, since it is only used for llbuild, etc.
81+
#git apply -C1 $PATCHDIR/swift-android-ci.patch || true
8182

8283
# need to un-apply libandroid-spawn since we don't need it for API28+
8384
perl -pi -e 's/MATCHES "Android"/MATCHES "AndroidDISABLED"/g' llbuild/lib/llvm/Support/CMakeLists.txt
@@ -89,8 +90,5 @@ pushd ${SDKROOT}/src/swift-project
8990
perl -pi -e 's%String\(cString: getpass%\"fake\" //%' swiftpm/Sources/PackageRegistryCommand/PackageRegistryCommand+Auth.swift
9091
popd
9192

92-
./scripts/build.sh --products-dir ${SDKROOT}/products --source-dir ${SDKROOT}/src --build-dir ${SDKROOT}/build --ndk-home ${ANDROID_NDK_HOME} --android-api ${ANDROID_API} --host-toolchain ${HOST_TOOLCHAIN} --archs $TARGET_ARCHS
93-
94-
# assemble the artifactbundle
95-
#./scripts/assemble.sh --products-dir ${SDKROOT}/products --build-dir ${SDKROOT}/build --ndk-home ${ANDROID_NDK_HOME} --archs $TARGET_ARCHS
93+
./scripts/build.sh --products-dir ${SDKROOT}/products --source-dir ${SDKROOT}/src --build-dir ${SDKROOT}/build --ndk-home ${ANDROID_NDK_HOME} --android-api ${ANDROID_API} --host-toolchain ${HOST_TOOLCHAIN} --archs ${TARGET_ARCHS}
9694

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

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,11 @@ function run() {
224224
}
225225

226226
for arch in $archs; do
227+
# enable short-circuiting the individual builds
228+
if [[ ! -z "$SKIP_ARCH_BUILD" ]]; then
229+
continue
230+
fi
231+
227232
case $arch in
228233
armv7) target_host="arm-linux-androideabi"; compiler_target_host="armv7a-linux-androideabi$android_api"; android_abi="armeabi-v7a" ;;
229234
aarch64) target_host="aarch64-linux-android"; compiler_target_host="$target_host$android_api"; android_abi="arm64-v8a" ;;
@@ -366,3 +371,100 @@ for arch in $archs; do
366371
header "Completed build for $arch in $sdk_root"
367372
done
368373

374+
# Now generate the bundle
375+
header "Bundling SDK"
376+
377+
sdk_name=swift-${swift_version}_static-linux-${static_linux_sdk_version}
378+
bundle="${sdk_name}.artifactbundle"
379+
380+
rm -rf "${build_dir}/$bundle"
381+
mkdir -p "${build_dir}/$bundle/$sdk_name/swift-linux-musl"
382+
383+
quiet_pushd ${build_dir}/$bundle
384+
385+
# First the info.json, for SwiftPM
386+
cat > info.json <<EOF
387+
{
388+
"schemaVersion": "1.0",
389+
"artifacts": {
390+
"$sdk_name": {
391+
"variants": [
392+
{
393+
"path": "$sdk_name/swift-linux-musl"
394+
}
395+
],
396+
"version": "0.0.1",
397+
"type": "swiftSDK"
398+
}
399+
}
400+
}
401+
EOF
402+
403+
404+
cd "$sdk_name/swift-linux-musl"
405+
406+
cat > swift-sdk.json <<EOF
407+
{
408+
"schemaVersion": "4.0",
409+
"targetTriples": {
410+
EOF
411+
412+
first=true
413+
for arch in $archs; do
414+
if [[ "$first" == "true" ]]; then
415+
first=false
416+
else
417+
cat >> swift-sdk.json <<EOF
418+
},
419+
EOF
420+
fi
421+
cat >> swift-sdk.json <<EOF
422+
"${arch}-swift-linux-musl": {
423+
"toolsetPaths": [
424+
"toolset.json"
425+
],
426+
"sdkRootPath": "musl-${musl_version}.sdk/${arch}",
427+
"swiftResourcesPath": "musl-${musl_version}.sdk/${arch}/usr/lib/swift_static",
428+
"swiftStaticResourcesPath": "musl-${musl_version}.sdk/${arch}/usr/lib/swift_static"
429+
EOF
430+
done
431+
432+
cat >> swift-sdk.json <<EOF
433+
}
434+
}
435+
}
436+
EOF
437+
438+
mkdir "musl-${musl_version}.sdk"
439+
quiet_pushd "musl-${musl_version}.sdk"
440+
cp -R ${build_dir}/sdk_root/* .
441+
quiet_popd
442+
443+
mkdir -p swift.xctoolchain/usr/bin
444+
445+
cat > toolset.json <<EOF
446+
{
447+
"rootPath": "swift.xctoolchain/usr/bin",
448+
"swiftCompiler" : {
449+
"extraCLIOptions" : [
450+
"-static-executable",
451+
"-static-stdlib"
452+
]
453+
},
454+
"schemaVersion": "1.0"
455+
}
456+
EOF
457+
458+
quiet_popd
459+
460+
#tree ${build_dir}/$bundle
461+
#tree $products_dir
462+
463+
#header "Outputting compressed bundle"
464+
465+
#quiet_pushd "${build_dir}"
466+
#mkdir -p "${products_dir}"
467+
#tar cvzf "${products_dir}/${bundle}.tar.gz" "${bundle}"
468+
#quiet_popd
469+
470+

0 commit comments

Comments
 (0)