Skip to content

Commit

Permalink
Merge pull request #1 from psyberfly/trunk
Browse files Browse the repository at this point in the history
Linux binary build with Docker
  • Loading branch information
i5hi authored Feb 3, 2024
2 parents 38f9f24 + 9bb7a02 commit 113e174
Show file tree
Hide file tree
Showing 7 changed files with 357 additions and 317 deletions.
6 changes: 4 additions & 2 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ name = "boltzclient"
doctest = false
crate-type = ["staticlib", "cdylib", "lib"]

[target.x86_64-unknown-linux-gnu]
linker = "x86_64-unknown-linux-gnu-gcc"
#Needed to build linux bin without docker
#[target.x86_64-unknown-linux-gnu]
#linker = "x86_64-unknown-linux-gnu-gcc"


[dependencies]
boltz-client = { version = "0.1.2"}
Expand Down
16 changes: 11 additions & 5 deletions rust/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FROM amd64/rust:slim-bullseye
ARG USER_ID
ARG VERSION

RUN if getent passwd $USER_ID >/dev/null; then \
existing_user=$(getent passwd $USER_ID | cut -d: -f1) && \
Expand All @@ -18,19 +19,24 @@ RUN apt-get update --allow-releaseinfo-change && \
openssl libssl-dev git expect jq lsb-release tree \
pkg-config autoconf libtool neovim

// CHANGE THIS TO ONLY USE LINUX TARGETS
RUN rustup target add x86_64-unknown-linux-gnu

RUN mkdir /.cargo
COPY config /.cargo/config
RUN chown -R debian /.cargo

RUN cargo
COPY Cargo.toml /.cargo/config
ENV CARGO_HOME=/.cargo
ENV NDK_VERSION=23.0.7599858


VOLUME ["/boltz-dart"]

# WORKDIR /boltz-dart

#Used for cargo build to find Cargo.toml

RUN rustup target add x86_64-unknown-linux-gnu
#RUN TARGET_CC=x86_64-unknown-linux-gnu cargo build --target-dir ./boltz-dart -r --target=x86_64-unknown-linux-gnu


COPY docker-entrypoint.sh /usr/bin
USER debian

Expand Down
3 changes: 1 addition & 2 deletions rust/build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/bin/bash -e
./android.sh
./darwin.sh
./linux.sh
exit
3 changes: 2 additions & 1 deletion rust/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash
/boltz-dart/rust/build.sh
cd boltz-dart || exit 1
bash linux.sh "$VERSION"
exec "$@"
12 changes: 9 additions & 3 deletions rust/linux.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
#!/bin/bash
ROOT="target"
VERSION="0.1.2"
VERSION=$1
NAME="libboltz"
LINUX_DIR=$ROOT/$NAME.$VERSION/linux # final binaries stored here
# aarch64-unknown-linux-gnu \
# arm-unknown-linux-gnueabi \
# armv7-unknown-linux-gnueabi \
# i686-unknown-linux-gnu \

for TARGET in \
x86_64-unknown-linux-gnu
x86_64-unknown-linux-gnu
# aarch64-unknown-linux-gnu install using docker image amd-64/rust:slim-bullseye requires aarch64-linux-gnu-gcc

do
rustup target add $TARGET
TARGET_CC=x86_64-unknown-linux-gnu cargo build --target-dir $LINUX_DIR -r --target=x86_64-unknown-linux-gnu
cargo build --release --target=$TARGET
done

mkdir -p $LINUX_DIR/x86_64
cp $ROOT/x86_64-unknown-linux-gnu/release/libboltzclient.so $LINUX_DIR/x86_64/
22 changes: 12 additions & 10 deletions rust/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,23 @@ init:

## all: Compile iOS, Android and bindings targets
all: init jnilib xcframework linux

linux:
@echo "[Creating linux binary ...] $@"
sh linux.sh $(VERSION)
@echo "[Done ✅]"
@echo "[Creating linux binary ...] $@"
docker stop bwcbuilder01 ; docker rm bwcbuilder01; \
docker build --platform linux/x86_64 --build-arg USER_ID=$(shell id -u) --build-arg VERSION=$(VERSION) -t bwcbuilder . && \
docker run --platform linux/x86_64 --name bwcbuilder01 -v $(shell pwd):/boltz-dart bwcbuilder ; docker stop bwcbuilder01 ; docker rm bwcbuilder01
@echo "[Done ✅]"

jnilib:
@echo "[Creating android jniLibs ...] $@"
sh android.sh $(VERSION)
@echo "[Done ✅]"
@echo "[Creating android jniLibs ...] $@"
sh android.sh $(VERSION)
@echo "[Done ✅]"

xcframework:
@echo "[Creating rust_bdk_ffi.xcframework ...] $@"
sh darwin.sh $(VERSION)
@echo "[Done ✅]"
@echo "[Creating rust_bdk_ffi.xcframework ...] $@"
sh darwin.sh $(VERSION)
@echo "[Done ✅]"

# compress-build:
# @echo "[COMPRESSING BINARIES TO FLUTTER PACKAGE ...] $@"
Expand Down
Loading

0 comments on commit 113e174

Please sign in to comment.