Skip to content

Commit

Permalink
Make statically linked binaries the default
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanBorislavovDimitrov committed Jan 4, 2024
1 parent 8c38579 commit e995c60
Showing 1 changed file with 37 additions and 37 deletions.
74 changes: 37 additions & 37 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function build() {
echo "building for $platform $arch"
GOOS=$platform GOARCH=$arch go build \
-ldflags "-X main.Version=${version}" \
-o ${plugin_name}
-o "${plugin_name}"
}

function buildstatic() {
Expand All @@ -21,18 +21,18 @@ function buildstatic() {
echo "building static for $platform $arch"
CGO_ENABLED=0 GOOS=$platform GOARCH=$arch go build -a -tags netgo \
-ldflags "-w -extldflags \"-static\" -X main.Version=${version}" \
-o ${plugin_name}
-o "${plugin_name}"
}

function movePluginsToBuildFolder() {
local folder=$1
mv $PLUGIN_NAME_WIN_32 $folder
mv $PLUGIN_NAME_WIN_64 $folder
mv $PLUGIN_NAME_LINUX_32 $folder
mv $PLUGIN_NAME_LINUX_64 $folder
mv $PLUGIN_NAME_LINUX_ARM64 $folder
mv $PLUGIN_NAME_OSX $folder
mv $PLUGIN_NAME_APPLE_ARM64 $folder
mv $PLUGIN_NAME_NON_STATIC_WIN_32 $folder
mv $PLUGIN_NAME_NON_STATIC_WIN_64 $folder
mv $PLUGIN_NAME_NON_STATIC_LINUX_32 $folder
mv $PLUGIN_NAME_NON_STATIC_LINUX_64 $folder
mv $PLUGIN_NAME_NON_STATIC_LINUX_ARM64 $folder
mv $PLUGIN_NAME_NON_STATIC_OSX $folder
mv $PLUGIN_NAME_NON_STATIC_APPLE_ARM64 $folder
mv $PLUGIN_NAME_STATIC_WIN_32 $folder
mv $PLUGIN_NAME_STATIC_WIN_64 $folder
mv $PLUGIN_NAME_STATIC_LINUX_32 $folder
Expand All @@ -53,38 +53,38 @@ script_dir="$(dirname -- "$(realpath -- "${BASH_SOURCE[0]}")")"
cd "${script_dir}"

BUILD_FOLDER=build
PLUGIN_NAME_WIN_32=multiapps-plugin.win32.exe
PLUGIN_NAME_WIN_64=multiapps-plugin.win64.exe
PLUGIN_NAME_LINUX_32=multiapps-plugin.linux32
PLUGIN_NAME_LINUX_64=multiapps-plugin.linux64
PLUGIN_NAME_LINUX_ARM64=multiapps-plugin.linuxarm64
PLUGIN_NAME_OSX=multiapps-plugin.osx
PLUGIN_NAME_APPLE_ARM64=multiapps-plugin.osxarm64
PLUGIN_NAME_NON_STATIC_WIN_32=multiapps-plugin-non-static.win32.exe
PLUGIN_NAME_NON_STATIC_WIN_64=multiapps-plugin-non-static.win64.exe
PLUGIN_NAME_NON_STATIC_LINUX_32=multiapps-plugin-non-static.linux32
PLUGIN_NAME_NON_STATIC_LINUX_64=multiapps-plugin-non-static.linux64
PLUGIN_NAME_NON_STATIC_LINUX_ARM64=multiapps-plugin-non-static.linuxarm64
PLUGIN_NAME_NON_STATIC_OSX=multiapps-plugin-non-static.osx
PLUGIN_NAME_NON_STATIC_APPLE_ARM64=multiapps-plugin-non-static.osxarm64

PLUGIN_NAME_STATIC_WIN_32=multiapps-plugin-static.win32.exe
PLUGIN_NAME_STATIC_WIN_64=multiapps-plugin-static.win64.exe
PLUGIN_NAME_STATIC_LINUX_32=multiapps-plugin-static.linux32
PLUGIN_NAME_STATIC_LINUX_64=multiapps-plugin-static.linux64
PLUGIN_NAME_STATIC_LINUX_ARM64=multiapps-plugin-static.linuxarm64
PLUGIN_NAME_STATIC_OSX=multiapps-plugin-static.osx
PLUGIN_NAME_STATIC_APPLE_ARM64=multiapps-plugin-static.osxarm64
PLUGIN_NAME_STATIC_WIN_32=multiapps-plugin.win32.exe
PLUGIN_NAME_STATIC_WIN_64=multiapps-plugin.win64.exe
PLUGIN_NAME_STATIC_LINUX_32=multiapps-plugin.linux32
PLUGIN_NAME_STATIC_LINUX_64=multiapps-plugin.linux64
PLUGIN_NAME_STATIC_LINUX_ARM64=multiapps-plugin.linuxarm64
PLUGIN_NAME_STATIC_OSX=multiapps-plugin.osx
PLUGIN_NAME_STATIC_APPLE_ARM64=multiapps-plugin.osxarm64

version=$(<cfg/VERSION)
build $version linux 386 $PLUGIN_NAME_LINUX_32
build $version linux amd64 $PLUGIN_NAME_LINUX_64
build $version linux arm64 $PLUGIN_NAME_LINUX_ARM64
build $version windows 386 $PLUGIN_NAME_WIN_32
build $version windows amd64 $PLUGIN_NAME_WIN_64
build $version darwin amd64 $PLUGIN_NAME_OSX
build $version darwin arm64 $PLUGIN_NAME_APPLE_ARM64
build "$version" linux 386 $PLUGIN_NAME_NON_STATIC_LINUX_32
build "$version" linux amd64 $PLUGIN_NAME_NON_STATIC_LINUX_64
build "$version" linux arm64 $PLUGIN_NAME_NON_STATIC_LINUX_ARM64
build "$version" windows 386 $PLUGIN_NAME_NON_STATIC_WIN_32
build "$version" windows amd64 $PLUGIN_NAME_NON_STATIC_WIN_64
build "$version" darwin amd64 $PLUGIN_NAME_NON_STATIC_OSX
build "$version" darwin arm64 $PLUGIN_NAME_NON_STATIC_APPLE_ARM64

buildstatic $version linux 386 $PLUGIN_NAME_STATIC_LINUX_32
buildstatic $version linux amd64 $PLUGIN_NAME_STATIC_LINUX_64
buildstatic $version linux arm64 $PLUGIN_NAME_STATIC_LINUX_ARM64
buildstatic $version windows 386 $PLUGIN_NAME_STATIC_WIN_32
buildstatic $version windows amd64 $PLUGIN_NAME_STATIC_WIN_64
buildstatic $version darwin amd64 $PLUGIN_NAME_STATIC_OSX
buildstatic $version darwin arm64 $PLUGIN_NAME_STATIC_APPLE_ARM64
buildstatic "$version" linux 386 $PLUGIN_NAME_STATIC_LINUX_32
buildstatic "$version" linux amd64 $PLUGIN_NAME_STATIC_LINUX_64
buildstatic "$version" linux arm64 $PLUGIN_NAME_STATIC_LINUX_ARM64
buildstatic "$version" windows 386 $PLUGIN_NAME_STATIC_WIN_32
buildstatic "$version" windows amd64 $PLUGIN_NAME_STATIC_WIN_64
buildstatic "$version" darwin amd64 $PLUGIN_NAME_STATIC_OSX
buildstatic "$version" darwin arm64 $PLUGIN_NAME_STATIC_APPLE_ARM64

mkdir -p $BUILD_FOLDER
createBuildMetadataFiles $version $BUILD_FOLDER
Expand Down

0 comments on commit e995c60

Please sign in to comment.