From 6a41f7fa0b6e5bf0323169a159bb9420e372b92f Mon Sep 17 00:00:00 2001 From: Aravinth Manivannan Date: Mon, 23 Oct 2023 18:54:44 +0530 Subject: [PATCH] feat: setup cross compilation --- .env.dev.sample | 4 +++ .gitignore | 2 ++ Makefile | 71 +++++++++++++++++++++++++++++++++++++++++++++++++ pack.sh | 38 ++++++++++++++++++++++++++ 4 files changed, 115 insertions(+) create mode 100644 .env.dev.sample create mode 100644 Makefile create mode 100755 pack.sh diff --git a/.env.dev.sample b/.env.dev.sample new file mode 100644 index 0000000..6665755 --- /dev/null +++ b/.env.dev.sample @@ -0,0 +1,4 @@ +export GPG_PASSWORD=yourgpgkeypassword +export KEY=yourgpgkeyid +export DUMBSERVE_USERNAME=username +export DUMBSERVE_PASSWORD=password diff --git a/.gitignore b/.gitignore index 9a6de14..12ea7fa 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ tarpaulin-report.html .env out +dist/ +build/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ec0668e --- /dev/null +++ b/Makefile @@ -0,0 +1,71 @@ +install.rust: + rustup target add aarch64-linux-android + rustup target add aarch64-unknown-linux-gnu + rustup target add aarch64-unknown-linux-musl + rustup target add arm-linux-androideabi + rustup target add arm-unknown-linux-gnueabi + rustup target add arm-unknown-linux-gnueabihf + rustup target add arm-unknown-linux-musleabi + rustup target add arm-unknown-linux-musleabihf + rustup target add i586-unknown-linux-gnu + rustup target add i586-unknown-linux-musl + rustup target add i686-pc-windows-gnu + rustup target add armv5te-unknown-linux-gnueabi + rustup target add armv5te-unknown-linux-musleabi + rustup target add armv7-linux-androideabi + rustup target add armv7-unknown-linux-gnueabi + rustup target add armv7-unknown-linux-gnueabihf + rustup target add armv7-unknown-linux-musleabi + rustup target add armv7-unknown-linux-musleabihf + rustup target add i686-unknown-freebsd + rustup target add i686-unknown-linux-gnu + rustup target add i686-unknown-linux-musl + rustup target add powerpc-unknown-linux-gnu + rustup target add powerpc64-unknown-linux-gnu + rustup target add x86_64-linux-android + rustup target add x86_64-pc-windows-gnu + rustup target add x86_64-unknown-freebsd + rustup target add x86_64-unknown-linux-gnu + rustup target add x86_64-unknown-linux-musl + rustup target add x86_64-unknown-netbsd + +define build + rm -rf target/ + cross build --release --target $(1) + mkdir -p build2/$(1) + @rm target/$(1)/release/mcaptcha-cli.d + mv target/$(1)/release/mcaptcha-cli* build2/$(1)/ + rm -rf target/ +endef + +build.all: + @rm -rf build/ + @$(call build,"aarch64-linux-android") + @$(call build,"aarch64-unknown-linux-gnu") + @$(call build,"aarch64-unknown-linux-musl") + @$(call build,"arm-linux-androideabi") + @$(call build,"arm-unknown-linux-gnueabi") + @$(call build,"arm-unknown-linux-gnueabihf") + @$(call build,"arm-unknown-linux-musleabi") + @$(call build,"arm-unknown-linux-musleabihf") + @$(call build,"i586-unknown-linux-gnu") + @$(call build,"i586-unknown-linux-musl") + @$(call build,"i686-pc-windows-gnu") + @$(call build,"armv5te-unknown-linux-gnueabi") + @$(call build,"armv5te-unknown-linux-musleabi") + @$(call build,"armv7-linux-androideabi") + @$(call build,"armv7-unknown-linux-gnueabi") + @$(call build,"armv7-unknown-linux-gnueabihf") + @$(call build,"armv7-unknown-linux-musleabi") + @$(call build,"armv7-unknown-linux-musleabihf") + @$(call build,"i686-unknown-freebsd") + @$(call build,"i686-unknown-linux-gnu") + @$(call build,"i686-unknown-linux-musl") + @$(call build,"powerpc-unknown-linux-gnu") + @$(call build,"powerpc64-unknown-linux-gnu") + @$(call build,"x86_64-linux-android") + @$(call build,"x86_64-pc-windows-gnu") + @$(call build,"x86_64-unknown-freebsd") + @$(call build,"x86_64-unknown-linux-gnu") + @$(call build,"x86_64-unknown-linux-musl") + @$(call build,"x86_64-unknown-netbsd") diff --git a/pack.sh b/pack.sh new file mode 100755 index 0000000..6b9ae41 --- /dev/null +++ b/pack.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +set -xEeuo pipefail + +GPG_TTY=$(tty) +DIST_DIR=dist + +pack() { + SRC=build/$1/ + TARBALL=$DIST_DIR/$1.tar.gz + + + cp README.md $SRC + cp LICENSE.md $SRC + tar -cvzf $TARBALL $SRC + gpg --verbose \ + --pinentry-mode loopback \ + --batch --yes \ + --passphrase $GPG_PASSWORD \ + --local-user $KEY \ + --output $TARBALL.asc \ + --sign --detach \ + --armor $TARBALL + pushd $DIST_DIR + local_tar=$1.tar.gz + sha256sum $local_tar > $local_tar.sha256 + sha256sum $local_tar.asc >> $local_tar.sha256 + popd +} + +rm -rf $DIST_DIR +mkdir $DIST_DIR + +for i in build/* +do + arch=$(echo $i | cut -d '/' -f 2) + pack $arch +done