Skip to content

Commit 6ab8bd3

Browse files
Build Brotli in advance of it being a Foundation dep (#1035)
1 parent 1a697d7 commit 6ab8bd3

File tree

2 files changed

+104
-0
lines changed

2 files changed

+104
-0
lines changed

.github/workflows/build-toolchain.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ jobs:
156156
context:
157157
runs-on: ubuntu-latest
158158
outputs:
159+
brotli_revision: ${{ steps.context.outputs.brotli_revision }}
160+
brotli_version: ${{ steps.context.outputs.brotli_version }}
159161
curl_revision: ${{ steps.context.outputs.curl_revision }}
160162
curl_version: ${{ steps.context.outputs.curl_version }}
161163
ds2_revision: ${{ steps.context.outputs.ds2_revision }}
@@ -281,6 +283,7 @@ jobs:
281283
ds2_revision=refs/tags/nightly-2024-11-07
282284
libxml2_revision=refs/tags/v2.11.5
283285
zlib_revision=refs/tags/v1.3.1
286+
brotli_revision=refs/tags/v1.1.0
284287
EOF
285288
else
286289
repo manifest -r --suppress-upstream-revision --suppress-dest-branch | \
@@ -299,6 +302,7 @@ jobs:
299302
echo swift_toolchain_sqlite_version=3.46.0 >> ${GITHUB_OUTPUT}
300303
echo swift_cmark_version=0.29.0.gfm.13 >> ${GITHUB_OUTPUT}
301304
echo zlib_version=1.3 >> ${GITHUB_OUTPUT}
305+
echo brotli_version=1.1.0 >> ${GITHUB_OUTPUT}
302306
303307
# FIXME(z2oh): Remove /D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR when GitHub runner image updates to 20240610.1.
304308
# see: https://github.com/actions/runner-images/issues/10004
@@ -569,6 +573,8 @@ jobs:
569573
curl_revision: ${{ needs.context.outputs.curl_revision }}
570574
curl_version: ${{ needs.context.outputs.curl_version }}
571575
ds2_revision: ${{ needs.context.outputs.ds2_revision }}
576+
brotli_revision: ${{ needs.context.outputs.brotli_revision }}
577+
brotli_version: ${{ needs.context.outputs.brotli_version }}
572578
indexstore_db_revision: ${{ needs.context.outputs.indexstore_db_revision }}
573579
libxml2_revision: ${{ needs.context.outputs.libxml2_revision }}
574580
libxml2_version: ${{ needs.context.outputs.libxml2_version }}
@@ -648,6 +654,8 @@ jobs:
648654
curl_revision: ${{ needs.context.outputs.curl_revision }}
649655
curl_version: ${{ needs.context.outputs.curl_version }}
650656
ds2_revision: ${{ needs.context.outputs.ds2_revision }}
657+
brotli_revision: ${{ needs.context.outputs.brotli_revision }}
658+
brotli_version: ${{ needs.context.outputs.brotli_version }}
651659
indexstore_db_revision: ${{ needs.context.outputs.indexstore_db_revision }}
652660
libxml2_revision: ${{ needs.context.outputs.libxml2_revision }}
653661
libxml2_version: ${{ needs.context.outputs.libxml2_version }}

.github/workflows/swift-toolchain.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,14 @@ on:
191191
required: true
192192
type: string
193193

194+
brotli_revision:
195+
required: true
196+
type: string
197+
198+
brotli_version:
199+
required: true
200+
type: string
201+
194202
ANDROID_API_LEVEL:
195203
required: true
196204
type: string
@@ -1308,6 +1316,94 @@ jobs:
13081316
name: ${{ matrix.os }}-${{ matrix.arch }}-zlib-${{ inputs.zlib_version }}
13091317
path: ${{ github.workspace }}/BuildRoot/Library/zlib-${{ inputs.zlib_version }}/usr
13101318

1319+
brotli:
1320+
runs-on: ${{ inputs.default_build_runner }}
1321+
1322+
strategy:
1323+
fail-fast: false
1324+
matrix: ${{ fromJSON(inputs.target_matrix) }}
1325+
1326+
name: ${{ matrix.os }} ${{ matrix.arch }} brotli
1327+
1328+
steps:
1329+
- uses: actions/[email protected]
1330+
with:
1331+
path: ${{ github.workspace }}/SourceCache/ci-build
1332+
show-progress: false
1333+
1334+
- uses: ./SourceCache/ci-build/.github/actions/setup-build
1335+
with:
1336+
setup-vs-dev-env: ${{ matrix.os == 'Windows' }}
1337+
host-arch: ${{ matrix.arch }}
1338+
- uses: seanmiddleditch/gha-setup-ninja@96bed6edff20d1dd61ecff9b75cc519d516e6401 # master
1339+
if: inputs.build_os == 'Darwin'
1340+
1341+
- name: Compute workspace hash
1342+
id: workspace_hash
1343+
run: |
1344+
$stringAsStream = [System.IO.MemoryStream]::new()
1345+
$writer = [System.IO.StreamWriter]::new($stringAsStream)
1346+
$writer.write("${{ github.workspace }}")
1347+
$writer.Flush()
1348+
$stringAsStream.Position = 0
1349+
$hash = (Get-FileHash -Algorithm SHA256 -InputStream $stringAsStream).Hash
1350+
echo "hash=$hash" >> $env:GITHUB_OUTPUT
1351+
- name: Setup sccache
1352+
uses: ./SourceCache/ci-build/.github/actions/setup-sccache
1353+
with:
1354+
s3-bucket: ${{ vars.SCCACHE_S3_BUCKET }}
1355+
aws-region: ${{ vars.SCCACHE_AWS_REGION }}
1356+
aws-arn: ${{ vars.SCCACHE_AWS_ARN }}
1357+
disk-max-size: 100M
1358+
disk-cache-key: ${{ steps.workspace_hash.outputs.hash }}-${{ matrix.os }}-${{ matrix.arch }}-brotli
1359+
1360+
- uses: actions/[email protected]
1361+
with:
1362+
repository: google/brotli
1363+
ref: ${{ inputs.brotli_revision }}
1364+
path: ${{ github.workspace }}/SourceCache/brotli
1365+
show-progress: false
1366+
1367+
- uses: nttld/setup-ndk@v1
1368+
if: matrix.os == 'Android'
1369+
id: setup-ndk
1370+
with:
1371+
ndk-version: ${{ inputs.ANDROID_NDK_VERSION }}
1372+
local-cache: true
1373+
1374+
- name: Configure brotli
1375+
uses: ./SourceCache/ci-build/.github/actions/configure-cmake-project
1376+
with:
1377+
project-name: brotli
1378+
swift-version: ${{ inputs.swift_version }}
1379+
enable-caching: true
1380+
debug-info: ${{ inputs.debug_info }}
1381+
build-os: ${{ inputs.build_os }}
1382+
build-arch: ${{ inputs.build_arch }}
1383+
os: ${{ matrix.os }}
1384+
arch: ${{ matrix.arch }}
1385+
src-dir: ${{ github.workspace }}/SourceCache/brotli
1386+
bin-dir: ${{ github.workspace }}/BinaryCache/brotli-${{ inputs.brotli_version }}
1387+
install-dir: ${{ github.workspace }}/BuildRoot/Library/brotli-${{ inputs.brotli_version }}/usr
1388+
android-api-level: ${{ inputs.ANDROID_API_LEVEL }}
1389+
android-clang-version: ${{ inputs.ANDROID_CLANG_VERSION }}
1390+
ndk-path: ${{ steps.setup-ndk.outputs.ndk-path }}
1391+
msvc-compilers: '@("C")'
1392+
cmake-defines: |
1393+
@{
1394+
'BUILD_SHARED_LIBS' = "NO";
1395+
'CMAKE_POSITION_INDEPENDENT_CODE' = "YES";
1396+
}
1397+
- name: Build brotli
1398+
run: cmake --build ${{ github.workspace }}/BinaryCache/brotli-${{ inputs.brotli_version }}
1399+
- name: Install brotli
1400+
run: cmake --build ${{ github.workspace }}/BinaryCache/brotli-${{ inputs.brotli_version }} --target install
1401+
1402+
- uses: actions/upload-artifact@v4
1403+
with:
1404+
name: ${{ matrix.os }}-${{ matrix.arch }}-brotli-${{ inputs.brotli_version }}
1405+
path: ${{ github.workspace }}/BuildRoot/Library/brotli-${{ inputs.brotli_version }}/usr
1406+
13111407
curl:
13121408
needs: [zlib]
13131409
runs-on: ${{ inputs.default_build_runner }}

0 commit comments

Comments
 (0)