From 86b0d29cf8dfcadd120fecb97d4ac3943730c526 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Bj=C3=A4reholt?= Date: Thu, 16 Jul 2020 10:28:32 +0200 Subject: [PATCH 1/3] ci: switched to using rust-android-gradle for building aw-server-rust --- mobile/build.gradle | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/mobile/build.gradle b/mobile/build.gradle index b6fa2c84..dc4590ea 100644 --- a/mobile/build.gradle +++ b/mobile/build.gradle @@ -70,7 +70,6 @@ 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 { @@ -82,10 +81,9 @@ cargo { tasks.whenTaskAdded { task -> // TODO: Build aw-server lib here instead of in Makefile? - // 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")) { From 4fd02820a27f6868135b48ae6fc37285a57cf920 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Bj=C3=A4reholt?= Date: Tue, 28 Jul 2020 09:20:38 +0200 Subject: [PATCH 2/3] build: changed default aw-server-rust build profile to debug --- mobile/build.gradle | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mobile/build.gradle b/mobile/build.gradle index dc4590ea..e0dc3cfa 100644 --- a/mobile/build.gradle +++ b/mobile/build.gradle @@ -76,11 +76,12 @@ 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 if ((task.name == 'javaPreCompileDebug' || task.name == 'javaPreCompileRelease')) { task.dependsOn 'cargoBuild' } From eb2676f1bdd831a1a6adcfd0f83e1122ef722f04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Bj=C3=A4reholt?= Date: Mon, 7 Dec 2020 11:54:43 +0100 Subject: [PATCH 3/3] build: progress on move to rust-android-gradle for building aw-server-rust --- Makefile | 53 ++++----------------------------------------- mobile/build.gradle | 1 + 2 files changed, 5 insertions(+), 49 deletions(-) diff --git a/Makefile b/Makefile index a110a295..d314f72a 100644 --- a/Makefile +++ b/Makefile @@ -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): @@ -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 diff --git a/mobile/build.gradle b/mobile/build.gradle index e0dc3cfa..90432ff4 100644 --- a/mobile/build.gradle +++ b/mobile/build.gradle @@ -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' }