From c0f8a31d8257d029ce570bb33fd675c11fbc83d7 Mon Sep 17 00:00:00 2001 From: Orpheus Lummis Date: Fri, 4 Nov 2022 06:11:12 -0400 Subject: [PATCH] chore: Include version metadata in cross-building (#930) --- Makefile | 7 +++++++ tools/scripts/cross-build.sh | 6 ++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index b285af0ec3..370d551ed4 100644 --- a/Makefile +++ b/Makefile @@ -32,9 +32,16 @@ default: install: @go install $(BUILD_FLAGS) ./cmd/defradb +# Usage: +# - make build +# - make build path="path/to/defradb-binary" .PHONY: build build: +ifeq ($(path),) @go build $(BUILD_FLAGS) -o build/defradb cmd/defradb/main.go +else + @go build $(BUILD_FLAGS) -o $(path) cmd/defradb/main.go +endif # Usage: make cross-build platforms="{platforms}" # platforms is specified as a comma-separated list with no whitespace, e.g. "linux/amd64,linux/arm,linux/arm64" diff --git a/tools/scripts/cross-build.sh b/tools/scripts/cross-build.sh index ce5d302b13..d5bbbc4194 100755 --- a/tools/scripts/cross-build.sh +++ b/tools/scripts/cross-build.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash -DEFRADB_MAIN="cmd/defradb/main.go" +# Cross-compilation script for DefraDB. +# We assume we run this from a position where DefraDB's build toolchain (go, make, ...) is available. + BUILD_DIR="build/" platforms=$1 @@ -31,7 +33,7 @@ do if [ "$GOOS" = "windows" ]; then output_name+='.exe' fi - if ! env GOOS="$GOOS" GOARCH="$GOARCH" go build -o $output_name $DEFRADB_MAIN; then + if ! env GOOS="$GOOS" GOARCH="$GOARCH" make build path="$output_name"; then echo 'An error has occurred! Aborting the script execution...' exit 1 fi