Skip to content

Commit

Permalink
refactor:dockerfile, linux.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
Anorak committed Feb 3, 2024
1 parent 23967fe commit 9bb7a02
Show file tree
Hide file tree
Showing 5 changed files with 338 additions and 309 deletions.
3 changes: 2 additions & 1 deletion 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 Down Expand Up @@ -28,7 +29,7 @@ ENV NDK_VERSION=23.0.7599858

VOLUME ["/boltz-dart"]

#WORKDIR /boltz-dart
# WORKDIR /boltz-dart

#Used for cargo build to find Cargo.toml

Expand Down
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/linux.sh
cd boltz-dart || exit 1
bash linux.sh "$VERSION"
exec "$@"
9 changes: 5 additions & 4 deletions rust/linux.sh
Original file line number Diff line number Diff line change
@@ -1,20 +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 \

cd boltz-dart || exit

for TARGET in \
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
cargo build --target-dir $LINUX_DIR -r --target=$TARGET
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/
20 changes: 11 additions & 9 deletions rust/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,21 @@ init:
all: init jnilib xcframework linux

linux:
@echo "[Creating linux binary ...] $@"
docker run --platform linux/x86_64 --name bwcbuilder01 -v $(shell pwd):/boltz-dart bwcbuilder && docker stop bwcbuilder01 && docker rm bwcbuilder01
@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 9bb7a02

Please sign in to comment.