Skip to content

Commit

Permalink
build: progress on move to rust-android-gradle for building aw-server…
Browse files Browse the repository at this point in the history
…-rust
  • Loading branch information
ErikBjare committed Dec 7, 2020
1 parent 4fd0282 commit eb2676f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 49 deletions.
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
1 change: 1 addition & 0 deletions mobile/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ cargo {

tasks.whenTaskAdded { task ->
// Build aw-server-rust
// Doesn't work, chokes on building openssl-sys
if ((task.name == 'javaPreCompileDebug' || task.name == 'javaPreCompileRelease')) {
task.dependsOn 'cargoBuild'
}
Expand Down

0 comments on commit eb2676f

Please sign in to comment.