Leah Hanson 2d03820ebb Make build.sh work for windows plugins.
When building the windows plugin exe's (host-local, flannel, win-overlay, win-bridge),
it was necessary to use 'GOOS=windows go build path/to/plugin' rather than the build script.

This makes 'GOOS=windows GOARCH=amd64 ./build.sh' build all the windows plugin binaries.
2018-10-17 16:44:57 -07:00

48 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
set -e
cd $(dirname "$0")
if [ "$(uname)" == "Darwin" ]; then
export GOOS="${GOOS:-linux}"
fi
ORG_PATH="github.com/containernetworking"
export REPO_PATH="${ORG_PATH}/plugins"
if [ ! -h gopath/src/${REPO_PATH} ]; then
mkdir -p gopath/src/${ORG_PATH}
ln -s ../../../.. gopath/src/${REPO_PATH} || exit 255
fi
export GOPATH=${PWD}/gopath
export GO="${GO:-go}"
mkdir -p "${PWD}/bin"
echo "Building plugins ${GOOS}"
if [[ $GOOS == "windows" ]]; then
PLUGINS=$(cat plugins/windows_only.txt)
if [ "$GOARCH" == "amd64" ]; then
for d in $PLUGINS; do
if [ -d "$d" ]; then
plugin="$(basename "$d").exe"
echo " $plugin"
$GO build -o "${PWD}/bin/$plugin" "$@" "$REPO_PATH"/$d
fi
done
else
echo "Could not build windows plugins when GOARCH != amd64"
fi
else
PLUGINS="plugins/meta/* plugins/main/* plugins/ipam/* plugins/sample"
for d in $PLUGINS; do
if [ -d "$d" ]; then
plugin="$(basename "$d")"
if [ $plugin != "windows" ]; then
echo " $plugin"
$GO build -o "${PWD}/bin/$plugin" "$@" "$REPO_PATH"/$d
fi
fi
done
fi