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 |
| 10 | |
| 11 | |
| 12 | def clean_os(os): |
| 13 | if os == "ubuntu-latest": |
| 14 | return "Ubuntu" |
| 15 | elif os == "macos-latest": |
| 16 | return "macOS" |
| 17 | return os.replace("-latest", "") |
| 18 | |
| 19 | |
| 20 | def clean_ssl(ssl): |
| 21 | return ssl.replace("_VERSION", "").lower() |
| 22 | |
| 23 | |
| 24 | def clean_compression(compression): |
| 25 | return compression.replace("USE_", "").lower() |
| 26 | |
| 27 | |
| 28 | def get_asan_flags(cc): |
| 29 | if cc == "clang": |
| 30 | return [ |
| 31 | "USE_OBSOLETE_LINKER=1", |
| 32 | 'DEBUG_CFLAGS="-g -fsanitize=address"', |
| 33 | 'LDFLAGS="-fsanitize=address"', |
| 34 | 'CPU_CFLAGS.generic="-O1"', |
| 35 | ] |
| 36 | |
| 37 | raise ValueError("ASAN is only supported for clang") |
| 38 | |
| 39 | |
| 40 | matrix = [] |
| 41 | |
| 42 | # Ubuntu |
| 43 | |
| 44 | os = "ubuntu-latest" |
| 45 | TARGET = "linux-glibc" |
| 46 | for CC in ["gcc", "clang"]: |
| 47 | matrix.append( |
| 48 | { |
| 49 | "name": "{}, {}, no features".format(clean_os(os), CC), |
| 50 | "os": os, |
| 51 | "TARGET": TARGET, |
| 52 | "CC": CC, |
| 53 | "FLAGS": [], |
| 54 | } |
| 55 | ) |
| 56 | |
| 57 | matrix.append( |
| 58 | { |
| 59 | "name": "{}, {}, all features".format(clean_os(os), CC), |
| 60 | "os": os, |
| 61 | "TARGET": TARGET, |
| 62 | "CC": CC, |
| 63 | "FLAGS": [ |
| 64 | "USE_ZLIB=1", |
| 65 | "USE_PCRE=1", |
| 66 | "USE_PCRE_JIT=1", |
| 67 | "USE_LUA=1", |
| 68 | "USE_OPENSSL=1", |
| 69 | "USE_SYSTEMD=1", |
| 70 | "USE_WURFL=1", |
| 71 | "WURFL_INC=contrib/wurfl", |
| 72 | "WURFL_LIB=contrib/wurfl", |
| 73 | "USE_DEVICEATLAS=1", |
| 74 | "DEVICEATLAS_SRC=contrib/deviceatlas", |
| 75 | # "USE_51DEGREES=1", |
| 76 | # "FIFTYONEDEGREES_SRC=contrib/51d/src/pattern", |
| 77 | ], |
| 78 | } |
| 79 | ) |
| 80 | |
| 81 | for compression in ["USE_SLZ=1", "USE_ZLIB=1"]: |
| 82 | matrix.append( |
| 83 | { |
| 84 | "name": "{}, {}, gz={}".format( |
| 85 | clean_os(os), CC, clean_compression(compression) |
| 86 | ), |
| 87 | "os": os, |
| 88 | "TARGET": TARGET, |
| 89 | "CC": CC, |
| 90 | "FLAGS": [compression], |
| 91 | } |
| 92 | ) |
| 93 | |
| 94 | for ssl in [ |
| 95 | "stock", |
| 96 | "OPENSSL_VERSION=1.0.2u", |
| 97 | "LIBRESSL_VERSION=2.9.2", |
| 98 | "LIBRESSL_VERSION=3.0.2", |
| 99 | "LIBRESSL_VERSION=3.1.1", |
| 100 | ]: |
| 101 | flags = ["USE_OPENSSL=1"] |
| 102 | if ssl != "stock": |
| 103 | flags.append("SSL_LIB=${HOME}/opt/lib") |
| 104 | flags.append("SSL_INC=${HOME}/opt/include") |
| 105 | matrix.append( |
| 106 | { |
| 107 | "name": "{}, {}, ssl={}".format(clean_os(os), CC, clean_ssl(ssl)), |
| 108 | "os": os, |
| 109 | "TARGET": TARGET, |
| 110 | "CC": CC, |
| 111 | "ssl": ssl, |
| 112 | "FLAGS": flags, |
| 113 | } |
| 114 | ) |
| 115 | |
| 116 | # ASAN |
| 117 | |
| 118 | os = "ubuntu-latest" |
| 119 | CC = "clang" |
| 120 | TARGET = "linux-glibc" |
| 121 | matrix.append( |
| 122 | { |
| 123 | "name": "{}, {}, ASAN, all features".format(clean_os(os), CC), |
| 124 | "os": os, |
| 125 | "TARGET": TARGET, |
| 126 | "CC": CC, |
| 127 | "FLAGS": get_asan_flags(CC) |
| 128 | + [ |
| 129 | "USE_ZLIB=1", |
| 130 | "USE_PCRE=1", |
| 131 | "USE_PCRE_JIT=1", |
| 132 | "USE_LUA=1", |
| 133 | "USE_OPENSSL=1", |
| 134 | "USE_SYSTEMD=1", |
| 135 | "USE_WURFL=1", |
| 136 | "WURFL_INC=contrib/wurfl", |
| 137 | "WURFL_LIB=contrib/wurfl", |
| 138 | "USE_DEVICEATLAS=1", |
| 139 | "DEVICEATLAS_SRC=contrib/deviceatlas", |
| 140 | # "USE_51DEGREES=1", |
| 141 | # "FIFTYONEDEGREES_SRC=contrib/51d/src/pattern", |
| 142 | ], |
| 143 | } |
| 144 | ) |
| 145 | |
| 146 | # macOS |
| 147 | |
| 148 | os = "macos-latest" |
| 149 | TARGET = "osx" |
| 150 | for CC in ["clang"]: |
| 151 | matrix.append( |
| 152 | { |
| 153 | "name": "{}, {}, no features".format(clean_os(os), CC), |
| 154 | "os": os, |
| 155 | "TARGET": TARGET, |
| 156 | "CC": CC, |
| 157 | "FLAGS": [], |
| 158 | } |
| 159 | ) |
| 160 | |
| 161 | # Print matrix |
| 162 | |
| 163 | print(json.dumps(matrix, indent=4, sort_keys=True)) |
| 164 | |
| 165 | print("::set-output name=matrix::{}".format(json.dumps({"include": matrix}))) |