add build-cross for local cross building
This commit is contained in:
@@ -3,4 +3,18 @@ build:
|
||||
CGO_ENABLED=1 go build -mod=vendor -o service main.go
|
||||
|
||||
build-static:
|
||||
CGO_ENABLED=1 go build -mod=vendor -tags=embed -o service main.go
|
||||
CGO_ENABLED=1 go build -mod=vendor -tags=embed -o service main.go
|
||||
|
||||
build-armhf:
|
||||
GOARCH=arm \
|
||||
ARCH=armhf \
|
||||
DEPS="gcc-arm-linux-gnueabihf libc6-dev-armhf-cross" \
|
||||
PREFIX=arm-linux-gnueabihf \
|
||||
./build-cross.sh
|
||||
|
||||
build-arm64:
|
||||
GOARCH=arm64 \
|
||||
ARCH=arm64 \
|
||||
DEPS="gcc-aarch64-linux-gnu libc6-dev-arm64-cross" \
|
||||
PREFIX=aarch64-linux-gnu \
|
||||
./build-cross.sh
|
||||
|
||||
Executable
+29
@@ -0,0 +1,29 @@
|
||||
#!/bin/sh
|
||||
|
||||
GOVERSION=${GOVERSION:-1.20.5}
|
||||
CONTAINER=${PREFIX}-${ARCH}
|
||||
|
||||
# prepare
|
||||
podman build -t ${CONTAINER} -f - <<EOF
|
||||
FROM debian:stable-slim
|
||||
|
||||
RUN dpkg --add-architecture ${ARCH}
|
||||
RUN apt-get update && apt-get install --yes --no-install-recommends make curl ca-certificates libgstreamer1.0-dev:${ARCH} libgstreamer-plugins-base1.0-dev:${ARCH} ${DEPS}
|
||||
|
||||
WORKDIR /go
|
||||
RUN curl -L "https://go.dev/dl/go${GOVERSION}.linux-amd64.tar.gz" | tar xzf - --strip-components 1
|
||||
ENV PATH "$PATH:/go/bin"
|
||||
|
||||
ENV CGO_ENABLED 1
|
||||
ENV GOOS "linux"
|
||||
ENV GOARCH "${GOARCH}"
|
||||
ENV CC "${PREFIX:+$PREFIX-}gcc"
|
||||
ENV PKG_CONFIG_PATH "/usr/lib/${PREFIX}/pkgconfig"
|
||||
EOF
|
||||
|
||||
podman run \
|
||||
--rm \
|
||||
--volume ./:/data \
|
||||
--workdir /data \
|
||||
${CONTAINER} \
|
||||
go build -mod=vendor -tags=embed -o service-${GOOS}-${GOARCH} main.go
|
||||
Reference in New Issue
Block a user