Przeglądaj źródła

fix darkirc android build using dockerfile

zero 2 lat temu
rodzic
commit
8a17b7175e

+ 4 - 0
bin/darkirc/Cargo.toml

@@ -56,3 +56,7 @@ smol = "1.3.0"
 serde = {version = "1.0.195", features = ["derive"]}
 structopt = "0.3.26"
 structopt-toml = "0.5.1"
+
+# See https://github.com/rust-mobile/android-rs-glue/issues/193
+[target.aarch64-linux-android.dependencies]
+openssl = { version = "*", features = ["vendored"] }

+ 12 - 0
bin/darkirc/Makefile

@@ -52,6 +52,18 @@ $(BIN).android64:
 #	RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) ndk -t armeabi-v7a -o ./jniLibs build --release --package $(BIN)
 #	cp -f ../../target/armv7-linux-androideabi/release/$(BIN) $(BIN).$@
 
+# This target doesn't require installing any packages from Android Studio
+docker-android:
+	docker build -t test:latest . --file android.Dockerfile
+	# Use this command to get an interactive terminal inside docker:
+	#docker run -v $(shell pwd)/../../:/root/src -it test:latest /bin/bash
+	docker run --rm -v $(shell pwd)/../../:/root/src -t test:latest make _aarch64-android
+	cp -f ../../target/aarch64-linux-android/release/darkirc darkirc.aarch64-android
+# Invoked inside docker by the command above
+# We need to mount this directory as a volume using -v so docker can access it
+_aarch64-android:
+	cargo build --release --target aarch64-linux-android --package darkirc
+
 clean:
 	RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) clean --target=$(RUST_TARGET) --release --package $(BIN)
 	rm -f $(BIN) ../../$(BIN) $(BIN).android64 $(BIN).android32

+ 19 - 10
bin/darkirc/android.Dockerfile

@@ -1,8 +1,11 @@
 FROM ubuntu
+ENV DEBIAN_FRONTEND noninteractive
 
 RUN apt update
 RUN apt install -yq openjdk-19-jre-headless openjdk-19-jdk-headless
 RUN apt install -yq wget unzip cmake file
+# For vendored openssl
+RUN apt-get update && apt-get install -y build-essential checkinstall zlib1g-dev
 
 RUN cd /tmp/ && \
     wget -O install-rustup.sh https://sh.rustup.rs && \
@@ -35,19 +38,25 @@ RUN ${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager "build-tools;34.0.0"
 RUN echo '[target.aarch64-linux-android] \n\
 ar = "/opt/android-sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" \n\
 linker = "/opt/android-sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android33-clang" \n\
-' > /root/.cargo/config
+' > /root/.cargo/config.toml
+# wtf cargo
+ENV RANLIB /opt/android-sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ranlib
 
 # Needed by the ring dependency
 ENV TARGET_AR /opt/android-sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar
 ENV TARGET_CC /opt/android-sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android33-clang
 
-# Make sqlite3
+# Make sqlcipher
+# Needed for sqlcipher amalgamation
+RUN apt install -yq tclsh libssl-dev
 RUN cd /tmp/ && \
-    wget -O sqlite.zip https://www.sqlite.org/2023/sqlite-amalgamation-3430000.zip && \
-    unzip sqlite.zip && \
-    rm sqlite.zip && \
-    mv sqlite* sqlite && \
-    cd sqlite && \
+    wget -O sqlcipher.zip https://github.com/sqlcipher/sqlcipher/archive/refs/tags/v4.5.6.zip && \
+    unzip sqlcipher.zip && \
+    rm sqlcipher.zip && \
+    mv sqlcipher* sqlcipher && \
+    cd sqlcipher && \
+    ./configure && \
+    make sqlite3.c && \
     mkdir build && \
     mv *.c *.h build/ && \
     mkdir jni && \
@@ -58,15 +67,15 @@ APP_STL := c++_shared' > jni/Application.mk && \
     echo '\
 LOCAL_PATH := $(call my-dir) \n\
 include $(CLEAR_VARS) \n\
-LOCAL_MODULE            := sqlite3-a \n\
-LOCAL_MODULE_FILENAME   := libsqlite3 \n\
+LOCAL_MODULE            := sqlcipher-a \n\
+LOCAL_MODULE_FILENAME   := libsqlcipher \n\
 LOCAL_SRC_FILES         := ../build/sqlite3.c \n\
 LOCAL_C_INCLUDES        := ../build \n\
 LOCAL_EXPORT_C_INCLUDES := ../build \n\
 LOCAL_CFLAGS            := -DSQLITE_THREADSAFE=1 \n\
 include $(BUILD_STATIC_LIBRARY)' > jni/Android.mk && \
     /opt/android-sdk/ndk/25.2.9519653/ndk-build
-ENV RUSTFLAGS "-L/tmp/sqlite/obj/local/arm64-v8a/"
+ENV RUSTFLAGS "-L/tmp/sqlcipher/obj/local/arm64-v8a/"
 
 # Make directory for user code
 RUN mkdir /root/src

+ 7 - 3
doc/src/misc/ircd/ircd.md

@@ -36,9 +36,13 @@ you have all the necessary dependencies.
 
 This is for Android 64 bit (which is most phones).
 
-1. Install Docker
-2. Run `cd bin/ircd/ && make android`. The resulting file will be called
-   `ircd.aarch64-android`. Copy this to your phone.
+1. Setup Docker on your machine which may look like:
+    1. Install docker and docker-buildx packages.
+    2. Enable the docker daemon service.
+    3. Add your user to the docker group and refresh the session
+       (either with `su -c $USER` or logout/login).
+2. Run `cd bin/darkirc/ && make docker-android`. The resulting file will be
+   called `darkirc.aarch64-android`. Copy this to your phone.
 3. Install Termux and RevolutionIRC on F-Droid.
 4. You can access the phone storage from `/sdcard/` and copy the file
    into the Termux home.