pkg/client-sdk/wasm: build wasm (#238)

Signed-off-by: tiero <3596602+tiero@users.noreply.github.com>
This commit is contained in:
Marco Argentieri
2024-08-12 16:40:27 +02:00
committed by GitHub
parent 72a7f29bab
commit c559b91fec
17 changed files with 273 additions and 44 deletions

View File

@@ -1,18 +1,32 @@
#!/bin/bash
set -e
# Get the parent directory path
PARENT_PATH=$(dirname $(
cd $(dirname $0)
pwd -P
cd $(dirname $0)
pwd -P
))
OS=$(eval "go env GOOS")
ARCH=$(eval "go env GOARCH")
# Set VERSION (you can modify this to get the version from a file or environment variable)
VERSION=$(git describe --tags --always --dirty 2>/dev/null || echo "unknown")
# Get OS and ARCH
OS=$(go env GOOS)
ARCH=$(go env GOARCH)
echo "Building arkd for $OS $ARCH"
echo "Version: $VERSION"
# Change to the parent directory
pushd $PARENT_PATH
# Create build directory if it doesn't exist
mkdir -p build
GO111MODULE=on go build -o build/arkd-$OS-$ARCH ./cmd/arkd
popd
# Build the binary with version information
go build -ldflags="-s -w -X 'main.Version=$VERSION'" -o build/arkd-$OS-$ARCH ./cmd/arkd
echo "Build complete: build/arkd-$OS-$ARCH"
# Return to the original directory
popd

View File

@@ -1,23 +1,46 @@
#!/bin/bash
set -e
# Get the parent directory path
PARENT_PATH=$(dirname $(
cd $(dirname $0)
pwd -P
cd $(dirname $0)
pwd -P
))
# Set VERSION (you can modify this to get the version from a file or environment variable)
VERSION=$(git describe --tags --always --dirty 2>/dev/null || echo "unknown")
# Define OS and ARCH arrays
declare -a OS=("darwin" "linux")
declare -a ARCH=("amd64" "arm64")
# Change to the parent directory
pushd $PARENT_PATH
mkdir -p build
# Function to handle errors
handle_error() {
echo "Error occurred in build for $1 $2"
echo "Build command: VERSION=$VERSION GOOS=$1 GOARCH=$2 ./scripts/build"
echo "Exit code: $3"
echo "You may want to run this build manually to see more detailed error messages."
}
echo "Starting builds for version: $VERSION"
# Loop through OS and ARCH combinations
for os in "${OS[@]}"; do
for arch in "${ARCH[@]}"; do
echo "Building for $os $arch"
GOOS=$os GOARCH=$arch go build -o build/arkd-$os-$arch cmd/arkd/main.go
done
for arch in "${ARCH[@]}"; do
echo "Building for $os $arch"
if VERSION=$VERSION GOOS=$os GOARCH=$arch ./scripts/build; then
echo "Build successful for $os $arch"
else
handle_error $os $arch $?
fi
echo "------------------------"
done
done
popd
# Return to the original directory
popd
echo "All builds completed for version $VERSION."