Skip to content

Commit 7527068

Browse files
committed
Add ndk-version input parameter
1 parent 121a0a3 commit 7527068

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

.github/workflows/test-action.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ jobs:
1313
os: ['ubuntu-24.04', 'ubuntu-22.04', 'macos-13', 'macos-15']
1414
#swift-version: ['6.0', '6.1']
1515
swift-version: ['6.0', '6.1', '6.1.1', 'nightly-6.2']
16+
ndk-version: ['27', '28']
1617
steps:
1718
- name: Checkout Action
1819
uses: actions/checkout@v4
@@ -34,6 +35,7 @@ jobs:
3435
with:
3536
package-path: jpsim/Yams
3637
swift-version: ${{ matrix.swift-version }}
38+
ndk-version: ${{ matrix.ndk-version }}
3739
run-tests: ${{ matrix.os != 'macos-15' }} # no tests on macOS ARM
3840
copy-files: Tests
3941
test-env: TEST_WORKSPACE=1
@@ -48,6 +50,7 @@ jobs:
4850
with:
4951
package-path: skiptools/swift-android-native
5052
swift-version: ${{ matrix.swift-version }}
53+
ndk-version: ${{ matrix.ndk-version }}
5154
run-tests: ${{ matrix.os != 'macos-15' }} # no tests on macOS ARM
5255

5356
toolchain-setup:
@@ -57,15 +60,12 @@ jobs:
5760
matrix:
5861
os: ['ubuntu-24.04', 'ubuntu-22.04', 'macos-13', 'macos-15']
5962
swift-version: ['6.0', '6.1', 'nightly-6.2']
63+
ndk-version: ['27', '28']
6064
steps:
6165
- name: Checkout Action
6266
uses: actions/checkout@v4
6367
with:
6468
path: swift-android-action
65-
- name: Setup NDK
66-
if: ${{ matrix.os == 'macos-13' }} # macOS-13 defaults to NDK 16, NDK 17+ needed
67-
run: |
68-
echo "ANDROID_NDK_HOME=$HOME/Library/Android/sdk/ndk/27.2.12479018" >> $GITHUB_ENV
6969
- name: Setup Toolchain
7070
id: setup-toolchain
7171
uses: ./swift-android-action/
@@ -74,6 +74,7 @@ jobs:
7474
# just set up the toolchain and don't build anything
7575
build-package: false
7676
swift-version: ${{ matrix.swift-version }}
77+
ndk-version: ${{ matrix.ndk-version }}
7778
- name: Checkout apple/swift-numerics
7879
uses: actions/checkout@v4
7980
with:

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ or the most recent snapshot/nightly build can be specified with `nightly-6.2`.
8484
| Parameter | Description | Default |
8585
|-----|-----|-----|
8686
| swift-version | The version of the Swift toolchain to use | 6.1 |
87+
| ndk-version | The version of the Android NDK to use | <default> |
8788
| package-path | The folder where the swift package is checked out | . |
8889
| swift-configuration | Whether to build with debug or release configuration | debug |
8990
| swift-build-flags | Additional flags to pass to the swift build command | |

action.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ inputs:
1818
description: 'The version of the Swift toolchain to use'
1919
required: true
2020
default: 'latest'
21+
ndk-version:
22+
description: 'The version of the NDK to use for 6.2+'
23+
required: false
24+
type: string
25+
default: ''
2126
swift-branch:
2227
description: 'The branch of the Swift toolchain to use'
2328
required: true
@@ -219,10 +224,15 @@ runs:
219224
echo "SWIFT_BRANCH: ${SWIFT_BRANCH}"
220225
echo "swift-branch=${SWIFT_BRANCH}" >> $GITHUB_OUTPUT
221226
222-
if [[ ${SWIFT_VERSION_ID} != swift-6.0* ]]; then
223-
# recent releases require that ANDROID_NDK_ROOT *not* be set
227+
NDK_VERSION="${{ inputs.ndk-version }}"
228+
if [[ ${SWIFT_VERSION_ID} == swift-6.1* ]]; then
229+
# 6.1 releases require that ANDROID_NDK_ROOT *not* be set
224230
# see https://github.com/finagolfin/swift-android-sdk/issues/207
225231
echo "ANDROID_NDK_ROOT=" >> $GITHUB_ENV
232+
elif [[ "${NDK_VERSION}" != '' ]]; then
233+
# we can set ndk-version to "27" or "27.0" or "27.2.12479018"
234+
NDK_BASE=$(dirname "${ANDROID_NDK_ROOT}")
235+
echo "ANDROID_NDK_ROOT=$(ls -rd ${NDK_BASE}/${NDK_VERSION}* | head -n 1)" >> $GITHUB_ENV
226236
fi
227237
228238
- name: Cache Swift ${{ steps.setup.outputs.swift-version }} Host Toolchain

0 commit comments

Comments
 (0)