Skip to content

Commit d5edc18

Browse files
authored
GHA: include ds2 as part of the Android SDK
There are several jobs in the swift-toolchain workflow that build against the Android NDK, and they all specify the same r26b version. This change extracts the NDK version to workflow input so that it needs only be specified in one place. ANDROID_NDK_VERSION and ds2_revision are required in all of the builds.
1 parent 33f467c commit d5edc18

File tree

2 files changed

+185
-7
lines changed

2 files changed

+185
-7
lines changed

.github/workflows/build-toolchain.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ jobs:
9797
runs-on: ubuntu-latest
9898
outputs:
9999
curl_revision: ${{ steps.context.outputs.curl_revision }}
100+
ds2_revision: ${{ steps.context.outputs.ds2_revision }}
100101
indexstore_db_revision: ${{ steps.context.outputs.indexstore_db_revision }}
101102
libxml2_revision: ${{ steps.context.outputs.libxml2_revision }}
102103
llvm_project_revision: ${{ steps.context.outputs.llvm_project_revision }}
@@ -141,6 +142,7 @@ jobs:
141142
ANDROID_CMAKE_CXX_FLAGS: ${{ steps.context.outputs.ANDROID_CMAKE_CXX_FLAGS }}
142143
ANDROID_CMAKE_EXE_LINKER_FLAGS: ${{ steps.context.outputs.ANDROID_CMAKE_EXE_LINKER_FLAGS }}
143144
ANDROID_CMAKE_SHARED_LINKER_FLAGS: ${{ steps.context.outputs.ANDROID_CMAKE_SHARED_LINKER_FLAGS }}
145+
ANDROID_NDK_VERSION: ${{ steps.context.outputs.ANDROID_NDK_VERSION }}
144146
CMAKE_Swift_FLAGS: ${{ steps.context.outputs.CMAKE_Swift_FLAGS }}
145147
debug_info: ${{ steps.context.outputs.debug_info }}
146148
signed: ${{ steps.context.outputs.signed }}
@@ -201,6 +203,7 @@ jobs:
201203
swift_toolchain_sqlite_revision=refs/tags/main
202204
swift_tools_support_core_revision=refs/tags/${{ inputs.swift_tag }}
203205
curl_revision=refs/tags/curl-8_5_0
206+
ds2_revision=refs/tags/nightly-2024-08-10
204207
libxml2_revision=refs/tags/v2.11.5
205208
yams_revision=refs/tags/5.0.6
206209
zlib_revision=refs/tags/v1.3.1
@@ -272,6 +275,7 @@ jobs:
272275
echo mac_build_runner=macos-latest >> ${GITHUB_OUTPUT}
273276
274277
echo ANDROID_API_LEVEL=${{ inputs.android_api_level }} >> ${GITHUB_OUTPUT}
278+
echo ANDROID_NDK_VERSION=r26b >> ${GITHUB_OUTPUT}
275279
276280
- uses: actions/upload-artifact@v4
277281
with:
@@ -336,6 +340,7 @@ jobs:
336340
build_os: Windows
337341
build_arch: amd64
338342
curl_revision: ${{ needs.context.outputs.curl_revision }}
343+
ds2_revision: ${{ needs.context.outputs.ds2_revision }}
339344
indexstore_db_revision: ${{ needs.context.outputs.indexstore_db_revision }}
340345
libxml2_revision: ${{ needs.context.outputs.libxml2_revision }}
341346
llvm_project_revision: ${{ needs.context.outputs.llvm_project_revision }}
@@ -378,6 +383,7 @@ jobs:
378383
ANDROID_CMAKE_CXX_FLAGS: ${{ needs.context.outputs.ANDROID_CMAKE_CXX_FLAGS }}
379384
ANDROID_CMAKE_EXE_LINKER_FLAGS: ${{ needs.context.outputs.ANDROID_CMAKE_EXE_LINKER_FLAGS }}
380385
ANDROID_CMAKE_SHARED_LINKER_FLAGS: ${{ needs.context.outputs.ANDROID_CMAKE_SHARED_LINKER_FLAGS }}
386+
ANDROID_NDK_VERSION: ${{ needs.context.outputs.ANDROID_NDK_VERSION }}
381387
CMAKE_Swift_FLAGS: ${{ needs.context.outputs.CMAKE_Swift_FLAGS }}
382388
debug_info: ${{ fromJSON(needs.context.outputs.debug_info) }}
383389
signed: ${{ fromJSON(needs.context.outputs.signed) }}
@@ -401,6 +407,7 @@ jobs:
401407
build_os: Darwin
402408
build_arch: aarch64
403409
curl_revision: ${{ needs.context.outputs.curl_revision }}
410+
ds2_revision: ${{ needs.context.outputs.ds2_revision }}
404411
indexstore_db_revision: ${{ needs.context.outputs.indexstore_db_revision }}
405412
libxml2_revision: ${{ needs.context.outputs.libxml2_revision }}
406413
llvm_project_revision: ${{ needs.context.outputs.llvm_project_revision }}
@@ -443,6 +450,7 @@ jobs:
443450
ANDROID_CMAKE_CXX_FLAGS: ${{ needs.context.outputs.ANDROID_CMAKE_CXX_FLAGS }}
444451
ANDROID_CMAKE_EXE_LINKER_FLAGS: ${{ needs.context.outputs.ANDROID_CMAKE_EXE_LINKER_FLAGS }}
445452
ANDROID_CMAKE_SHARED_LINKER_FLAGS: ${{ needs.context.outputs.ANDROID_CMAKE_SHARED_LINKER_FLAGS }}
453+
ANDROID_NDK_VERSION: ${{ needs.context.outputs.ANDROID_NDK_VERSION }}
446454
CMAKE_Swift_FLAGS: ${{ needs.context.outputs.CMAKE_Swift_FLAGS }}
447455
debug_info: ${{ fromJSON(needs.context.outputs.debug_info) }}
448456
signed: ${{ fromJSON(needs.context.outputs.signed) }}

.github/workflows/swift-toolchain.yml

Lines changed: 177 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ on:
1919
required: true
2020
type: string
2121

22+
ds2_revision:
23+
required: true
24+
type: string
25+
2226
indexstore_db_revision:
2327
required: true
2428
type: string
@@ -155,6 +159,10 @@ on:
155159
required: true
156160
type: string
157161

162+
ANDROID_NDK_VERSION:
163+
required: true
164+
type: string
165+
158166
WINDOWS_CMAKE_C_FLAGS:
159167
required: true
160168
type: string
@@ -307,6 +315,159 @@ jobs:
307315
name: sqlite-${{ matrix.os }}-${{ matrix.arch }}-${{ inputs.swift_toolchain_sqlite_version }}
308316
path: ${{ github.workspace }}/BuildRoot/Library/sqlite-${{ inputs.swift_toolchain_sqlite_version }}/usr
309317

318+
ds2_tools:
319+
# TODO: Build this on macOS or make an equivalent Mac-only job
320+
if: inputs.build_os == 'Windows'
321+
runs-on: ${{ inputs.default_build_runner }}
322+
323+
name: ds2 Build Tools
324+
325+
steps:
326+
- uses: actions/checkout@v4
327+
with:
328+
repository: compnerd/ds2
329+
ref: ${{ inputs.ds2_revision }}
330+
path: ${{ github.workspace }}/SourceCache/ds2
331+
show-progress: false
332+
333+
- uses: compnerd/gha-setup-vsdevenv@main
334+
with:
335+
host_arch: amd64
336+
components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64'
337+
arch: amd64
338+
339+
# TODO(issues/205): Preload Chocolatey package manager on Azure images so we can remove this step.
340+
- uses: andrurogerz/ensure-chocolatey@v1
341+
342+
- name: Install Flex and Bison Tools
343+
run: choco install winflexbison3
344+
345+
- name: Configure RegsGen2
346+
run: |
347+
cmake -B ${{ github.workspace }}/BinaryCache/RegsGen2 `
348+
-S ${{ github.workspace }}/SourceCache/ds2/Tools/RegsGen2 `
349+
-C ${{ github.workspace }}/SourceCache/ds2/cmake/caches/MSVCWarnings.cmake `
350+
-D CMAKE_BUILD_TYPE=Release `
351+
-D CMAKE_C_COMPILER=cl `
352+
-D CMAKE_CXX_COMPILER=cl `
353+
-D CMAKE_C_FLAGS="${{ inputs.WINDOWS_CMAKE_C_FLAGS }}" `
354+
-D CMAKE_CXX_FLAGS="${{ inputs.WINDOWS_CMAKE_CXX_FLAGS }}" `
355+
-D CMAKE_MT=mt `
356+
-G Ninja
357+
358+
- name: Build RegsGen2
359+
run: cmake --build ${{ github.workspace }}/BinaryCache/RegsGen2 --config Release
360+
361+
- uses: actions/upload-artifact@v4
362+
with:
363+
name: windows-regsgen2
364+
path: |
365+
${{ github.workspace }}/BinaryCache/RegsGen2/regsgen2.exe
366+
367+
ds2:
368+
# TODO: Build this on macOS or make an equivalent Mac-only job
369+
if: inputs.build_os == 'Windows'
370+
needs: [ds2_tools]
371+
runs-on: ${{ inputs.default_build_runner }}
372+
373+
strategy:
374+
fail-fast: false
375+
matrix:
376+
include:
377+
- arch: arm64
378+
cc: clang
379+
cflags: ${{ inputs.ANDROID_CMAKE_C_FLAGS }}
380+
cxx: clang++
381+
cxxflags: ${{ inputs.ANDROID_CMAKE_CXX_FLAGS }}
382+
os: Android
383+
extra_flags: -DCMAKE_ANDROID_API=${{ inputs.ANDROID_API_LEVEL }} -DCMAKE_ANDROID_ARCH_ABI=arm64-v8a
384+
385+
- arch: armv7
386+
cc: clang
387+
cflags: ${{ inputs.ANDROID_CMAKE_C_FLAGS }}
388+
cxx: clang++
389+
cxxflags: ${{ inputs.ANDROID_CMAKE_CXX_FLAGS }}
390+
os: Android
391+
extra_flags: -DCMAKE_ANDROID_API=${{ inputs.ANDROID_API_LEVEL }} -DCMAKE_ANDROID_ARCH_ABI=armeabi-v7a
392+
393+
- arch: i686
394+
cc: clang
395+
cflags: ${{ inputs.ANDROID_CMAKE_C_FLAGS }}
396+
cxx: clang++
397+
cxxflags: ${{ inputs.ANDROID_CMAKE_CXX_FLAGS }}
398+
os: Android
399+
extra_flags: -DCMAKE_ANDROID_API=${{ inputs.ANDROID_API_LEVEL }} -DCMAKE_ANDROID_ARCH_ABI=x86
400+
401+
- arch: x86_64
402+
cc: clang
403+
cflags: ${{ inputs.ANDROID_CMAKE_C_FLAGS }}
404+
cxx: clang++
405+
cxxflags: ${{ inputs.ANDROID_CMAKE_CXX_FLAGS }}
406+
os: Android
407+
extra_flags: -DCMAKE_ANDROID_API=${{ inputs.ANDROID_API_LEVEL }} -DCMAKE_ANDROID_ARCH_ABI=x86_64
408+
409+
name: ${{ matrix.os }} ${{ matrix.arch }} ds2
410+
411+
steps:
412+
- uses: actions/checkout@v4
413+
with:
414+
repository: compnerd/ds2
415+
ref: ${{ inputs.ds2_revision }}
416+
path: ${{ github.workspace }}/SourceCache/ds2
417+
show-progress: false
418+
419+
- uses: compnerd/gha-setup-vsdevenv@main
420+
with:
421+
host_arch: amd64
422+
components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64'
423+
arch: ${{ matrix.arch }}
424+
425+
# TODO(issues/205): Preload Chocolatey package manager on Azure images so we can remove this step.
426+
- uses: andrurogerz/ensure-chocolatey@v1
427+
428+
- name: Install Flex and Bison Tools
429+
run: choco install winflexbison3
430+
431+
- uses: actions/download-artifact@v4
432+
with:
433+
name: windows-regsgen2
434+
path: ${{ github.workspace }}/BinaryCache/RegsGen2
435+
436+
- uses: nttld/setup-ndk@v1
437+
id: setup-ndk
438+
with:
439+
ndk-version: ${{ inputs.ANDROID_NDK_VERSION }}
440+
441+
- name: Configure DS2
442+
run: |
443+
$NDKPATH = cygpath -m ${{ steps.setup-ndk.outputs.ndk-path }}
444+
cmake -B ${{ github.workspace }}/BinaryCache/ds2 `
445+
-S ${{ github.workspace }}/SourceCache/ds2 `
446+
-D CMAKE_BUILD_TYPE=Release `
447+
-D CMAKE_C_COMPILER=${{ matrix.cc }} `
448+
-D CMAKE_C_FLAGS="${{ matrix.cflags }}" `
449+
-D CMAKE_CXX_COMPILER=${{ matrix.cxx }} `
450+
-D CMAKE_CXX_FLAGS="${{ matrix.cxxflags }}" `
451+
-D CMAKE_MT=mt `
452+
-D MSVC_C_ARCHITECTURE_ID=${{ matrix.arch }} `
453+
-D DS2_REGSGEN2=${{ github.workspace }}/BinaryCache/RegsGen2/regsgen2.exe `
454+
-D CMAKE_INSTALL_PREFIX=${{ github.workspace }}/BinaryCache/Library/Developer `
455+
-D CMAKE_SYSTEM_NAME=${{ matrix.os }} `
456+
-D CMAKE_ANDROID_NDK=$NDKPATH `
457+
${{ matrix.extra_flags }} `
458+
-G Ninja
459+
460+
- name: Build DS2
461+
run: cmake --build ${{ github.workspace }}/BinaryCache/ds2
462+
463+
- name: Install DS2
464+
run: cmake --build ${{ github.workspace }}/BinaryCache/ds2 --target install
465+
466+
- uses: actions/upload-artifact@v4
467+
with:
468+
name: ds2-${{ matrix.os }}-${{ matrix.arch }}
469+
path: ${{ github.workspace }}/BinaryCache/Library/Developer
470+
310471
cmark_gfm:
311472
runs-on: ${{ inputs.default_build_runner }}
312473

@@ -603,7 +764,7 @@ jobs:
603764
- uses: nttld/setup-ndk@v1
604765
id: setup-ndk
605766
with:
606-
ndk-version: r26b
767+
ndk-version: ${{ inputs.ANDROID_NDK_VERSION }}
607768

608769
- name: Compute workspace hash
609770
id: workspace_hash
@@ -873,7 +1034,7 @@ jobs:
8731034
- uses: nttld/setup-ndk@v1
8741035
id: setup-ndk
8751036
with:
876-
ndk-version: r26b
1037+
ndk-version: ${{ inputs.ANDROID_NDK_VERSION }}
8771038

8781039
- name: Configure zlib
8791040
run: |
@@ -1015,7 +1176,7 @@ jobs:
10151176
- uses: nttld/setup-ndk@v1
10161177
id: setup-ndk
10171178
with:
1018-
ndk-version: r26b
1179+
ndk-version: ${{ inputs.ANDROID_NDK_VERSION }}
10191180

10201181
- name: Configure curl
10211182
run: |
@@ -1228,7 +1389,7 @@ jobs:
12281389
- uses: nttld/setup-ndk@v1
12291390
id: setup-ndk
12301391
with:
1231-
ndk-version: r26b
1392+
ndk-version: ${{ inputs.ANDROID_NDK_VERSION }}
12321393

12331394
- name: Configure libxml2
12341395
run: |
@@ -1439,7 +1600,7 @@ jobs:
14391600
- uses: nttld/setup-ndk@v1
14401601
id: setup-ndk
14411602
with:
1442-
ndk-version: r26b
1603+
ndk-version: ${{ inputs.ANDROID_NDK_VERSION }}
14431604

14441605
- name: Configure LLVM
14451606
run: |
@@ -1932,7 +2093,7 @@ jobs:
19322093
- uses: nttld/setup-ndk@v1
19332094
id: setup-ndk
19342095
with:
1935-
ndk-version: r26b
2096+
ndk-version: ${{ inputs.ANDROID_NDK_VERSION }}
19362097

19372098
- name: Configure libdispatch
19382099
run: |
@@ -3348,7 +3509,7 @@ jobs:
33483509
# TODO: Build this on macOS or make an equivalent Mac-only job
33493510
if: inputs.build_os == 'Windows'
33503511
name: Package Android SDK & Runtime
3351-
needs: [stdlib, sdk]
3512+
needs: [stdlib, ds2, sdk]
33523513
runs-on: ${{ inputs.default_build_runner }}
33533514

33543515
strategy:
@@ -3357,12 +3518,16 @@ jobs:
33573518
include:
33583519
- arch: arm64
33593520
cpu: aarch64
3521+
triple_no_api_level: aarch64-unknown-linux-android
33603522
- arch: armv7
33613523
cpu: armv7
3524+
triple_no_api_level: armv7-unknown-linux-androideabi
33623525
- arch: i686
33633526
cpu: i686
3527+
triple_no_api_level: i686-unknown-linux-android
33643528
- arch: x86_64
33653529
cpu: x86_64
3530+
triple_no_api_level: x86_64-unknown-linux-android
33663531

33673532
steps:
33683533
- uses: actions/download-artifact@v4
@@ -3374,6 +3539,11 @@ jobs:
33743539
name: Android-sdk-${{ matrix.arch }}
33753540
path: ${{ github.workspace }}/BuildRoot/Library/Developer/Platforms/Android.platform
33763541

3542+
- uses: actions/download-artifact@v4
3543+
with:
3544+
name: ds2-Android-${{ matrix.arch }}
3545+
path: ${{ github.workspace }}/BuildRoot/Library/Developer/Platforms/Android.platform/Developer/Library/Android/${{ matrix.triple_no_api_level }}
3546+
33773547
- uses: actions/checkout@v4
33783548
with:
33793549
repository: swiftlang/swift-installer-scripts

0 commit comments

Comments
 (0)