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

Support plugin builds #856

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
27 changes: 24 additions & 3 deletions build-go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ function goBuild() {
local package="$1"
local goos="$2"
local goarch="$3"
local plugin="$4"

(
export GOOS="$goos"
if [[ "$goarch" == amd64-* ]]; then
Expand All @@ -106,10 +108,21 @@ function goBuild() {

local output
output="$(pwd)/$(basename "$package")$(go env GOEXE)"
go build -mod=mod -o "$output" \

local buildmode="default"
if [ "$plugin" = "true" ]; then
export CGO_ENABLED=1
buildmode="plugin"
fi

go build -buildmode="$buildmode" -mod=mod -o "$output" \
-trimpath \
"${package}"

if [ "$buildmode" = "plugin" ]; then
chmod +x "$output"
fi

if [ -x "$(which glibc-check)" ] && [ "$GOOS" == "linux" ] && [ "$GOARCH" == "amd64" ]; then
echo "GLIBC versions:"
glibc-check list-versions "$output"
Expand All @@ -124,6 +137,7 @@ function doBuild() {
local package=$3
local output=$4
local version=$5
local plugin=$6

local dir name binname

Expand All @@ -144,7 +158,7 @@ function doBuild() {

mkdir -p "$dir"

if ! (cd "$build_dir_name" && goBuild "$package" "$goos" "$goarch") > build-log; then
if ! (cd "$build_dir_name" && goBuild "$package" "$goos" "$goarch" "$plugin") > build-log; then
local logfi="$dir/build-log-$goos-$goarch"
cp "$build_dir_name/build-log" "$logfi"
warn " $binname failed. logfile at '$logfi'"
Expand Down Expand Up @@ -211,6 +225,7 @@ function printInitialDistfile() {
"owner": "$(< repo-owner)",
"description": "$(< description)",
"date": "$(date -u '+%B %d, %Y')",
"plugin": "$plugin",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is this set? (sorry if this is just obvious, my shell is pretty meh)

"platforms": {}
}
EOF
Expand Down Expand Up @@ -240,13 +255,19 @@ function buildWithMatrix() {
local distname
distname=$(basename "$(pwd)")

local plugin="false"
if [ -e plugin ]; then
plugin="true"
fi
Comment on lines +258 to +261
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you manually adding a plugin file to indicate something is a plugin? If so could you document it, and if not too painful add it to dist.sh new-go-dist? If it's a pain then just documenting should be fine.



printInitialDistfile "$distname" "$buildVersion" > dist.json
printBuildInfo "$commit" > "$output/build-info"

# build each os/arch combo
while read -r goos goarch
do
doBuild "$goos" "$goarch" "$package" "$output" "$buildVersion"
doBuild "$goos" "$goarch" "$package" "$output" "$buildVersion" "$plugin"
done < "$matfile"

# build the source
Expand Down