Make the CI actually not use static linking of libc

This commit is contained in:
Alessio 2024-06-09 14:33:25 -07:00
parent 03c082ab4b
commit 4dbe8b1558
3 changed files with 22 additions and 4 deletions

View File

@ -8,6 +8,9 @@ then
>&2 echo "No version number provided! Exiting." >&2 echo "No version number provided! Exiting."
exit 1 exit 1
fi fi
version=$1
(cd ../cmd && ./compile.sh --static $version)
# Prepare the output folder # Prepare the output folder
if [[ -e dpkg_tmp ]] if [[ -e dpkg_tmp ]]
@ -32,7 +35,7 @@ cp Twitter.desktop dpkg_tmp/usr/share/applications/Twitter.desktop
# Create the `DEBIAN/control` file # Create the `DEBIAN/control` file
mkdir dpkg_tmp/DEBIAN mkdir dpkg_tmp/DEBIAN
echo "Package: offline-twitter echo "Package: offline-twitter
Version: $1 Version: $version
Architecture: all Architecture: all
Maintainer: alex@playfulpachyderm.com Maintainer: alex@playfulpachyderm.com
Installed-Size: `du -k dpkg_tmp | tail -n 1 | cut -f 1` Installed-Size: `du -k dpkg_tmp | tail -n 1 | cut -f 1`

View File

@ -6,13 +6,25 @@ set -e
# General build flags # General build flags
FLAGS="-s -w -X gitlab.com/offline-twitter/twitter_offline_engine/internal/webserver.use_embedded=true" FLAGS="-s -w -X gitlab.com/offline-twitter/twitter_offline_engine/internal/webserver.use_embedded=true"
if [[ -n "$1" ]]; then # Check for the `--static` flag and consume it
USE_STATIC=false
if [[ "$1" == "--static" ]] || [[ "$1" == "-static" ]]; then
USE_STATIC=true
shift
fi
if [[ -z "$1" ]]; then
# If no version string, it's a development build
go build -ldflags="$FLAGS" -o tw ./twitter
elif $USE_STATIC; then
# Static build params # Static build params
export CGO_ENABLED=1 export CGO_ENABLED=1
export CC=musl-gcc export CC=musl-gcc
SPECIAL_FLAGS_FOR_STATIC_BUILD="-linkmode=external -extldflags=-static" SPECIAL_FLAGS_FOR_STATIC_BUILD="-linkmode=external -extldflags=-static"
go build -ldflags="$FLAGS $SPECIAL_FLAGS_FOR_STATIC_BUILD -X main.version_string=$1" -o tw ./twitter go build -ldflags="$FLAGS $SPECIAL_FLAGS_FOR_STATIC_BUILD -X main.version_string=$1" -o tw ./twitter
else else
go build -ldflags="$FLAGS" -o tw ./twitter # Version string, but not static
go build -ldflags="$FLAGS -X main.version_string=$1" -o tw ./twitter
fi fi
chmod +x tw chmod +x tw

View File

@ -13,4 +13,7 @@ if [[ -z "$1" ]]; then
exit 1 exit 1
fi fi
go build -ldflags="-linkmode external -extldflags -static -s -w -X main.version_string=$1 -X gitlab.com/offline-twitter/twitter_offline_engine/internal/webserver.use_embedded=true" -o twitter.exe ./twitter # Always use static build for windows
FLAGS="-s -w -X gitlab.com/offline-twitter/twitter_offline_engine/internal/webserver.use_embedded=true"
SPECIAL_FLAGS_FOR_STATIC_BUILD="-linkmode=external -extldflags=-static"
go build -ldflags="$FLAGS $SPECIAL_FLAGS_FOR_STATIC_BUILD -X main.version_string=$1" -o twitter.exe ./twitter