blob: 264a3d23d85602059d368d515d0dd446b6b2d714 [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 Duesterhus8d173e12020-11-20 00:16:00 +010013
14if len(sys.argv) == 2:
15 build_type = sys.argv[1]
16else:
17 print("Usage: {} <build_type>".format(sys.argv[0]), file=sys.stderr)
18 sys.exit(1)
19
20print("Generating matrix for type '{}'.".format(build_type))
Tim Duesterhus288c0772020-07-28 23:00:35 +020021
22
23def clean_os(os):
24 if os == "ubuntu-latest":
25 return "Ubuntu"
26 elif os == "macos-latest":
27 return "macOS"
28 return os.replace("-latest", "")
29
30
31def clean_ssl(ssl):
32 return ssl.replace("_VERSION", "").lower()
33
Ilya Shipitsin3add74a2022-05-20 23:02:38 +050034def determine_latest_openssl(ssl):
35 openssl_tags = urllib.request.urlopen("https://api.github.com/repos/openssl/openssl/tags")
36 tags = json.loads(openssl_tags.read().decode('utf-8'))
37 latest_tag = ''
38 for tag in tags:
39 name = tag['name']
40 if "openssl-" in name:
41 if name > latest_tag:
42 latest_tag = name
43 return "OPENSSL={}".format(latest_tag[8:])
44
Ilya Shipitsinbfdc6842022-05-13 21:59:38 +050045def determine_latest_libressl(ssl):
46 libressl_download_list = urllib.request.urlopen("http://ftp.openbsd.org/pub/OpenBSD/LibreSSL/")
47 for line in libressl_download_list.readlines():
48 decoded_line = line.decode("utf-8")
49 if "libressl-" in decoded_line and ".tar.gz.asc" in decoded_line:
50 l = re.split("libressl-|.tar.gz.asc", decoded_line)[1]
51 return "LIBRESSL={}".format(l)
Tim Duesterhus288c0772020-07-28 23:00:35 +020052
53def clean_compression(compression):
54 return compression.replace("USE_", "").lower()
55
56
57def get_asan_flags(cc):
Ilya Shipitsin9cd47242022-07-02 10:30:28 +050058 return [
59 "USE_OBSOLETE_LINKER=1",
60 'DEBUG_CFLAGS="-g -fsanitize=address"',
61 'LDFLAGS="-fsanitize=address"',
62 'CPU_CFLAGS.generic="-O1"',
63 ]
Tim Duesterhus288c0772020-07-28 23:00:35 +020064
Tim Duesterhus288c0772020-07-28 23:00:35 +020065
66matrix = []
67
68# Ubuntu
69
70os = "ubuntu-latest"
71TARGET = "linux-glibc"
72for CC in ["gcc", "clang"]:
73 matrix.append(
74 {
75 "name": "{}, {}, no features".format(clean_os(os), CC),
76 "os": os,
77 "TARGET": TARGET,
78 "CC": CC,
79 "FLAGS": [],
80 }
81 )
82
83 matrix.append(
84 {
85 "name": "{}, {}, all features".format(clean_os(os), CC),
86 "os": os,
87 "TARGET": TARGET,
88 "CC": CC,
89 "FLAGS": [
90 "USE_ZLIB=1",
Ilya Shipitsin73c3ed92021-05-18 09:46:43 +000091 "USE_OT=1",
Ilya Shipitsinef86b472022-01-13 11:36:28 +050092 "OT_INC=${HOME}/opt-ot/include",
93 "OT_LIB=${HOME}/opt-ot/lib",
Ilya Shipitsin73c3ed92021-05-18 09:46:43 +000094 "OT_RUNPATH=1",
Tim Duesterhus288c0772020-07-28 23:00:35 +020095 "USE_PCRE=1",
96 "USE_PCRE_JIT=1",
97 "USE_LUA=1",
98 "USE_OPENSSL=1",
99 "USE_SYSTEMD=1",
100 "USE_WURFL=1",
Willy Tarreau57610c62021-04-02 16:39:44 +0200101 "WURFL_INC=addons/wurfl/dummy",
102 "WURFL_LIB=addons/wurfl/dummy",
Tim Duesterhus288c0772020-07-28 23:00:35 +0200103 "USE_DEVICEATLAS=1",
Willy Tarreauf8d9ec52021-04-02 16:19:39 +0200104 "DEVICEATLAS_SRC=addons/deviceatlas/dummy",
Willy Tarreau3dfadc72021-04-02 15:35:19 +0200105 "USE_PROMEX=1",
Ilya Shipitsinb34aee82020-11-26 20:59:42 +0500106 "USE_51DEGREES=1",
Willy Tarreau977209d2021-04-02 16:12:32 +0200107 "51DEGREES_SRC=addons/51degrees/dummy/pattern",
Tim Duesterhus288c0772020-07-28 23:00:35 +0200108 ],
109 }
110 )
111
112 for compression in ["USE_SLZ=1", "USE_ZLIB=1"]:
113 matrix.append(
114 {
115 "name": "{}, {}, gz={}".format(
116 clean_os(os), CC, clean_compression(compression)
117 ),
118 "os": os,
119 "TARGET": TARGET,
120 "CC": CC,
121 "FLAGS": [compression],
122 }
123 )
124
125 for ssl in [
126 "stock",
127 "OPENSSL_VERSION=1.0.2u",
Ilya Shipitsin3add74a2022-05-20 23:02:38 +0500128 "OPENSSL_VERSION=latest",
Ilya Shipitsinbfdc6842022-05-13 21:59:38 +0500129 "LIBRESSL_VERSION=latest",
Willy Tarreau61cda6d2021-09-02 17:32:43 +0200130# "BORINGSSL=yes",
Tim Duesterhus288c0772020-07-28 23:00:35 +0200131 ]:
132 flags = ["USE_OPENSSL=1"]
Ilya Shipitsin714f28c2021-05-09 21:27:28 +0500133 if ssl == "BORINGSSL=yes":
134 flags.append("USE_QUIC=1")
Ilya Shipitsin9c872552021-12-25 14:01:52 +0500135 if "OPENSSL_VERSION=3.0." in ssl:
William Lallemandd8580d92021-06-07 15:27:57 +0200136 flags.append('DEBUG_CFLAGS="-g -Wno-deprecated-declarations"')
Tim Duesterhus288c0772020-07-28 23:00:35 +0200137 if ssl != "stock":
138 flags.append("SSL_LIB=${HOME}/opt/lib")
139 flags.append("SSL_INC=${HOME}/opt/include")
Ilya Shipitsinbfdc6842022-05-13 21:59:38 +0500140 if "LIBRESSL" in ssl and "latest" in ssl:
141 ssl = determine_latest_libressl(ssl)
Ilya Shipitsin3add74a2022-05-20 23:02:38 +0500142 if "OPENSSL" in ssl and "latest" in ssl:
143 ssl = determine_latest_openssl(ssl)
144
Tim Duesterhus288c0772020-07-28 23:00:35 +0200145 matrix.append(
146 {
147 "name": "{}, {}, ssl={}".format(clean_os(os), CC, clean_ssl(ssl)),
148 "os": os,
149 "TARGET": TARGET,
150 "CC": CC,
151 "ssl": ssl,
152 "FLAGS": flags,
153 }
154 )
155
156# ASAN
157
158os = "ubuntu-latest"
Tim Duesterhus288c0772020-07-28 23:00:35 +0200159TARGET = "linux-glibc"
Ilya Shipitsin9cd47242022-07-02 10:30:28 +0500160for CC in ["gcc","clang"]:
161 matrix.append(
162 {
163 "name": "{}, {}, ASAN, all features".format(clean_os(os), CC),
164 "os": os,
165 "TARGET": TARGET,
166 "CC": CC,
167 "FLAGS": get_asan_flags(CC)
168 + [
169 "USE_ZLIB=1",
170 "USE_OT=1",
171 "OT_INC=${HOME}/opt-ot/include",
172 "OT_LIB=${HOME}/opt-ot/lib",
173 "OT_RUNPATH=1",
174 "USE_PCRE=1",
175 "USE_PCRE_JIT=1",
176 "USE_LUA=1",
177 "USE_OPENSSL=1",
178 "USE_SYSTEMD=1",
179 "USE_WURFL=1",
180 "WURFL_INC=addons/wurfl/dummy",
181 "WURFL_LIB=addons/wurfl/dummy",
182 "USE_DEVICEATLAS=1",
183 "DEVICEATLAS_SRC=addons/deviceatlas/dummy",
184 "USE_PROMEX=1",
185 "USE_51DEGREES=1",
186 "51DEGREES_SRC=addons/51degrees/dummy/pattern",
187 ],
188 }
189 )
Tim Duesterhus288c0772020-07-28 23:00:35 +0200190
191# macOS
192
193os = "macos-latest"
194TARGET = "osx"
195for CC in ["clang"]:
196 matrix.append(
197 {
198 "name": "{}, {}, no features".format(clean_os(os), CC),
199 "os": os,
200 "TARGET": TARGET,
201 "CC": CC,
202 "FLAGS": [],
203 }
204 )
205
206# Print matrix
207
208print(json.dumps(matrix, indent=4, sort_keys=True))
209
210print("::set-output name=matrix::{}".format(json.dumps({"include": matrix})))