feat: setup cross compilation

This commit is contained in:
Aravinth Manivannan 2023-10-23 18:54:44 +05:30
parent dcadca1e6f
commit 6a41f7fa0b
Signed by: realaravinth
GPG key ID: F8F50389936984FF
4 changed files with 115 additions and 0 deletions

4
.env.dev.sample Normal file
View file

@ -0,0 +1,4 @@
export GPG_PASSWORD=yourgpgkeypassword
export KEY=yourgpgkeyid
export DUMBSERVE_USERNAME=username
export DUMBSERVE_PASSWORD=password

2
.gitignore vendored
View file

@ -2,3 +2,5 @@
tarpaulin-report.html tarpaulin-report.html
.env .env
out out
dist/
build/

71
Makefile Normal file
View file

@ -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")

38
pack.sh Executable file
View file

@ -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