Skip to content

Commit

Permalink
Merge pull request #27 from puellanivis/feature/add-support-for-arm64
Browse files Browse the repository at this point in the history
Add support for ARM64
  • Loading branch information
puellanivis authored Apr 11, 2023
2 parents b7166c6 + 9f628dc commit 163970a
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 20 deletions.
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ module github.com/puellanivis/breton
go 1.16

require (
github.com/aws/aws-sdk-go v1.40.27
github.com/aws/aws-sdk-go v1.44.240
github.com/pkg/errors v0.9.1
github.com/pkg/sftp v1.13.2
github.com/prometheus/client_golang v1.11.0
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5
golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d
golang.org/x/text v0.3.7
github.com/pkg/sftp v1.13.5
github.com/prometheus/client_golang v1.14.0
golang.org/x/crypto v0.8.0
golang.org/x/net v0.9.0
golang.org/x/text v0.9.0
)
30 changes: 18 additions & 12 deletions masher/mash.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/bin/bash

ARCH="amd64"
ARCH_DIR="x86_64"

while [[ $# -gt 0 ]]; do
key="$1"
val="${key#*=}"
Expand All @@ -21,6 +24,10 @@ while [[ $# -gt 0 ]]; do
export GOPRIVATE="$val"
;;

--arm64)
ARCH="arm64"
ARCH_DIR="arm64"
;;
--linux)
LINUX="true"
;;
Expand Down Expand Up @@ -210,42 +217,42 @@ if [[ -r ./.gitignore ]]; then
fi

if [[ $LINUX == "true" ]]; then
OUT="bin/linux.x86_64"
OUT="bin/linux.${ARCH_DIR}"
echo "Compiling ${OUT}/${PROJECT}"
[ -d "$OUT" ] || mkdir -p $OUT || exit 1
GOOS=linux GOARCH=amd64 go build -o "${OUT}/${PROJECT}" "${LDFLAGS}" || exit 1
GOOS=linux GOARCH=$ARCH go build -o "${OUT}/${PROJECT}" "${LDFLAGS}" || exit 1

[[ ( ${DEB} != "false" ) && ( -d debian ) ]] && DEB="true"
fi

if [[ $DARWIN == "true" ]]; then
OUT="bin/darwin.x86_64"
OUT="bin/darwin.${ARCH_DIR}"
echo "Compiling ${OUT}/${PROJECT}"
[ -d "$OUT" ] || mkdir -p $OUT || exit 1
GOOS=darwin GOARCH=amd64 go build -o "${OUT}/${PROJECT}" "${LDFLAGS}" || exit 1
GOOS=darwin GOARCH=$ARCH go build -o "${OUT}/${PROJECT}" "${LDFLAGS}" || exit 1
fi

if [[ $OPENBSD == "true" ]]; then
OUT="bin/openbsd.x86_64"
OUT="bin/openbsd.${ARCH_DIR}"
echo "Compiling ${OUT}/${PROJECT}"
[ -d "$OUT" ] || mkdir -p $OUT || exit 1
GOOS=openbsd GOARCH=amd64 go build -o "${OUT}/${PROJECT}" "${LDFLAGS}" || exit 1
GOOS=openbsd GOARCH=$ARCH go build -o "${OUT}/${PROJECT}" "${LDFLAGS}" || exit 1
fi

if [[ $WINDOWS == "true" ]]; then
OUT="bin/windows.x86_64"
OUT="bin/windows.${ARCH_DIR}"
echo "Compiling ${OUT}/${PROJECT}.exe"
[ -d "$OUT" ] || mkdir -p $OUT || exit 1
GOOS=windows GOARCH=amd64 go build -o "${OUT}/${PROJECT}.exe" "${LDFLAGS}" || exit 1
GOOS=windows GOARCH=$ARCH go build -o "${OUT}/${PROJECT}.exe" "${LDFLAGS}" || exit 1
fi

if [[ ( $DEB == "true" ) && ( -x bin/linux.x86_64/${PROJECT} ) ]]; then
if [[ ( $DEB == "true" ) && ( -x bin/linux.${ARCH_DIR}/${PROJECT} ) ]]; then
[ -d debian ] || mkdir debian

echo "Building debian package..."

VERSION="${BUILDSTAMP}"
BIN_VERSION="$( ./bin/linux.x86_64/${PROJECT} --version )"
BIN_VERSION="$( ./bin/linux.${ARCH_DIR}/${PROJECT} --version )"
[[ -n $BIN_VERSION ]] && echo "BIN_VERSION=\"$BIN_VERSION\""
case "${BIN_VERSION}" in
*\ v*)
Expand All @@ -254,7 +261,6 @@ if [[ ( $DEB == "true" ) && ( -x bin/linux.x86_64/${PROJECT} ) ]]; then
;;
esac
echo "VERSION=${VERSION}"
ARCH="amd64" # TODO(puellanivis): this shouldn’t be baked in, but it’s already baked in all over, already.

if [[ -r ./.gitignore ]]; then
grep -qFx -e "build" ./.gitignore || echo "build" >> ./.gitignore
Expand Down Expand Up @@ -354,7 +360,7 @@ EOF

# install binary
install -d build/usr/bin
install -m755 "bin/linux.x86_64/${PROJECT}" "build/usr/bin/${PROJECT}"
install -m755 "bin/linux.${ARCH_DIR}/${PROJECT}" "build/usr/bin/${PROJECT}"

if [[ ( -n ${DEB_PACKAGE} ) && ( -n ${VERSION} ) && ( -n ${ARCH} ) ]]; then
DEB_FILE="${DEB_PACKAGE}_${VERSION}_${ARCH}.deb"
Expand Down
19 changes: 17 additions & 2 deletions masher/masher
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ DARWIN=""
LINUX=""
OPENBSD=""
WINDOWS=""
ARM64=""
if [[ -n ${MASHALL} ]]; then
DARWIN="--darwin"
LINUX="--linux"
Expand Down Expand Up @@ -60,6 +61,13 @@ else
esac
fi

CPU="$( uname -m )"
case $CPU in
arm64)
ARM64="--arm64"
;;
esac

while [[ $# -gt 0 ]]; do
key="$1"
val="${key#*=}"
Expand All @@ -72,6 +80,13 @@ while [[ $# -gt 0 ]]; do
REGISTRY="$val"
;;

--arm64)
ARM64="--arm64"
;;
--x86_64|--amd64)
ARM64=""
;;

--darwin)
DARWINFLAG="--darwin"
;;
Expand Down Expand Up @@ -278,7 +293,7 @@ fi
TIMESTAMP="$(date -u +"%Y%m%d.%H%M%S")"

echo Using image: ${IMAGE}
echo /bin/mash.sh ${ESCAPE} ${DARWIN} ${LINUX} ${OPENBSD} ${WINDOWS} ${TEST} ${PROTO} ${BUILD} ${CACHE} ${PRIVATE} ${BUILD_VERSION} --timestamp=${TIMESTAMP} --id=${HASHID} $@
echo /bin/mash.sh ${ESCAPE} ${ARM64} ${DARWIN} ${LINUX} ${OPENBSD} ${WINDOWS} ${TEST} ${PROTO} ${BUILD} ${CACHE} ${PRIVATE} ${BUILD_VERSION} --timestamp=${TIMESTAMP} --id=${HASHID} $@

DOCKER_VERSION="$(docker --version)"
DOCKER_VERSION="${DOCKER_VERSION%%,*}"
Expand Down Expand Up @@ -378,7 +393,7 @@ ${EXEC} docker run ${FLAGS} --rm \
$LIBS \
--workdir "${SRCROOT}/${PRJPATH}" \
${IMAGE} \
/bin/mash.sh ${ESCAPE} ${DARWIN} ${LINUX} ${OPENBSD} ${WINDOWS} ${TEST} ${PROTO} ${BUILD} ${CACHE} ${PRIVATE} ${BUILD_VERSION} --timestamp="${TIMESTAMP}" --id="${HASHID}" "$@" || exit 1
/bin/mash.sh ${ESCAPE} ${ARM64} ${DARWIN} ${LINUX} ${OPENBSD} ${WINDOWS} ${TEST} ${PROTO} ${BUILD} ${CACHE} ${PRIVATE} ${BUILD_VERSION} --timestamp="${TIMESTAMP}" --id="${HASHID}" "$@" || exit 1

if [[ $PROD == "true" ]]; then
make push || exit 1
Expand Down

0 comments on commit 163970a

Please sign in to comment.