Skip to content

ci: switched to using rust-android-gradle for building aw-server-rust #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 4 additions & 49 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: aw-webui
.PHONY: aw-webui apk
SHELL := /bin/bash

# We should probably do this the "Android way" (would also help with getting it on FDroid):
Expand All @@ -8,56 +8,11 @@ SHELL := /bin/bash
RELEASE_TYPE = $(shell $$RELEASE && echo 'release' || echo 'debug')

# Main targets
all: aw-server-rust aw-webui
all: aw-webui apk
build: all


# aw-server-rust stuff

RS_SRCDIR := aw-server-rust
RS_OUTDIR := $(JNILIBS)
RS_SOURCES := $(shell find $(RS_SRCDIR)/aw-* -type f -name '*.rs')

JNILIBS := mobile/src/main/jniLibs
JNI_arm8 := $(JNILIBS)/arm64-v8a
JNI_arm7 := $(JNILIBS)/armeabi-v7a
JNI_x86 := $(JNILIBS)/x86
JNI_x64 := $(JNILIBS)/x86_64

TARGET := aw-server-rust/target
TARGET_arm7 := $(TARGET)/armv7-linux-androideabi
TARGET_arm8 := $(TARGET)/aarch64-linux-android
TARGET_x64 := $(TARGET)/x86_64-linux-android
TARGET_x86 := $(TARGET)/i686-linux-android

aw-server-rust: $(JNILIBS)

.PHONY: $(JNILIBS)
$(JNILIBS): $(JNI_arm7)/libaw_server.so $(JNI_arm8)/libaw_server.so $(JNI_x86)/libaw_server.so $(JNI_x64)/libaw_server.so
ls -lL $@/*/* # Check that symlinks are valid

# There must be a better way to do this without repeating almost the same rule over and over?
$(JNI_arm7)/libaw_server.so: $(TARGET_arm7)/$(RELEASE_TYPE)/libaw_server.so
mkdir -p $$(dirname $@)
ln -sfnv $$(pwd)/$^ $@
$(JNI_arm8)/libaw_server.so: $(TARGET_arm8)/$(RELEASE_TYPE)/libaw_server.so
mkdir -p $$(dirname $@)
ln -sfnv $$(pwd)/$^ $@
$(JNI_x86)/libaw_server.so: $(TARGET_x86)/$(RELEASE_TYPE)/libaw_server.so
mkdir -p $$(dirname $@)
ln -sfnv $$(pwd)/$^ $@
$(JNI_x64)/libaw_server.so: $(TARGET_x64)/$(RELEASE_TYPE)/libaw_server.so
mkdir -p $$(dirname $@)
ln -sfnv $$(pwd)/$^ $@

# This target runs multiple times because it's matched multiple times, not sure how to fix
$(RS_SRCDIR)/target/%/$(RELEASE_TYPE)/libaw_server.so: $(RS_SOURCES)
echo $@
cd aw-server-rust && env RUSTFLAGS="-C debuginfo=2 -Awarnings" bash compile-android.sh
# Explanation of RUSTFLAGS:
# `-Awarnings` allows all warnings, for cleaner output (warnings should be detected in aw-server-rust CI anyway)
# `-C debuginfo=2` is to keep debug symbols, even in release builds (later stripped by gradle on production builds, non-stripped versions needed for stack resymbolizing with ndk-stack)

apk:
env RUSTFLAGS="-C debuginfo=2 -Awarnings" TERM=xterm ./gradlew build

# aw-webui

Expand Down
12 changes: 6 additions & 6 deletions mobile/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,22 @@ dependencies {
}

// Can be used to build with: ./gradlew cargoBuild
// NOTE: Doesn't work, chokes on building openssl-sys
apply plugin: 'org.mozilla.rust-android-gradle.rust-android'

cargo {
module = "../aw-server-rust" // Or whatever directory contains your Cargo.toml
libname = "aw_server" // Or whatever matches Cargo.toml's [package] name.
targets = ["arm", "arm64", "x86", "x86_64"] // See bellow for a longer list of options
profile = 'release' // Selects the Cargo release profile (defaults to 'debug')
// TODO: Set to 'release' on release builds
profile = 'debug' // Selects the Cargo release profile (defaults to 'debug')
}

tasks.whenTaskAdded { task ->
// TODO: Build aw-server lib here instead of in Makefile?
// Build aw-server-rust
// Doesn't work, chokes on building openssl-sys
//if ((task.name == 'javaPreCompileDebug' || task.name == 'javaPreCompileRelease')) {
// task.dependsOn 'cargoBuild'
//}
if ((task.name == 'javaPreCompileDebug' || task.name == 'javaPreCompileRelease')) {
task.dependsOn 'cargoBuild'
}

// TODO: Build aw-webui here?
//if (task.name.contains("assembleRelease")) {
Expand Down