Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 1 | # 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 | |
| 9 | import json |
Tim Duesterhus | 8d173e1 | 2020-11-20 00:16:00 +0100 | [diff] [blame] | 10 | import sys |
Ilya Shipitsin | bfdc684 | 2022-05-13 21:59:38 +0500 | [diff] [blame] | 11 | import urllib.request |
| 12 | import re |
Tim Duesterhus | 04ca234 | 2022-10-14 19:46:06 +0200 | [diff] [blame] | 13 | from os import environ |
Tim Duesterhus | 8d173e1 | 2020-11-20 00:16:00 +0100 | [diff] [blame] | 14 | |
| 15 | if len(sys.argv) == 2: |
| 16 | build_type = sys.argv[1] |
| 17 | else: |
| 18 | print("Usage: {} <build_type>".format(sys.argv[0]), file=sys.stderr) |
| 19 | sys.exit(1) |
| 20 | |
| 21 | print("Generating matrix for type '{}'.".format(build_type)) |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 22 | |
| 23 | |
| 24 | def 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 | |
| 32 | def clean_ssl(ssl): |
| 33 | return ssl.replace("_VERSION", "").lower() |
| 34 | |
Ilya Shipitsin | 3add74a | 2022-05-20 23:02:38 +0500 | [diff] [blame] | 35 | def 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 Shipitsin | 2fb578c | 2022-10-11 12:10:57 +0500 | [diff] [blame] | 44 | return "OPENSSL_VERSION={}".format(latest_tag[8:]) |
Ilya Shipitsin | 3add74a | 2022-05-20 23:02:38 +0500 | [diff] [blame] | 45 | |
Ilya Shipitsin | bfdc684 | 2022-05-13 21:59:38 +0500 | [diff] [blame] | 46 | def determine_latest_libressl(ssl): |
Ilia Shipitsin | 418c10c | 2023-04-26 12:12:54 +0200 | [diff] [blame] | 47 | libressl_download_list = urllib.request.urlopen( |
| 48 | "https://cdn.openbsd.org/pub/OpenBSD/LibreSSL/" |
| 49 | ) |
Ilya Shipitsin | bfdc684 | 2022-05-13 21:59:38 +0500 | [diff] [blame] | 50 | for line in libressl_download_list.readlines(): |
| 51 | decoded_line = line.decode("utf-8") |
| 52 | if "libressl-" in decoded_line and ".tar.gz.asc" in decoded_line: |
| 53 | l = re.split("libressl-|.tar.gz.asc", decoded_line)[1] |
Ilya Shipitsin | 2fb578c | 2022-10-11 12:10:57 +0500 | [diff] [blame] | 54 | return "LIBRESSL_VERSION={}".format(l) |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 55 | |
| 56 | def clean_compression(compression): |
| 57 | return compression.replace("USE_", "").lower() |
| 58 | |
| 59 | |
| 60 | def get_asan_flags(cc): |
Ilya Shipitsin | 9cd4724 | 2022-07-02 10:30:28 +0500 | [diff] [blame] | 61 | return [ |
| 62 | "USE_OBSOLETE_LINKER=1", |
| 63 | 'DEBUG_CFLAGS="-g -fsanitize=address"', |
| 64 | 'LDFLAGS="-fsanitize=address"', |
| 65 | 'CPU_CFLAGS.generic="-O1"', |
| 66 | ] |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 67 | |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 68 | |
| 69 | matrix = [] |
| 70 | |
| 71 | # Ubuntu |
| 72 | |
William Lallemand | 0409157 | 2022-12-09 15:55:18 +0100 | [diff] [blame] | 73 | os = "ubuntu-20.04" |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 74 | TARGET = "linux-glibc" |
| 75 | for CC in ["gcc", "clang"]: |
| 76 | matrix.append( |
| 77 | { |
| 78 | "name": "{}, {}, no features".format(clean_os(os), CC), |
| 79 | "os": os, |
| 80 | "TARGET": TARGET, |
| 81 | "CC": CC, |
| 82 | "FLAGS": [], |
| 83 | } |
| 84 | ) |
| 85 | |
| 86 | matrix.append( |
| 87 | { |
| 88 | "name": "{}, {}, all features".format(clean_os(os), CC), |
| 89 | "os": os, |
| 90 | "TARGET": TARGET, |
| 91 | "CC": CC, |
| 92 | "FLAGS": [ |
| 93 | "USE_ZLIB=1", |
Ilya Shipitsin | 73c3ed9 | 2021-05-18 09:46:43 +0000 | [diff] [blame] | 94 | "USE_OT=1", |
Ilya Shipitsin | ef86b47 | 2022-01-13 11:36:28 +0500 | [diff] [blame] | 95 | "OT_INC=${HOME}/opt-ot/include", |
| 96 | "OT_LIB=${HOME}/opt-ot/lib", |
Ilya Shipitsin | 73c3ed9 | 2021-05-18 09:46:43 +0000 | [diff] [blame] | 97 | "OT_RUNPATH=1", |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 98 | "USE_PCRE=1", |
| 99 | "USE_PCRE_JIT=1", |
| 100 | "USE_LUA=1", |
| 101 | "USE_OPENSSL=1", |
| 102 | "USE_SYSTEMD=1", |
| 103 | "USE_WURFL=1", |
Willy Tarreau | 57610c6 | 2021-04-02 16:39:44 +0200 | [diff] [blame] | 104 | "WURFL_INC=addons/wurfl/dummy", |
| 105 | "WURFL_LIB=addons/wurfl/dummy", |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 106 | "USE_DEVICEATLAS=1", |
Willy Tarreau | f8d9ec5 | 2021-04-02 16:19:39 +0200 | [diff] [blame] | 107 | "DEVICEATLAS_SRC=addons/deviceatlas/dummy", |
Willy Tarreau | 3dfadc7 | 2021-04-02 15:35:19 +0200 | [diff] [blame] | 108 | "USE_PROMEX=1", |
Ilya Shipitsin | b34aee8 | 2020-11-26 20:59:42 +0500 | [diff] [blame] | 109 | "USE_51DEGREES=1", |
Willy Tarreau | 977209d | 2021-04-02 16:12:32 +0200 | [diff] [blame] | 110 | "51DEGREES_SRC=addons/51degrees/dummy/pattern", |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 111 | ], |
| 112 | } |
| 113 | ) |
| 114 | |
| 115 | for compression in ["USE_SLZ=1", "USE_ZLIB=1"]: |
| 116 | matrix.append( |
| 117 | { |
| 118 | "name": "{}, {}, gz={}".format( |
| 119 | clean_os(os), CC, clean_compression(compression) |
| 120 | ), |
| 121 | "os": os, |
| 122 | "TARGET": TARGET, |
| 123 | "CC": CC, |
| 124 | "FLAGS": [compression], |
| 125 | } |
| 126 | ) |
| 127 | |
| 128 | for ssl in [ |
| 129 | "stock", |
| 130 | "OPENSSL_VERSION=1.0.2u", |
Christopher Faulet | 463c807 | 2022-12-06 11:33:29 +0100 | [diff] [blame] | 131 | "OPENSSL_VERSION=3.0.2", |
Christopher Faulet | 83830e9 | 2022-12-06 11:25:06 +0100 | [diff] [blame] | 132 | "LIBRESSL_VERSION=3.5.3", |
Willy Tarreau | 61cda6d | 2021-09-02 17:32:43 +0200 | [diff] [blame] | 133 | # "BORINGSSL=yes", |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 134 | ]: |
| 135 | flags = ["USE_OPENSSL=1"] |
Ilya Shipitsin | 714f28c | 2021-05-09 21:27:28 +0500 | [diff] [blame] | 136 | if ssl == "BORINGSSL=yes": |
| 137 | flags.append("USE_QUIC=1") |
Ilya Shipitsin | 9c87255 | 2021-12-25 14:01:52 +0500 | [diff] [blame] | 138 | if "OPENSSL_VERSION=3.0." in ssl: |
William Lallemand | d8580d9 | 2021-06-07 15:27:57 +0200 | [diff] [blame] | 139 | flags.append('DEBUG_CFLAGS="-g -Wno-deprecated-declarations"') |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 140 | if ssl != "stock": |
| 141 | flags.append("SSL_LIB=${HOME}/opt/lib") |
| 142 | flags.append("SSL_INC=${HOME}/opt/include") |
Ilya Shipitsin | bfdc684 | 2022-05-13 21:59:38 +0500 | [diff] [blame] | 143 | if "LIBRESSL" in ssl and "latest" in ssl: |
| 144 | ssl = determine_latest_libressl(ssl) |
Ilya Shipitsin | 3add74a | 2022-05-20 23:02:38 +0500 | [diff] [blame] | 145 | if "OPENSSL" in ssl and "latest" in ssl: |
| 146 | ssl = determine_latest_openssl(ssl) |
| 147 | |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 148 | matrix.append( |
| 149 | { |
| 150 | "name": "{}, {}, ssl={}".format(clean_os(os), CC, clean_ssl(ssl)), |
| 151 | "os": os, |
| 152 | "TARGET": TARGET, |
| 153 | "CC": CC, |
| 154 | "ssl": ssl, |
| 155 | "FLAGS": flags, |
| 156 | } |
| 157 | ) |
| 158 | |
| 159 | # ASAN |
| 160 | |
William Lallemand | 0409157 | 2022-12-09 15:55:18 +0100 | [diff] [blame] | 161 | os = "ubuntu-20.04" |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 162 | TARGET = "linux-glibc" |
Ilya Shipitsin | 9cd4724 | 2022-07-02 10:30:28 +0500 | [diff] [blame] | 163 | for CC in ["gcc","clang"]: |
| 164 | matrix.append( |
| 165 | { |
| 166 | "name": "{}, {}, ASAN, all features".format(clean_os(os), CC), |
| 167 | "os": os, |
| 168 | "TARGET": TARGET, |
| 169 | "CC": CC, |
| 170 | "FLAGS": get_asan_flags(CC) |
| 171 | + [ |
| 172 | "USE_ZLIB=1", |
| 173 | "USE_OT=1", |
| 174 | "OT_INC=${HOME}/opt-ot/include", |
| 175 | "OT_LIB=${HOME}/opt-ot/lib", |
| 176 | "OT_RUNPATH=1", |
| 177 | "USE_PCRE=1", |
| 178 | "USE_PCRE_JIT=1", |
| 179 | "USE_LUA=1", |
| 180 | "USE_OPENSSL=1", |
| 181 | "USE_SYSTEMD=1", |
| 182 | "USE_WURFL=1", |
| 183 | "WURFL_INC=addons/wurfl/dummy", |
| 184 | "WURFL_LIB=addons/wurfl/dummy", |
| 185 | "USE_DEVICEATLAS=1", |
| 186 | "DEVICEATLAS_SRC=addons/deviceatlas/dummy", |
| 187 | "USE_PROMEX=1", |
| 188 | "USE_51DEGREES=1", |
| 189 | "51DEGREES_SRC=addons/51degrees/dummy/pattern", |
| 190 | ], |
| 191 | } |
| 192 | ) |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 193 | |
| 194 | # macOS |
| 195 | |
| 196 | os = "macos-latest" |
| 197 | TARGET = "osx" |
| 198 | for CC in ["clang"]: |
| 199 | matrix.append( |
| 200 | { |
| 201 | "name": "{}, {}, no features".format(clean_os(os), CC), |
| 202 | "os": os, |
| 203 | "TARGET": TARGET, |
| 204 | "CC": CC, |
| 205 | "FLAGS": [], |
| 206 | } |
| 207 | ) |
| 208 | |
| 209 | # Print matrix |
| 210 | |
| 211 | print(json.dumps(matrix, indent=4, sort_keys=True)) |
| 212 | |
Tim Duesterhus | 04ca234 | 2022-10-14 19:46:06 +0200 | [diff] [blame] | 213 | if environ.get('GITHUB_OUTPUT') is not None: |
| 214 | with open(environ.get('GITHUB_OUTPUT'), 'a') as f: |
| 215 | print("matrix={}".format(json.dumps({"include": matrix})), file=f) |