Skip to content

Commit 9d79b2f

Browse files
authored
Use config action for the remaining jobs (#1027)
1 parent ca0c04b commit 9d79b2f

File tree

1 file changed

+75
-79
lines changed

1 file changed

+75
-79
lines changed

.github/workflows/swift-toolchain.yml

Lines changed: 75 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,6 +1638,27 @@ jobs:
16381638
swift-version: ${{ env.PINNED_BOOTSTRAP_TOOLCHAIN_VERSION }}
16391639
- uses: seanmiddleditch/gha-setup-ninja@96bed6edff20d1dd61ecff9b75cc519d516e6401 # master
16401640
if: inputs.build_os == 'Darwin'
1641+
- name: Compute workspace hash
1642+
if: matrix.os != 'Android' || inputs.build_android
1643+
id: workspace_hash
1644+
run: |
1645+
$stringAsStream = [System.IO.MemoryStream]::new()
1646+
$writer = [System.IO.StreamWriter]::new($stringAsStream)
1647+
$writer.write("${{ github.workspace }}")
1648+
$writer.Flush()
1649+
$stringAsStream.Position = 0
1650+
$hash = (Get-FileHash -Algorithm SHA256 -InputStream $stringAsStream).Hash
1651+
echo "hash=$hash" >> $env:GITHUB_OUTPUT
1652+
- name: Setup sccache
1653+
if: matrix.os != 'Android' || inputs.build_android
1654+
uses: ./SourceCache/ci-build/.github/actions/setup-sccache
1655+
with:
1656+
s3-bucket: ${{ vars.SCCACHE_S3_BUCKET }}
1657+
aws-region: ${{ vars.SCCACHE_AWS_REGION }}
1658+
aws-arn: ${{ vars.SCCACHE_AWS_ARN }}
1659+
disk-max-size: 500M
1660+
disk-cache-key: ${{ steps.workspace_hash.outputs.hash }}-${{ matrix.os }}-${{ matrix.arch }}-stdlib
1661+
16411662

16421663
- name: Download Compilers
16431664
if: matrix.os != 'Android' || inputs.build_android
@@ -1688,88 +1709,63 @@ jobs:
16881709

16891710
- name: Configure LLVM
16901711
if: matrix.os != 'Android' || inputs.build_android
1691-
run: |
1692-
if ("${{ matrix.os }}" -eq "Android") {
1693-
$NDKPATH = cygpath -m "${{ steps.setup-ndk.outputs.ndk-path }}"
1694-
}
1695-
1696-
cmake -B ${{ github.workspace }}/BinaryCache/llvm `
1697-
-D CMAKE_BUILD_TYPE=Release `
1698-
-D CMAKE_C_COMPILER=${{ matrix.cc }} `
1699-
-D CMAKE_C_FLAGS="${{ matrix.cflags }}" `
1700-
-D CMAKE_CXX_COMPILER=${{ matrix.cxx }} `
1701-
-D CMAKE_CXX_FLAGS="${{ matrix.cxxflags }}" `
1702-
-D CMAKE_INSTALL_PREFIX=${{ matrix.sdk_install_dir }} `
1703-
-D CMAKE_SYSTEM_NAME=${{ matrix.os }} `
1704-
${{ matrix.llvm_cmake_flags }} `
1705-
${{ matrix.extra_flags }} `
1706-
${{ matrix.cmake_ndk_flags }} `
1707-
${{ matrix.stdlib_cmake_flags }} `
1708-
-G Ninja `
1709-
-S ${{ github.workspace }}/SourceCache/llvm-project/llvm `
1710-
-D LLVM_ENABLE_ASSERTIONS=YES
1712+
uses: ./SourceCache/ci-build/.github/actions/configure-cmake-project
1713+
with:
1714+
project-name: llvm
1715+
swift-version: ${{ inputs.swift_version }}
1716+
enable-caching: true
1717+
debug-info: ${{ inputs.debug_info }}
1718+
build-os: ${{ inputs.build_os }}
1719+
build-arch: ${{ inputs.build_arch }}
1720+
os: ${{ matrix.os }}
1721+
arch: ${{ matrix.arch }}
1722+
src-dir: ${{ github.workspace }}/SourceCache/llvm-project/llvm
1723+
bin-dir: ${{ github.workspace }}/BinaryCache/llvm
1724+
android-api-level: ${{ inputs.ANDROID_API_LEVEL }}
1725+
android-clang-version: ${{ inputs.ANDROID_CLANG_VERSION }}
1726+
ndk-path: ${{ steps.setup-ndk.outputs.ndk-path }}
1727+
msvc-compilers: '@("ASM_MASM", "C", "CXX")'
1728+
cmake-defines: |
1729+
@{
1730+
'LLVM_ENABLE_ASSERTIONS' = "YES";
1731+
'LLVM_HOST_TRIPLE' = "${{ matrix.triple }}";
1732+
}
17111733
17121734
- name: Configure Swift Standard Library
17131735
if: matrix.os != 'Android' || inputs.build_android
1714-
run: |
1715-
if ("${{ matrix.os }}" -eq "Windows") {
1716-
# NOTE: clang-cl is required to build the Swift Standard Library on Windows.
1717-
$CC = cygpath -m "${{ github.workspace }}/BinaryCache/Library/Developer/Toolchains/${{ inputs.swift_version }}+Asserts/usr/bin/clang-cl.exe"
1718-
$CXX = $CC
1719-
} elseif ("${{ matrix.os }}" -eq "Darwin") {
1720-
$CC = "${{ github.workspace }}/BinaryCache/Library/Developer/Toolchains/${{ inputs.swift_version }}+Asserts/usr/bin/clang"
1721-
$CXX = "${{ github.workspace }}/BinaryCache/Library/Developer/Toolchains/${{ inputs.swift_version }}+Asserts/usr/bin/clang++"
1722-
} else {
1723-
$CC = "${{ matrix.cc }}"
1724-
$CXX = "${{ matrix.cxx }}"
1725-
}
1726-
1727-
if ("${{ inputs.build_os }}" -eq "Windows") {
1728-
$SWIFTC = cygpath -m "${{ github.workspace }}/BinaryCache/Library/Developer/Toolchains/${{ inputs.swift_version }}+Asserts/usr/bin/swiftc.exe"
1729-
Remove-Item env:\SDKROOT
1730-
} else {
1731-
$SWIFTC = "${{ github.workspace }}/BinaryCache/Library/Developer/Toolchains/${{ inputs.swift_version }}+Asserts/usr/bin/swiftc"
1732-
}
1733-
1734-
if ("${{ matrix.os }}" -eq "Android") {
1735-
# NOTE: Used by matrix definitions.
1736-
$NDKPATH = cygpath -m "${{ steps.setup-ndk.outputs.ndk-path }}"
1737-
}
1738-
1739-
cmake -B ${{ github.workspace }}/BinaryCache/swift `
1740-
-C ${{ github.workspace }}/SourceCache/swift/cmake/caches/Runtime-${{ matrix.platform }}-${{ matrix.cpu }}.cmake `
1741-
-D CMAKE_BUILD_TYPE=Release `
1742-
-D CMAKE_C_COMPILER=${CC} `
1743-
-D CMAKE_C_FLAGS="${{ matrix.cflags }}" `
1744-
-D CMAKE_C_COMPILER_TARGET=${{ matrix.triple }} `
1745-
-D CMAKE_CXX_COMPILER=${CXX} `
1746-
-D CMAKE_CXX_FLAGS="${{ matrix.cxxflags }}" `
1747-
-D CMAKE_CXX_COMPILER_TARGET=${{ matrix.triple }} `
1748-
-D CMAKE_INSTALL_PREFIX=${{ matrix.sdk_install_dir }} `
1749-
-D CMAKE_SYSTEM_NAME=${{ matrix.os }} `
1750-
-D CMAKE_Swift_COMPILER=${SWIFTC} `
1751-
-D CMAKE_Swift_COMPILER_WORKS=YES `
1752-
-D CMAKE_Swift_COMPILER_TARGET=${{ matrix.triple_no_api_level }} `
1753-
-D CMAKE_Swift_FLAGS="-resource-dir ${{ github.workspace }}/BinaryCache/swift/lib/swift ${{ matrix.swiftflags }}" `
1754-
${{ matrix.cmake_linker_flags }} `
1755-
${{ matrix.extra_flags }} `
1756-
${{ matrix.cmake_ndk_flags }} `
1757-
${{ matrix.stdlib_cmake_flags }} `
1758-
-G Ninja `
1759-
-S ${{ github.workspace }}/SourceCache/swift `
1760-
-D LLVM_DIR=${{ github.workspace }}/BinaryCache/llvm/lib/cmake/llvm `
1761-
-D SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY=YES `
1762-
-D SWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP=YES `
1763-
-D SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED=YES `
1764-
-D SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING=YES `
1765-
-D SWIFT_ENABLE_EXPERIMENTAL_OBSERVATION=YES `
1766-
-D SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING=YES `
1767-
-D SWIFT_ENABLE_SYNCHRONIZATION=YES `
1768-
-D SWIFT_ENABLE_VOLATILE=YES `
1769-
-D SWIFT_NATIVE_SWIFT_TOOLS_PATH=${{ github.workspace }}/BinaryCache/Library/Developer/Toolchains/${{ inputs.swift_version }}+Asserts/usr/bin `
1770-
-D SWIFT_PATH_TO_LIBDISPATCH_SOURCE=${{ github.workspace }}/SourceCache/swift-corelibs-libdispatch `
1771-
-D SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE=${{ github.workspace }}/SourceCache/swift-syntax `
1772-
-D SWIFT_PATH_TO_STRING_PROCESSING_SOURCE=${{ github.workspace }}/SourceCache/swift-experimental-string-processing
1736+
uses: ./SourceCache/ci-build/.github/actions/configure-cmake-project
1737+
with:
1738+
project-name: swift-runtime
1739+
swift-version: ${{ inputs.swift_version }}
1740+
enable-caching: true
1741+
debug-info: ${{ inputs.debug_info }}
1742+
build-os: ${{ inputs.build_os }}
1743+
build-arch: ${{ inputs.build_arch }}
1744+
os: ${{ matrix.os }}
1745+
arch: ${{ matrix.arch }}
1746+
src-dir: ${{ github.workspace }}/SourceCache/swift
1747+
bin-dir: ${{ github.workspace }}/BinaryCache/swift
1748+
install-dir: ${{ github.workspace }}/BuildRoot/Library/Developer/Platforms/${{ matrix.os }}.platform/Developer/SDKs/${{ matrix.os }}.sdk/usr
1749+
android-api-level: ${{ inputs.ANDROID_API_LEVEL }}
1750+
android-clang-version: ${{ inputs.ANDROID_CLANG_VERSION }}
1751+
ndk-path: ${{ steps.setup-ndk.outputs.ndk-path }}
1752+
built-compilers: '@("C", "CXX", "Swift")'
1753+
cache-script: ${{ github.workspace }}/SourceCache/swift/cmake/caches/Runtime-${{ matrix.platform }}-${{ matrix.cpu }}.cmake
1754+
cmake-defines: |
1755+
@{
1756+
'LLVM_DIR' = "${{ github.workspace }}/BinaryCache/llvm/lib/cmake/llvm";
1757+
'SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY' = "YES";
1758+
'SWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP' = "YES";
1759+
'SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING' = "YES";
1760+
'SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED' = "YES";
1761+
'SWIFT_ENABLE_EXPERIMENTAL_OBSERVATION' = "YES";
1762+
'SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING' = "YES";
1763+
'SWIFT_ENABLE_SYNCHRONIZATION' = "YES";
1764+
'SWIFT_ENABLE_VOLATILE' = "YES";
1765+
'SWIFT_NATIVE_SWIFT_TOOLS_PATH' = "${{ github.workspace }}/BinaryCache/Library/Developer/Toolchains/${{ inputs.swift_version }}+Asserts/usr/bin";
1766+
'SWIFT_PATH_TO_LIBDISPATCH_SOURCE' = "${{ github.workspace }}/SourceCache/swift-corelibs-libdispatch";
1767+
'SWIFT_PATH_TO_STRING_PROCESSING_SOURCE' = "${{ github.workspace }}/SourceCache/swift-experimental-string-processing";
1768+
}
17731769
- name: Build Swift Standard Library
17741770
if: matrix.os != 'Android' || inputs.build_android
17751771
run: |

0 commit comments

Comments
 (0)