Skip to content

Commit 812f6b0

Browse files
committed
Add brotli support to FoundationNetworking
1 parent 49dbb15 commit 812f6b0

File tree

2 files changed

+43
-4
lines changed

2 files changed

+43
-4
lines changed

utils/build.ps1

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,7 @@ enum Project {
619619
SourceKitLSP
620620
SymbolKit
621621
DocC
622+
brotli
622623

623624
LLVM
624625
Runtime
@@ -1996,6 +1997,21 @@ function Build-Sanitizers([Hashtable] $Platform) {
19961997
})
19971998
}
19981999

2000+
function Build-Brotli([Hashtable] $Platform) {
2001+
Build-CMakeProject `
2002+
-Src $SourceCache\brotli `
2003+
-Bin "$(Get-ProjectBinaryCache $Platform brotli)" `
2004+
-InstallTo "$LibraryRoot\brotli\usr" `
2005+
-Platform $Platform `
2006+
-UseMSVCCompilers C `
2007+
-Defines @{
2008+
BUILD_SHARED_LIBS = "NO";
2009+
CMAKE_POSITION_INDEPENDENT_CODE = "YES";
2010+
CMAKE_SYSTEM_NAME = $Platform.OS.ToString();
2011+
}
2012+
}
2013+
2014+
19992015
function Build-ZLib([Hashtable] $Platform) {
20002016
$ArchName = $Platform.Architecture.LLVMName
20012017

@@ -2095,7 +2111,7 @@ function Build-CURL([Hashtable] $Platform) {
20952111
CURL_CA_BUNDLE = "none";
20962112
CURL_CA_FALLBACK = "NO";
20972113
CURL_CA_PATH = "none";
2098-
CURL_BROTLI = "NO";
2114+
CURL_BROTLI = "YES";
20992115
CURL_DISABLE_ALTSVC = "NO";
21002116
CURL_DISABLE_AWS = "YES";
21012117
CURL_DISABLE_BASIC_AUTH = "NO";
@@ -2173,6 +2189,9 @@ function Build-CURL([Hashtable] $Platform) {
21732189
USE_WIN32_LDAP = "NO";
21742190
ZLIB_ROOT = "$LibraryRoot\zlib-1.3.1\usr";
21752191
ZLIB_LIBRARY = "$LibraryRoot\zlib-1.3.1\usr\lib\$($Platform.OS.ToString())\$ArchName\zlibstatic.lib";
2192+
DBROTLI_INCLUDE_DIR = "$LibraryRoot\brotli\usr\include";
2193+
BROTLIDEC_LIBRARY = "$LibraryRoot\brotli\usr\lib\brotlidec.lib";
2194+
BROTLICOMMON_LIBRARY = "$LibraryRoot\brotli\usr\lib\brotlicommon.lib";
21762195
})
21772196
}
21782197

@@ -2404,6 +2423,17 @@ function Build-Foundation {
24042423
"$LibraryRoot\zlib-1.3.1\usr\lib\$($Platform.OS.ToString())\$($Platform.Architecture.LLVMName)\libz.a"
24052424
};
24062425
ZLIB_INCLUDE_DIR = "$LibraryRoot\zlib-1.3.1\usr\include";
2426+
BROTLIDEC_LIBRARY = if ($Platform.OS -eq [OS]::Windows) {
2427+
"$LibraryRoot\brotli\usr\lib\brotlidec.lib"
2428+
} else {
2429+
"$LibraryRoot\brotli\usr\lib64\brotlidec.a"
2430+
}
2431+
BROTLICOMMON_LIBRARY = if ($Platform.OS -eq [OS]::Windows) {
2432+
"$LibraryRoot\brotli\usr\lib\brotlicommon.lib"
2433+
}else {
2434+
"$LibraryRoot\brotli\usr\lib64\brotlicommon.a"
2435+
}
2436+
DBROTLI_INCLUDE_DIR = "$LibraryRoot\brotli\usr\include";
24072437
dispatch_DIR = (Get-ProjectCMakeModules $Platform Dispatch);
24082438
SwiftSyntax_DIR = (Get-ProjectBinaryCache $HostPlatform Compilers);
24092439
_SwiftFoundation_SourceDIR = "$SourceCache\swift-foundation";
@@ -2426,6 +2456,7 @@ function Test-Foundation {
24262456
$env:LIBXML_LIBRARY_PATH="$LibraryRoot/libxml2-2.11.5/usr/lib/windows/$($BuildPlatform.Architecture.LLVMName)"
24272457
$env:LIBXML_INCLUDE_PATH="$LibraryRoot/libxml2-2.11.5/usr/include/libxml2"
24282458
$env:ZLIB_LIBRARY_PATH="$LibraryRoot/zlib-1.3.1/usr/lib/windows/$($BuildPlatform.Architecture.LLVMName)"
2459+
$env:BROTLI_LIBRARY_PATH="$LibraryRoot/brotli/usr/lib"
24292460
$env:CURL_LIBRARY_PATH="$LibraryRoot/curl-8.9.1/usr/lib/windows/$($BuildPlatform.Architecture.LLVMName)"
24302461
$env:CURL_INCLUDE_PATH="$LibraryRoot/curl-8.9.1/usr/include"
24312462
Build-SPMProject `
@@ -2566,6 +2597,7 @@ function Build-SDK([Hashtable] $Platform, [switch] $IncludeMacros = $false) {
25662597

25672598
# Third Party Dependencies
25682599
Invoke-BuildStep Build-ZLib $Platform
2600+
Invoke-BuildStep Build-Brotli $Platform
25692601
Invoke-BuildStep Build-XML2 $Platform
25702602
Invoke-BuildStep Build-CURL $Platform
25712603
Invoke-BuildStep Build-LLVM $Platform

utils/update_checkout/update-checkout-config.json

Lines changed: 10 additions & 3 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" ]
@@ -177,7 +180,8 @@
177180
"curl": "curl-8_9_1",
178181
"libxml2": "v2.11.5",
179182
"zlib": "v1.3.1",
180-
"mimalloc": "v3.0.1"
183+
"mimalloc": "v3.0.1",
184+
"brotli": "v1.1.0"
181185
}
182186
},
183187
"release/6.2": {
@@ -232,6 +236,7 @@
232236
"curl": "curl-8_9_1",
233237
"libxml2": "v2.11.5",
234238
"zlib": "v1.3.1",
239+
"brotli": "v1.1.0",
235240
"mimalloc": "v3.0.1"
236241
}
237242
},
@@ -441,7 +446,8 @@
441446
"curl": "curl-8_9_1",
442447
"libxml2": "v2.11.5",
443448
"zlib": "v1.3.1",
444-
"mimalloc": "v3.0.1"
449+
"mimalloc": "v3.0.1",
450+
"brotli": "v1.1.0"
445451
}
446452
},
447453
"next" : {
@@ -491,7 +497,8 @@
491497
"curl": "curl-8_9_1",
492498
"libxml2": "v2.11.5",
493499
"zlib": "v1.3.1",
494-
"mimalloc": "v3.0.1"
500+
"mimalloc": "v3.0.1",
501+
"brotli": "v1.1.0"
495502
}
496503
}
497504
}

0 commit comments

Comments
 (0)