Skip to content

Commit

Permalink
chore: Include version metadata in cross-building (#930)
Browse files Browse the repository at this point in the history
  • Loading branch information
orpheuslummis committed Nov 4, 2022
1 parent a530749 commit c0f8a31
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 4 additions & 2 deletions tools/scripts/cross-build.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c0f8a31

Please sign in to comment.