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