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): |
| 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 Shipitsin | 2fb578c | 2022-10-11 12:10:57 +0500 | [diff] [blame^] | 52 | return "LIBRESSL_VERSION={}".format(l) |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 53 | |
| 54 | def clean_compression(compression): |
| 55 | return compression.replace("USE_", "").lower() |
| 56 | |
| 57 | |
| 58 | def get_asan_flags(cc): |
Ilya Shipitsin | 9cd4724 | 2022-07-02 10:30:28 +0500 | [diff] [blame] | 59 | return [ |
| 60 | "USE_OBSOLETE_LINKER=1", |
| 61 | 'DEBUG_CFLAGS="-g -fsanitize=address"', |
| 62 | 'LDFLAGS="-fsanitize=address"', |
| 63 | 'CPU_CFLAGS.generic="-O1"', |
| 64 | ] |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 65 | |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 66 | |
| 67 | matrix = [] |
| 68 | |
| 69 | # Ubuntu |
| 70 | |
| 71 | os = "ubuntu-latest" |
| 72 | TARGET = "linux-glibc" |
| 73 | for 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 Shipitsin | 73c3ed9 | 2021-05-18 09:46:43 +0000 | [diff] [blame] | 92 | "USE_OT=1", |
Ilya Shipitsin | ef86b47 | 2022-01-13 11:36:28 +0500 | [diff] [blame] | 93 | "OT_INC=${HOME}/opt-ot/include", |
| 94 | "OT_LIB=${HOME}/opt-ot/lib", |
Ilya Shipitsin | 73c3ed9 | 2021-05-18 09:46:43 +0000 | [diff] [blame] | 95 | "OT_RUNPATH=1", |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 96 | "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 Tarreau | 57610c6 | 2021-04-02 16:39:44 +0200 | [diff] [blame] | 102 | "WURFL_INC=addons/wurfl/dummy", |
| 103 | "WURFL_LIB=addons/wurfl/dummy", |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 104 | "USE_DEVICEATLAS=1", |
Willy Tarreau | f8d9ec5 | 2021-04-02 16:19:39 +0200 | [diff] [blame] | 105 | "DEVICEATLAS_SRC=addons/deviceatlas/dummy", |
Willy Tarreau | 3dfadc7 | 2021-04-02 15:35:19 +0200 | [diff] [blame] | 106 | "USE_PROMEX=1", |
Ilya Shipitsin | b34aee8 | 2020-11-26 20:59:42 +0500 | [diff] [blame] | 107 | "USE_51DEGREES=1", |
Willy Tarreau | 977209d | 2021-04-02 16:12:32 +0200 | [diff] [blame] | 108 | "51DEGREES_SRC=addons/51degrees/dummy/pattern", |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 109 | ], |
| 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", |
Ilya Shipitsin | 3add74a | 2022-05-20 23:02:38 +0500 | [diff] [blame] | 129 | "OPENSSL_VERSION=latest", |
Ilya Shipitsin | bfdc684 | 2022-05-13 21:59:38 +0500 | [diff] [blame] | 130 | "LIBRESSL_VERSION=latest", |
Willy Tarreau | 61cda6d | 2021-09-02 17:32:43 +0200 | [diff] [blame] | 131 | # "BORINGSSL=yes", |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 132 | ]: |
| 133 | flags = ["USE_OPENSSL=1"] |
Ilya Shipitsin | 714f28c | 2021-05-09 21:27:28 +0500 | [diff] [blame] | 134 | if ssl == "BORINGSSL=yes": |
| 135 | flags.append("USE_QUIC=1") |
Ilya Shipitsin | 9c87255 | 2021-12-25 14:01:52 +0500 | [diff] [blame] | 136 | if "OPENSSL_VERSION=3.0." in ssl: |
William Lallemand | d8580d9 | 2021-06-07 15:27:57 +0200 | [diff] [blame] | 137 | flags.append('DEBUG_CFLAGS="-g -Wno-deprecated-declarations"') |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 138 | if ssl != "stock": |
| 139 | flags.append("SSL_LIB=${HOME}/opt/lib") |
| 140 | flags.append("SSL_INC=${HOME}/opt/include") |
Ilya Shipitsin | bfdc684 | 2022-05-13 21:59:38 +0500 | [diff] [blame] | 141 | if "LIBRESSL" in ssl and "latest" in ssl: |
| 142 | ssl = determine_latest_libressl(ssl) |
Ilya Shipitsin | 3add74a | 2022-05-20 23:02:38 +0500 | [diff] [blame] | 143 | if "OPENSSL" in ssl and "latest" in ssl: |
| 144 | ssl = determine_latest_openssl(ssl) |
| 145 | |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 146 | 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 | |
| 159 | os = "ubuntu-latest" |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 160 | TARGET = "linux-glibc" |
Ilya Shipitsin | 9cd4724 | 2022-07-02 10:30:28 +0500 | [diff] [blame] | 161 | for 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 Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 191 | |
| 192 | # macOS |
| 193 | |
| 194 | os = "macos-latest" |
| 195 | TARGET = "osx" |
| 196 | for 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 | |
| 209 | print(json.dumps(matrix, indent=4, sort_keys=True)) |
| 210 | |
Tim Duesterhus | 04ca234 | 2022-10-14 19:46:06 +0200 | [diff] [blame] | 211 | if 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) |