-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
stop promoting the TLS lib alternatives; generalize the switchtls scr…
…ipt to document how to switch between libs
- Loading branch information
Showing
3 changed files
with
56 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env bash | ||
|
||
BASENAME="$(basename "${0}")" | ||
BASEDIR="$(cd "$(dirname "${0}")" && pwd)" # full path to scripts dir | ||
|
||
if ! (( $# )) || [[ $* =~ -h|(--)?help ]]; then | ||
echo -e "\nUsage: ${BASENAME} [openssl|mbedtls] [x64|arm64|arm]"\ | ||
"\n\nConfigures build preset for OpenSSL or Mbed-TLS and"\ | ||
"\nbuilds the binary if ARCH is specified\n" | ||
exit 0 | ||
fi | ||
|
||
set -euo pipefail; | ||
|
||
function switch_tls(){ | ||
local old=$1; | ||
local new=$2; | ||
# munge the preset to use openssl | ||
TMPFILE=$(mktemp); | ||
jq --arg old $old --arg new $new '.dependencies |= map(if . == $old then $new else . end)' ./vcpkg.json > "$TMPFILE"; | ||
mv "$TMPFILE" ./vcpkg.json; | ||
|
||
jq --arg old $old --arg new $new \ | ||
'.configurePresets |= map( | ||
if .cacheVariables.TLSUV_TLSLIB == $old then | ||
.cacheVariables.TLSUV_TLSLIB |= $new | ||
else | ||
. | ||
end | ||
) | ||
' ./CMakePresets.json > "$TMPFILE"; | ||
mv "$TMPFILE" ./CMakePresets.json; | ||
} | ||
|
||
TLSLIB=${1:-} | ||
TARGETARCH=${2:-} | ||
|
||
if [[ $TLSLIB == "mbedtls" ]]; then | ||
switch_tls "openssl" "mbedtls" | ||
PRESET="ci-linux-${TARGETARCH}" | ||
elif [[ $TLSLIB == "openssl" ]]; then | ||
switch_tls "mbedtls" "openssl" | ||
PRESET="ci-linux-${TARGETARCH}-static-libssl" | ||
else | ||
echo "Unknown TLS library: $TLSLIB" | ||
exit 1 | ||
fi | ||
|
||
if [[ -z $TARGETARCH ]]; then | ||
echo "No architecture specified, only switching TLS library in vcpkg.json and CMakePresets.json" | ||
exit 0 | ||
elif [[ $TARGETARCH =~ ^(x64|arm(64))$ ]]; then | ||
"$BASEDIR/ziti-builder.sh" -p "$PRESET" | ||
else | ||
echo "ERROR: Unknown architecture preset: $PRESET" | ||
fi |