blob: abd6caf652bd2c3b771345fdab5357e3a0941d2d [file] [log] [blame]
Tim Duesterhus288c0772020-07-28 23:00:35 +02001# Copyright 2019 Ilya Shipitsin <chipitsine@gmail.com>
2# Copyright 2020 Tim Duesterhus <tim@bastelstu.be>
3#
4# This program is free software; you can redistribute it and/or
5# modify it under the terms of the GNU General Public License
6# as published by the Free Software Foundation; either version
7# 2 of the License, or (at your option) any later version.
8
9import json
Tim Duesterhus8d173e12020-11-20 00:16:00 +010010import sys
Ilya Shipitsinbfdc6842022-05-13 21:59:38 +050011import urllib.request
12import re
Tim Duesterhus04ca2342022-10-14 19:46:06 +020013from os import environ
Tim Duesterhus8d173e12020-11-20 00:16:00 +010014
15if len(sys.argv) == 2:
16 build_type = sys.argv[1]
17else:
18 print("Usage: {} <build_type>".format(sys.argv[0]), file=sys.stderr)
19 sys.exit(1)
20
21print("Generating matrix for type '{}'.".format(build_type))
Tim Duesterhus288c0772020-07-28 23:00:35 +020022
23
24def clean_os(os):
25 if os == "ubuntu-latest":
26 return "Ubuntu"
27 elif os == "macos-latest":
28 return "macOS"
29 return os.replace("-latest", "")
30
31
32def clean_ssl(ssl):
33 return ssl.replace("_VERSION", "").lower()
34
Ilya Shipitsin3add74a2022-05-20 23:02:38 +050035def determine_latest_openssl(ssl):
36 openssl_tags = urllib.request.urlopen("https://api.github.com/repos/openssl/openssl/tags")
37 tags = json.loads(openssl_tags.read().decode('utf-8'))
38 latest_tag = ''
39 for tag in tags:
40 name = tag['name']
41 if "openssl-" in name:
42 if name > latest_tag:
43 latest_tag = name
Ilya Shipitsin2fb578c2022-10-11 12:10:57 +050044 return "OPENSSL_VERSION={}".format(latest_tag[8:])
Ilya Shipitsin3add74a2022-05-20 23:02:38 +050045
Ilya Shipitsinbfdc6842022-05-13 21:59:38 +050046def determine_latest_libressl(ssl):
47 libressl_download_list = urllib.request.urlopen("http://ftp.openbsd.org/pub/OpenBSD/LibreSSL/")
48 for line in libressl_download_list.readlines():
49 decoded_line = line.decode("utf-8")
50 if "libressl-" in decoded_line and ".tar.gz.asc" in decoded_line:
51 l = re.split("libressl-|.tar.gz.asc", decoded_line)[1]
Ilya Shipitsin2fb578c2022-10-11 12:10:57 +050052 return "LIBRESSL_VERSION={}".format(l)
Tim Duesterhus288c0772020-07-28 23:00:35 +020053
54def clean_compression(compression):
55 return compression.replace("USE_", "").lower()
56
57
58def get_asan_flags(cc):
Ilya Shipitsin9cd47242022-07-02 10:30:28 +050059 return [
60 "USE_OBSOLETE_LINKER=1",
61 'DEBUG_CFLAGS="-g -fsanitize=address"',
62 'LDFLAGS="-fsanitize=address"',
63 'CPU_CFLAGS.generic="-O1"',
64 ]
Tim Duesterhus288c0772020-07-28 23:00:35 +020065
Tim Duesterhus288c0772020-07-28 23:00:35 +020066
67matrix = []
68
69# Ubuntu
70
William Lallemand04091572022-12-09 15:55:18 +010071os = "ubuntu-20.04"
Tim Duesterhus288c0772020-07-28 23:00:35 +020072TARGET = "linux-glibc"
73for CC in ["gcc", "clang"]:
74 matrix.append(
75 {
76 "name": "{}, {}, no features".format(clean_os(os), CC),
77 "os": os,
78 "TARGET": TARGET,
79 "CC": CC,
80 "FLAGS": [],
81 }
82 )
83
84 matrix.append(
85 {
86 "name": "{}, {}, all features".format(clean_os(os), CC),
87 "os": os,
88 "TARGET": TARGET,
89 "CC": CC,
90 "FLAGS": [
91 "USE_ZLIB=1",
Ilya Shipitsin73c3ed92021-05-18 09:46:43 +000092 "USE_OT=1",
Ilya Shipitsinef86b472022-01-13 11:36:28 +050093 "OT_INC=${HOME}/opt-ot/include",
94 "OT_LIB=${HOME}/opt-ot/lib",
Ilya Shipitsin73c3ed92021-05-18 09:46:43 +000095 "OT_RUNPATH=1",
Tim Duesterhus288c0772020-07-28 23:00:35 +020096 "USE_PCRE=1",
97 "USE_PCRE_JIT=1",
98 "USE_LUA=1",
99 "USE_OPENSSL=1",
100 "USE_SYSTEMD=1",
101 "USE_WURFL=1",
Willy Tarreau57610c62021-04-02 16:39:44 +0200102 "WURFL_INC=addons/wurfl/dummy",
103 "WURFL_LIB=addons/wurfl/dummy",
Tim Duesterhus288c0772020-07-28 23:00:35 +0200104 "USE_DEVICEATLAS=1",
Willy Tarreauf8d9ec52021-04-02 16:19:39 +0200105 "DEVICEATLAS_SRC=addons/deviceatlas/dummy",
Willy Tarreau3dfadc72021-04-02 15:35:19 +0200106 "USE_PROMEX=1",
Ilya Shipitsinb34aee82020-11-26 20:59:42 +0500107 "USE_51DEGREES=1",
Willy Tarreau977209d2021-04-02 16:12:32 +0200108 "51DEGREES_SRC=addons/51degrees/dummy/pattern",
Tim Duesterhus288c0772020-07-28 23:00:35 +0200109 ],
110 }
111 )
112
113 for compression in ["USE_SLZ=1", "USE_ZLIB=1"]:
114 matrix.append(
115 {
116 "name": "{}, {}, gz={}".format(
117 clean_os(os), CC, clean_compression(compression)
118 ),
119 "os": os,
120 "TARGET": TARGET,
121 "CC": CC,
122 "FLAGS": [compression],
123 }
124 )
125
126 for ssl in [
127 "stock",
128 "OPENSSL_VERSION=1.0.2u",
Christopher Faulet463c8072022-12-06 11:33:29 +0100129 "OPENSSL_VERSION=3.0.2",
Christopher Faulet83830e92022-12-06 11:25:06 +0100130 "LIBRESSL_VERSION=3.5.3",
Willy Tarreau61cda6d2021-09-02 17:32:43 +0200131# "BORINGSSL=yes",
Tim Duesterhus288c0772020-07-28 23:00:35 +0200132 ]:
133 flags = ["USE_OPENSSL=1"]
Ilya Shipitsin714f28c2021-05-09 21:27:28 +0500134 if ssl == "BORINGSSL=yes":
135 flags.append("USE_QUIC=1")
Ilya Shipitsin9c872552021-12-25 14:01:52 +0500136 if "OPENSSL_VERSION=3.0." in ssl:
William Lallemandd8580d92021-06-07 15:27:57 +0200137 flags.append('DEBUG_CFLAGS="-g -Wno-deprecated-declarations"')
Tim Duesterhus288c0772020-07-28 23:00:35 +0200138 if ssl != "stock":
139 flags.append("SSL_LIB=${HOME}/opt/lib")
140 flags.append("SSL_INC=${HOME}/opt/include")
Ilya Shipitsinbfdc6842022-05-13 21:59:38 +0500141 if "LIBRESSL" in ssl and "latest" in ssl:
142 ssl = determine_latest_libressl(ssl)
Ilya Shipitsin3add74a2022-05-20 23:02:38 +0500143 if "OPENSSL" in ssl and "latest" in ssl:
144 ssl = determine_latest_openssl(ssl)
145
Tim Duesterhus288c0772020-07-28 23:00:35 +0200146 matrix.append(
147 {
148 "name": "{}, {}, ssl={}".format(clean_os(os), CC, clean_ssl(ssl)),
149 "os": os,
150 "TARGET": TARGET,
151 "CC": CC,
152 "ssl": ssl,
153 "FLAGS": flags,
154 }
155 )
156
157# ASAN
158
William Lallemand04091572022-12-09 15:55:18 +0100159os = "ubuntu-20.04"
Tim Duesterhus288c0772020-07-28 23:00:35 +0200160TARGET = "linux-glibc"
Ilya Shipitsin9cd47242022-07-02 10:30:28 +0500161for CC in ["gcc","clang"]:
162 matrix.append(
163 {
164 "name": "{}, {}, ASAN, all features".format(clean_os(os), CC),
165 "os": os,
166 "TARGET": TARGET,
167 "CC": CC,
168 "FLAGS": get_asan_flags(CC)
169 + [
170 "USE_ZLIB=1",
171 "USE_OT=1",
172 "OT_INC=${HOME}/opt-ot/include",
173 "OT_LIB=${HOME}/opt-ot/lib",
174 "OT_RUNPATH=1",
175 "USE_PCRE=1",
176 "USE_PCRE_JIT=1",
177 "USE_LUA=1",
178 "USE_OPENSSL=1",
179 "USE_SYSTEMD=1",
180 "USE_WURFL=1",
181 "WURFL_INC=addons/wurfl/dummy",
182 "WURFL_LIB=addons/wurfl/dummy",
183 "USE_DEVICEATLAS=1",
184 "DEVICEATLAS_SRC=addons/deviceatlas/dummy",
185 "USE_PROMEX=1",
186 "USE_51DEGREES=1",
187 "51DEGREES_SRC=addons/51degrees/dummy/pattern",
188 ],
189 }
190 )
Tim Duesterhus288c0772020-07-28 23:00:35 +0200191
192# macOS
193
194os = "macos-latest"
195TARGET = "osx"
196for CC in ["clang"]:
197 matrix.append(
198 {
199 "name": "{}, {}, no features".format(clean_os(os), CC),
200 "os": os,
201 "TARGET": TARGET,
202 "CC": CC,
203 "FLAGS": [],
204 }
205 )
206
207# Print matrix
208
209print(json.dumps(matrix, indent=4, sort_keys=True))
210
Tim Duesterhus04ca2342022-10-14 19:46:06 +0200211if environ.get('GITHUB_OUTPUT') is not None:
212 with open(environ.get('GITHUB_OUTPUT'), 'a') as f:
213 print("matrix={}".format(json.dumps({"include": matrix})), file=f)