blob: 6282767fe4aa07bc040799b3f286fc17845cdd4a [file] [log] [blame]
Tim Duesterhus871ef2f2021-06-08 15:14:35 +02001#!/usr/bin/python3
2
Tim Duesterhus288c0772020-07-28 23:00:35 +02003# Copyright 2019 Ilya Shipitsin <chipitsine@gmail.com>
4# Copyright 2020 Tim Duesterhus <tim@bastelstu.be>
5#
6# This program is free software; you can redistribute it and/or
7# modify it under the terms of the GNU General Public License
8# as published by the Free Software Foundation; either version
9# 2 of the License, or (at your option) any later version.
10
11import json
Tim Duesterhus8d173e12020-11-20 00:16:00 +010012import sys
Ilya Shipitsin94cd7792022-05-13 21:59:38 +050013import urllib.request
14import re
Tim Duesterhus8d173e12020-11-20 00:16:00 +010015
16if len(sys.argv) == 2:
17 build_type = sys.argv[1]
18else:
19 print("Usage: {} <build_type>".format(sys.argv[0]), file=sys.stderr)
20 sys.exit(1)
21
22print("Generating matrix for type '{}'.".format(build_type))
Tim Duesterhus288c0772020-07-28 23:00:35 +020023
24
25def clean_os(os):
26 if os == "ubuntu-latest":
27 return "Ubuntu"
28 elif os == "macos-latest":
29 return "macOS"
30 return os.replace("-latest", "")
31
32
33def clean_ssl(ssl):
34 return ssl.replace("_VERSION", "").lower()
35
Ilya Shipitsin7b893c22022-05-20 23:02:38 +050036def determine_latest_openssl(ssl):
37 openssl_tags = urllib.request.urlopen("https://api.github.com/repos/openssl/openssl/tags")
38 tags = json.loads(openssl_tags.read().decode('utf-8'))
39 latest_tag = ''
40 for tag in tags:
41 name = tag['name']
42 if "openssl-" in name:
43 if name > latest_tag:
44 latest_tag = name
45 return "OPENSSL={}".format(latest_tag[8:])
46
Ilya Shipitsin94cd7792022-05-13 21:59:38 +050047def determine_latest_libressl(ssl):
48 libressl_download_list = urllib.request.urlopen("http://ftp.openbsd.org/pub/OpenBSD/LibreSSL/")
49 for line in libressl_download_list.readlines():
50 decoded_line = line.decode("utf-8")
51 if "libressl-" in decoded_line and ".tar.gz.asc" in decoded_line:
52 l = re.split("libressl-|.tar.gz.asc", decoded_line)[1]
53 return "LIBRESSL={}".format(l)
Tim Duesterhus288c0772020-07-28 23:00:35 +020054
55def clean_compression(compression):
56 return compression.replace("USE_", "").lower()
57
58
59def get_asan_flags(cc):
Ilya Shipitsincfba1f92022-07-02 10:30:28 +050060 return [
61 "USE_OBSOLETE_LINKER=1",
62 'DEBUG_CFLAGS="-g -fsanitize=address"',
63 'LDFLAGS="-fsanitize=address"',
64 'CPU_CFLAGS.generic="-O1"',
65 ]
Tim Duesterhus288c0772020-07-28 23:00:35 +020066
Tim Duesterhus288c0772020-07-28 23:00:35 +020067
68matrix = []
69
70# Ubuntu
71
72os = "ubuntu-latest"
73TARGET = "linux-glibc"
74for CC in ["gcc", "clang"]:
75 matrix.append(
76 {
77 "name": "{}, {}, no features".format(clean_os(os), CC),
78 "os": os,
79 "TARGET": TARGET,
80 "CC": CC,
81 "FLAGS": [],
82 }
83 )
84
85 matrix.append(
86 {
87 "name": "{}, {}, all features".format(clean_os(os), CC),
88 "os": os,
89 "TARGET": TARGET,
90 "CC": CC,
91 "FLAGS": [
92 "USE_ZLIB=1",
Willy Tarreaued17ca72021-09-12 07:01:36 +020093 "USE_OT=1",
Ilya Shipitsinb9e3fb72022-01-13 11:36:28 +050094 "OT_INC=${HOME}/opt-ot/include",
95 "OT_LIB=${HOME}/opt-ot/lib",
Ilya Shipitsin75c95aa2021-05-18 09:46:43 +000096 "OT_RUNPATH=1",
Tim Duesterhus288c0772020-07-28 23:00:35 +020097 "USE_PCRE=1",
98 "USE_PCRE_JIT=1",
99 "USE_LUA=1",
100 "USE_OPENSSL=1",
101 "USE_SYSTEMD=1",
102 "USE_WURFL=1",
Willy Tarreau57610c62021-04-02 16:39:44 +0200103 "WURFL_INC=addons/wurfl/dummy",
104 "WURFL_LIB=addons/wurfl/dummy",
Tim Duesterhus288c0772020-07-28 23:00:35 +0200105 "USE_DEVICEATLAS=1",
Willy Tarreauf8d9ec52021-04-02 16:19:39 +0200106 "DEVICEATLAS_SRC=addons/deviceatlas/dummy",
Willy Tarreau3dfadc72021-04-02 15:35:19 +0200107 "USE_PROMEX=1",
Ilya Shipitsinb34aee82020-11-26 20:59:42 +0500108 "USE_51DEGREES=1",
Willy Tarreau977209d2021-04-02 16:12:32 +0200109 "51DEGREES_SRC=addons/51degrees/dummy/pattern",
Tim Duesterhus288c0772020-07-28 23:00:35 +0200110 ],
111 }
112 )
113
Tim Duesterhus762b1fd2021-08-14 14:36:55 +0200114 for compression in ["USE_ZLIB=1"]:
Tim Duesterhus288c0772020-07-28 23:00:35 +0200115 matrix.append(
116 {
117 "name": "{}, {}, gz={}".format(
118 clean_os(os), CC, clean_compression(compression)
119 ),
120 "os": os,
121 "TARGET": TARGET,
122 "CC": CC,
123 "FLAGS": [compression],
124 }
125 )
126
127 for ssl in [
128 "stock",
129 "OPENSSL_VERSION=1.0.2u",
Ilya Shipitsin7b893c22022-05-20 23:02:38 +0500130 "OPENSSL_VERSION=latest",
Ilya Shipitsin94cd7792022-05-13 21:59:38 +0500131 "LIBRESSL_VERSION=latest",
Ilya Shipitsind69d65a2021-11-18 18:27:57 +0500132 "QUICTLS=yes",
Willy Tarreau30ee2962021-09-02 17:32:43 +0200133# "BORINGSSL=yes",
Tim Duesterhus288c0772020-07-28 23:00:35 +0200134 ]:
135 flags = ["USE_OPENSSL=1"]
Ilya Shipitsind69d65a2021-11-18 18:27:57 +0500136 if ssl == "BORINGSSL=yes" or ssl == "QUICTLS=yes":
Ilya Shipitsin714f28c2021-05-09 21:27:28 +0500137 flags.append("USE_QUIC=1")
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 Shipitsin94cd7792022-05-13 21:59:38 +0500141 if "LIBRESSL" in ssl and "latest" in ssl:
142 ssl = determine_latest_libressl(ssl)
Ilya Shipitsin7b893c22022-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
159os = "ubuntu-latest"
Tim Duesterhus288c0772020-07-28 23:00:35 +0200160TARGET = "linux-glibc"
Ilya Shipitsincfba1f92022-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
211print("::set-output name=matrix::{}".format(json.dumps({"include": matrix})))