mirror of
https://github.com/grafana/grafana.git
synced 2025-09-16 17:22:58 +08:00

* wip so far. need to prove rebuilds work * build common runner image * glibc support * ubuntu * add conditional * add support for cross-os builds * format * don't use zig by default on macos * use postgres * tidy up * more tidy * update readme * remove errant changes
31 lines
1005 B
Bash
Executable File
31 lines
1005 B
Bash
Executable File
#!/bin/bash
|
|
|
|
cd ../../
|
|
|
|
echo "Go mod cache: $(go env GOMODCACHE), $(ls -1 $(go env GOMODCACHE) | wc -l) items"
|
|
echo "Go build cache: $(go env GOCACHE), $(ls -1 $(go env GOCACHE) | wc -l) items"
|
|
|
|
# Set cross-compilation env vars only on macOS (Darwin)
|
|
if [[ "$(uname)" == "Darwin" ]]; then
|
|
echo "Setting up cross-compilation environment for macOS"
|
|
export CGO_ENABLED=0
|
|
export GOOS=linux
|
|
export GOARCH=arm64
|
|
fi
|
|
|
|
# It's not used by default now that we have CGO-less builds, but keeping this here for a
|
|
# little bit in case it causes issues for anyone.
|
|
if [[ -n "$USE_ZIG" ]]; then
|
|
echo "Using Zig for cross-compilation"
|
|
export CGO_ENABLED=1
|
|
export CC="zig cc -target aarch64-linux"
|
|
export CXX="zig c++ -target aarch64-linux"
|
|
fi
|
|
|
|
# Need to build version into the binary so plugin compatibility works correctly
|
|
VERSION=$(jq -r .version package.json)
|
|
|
|
go build -v \
|
|
-ldflags "-X main.version=${VERSION}" \
|
|
-gcflags "all=-N -l" \
|
|
-o ./devenv/frontend-service/build/grafana ./pkg/cmd/grafana |