Skip to content

Commit 75239ab

Browse files
committed
Add brotli support to FoundationNetworking
1 parent 295b5c6 commit 75239ab

File tree

2 files changed

+47
-4
lines changed

2 files changed

+47
-4
lines changed

utils/build.ps1

Lines changed: 37 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,25 @@ function Build-Sanitizers([Hashtable] $Platform) {
19961997
})
19971998
}
19981999

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

@@ -2095,7 +2115,7 @@ function Build-CURL([Hashtable] $Platform) {
20952115
CURL_CA_BUNDLE = "none";
20962116
CURL_CA_FALLBACK = "NO";
20972117
CURL_CA_PATH = "none";
2098-
CURL_BROTLI = "NO";
2118+
CURL_BROTLI = "YES";
20992119
CURL_DISABLE_ALTSVC = "NO";
21002120
CURL_DISABLE_AWS = "YES";
21012121
CURL_DISABLE_BASIC_AUTH = "NO";
@@ -2173,6 +2193,9 @@ function Build-CURL([Hashtable] $Platform) {
21732193
USE_WIN32_LDAP = "NO";
21742194
ZLIB_ROOT = "$LibraryRoot\zlib-1.3.1\usr";
21752195
ZLIB_LIBRARY = "$LibraryRoot\zlib-1.3.1\usr\lib\$($Platform.OS.ToString())\$ArchName\zlibstatic.lib";
2196+
BROTLI_INCLUDE_DIR = "$LibraryRoot\brotli\usr\include";
2197+
BROTLIDEC_LIBRARY = "$LibraryRoot\brotli\usr\lib\$($Platform.OS.ToString())\$ArchName\brotlidec.lib";
2198+
BROTLICOMMON_LIBRARY = "$LibraryRoot\brotli\usr\lib\$($Platform.OS.ToString())\$ArchName\brotlicommon.lib";
21762199
})
21772200
}
21782201

@@ -2404,6 +2427,17 @@ function Build-Foundation {
24042427
"$LibraryRoot\zlib-1.3.1\usr\lib\$($Platform.OS.ToString())\$($Platform.Architecture.LLVMName)\libz.a"
24052428
};
24062429
ZLIB_INCLUDE_DIR = "$LibraryRoot\zlib-1.3.1\usr\include";
2430+
BROTLIDEC_LIBRARY = if ($Platform.OS -eq [OS]::Windows) {
2431+
"$LibraryRoot\brotli\usr\lib\$($Platform.OS.ToString())\$($Platform.Architecture.LLVMName)\brotlidec.lib"
2432+
} else {
2433+
"$LibraryRoot\brotli\usr\lib64\$($Platform.OS.ToString())\$($Platform.Architecture.LLVMName)\brotlidec.a"
2434+
};
2435+
BROTLICOMMON_LIBRARY = if ($Platform.OS -eq [OS]::Windows) {
2436+
"$LibraryRoot\brotli\usr\lib\$($Platform.OS.ToString())\$($Platform.Architecture.LLVMName)\brotlicommon.lib"
2437+
} else {
2438+
"$LibraryRoot\brotli\usr\lib64\$($Platform.OS.ToString())\$($Platform.Architecture.LLVMName)\brotlicommon.a"
2439+
};
2440+
BROTLI_INCLUDE_DIR = "$LibraryRoot\brotli\usr\include";
24072441
dispatch_DIR = (Get-ProjectCMakeModules $Platform Dispatch);
24082442
SwiftSyntax_DIR = (Get-ProjectBinaryCache $HostPlatform Compilers);
24092443
_SwiftFoundation_SourceDIR = "$SourceCache\swift-foundation";
@@ -2426,6 +2460,7 @@ function Test-Foundation {
24262460
$env:LIBXML_LIBRARY_PATH="$LibraryRoot/libxml2-2.11.5/usr/lib/windows/$($BuildPlatform.Architecture.LLVMName)"
24272461
$env:LIBXML_INCLUDE_PATH="$LibraryRoot/libxml2-2.11.5/usr/include/libxml2"
24282462
$env:ZLIB_LIBRARY_PATH="$LibraryRoot/zlib-1.3.1/usr/lib/windows/$($BuildPlatform.Architecture.LLVMName)"
2463+
$env:BROTLI_LIBRARY_PATH="$LibraryRoot/brotli/usr/lib/windows/$($BuildPlatform.Architecture.LLVMName)"
24292464
$env:CURL_LIBRARY_PATH="$LibraryRoot/curl-8.9.1/usr/lib/windows/$($BuildPlatform.Architecture.LLVMName)"
24302465
$env:CURL_INCLUDE_PATH="$LibraryRoot/curl-8.9.1/usr/include"
24312466
Build-SPMProject `
@@ -2566,6 +2601,7 @@ function Build-SDK([Hashtable] $Platform, [switch] $IncludeMacros = $false) {
25662601

25672602
# Third Party Dependencies
25682603
Invoke-BuildStep Build-ZLib $Platform
2604+
Invoke-BuildStep Build-Brotli $Platform
25692605
Invoke-BuildStep Build-XML2 $Platform
25702606
Invoke-BuildStep Build-CURL $Platform
25712607
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)