-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tools: Fix the cross-build script (#460)
A cross build scripts that works for multiple target platforms and is located in `tools/scripts`. Additionally, with this commit, the top-level `build` directory goes away.
- Loading branch information
1 parent
9f896b2
commit 51d7aa5
Showing
3 changed files
with
45 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env bash | ||
|
||
DEFRADB_MAIN="cli/defradb/main.go" | ||
BUILD_DIR="build/" | ||
|
||
platforms=$1 | ||
if [[ -z "${platforms}" ]]; then | ||
echo "Building for all platforms" | ||
# A subset of the comprehensive list found at https://go.dev/doc/install/source#environment | ||
platforms=( | ||
"windows/amd64" | ||
"windows/arm64" | ||
"windows/arm" | ||
"linux/amd64" | ||
"linux/arm64" | ||
"linux/arm" | ||
"darwin/amd64" | ||
"darwin/arm64" | ||
# "js/wasm" | ||
) | ||
else | ||
platforms=(${platforms//,/ }) | ||
fi | ||
|
||
for platform in "${platforms[@]}" | ||
do | ||
platform_split=(${platform//\// }) | ||
GOOS="${platform_split[0]}" | ||
GOARCH="${platform_split[1]}" | ||
output_name=$BUILD_DIR'defradb-'$GOOS'-'$GOARCH | ||
if [ "$GOOS" = "windows" ]; then | ||
output_name+='.exe' | ||
fi | ||
if ! env GOOS="$GOOS" GOARCH="$GOARCH" go build -o $output_name $DEFRADB_MAIN; then | ||
echo 'An error has occurred! Aborting the script execution...' | ||
exit 1 | ||
fi | ||
echo "Completed: ${output_name}" | ||
done |