Skip to content

Commit 44acb66

Browse files
committed
Add brotli support to FoundationNetworking
1 parent 31470bb commit 44acb66

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

utils/build.ps1

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2260,6 +2260,21 @@ function Build-Sanitizers([Hashtable] $Platform) {
22602260
}
22612261
}
22622262

2263+
function Build-Brotli([Hashtable] $Platform) {
2264+
Build-CMakeProject `
2265+
-Src $SourceCache\brotli `
2266+
-Bin "$BinaryCache\$($Platform.Triple)\brotli" `
2267+
-InstallTo "$BinaryCache\$($Platform.Triple)\usr" `
2268+
-Platform $Platform `
2269+
-UseMSVCCompilers C `
2270+
-Defines @{
2271+
BUILD_SHARED_LIBS = "NO";
2272+
CMAKE_POSITION_INDEPENDENT_CODE = "YES";
2273+
CMAKE_SYSTEM_NAME = $Platform.OS.ToString();
2274+
}
2275+
}
2276+
2277+
22632278
function Build-ZLib([Hashtable] $Platform) {
22642279
Build-CMakeProject `
22652280
-Src $SourceCache\zlib `
@@ -2344,7 +2359,7 @@ function Build-CURL([Hashtable] $Platform) {
23442359
CURL_CA_BUNDLE = "none";
23452360
CURL_CA_FALLBACK = "NO";
23462361
CURL_CA_PATH = "none";
2347-
CURL_BROTLI = "NO";
2362+
CURL_BROTLI = "YES";
23482363
CURL_DISABLE_ALTSVC = "NO";
23492364
CURL_DISABLE_AWS = "YES";
23502365
CURL_DISABLE_BASIC_AUTH = "NO";
@@ -2422,6 +2437,8 @@ function Build-CURL([Hashtable] $Platform) {
24222437
USE_WIN32_LDAP = "NO";
24232438
ZLIB_ROOT = "$BinaryCache\$($Platform.Triple)\usr";
24242439
ZLIB_LIBRARY = "$BinaryCache\$($Platform.Triple)\usr\lib\zlibstatic.lib";
2440+
BROTLIDEC_LIBRARY = "$BinaryCache\$($Platform.Triple)\usr\lib\brotlidec.lib"
2441+
BROTLICOMMON_LIBRARY = "$BinaryCache\$($Platform.Triple)\usr\lib\brotlicommon.lib"
24252442
})
24262443
}
24272444

@@ -2835,6 +2852,17 @@ function Build-Foundation {
28352852
"$BinaryCache\$($Platform.Triple)\usr\lib\libz.a"
28362853
};
28372854
ZLIB_INCLUDE_DIR = "$BinaryCache\$($Platform.Triple)\usr\include";
2855+
BROTLIDEC_LIBRARY = if ($Platform.OS -eq [OS]::Windows) {
2856+
"$BinaryCache\$($Platform.Triple)\usr\lib\brotlidec.lib"
2857+
} else {
2858+
"$BinaryCache\$($Platform.Triple)\usr\lib64\brotlidec.a"
2859+
}
2860+
BROTLICOMMON_LIBRARY = if ($Platform.OS -eq [OS]::Windows) {
2861+
"$BinaryCache\$($Platform.Triple)\usr\lib\brotlicommon.lib"
2862+
}else {
2863+
"$BinaryCache\$($Platform.Triple)\usr\lib64\brotlicommon.a"
2864+
}
2865+
DBROTLI_INCLUDE_DIR = "$BinaryCache\$($Platform.Triple)\usr\include";
28382866
dispatch_DIR = $DispatchCMakeModules;
28392867
SwiftSyntax_DIR = (Get-ProjectBinaryCache $HostPlatform Compilers);
28402868
_SwiftFoundation_SourceDIR = "$SourceCache\swift-foundation";
@@ -2857,6 +2885,7 @@ function Test-Foundation {
28572885
$env:LIBXML_LIBRARY_PATH="$BinaryCache/$($Platform.Triple)/usr/lib"
28582886
$env:LIBXML_INCLUDE_PATH="$BinaryCache/$($Platform.Triple)/usr/include/libxml2"
28592887
$env:ZLIB_LIBRARY_PATH="$BinaryCache/$($Platform.Triple)/usr/lib"
2888+
$env:BROTLI_LIBRARY_PATH="$BinaryCache/$($Platform.Triple)/usr/lib"
28602889
$env:CURL_LIBRARY_PATH="$BinaryCache/$($Platform.Triple)/usr/lib"
28612890
$env:CURL_INCLUDE_PATH="$BinaryCache/$($Platform.Triple)/usr/include"
28622891
Build-SPMProject `
@@ -3004,6 +3033,7 @@ function Build-SDK([Hashtable] $Platform, [switch] $IncludeMacros = $false) {
30043033

30053034
# Third Party Dependencies
30063035
Invoke-BuildStep Build-ZLib $Platform
3036+
Invoke-BuildStep Build-Brotli $Platform
30073037
Invoke-BuildStep Build-XML2 $Platform
30083038
Invoke-BuildStep Build-CURL $Platform
30093039
Invoke-BuildStep Build-LLVM $Platform

utils/update_checkout/update-checkout-config.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@
118118
"zlib": {
119119
"remote": { "id": "madler/zlib" }
120120
},
121+
"brotli": {
122+
"remote": { "id": "google/brotli" }
123+
},
121124
"mimalloc": {
122125
"remote": { "id": "microsoft/mimalloc" },
123126
"platforms": [ "Windows" ]
@@ -180,6 +183,7 @@
180183
"curl": "curl-8_9_1",
181184
"libxml2": "v2.11.5",
182185
"zlib": "v1.3.1",
186+
"brotli": "v1.1.0",
183187
"mimalloc": "v3.0.3",
184188
"swift-subprocess": "development-snapshot-2025-07-21"
185189
}
@@ -236,6 +240,7 @@
236240
"curl": "curl-8_9_1",
237241
"libxml2": "v2.11.5",
238242
"zlib": "v1.3.1",
243+
"brotli": "v1.1.0",
239244
"mimalloc": "v3.0.1"
240245
}
241246
},
@@ -498,6 +503,7 @@
498503
"curl": "curl-8_9_1",
499504
"libxml2": "v2.11.5",
500505
"zlib": "v1.3.1",
506+
"brotli": "v1.1.0",
501507
"mimalloc": "v3.0.3",
502508
"swift-subprocess": "development-snapshot-2025-07-21"
503509
}
@@ -556,6 +562,7 @@
556562
"curl": "curl-8_9_1",
557563
"libxml2": "v2.11.5",
558564
"zlib": "v1.3.1",
565+
"brotli": "v1.1.0",
559566
"mimalloc": "v3.0.3",
560567
"swift-subprocess": "development-snapshot-2025-07-21"
561568
}

0 commit comments

Comments
 (0)