Skip to content

Commit dbb03db

Browse files
committed
Add support for zlib-ng
1 parent 4be6578 commit dbb03db

File tree

5 files changed

+48
-0
lines changed

5 files changed

+48
-0
lines changed

builder/builder.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ func (builder *Builder) name() string {
5151
name = "libressl"
5252
case ComponentZlib:
5353
name = "zlib"
54+
case ComponentZlibNG:
55+
name = "zlib-ng"
5456
case ComponentOpenResty:
5557
name = openresty.Name(builder.Version)
5658
case ComponentFreenginx:
@@ -74,6 +76,11 @@ func (builder *Builder) option() string {
7476
name = "pcre"
7577
}
7678

79+
// zlib-ng does not match option name
80+
if name == "zlib-ng" {
81+
name = "zlib"
82+
}
83+
7784
return fmt.Sprintf("--with-%s", name)
7885
}
7986

@@ -89,6 +96,8 @@ func (builder *Builder) DownloadURL() string {
8996
return fmt.Sprintf("%s/libressl-%s.tar.gz", LibreSSLDownloadURLPrefix, builder.Version)
9097
case ComponentZlib:
9198
return fmt.Sprintf("%s/zlib-%s.tar.gz", ZlibDownloadURLPrefix, builder.Version)
99+
case ComponentZlibNG:
100+
return fmt.Sprintf("%s/%s.tar.gz", ZlibNGDownloadURLPrefix, builder.Version)
92101
case ComponentOpenResty:
93102
return fmt.Sprintf("%s/openresty-%s.tar.gz", OpenRestyDownloadURLPrefix, builder.Version)
94103
case ComponentFreenginx:
@@ -99,6 +108,9 @@ func (builder *Builder) DownloadURL() string {
99108
}
100109

101110
func (builder *Builder) SourcePath() string {
111+
if builder.name() == "" {
112+
return fmt.Sprintf("%s", builder.Version)
113+
}
102114
return fmt.Sprintf("%s-%s", builder.name(), builder.Version)
103115
}
104116

@@ -180,6 +192,8 @@ func MakeBuilder(component int, version string) Builder {
180192
builder.DownloadURLPrefix = LibreSSLDownloadURLPrefix
181193
case ComponentZlib:
182194
builder.DownloadURLPrefix = ZlibDownloadURLPrefix
195+
case ComponentZlibNG:
196+
builder.DownloadURLPrefix = ZlibNGDownloadURLPrefix
183197
case ComponentOpenResty:
184198
builder.DownloadURLPrefix = OpenRestyDownloadURLPrefix
185199
case ComponentFreenginx:

builder/builder_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ func setupBuilders(t *testing.T) []Builder {
1212
builders[ComponentOpenSSL] = MakeLibraryBuilder(ComponentOpenSSL, OpenSSLVersion, true)
1313
builders[ComponentLibreSSL] = MakeLibraryBuilder(ComponentLibreSSL, LibreSSLVersion, true)
1414
builders[ComponentZlib] = MakeLibraryBuilder(ComponentZlib, ZlibVersion, false)
15+
builders[ComponentZlibNG] = MakeLibraryBuilder(ComponentZlibNG, ZlibNGVersion, false)
1516
builders[ComponentOpenResty] = MakeBuilder(ComponentOpenResty, OpenRestyVersion)
1617
builders[ComponentFreenginx] = MakeBuilder(ComponentFreenginx, FreenginxVersion)
1718
return builders
@@ -44,6 +45,10 @@ func TestName(t *testing.T) {
4445
got: builders[ComponentZlib].name(),
4546
want: "zlib",
4647
},
48+
{
49+
got: builders[ComponentZlibNG].name(),
50+
want: "zlib-ng",
51+
},
4752
{
4853
got: builders[ComponentOpenResty].name(),
4954
want: "openresty",

builder/const.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ const (
3030
ZlibDownloadURLPrefix = "https://zlib.net"
3131
)
3232

33+
// zlib-ng
34+
const (
35+
ZlibNGVersion = "2.2.4"
36+
ZlibNGDownloadURLPrefix = "https://github.com/zlib-ng/zlib-ng/archive/refs/tags"
37+
)
38+
3339
// openResty
3440
const (
3541
OpenRestyVersion = "1.27.1.2"
@@ -51,5 +57,6 @@ const (
5157
ComponentOpenSSL
5258
ComponentLibreSSL
5359
ComponentZlib
60+
ComponentZlibNG
5461
ComponentMax
5562
)

nginx-build.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ func main() {
114114
openSSLStatic := nginxBuildOptions.Bools["openssl"].Enabled
115115
libreSSLStatic := nginxBuildOptions.Bools["libressl"].Enabled
116116
zlibStatic := nginxBuildOptions.Bools["zlib"].Enabled
117+
zlibNGStatic := nginxBuildOptions.Bools["zlib-ng"].Enabled
117118
clear := nginxBuildOptions.Bools["clear"].Enabled
118119
versionPrint := nginxBuildOptions.Bools["version"].Enabled
119120
versionsPrint := nginxBuildOptions.Bools["versions"].Enabled
@@ -131,6 +132,7 @@ func main() {
131132
openSSLVersion := nginxBuildOptions.Values["opensslversion"].Value
132133
libreSSLVersion := nginxBuildOptions.Values["libresslversion"].Value
133134
zlibVersion := nginxBuildOptions.Values["zlibversion"].Value
135+
zlibNGVersion := nginxBuildOptions.Values["zlibngversion"].Value
134136
openRestyVersion := nginxBuildOptions.Values["openrestyversion"].Value
135137
freenginxVersion := nginxBuildOptions.Values["freenginxversion"].Value
136138
patchOption := nginxBuildOptions.Values["patch-opt"].Value
@@ -201,6 +203,7 @@ func main() {
201203
openSSLBuilder := builder.MakeLibraryBuilder(builder.ComponentOpenSSL, *openSSLVersion, *openSSLStatic)
202204
libreSSLBuilder := builder.MakeLibraryBuilder(builder.ComponentLibreSSL, *libreSSLVersion, *libreSSLStatic)
203205
zlibBuilder := builder.MakeLibraryBuilder(builder.ComponentZlib, *zlibVersion, *zlibStatic)
206+
zlibNGBuilder := builder.MakeLibraryBuilder(builder.ComponentZlibNG, *zlibNGVersion, *zlibNGStatic)
204207

205208
if *idempotent {
206209
builders := []builder.Builder{
@@ -318,6 +321,14 @@ func main() {
318321
}()
319322
}
320323

324+
if *zlibNGStatic {
325+
wg.Add(1)
326+
go func() {
327+
downloadAndExtractParallel(&zlibNGBuilder)
328+
wg.Done()
329+
}()
330+
}
331+
321332
wg.Add(1)
322333
go func() {
323334
downloadAndExtractParallel(&nginxBuilder)
@@ -366,6 +377,10 @@ func main() {
366377
dependencies = append(dependencies, builder.MakeStaticLibrary(&zlibBuilder))
367378
}
368379

380+
if *zlibNGStatic {
381+
dependencies = append(dependencies, builder.MakeStaticLibrary(&zlibNGBuilder))
382+
}
383+
369384
log.Printf("Generate configure script for %s.....", nginxBuilder.SourcePath())
370385

371386
if *pcreStatic && pcreBuilder.IsIncludeWithOption(nginxConfigure) {

option.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ func makeNginxBuildOptions() Options {
5858
argsBool["zlib"] = OptionBool{
5959
Desc: "embedded zlib staticlibrary",
6060
}
61+
argsBool["zlib-ng"] = OptionBool{
62+
Desc: "embedded zlib-ng staticlibrary",
63+
}
6164
argsBool["clear"] = OptionBool{
6265
Desc: "remove entries in working directory",
6366
}
@@ -115,6 +118,10 @@ func makeNginxBuildOptions() Options {
115118
Desc: "zlib version",
116119
Default: builder.ZlibVersion,
117120
}
121+
argsString["zlibngversion"] = OptionValue{
122+
Desc: "zlib-ng version",
123+
Default: builder.ZlibNGVersion,
124+
}
118125
argsString["openrestyversion"] = OptionValue{
119126
Desc: "openresty version",
120127
Default: builder.OpenRestyVersion,

0 commit comments

Comments
 (0)