Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kola: build kolet statically #1896

Merged
merged 1 commit into from
Dec 1, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 25 additions & 9 deletions mantle/build
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,24 @@ EOM
}

host_build() {
echo "Building $1"
local cmd=$1; shift
echo "Building $cmd"
go build -i \
-ldflags "${ldflags}" \
-mod vendor \
-o "bin/$1" \
"${REPO_PATH}/cmd/$1"
-o "bin/$cmd" \
"$@" "${REPO_PATH}/cmd/$cmd"
}

host_static_build() {
local cmd=$1; shift
echo "Building $cmd (static)"
go build \
-ldflags "${ldflags} -extldflags=-static" \
-mod vendor \
-o "bin/$cmd" \
-tags osusergo,netgo \
"${REPO_PATH}/cmd/$cmd"
}

# Unused now, but kept in case we want it in the future
Expand All @@ -76,10 +88,14 @@ cross_build() {
}

for arg in "$@"; do
if [ "${arg}" = "schema" ]; then
schema_generate
else
cmd=$(basename "${arg}")
host_build "${cmd}"
fi
if [ "${arg}" = "schema" ]; then
schema_generate
else
cmd=$(basename "${arg}")
if [ "${cmd}" = "kolet" ]; then
host_static_build kolet
else
host_build "${cmd}"
fi
fi
done