Skip to content

Commit 9a33962

Browse files
committed
Add brotli support to FoundationNetworking
1 parent 24154e3 commit 9a33962

File tree

2 files changed

+56
-4
lines changed

2 files changed

+56
-4
lines changed

utils/build.ps1

Lines changed: 46 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,26 @@ 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+
-BuildTargets default `
2010+
-Defines @{
2011+
BUILD_SHARED_LIBS = "NO";
2012+
CMAKE_POSITION_INDEPENDENT_CODE = "YES";
2013+
CMAKE_SYSTEM_NAME = $Platform.OS.ToString();
2014+
CMAKE_INSTALL_BINDIR = "$LibraryRoot\brotli\usr\bin\$($Platform.OS.ToString())\$ArchName";
2015+
CMAKE_INSTALL_LIBDIR = "$LibraryRoot\brotli\usr\lib\$($Platform.OS.ToString())\$ArchName";
2016+
}
2017+
}
2018+
2019+
19992020
function Build-ZLib([Hashtable] $Platform) {
20002021
$ArchName = $Platform.Architecture.LLVMName
20012022

@@ -2095,7 +2116,7 @@ function Build-CURL([Hashtable] $Platform) {
20952116
CURL_CA_BUNDLE = "none";
20962117
CURL_CA_FALLBACK = "NO";
20972118
CURL_CA_PATH = "none";
2098-
CURL_BROTLI = "NO";
2119+
CURL_BROTLI = "YES";
20992120
CURL_DISABLE_ALTSVC = "NO";
21002121
CURL_DISABLE_AWS = "YES";
21012122
CURL_DISABLE_BASIC_AUTH = "NO";
@@ -2173,6 +2194,17 @@ function Build-CURL([Hashtable] $Platform) {
21732194
USE_WIN32_LDAP = "NO";
21742195
ZLIB_ROOT = "$LibraryRoot\zlib-1.3.1\usr";
21752196
ZLIB_LIBRARY = "$LibraryRoot\zlib-1.3.1\usr\lib\$($Platform.OS.ToString())\$ArchName\zlibstatic.lib";
2197+
BROTLI_INCLUDE_DIR = "$LibraryRoot\brotli\usr\include";
2198+
BROTLIDEC_LIBRARY = if ($Platform.OS -eq [OS]::Windows) {
2199+
"$LibraryRoot\brotli\usr\lib\$($Platform.OS.ToString())\$ArchName\brotlidec.lib"
2200+
} else {
2201+
"$LibraryRoot\brotli\usr\lib\$($Platform.OS.ToString())\$ArchName\brotlidec.a"
2202+
};
2203+
BROTLICOMMON_LIBRARY = if ($Platform.OS -eq [OS]::Windows) {
2204+
"$LibraryRoot\brotli\usr\lib\$($Platform.OS.ToString())\$ArchName\brotlicommon.lib"
2205+
} else {
2206+
"$LibraryRoot\brotli\usr\lib\$($Platform.OS.ToString())\$ArchName\brotlicommon.a"
2207+
};
21762208
})
21772209
}
21782210

@@ -2404,6 +2436,17 @@ function Build-Foundation {
24042436
"$LibraryRoot\zlib-1.3.1\usr\lib\$($Platform.OS.ToString())\$($Platform.Architecture.LLVMName)\libz.a"
24052437
};
24062438
ZLIB_INCLUDE_DIR = "$LibraryRoot\zlib-1.3.1\usr\include";
2439+
BROTLIDEC_LIBRARY = if ($Platform.OS -eq [OS]::Windows) {
2440+
"$LibraryRoot\brotli\usr\lib\$($Platform.OS.ToString())\$($Platform.Architecture.LLVMName)\brotlidec.lib"
2441+
} else {
2442+
"$LibraryRoot\brotli\usr\lib64\$($Platform.OS.ToString())\$($Platform.Architecture.LLVMName)\brotlidec.a"
2443+
};
2444+
BROTLICOMMON_LIBRARY = if ($Platform.OS -eq [OS]::Windows) {
2445+
"$LibraryRoot\brotli\usr\lib\$($Platform.OS.ToString())\$($Platform.Architecture.LLVMName)\brotlicommon.lib"
2446+
} else {
2447+
"$LibraryRoot\brotli\usr\lib64\$($Platform.OS.ToString())\$($Platform.Architecture.LLVMName)\brotlicommon.a"
2448+
};
2449+
BROTLI_INCLUDE_DIR = "$LibraryRoot\brotli\usr\include";
24072450
dispatch_DIR = (Get-ProjectCMakeModules $Platform Dispatch);
24082451
SwiftSyntax_DIR = (Get-ProjectBinaryCache $HostPlatform Compilers);
24092452
_SwiftFoundation_SourceDIR = "$SourceCache\swift-foundation";
@@ -2426,6 +2469,7 @@ function Test-Foundation {
24262469
$env:LIBXML_LIBRARY_PATH="$LibraryRoot/libxml2-2.11.5/usr/lib/windows/$($BuildPlatform.Architecture.LLVMName)"
24272470
$env:LIBXML_INCLUDE_PATH="$LibraryRoot/libxml2-2.11.5/usr/include/libxml2"
24282471
$env:ZLIB_LIBRARY_PATH="$LibraryRoot/zlib-1.3.1/usr/lib/windows/$($BuildPlatform.Architecture.LLVMName)"
2472+
$env:BROTLI_LIBRARY_PATH="$LibraryRoot/brotli/usr/lib/windows/$($BuildPlatform.Architecture.LLVMName)"
24292473
$env:CURL_LIBRARY_PATH="$LibraryRoot/curl-8.9.1/usr/lib/windows/$($BuildPlatform.Architecture.LLVMName)"
24302474
$env:CURL_INCLUDE_PATH="$LibraryRoot/curl-8.9.1/usr/include"
24312475
Build-SPMProject `
@@ -2566,6 +2610,7 @@ function Build-SDK([Hashtable] $Platform, [switch] $IncludeMacros = $false) {
25662610

25672611
# Third Party Dependencies
25682612
Invoke-BuildStep Build-ZLib $Platform
2613+
Invoke-BuildStep Build-Brotli $Platform
25692614
Invoke-BuildStep Build-XML2 $Platform
25702615
Invoke-BuildStep Build-CURL $Platform
25712616
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)