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 |
| 11 | |
| 12 | if len(sys.argv) == 2: |
| 13 | build_type = sys.argv[1] |
| 14 | else: |
| 15 | print("Usage: {} <build_type>".format(sys.argv[0]), file=sys.stderr) |
| 16 | sys.exit(1) |
| 17 | |
| 18 | print("Generating matrix for type '{}'.".format(build_type)) |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 19 | |
| 20 | |
| 21 | def clean_os(os): |
| 22 | if os == "ubuntu-latest": |
| 23 | return "Ubuntu" |
| 24 | elif os == "macos-latest": |
| 25 | return "macOS" |
| 26 | return os.replace("-latest", "") |
| 27 | |
| 28 | |
| 29 | def clean_ssl(ssl): |
| 30 | return ssl.replace("_VERSION", "").lower() |
| 31 | |
| 32 | |
| 33 | def clean_compression(compression): |
| 34 | return compression.replace("USE_", "").lower() |
| 35 | |
| 36 | |
| 37 | def get_asan_flags(cc): |
| 38 | if cc == "clang": |
| 39 | return [ |
| 40 | "USE_OBSOLETE_LINKER=1", |
| 41 | 'DEBUG_CFLAGS="-g -fsanitize=address"', |
| 42 | 'LDFLAGS="-fsanitize=address"', |
| 43 | 'CPU_CFLAGS.generic="-O1"', |
| 44 | ] |
| 45 | |
| 46 | raise ValueError("ASAN is only supported for clang") |
| 47 | |
| 48 | |
| 49 | matrix = [] |
| 50 | |
| 51 | # Ubuntu |
| 52 | |
| 53 | os = "ubuntu-latest" |
| 54 | TARGET = "linux-glibc" |
| 55 | for CC in ["gcc", "clang"]: |
| 56 | matrix.append( |
| 57 | { |
| 58 | "name": "{}, {}, no features".format(clean_os(os), CC), |
| 59 | "os": os, |
| 60 | "TARGET": TARGET, |
| 61 | "CC": CC, |
| 62 | "FLAGS": [], |
| 63 | } |
| 64 | ) |
| 65 | |
| 66 | matrix.append( |
| 67 | { |
| 68 | "name": "{}, {}, all features".format(clean_os(os), CC), |
| 69 | "os": os, |
| 70 | "TARGET": TARGET, |
| 71 | "CC": CC, |
| 72 | "FLAGS": [ |
| 73 | "USE_ZLIB=1", |
| 74 | "USE_PCRE=1", |
| 75 | "USE_PCRE_JIT=1", |
| 76 | "USE_LUA=1", |
| 77 | "USE_OPENSSL=1", |
| 78 | "USE_SYSTEMD=1", |
| 79 | "USE_WURFL=1", |
Willy Tarreau | 57610c6 | 2021-04-02 16:39:44 +0200 | [diff] [blame] | 80 | "WURFL_INC=addons/wurfl/dummy", |
| 81 | "WURFL_LIB=addons/wurfl/dummy", |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 82 | "USE_DEVICEATLAS=1", |
Willy Tarreau | f8d9ec5 | 2021-04-02 16:19:39 +0200 | [diff] [blame] | 83 | "DEVICEATLAS_SRC=addons/deviceatlas/dummy", |
Willy Tarreau | 3dfadc7 | 2021-04-02 15:35:19 +0200 | [diff] [blame] | 84 | "USE_PROMEX=1", |
Ilya Shipitsin | b34aee8 | 2020-11-26 20:59:42 +0500 | [diff] [blame] | 85 | "USE_51DEGREES=1", |
Willy Tarreau | 977209d | 2021-04-02 16:12:32 +0200 | [diff] [blame] | 86 | "51DEGREES_SRC=addons/51degrees/dummy/pattern", |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 87 | ], |
| 88 | } |
| 89 | ) |
| 90 | |
| 91 | for compression in ["USE_SLZ=1", "USE_ZLIB=1"]: |
| 92 | matrix.append( |
| 93 | { |
| 94 | "name": "{}, {}, gz={}".format( |
| 95 | clean_os(os), CC, clean_compression(compression) |
| 96 | ), |
| 97 | "os": os, |
| 98 | "TARGET": TARGET, |
| 99 | "CC": CC, |
| 100 | "FLAGS": [compression], |
| 101 | } |
| 102 | ) |
| 103 | |
| 104 | for ssl in [ |
| 105 | "stock", |
| 106 | "OPENSSL_VERSION=1.0.2u", |
| 107 | "LIBRESSL_VERSION=2.9.2", |
Ilya Shipitsin | 04b57a7 | 2021-05-05 09:01:03 +0500 | [diff] [blame] | 108 | "LIBRESSL_VERSION=3.3.3", |
Ilya Shipitsin | f644c5a | 2020-11-20 14:43:23 +0500 | [diff] [blame] | 109 | "BORINGSSL=yes", |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 110 | ]: |
| 111 | flags = ["USE_OPENSSL=1"] |
| 112 | if ssl != "stock": |
| 113 | flags.append("SSL_LIB=${HOME}/opt/lib") |
| 114 | flags.append("SSL_INC=${HOME}/opt/include") |
| 115 | matrix.append( |
| 116 | { |
| 117 | "name": "{}, {}, ssl={}".format(clean_os(os), CC, clean_ssl(ssl)), |
| 118 | "os": os, |
| 119 | "TARGET": TARGET, |
| 120 | "CC": CC, |
| 121 | "ssl": ssl, |
| 122 | "FLAGS": flags, |
| 123 | } |
| 124 | ) |
| 125 | |
| 126 | # ASAN |
| 127 | |
| 128 | os = "ubuntu-latest" |
| 129 | CC = "clang" |
| 130 | TARGET = "linux-glibc" |
| 131 | matrix.append( |
| 132 | { |
| 133 | "name": "{}, {}, ASAN, all features".format(clean_os(os), CC), |
| 134 | "os": os, |
| 135 | "TARGET": TARGET, |
| 136 | "CC": CC, |
| 137 | "FLAGS": get_asan_flags(CC) |
| 138 | + [ |
| 139 | "USE_ZLIB=1", |
| 140 | "USE_PCRE=1", |
| 141 | "USE_PCRE_JIT=1", |
| 142 | "USE_LUA=1", |
| 143 | "USE_OPENSSL=1", |
| 144 | "USE_SYSTEMD=1", |
| 145 | "USE_WURFL=1", |
Willy Tarreau | 57610c6 | 2021-04-02 16:39:44 +0200 | [diff] [blame] | 146 | "WURFL_INC=addons/wurfl/dummy", |
| 147 | "WURFL_LIB=addons/wurfl/dummy", |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 148 | "USE_DEVICEATLAS=1", |
Willy Tarreau | f8d9ec5 | 2021-04-02 16:19:39 +0200 | [diff] [blame] | 149 | "DEVICEATLAS_SRC=addons/deviceatlas/dummy", |
Willy Tarreau | 3dfadc7 | 2021-04-02 15:35:19 +0200 | [diff] [blame] | 150 | "USE_PROMEX=1", |
Ilya Shipitsin | b34aee8 | 2020-11-26 20:59:42 +0500 | [diff] [blame] | 151 | "USE_51DEGREES=1", |
Willy Tarreau | 977209d | 2021-04-02 16:12:32 +0200 | [diff] [blame] | 152 | "51DEGREES_SRC=addons/51degrees/dummy/pattern", |
Tim Duesterhus | 288c077 | 2020-07-28 23:00:35 +0200 | [diff] [blame] | 153 | ], |
| 154 | } |
| 155 | ) |
| 156 | |
| 157 | # macOS |
| 158 | |
| 159 | os = "macos-latest" |
| 160 | TARGET = "osx" |
| 161 | for CC in ["clang"]: |
| 162 | matrix.append( |
| 163 | { |
| 164 | "name": "{}, {}, no features".format(clean_os(os), CC), |
| 165 | "os": os, |
| 166 | "TARGET": TARGET, |
| 167 | "CC": CC, |
| 168 | "FLAGS": [], |
| 169 | } |
| 170 | ) |
| 171 | |
| 172 | # Print matrix |
| 173 | |
| 174 | print(json.dumps(matrix, indent=4, sort_keys=True)) |
| 175 | |
| 176 | print("::set-output name=matrix::{}".format(json.dumps({"include": matrix}))) |