mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Make ndk-make.sh debug builds (for just one arch) more usable (#2173)
Debug builds of the core (like `ndk-make.sh arm64-v8a`) take about a minute, while a release bulid (`ndk-make.sh`) takes about 15 minutes. But as most people seem not to use debug builds regularly because they are tricky to use, here comes an improvement :) If you gave the wrong argument to `ndk-make.sh`, a warning dialog will now pop up inside the app, telling you what you did wrong and what you should do instead. `ndk-make.sh` writes its argument into the file `ndkArch`. `getNdkArch()` in `build.gradle` then reads this file and its content is assigned to `BuildConfig.NDK_ARCH`. `checkNdkArchitecture()` then checks this.
This commit is contained in:
@@ -26,6 +26,7 @@ ffpr
|
||||
test/androidTestEspresso/res/values/arrays.xml
|
||||
obj/
|
||||
jni/libspeex/.deps/
|
||||
ndkArch
|
||||
|
||||
# ignore debug symbols created by ./tools/upload-release.sh
|
||||
*-symbols.zip
|
||||
|
||||
+12
-1
@@ -121,6 +121,7 @@ android {
|
||||
|
||||
buildConfigField("String", "TEST_ADDR", buildConfigProperty("TEST_ADDR"))
|
||||
buildConfigField("String", "TEST_MAIL_PW", buildConfigProperty("TEST_MAIL_PW"))
|
||||
buildConfigField("String", "NDK_ARCH", getNdkArch())
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
@@ -229,8 +230,18 @@ String propertyOrEmpty(String name) {
|
||||
return (String) p
|
||||
}
|
||||
|
||||
String environmentVariable(String name) {
|
||||
static String environmentVariable(String name) {
|
||||
String env = System.getenv(name)
|
||||
if (env == null) return ""
|
||||
return env
|
||||
}
|
||||
|
||||
String getNdkArch() {
|
||||
Properties properties = new Properties()
|
||||
def file = project.rootProject.file('ndkArch')
|
||||
if (!file.exists()) return "\"\""
|
||||
properties.load(file.newDataInputStream())
|
||||
def arch = properties.getProperty('NDK_ARCH')
|
||||
if (arch == null) return "\"\""
|
||||
return "\"$arch\""
|
||||
}
|
||||
+12
-3
@@ -10,9 +10,9 @@
|
||||
#
|
||||
# adb shell uname -m
|
||||
#
|
||||
# or:
|
||||
#
|
||||
# adb shell cat /proc/cpuinfo
|
||||
# Or you just guess your phone's architecture to be arm64-v8a and if you
|
||||
# guessed wrongly, a warning message will pop up inside the app, telling
|
||||
# you what the correct one is.
|
||||
#
|
||||
# The values in the following lines mean the same:
|
||||
#
|
||||
@@ -27,6 +27,9 @@
|
||||
# typing `nmake`:
|
||||
#
|
||||
# nmake() {(cd ../..; ./ndk-make.sh arm64-v8a && ./gradlew installFatDebug; notify-send "install finished")}
|
||||
#
|
||||
#
|
||||
# If anything doesn't work, please open an issue!!
|
||||
|
||||
set -e
|
||||
echo "starting time: `date`"
|
||||
@@ -143,4 +146,10 @@ cd jni
|
||||
# Restore old Application.mk:
|
||||
echo "$oldDotMk" > Application.mk
|
||||
|
||||
if test $1; then
|
||||
echo "NDK_ARCH=$1" > ../ndkArch
|
||||
else
|
||||
rm ../ndkArch 2>/dev/null || true # Remove ndkArch, ignore if it doesn't exist
|
||||
fi
|
||||
|
||||
echo "ending time: `date`"
|
||||
|
||||
@@ -16,10 +16,22 @@
|
||||
*/
|
||||
package org.thoughtcrime.securesms;
|
||||
|
||||
import static org.thoughtcrime.securesms.ConversationActivity.CHAT_ID_EXTRA;
|
||||
import static org.thoughtcrime.securesms.ConversationActivity.STARTING_POSITION_EXTRA;
|
||||
import static org.thoughtcrime.securesms.map.MapDataManager.ALL_CHATS_GLOBAL_MAP;
|
||||
import static org.thoughtcrime.securesms.util.RelayUtil.REQUEST_RELAY;
|
||||
import static org.thoughtcrime.securesms.util.RelayUtil.acquireRelayMessageContent;
|
||||
import static org.thoughtcrime.securesms.util.RelayUtil.getDirectSharingChatId;
|
||||
import static org.thoughtcrime.securesms.util.RelayUtil.isDirectSharing;
|
||||
import static org.thoughtcrime.securesms.util.RelayUtil.isForwarding;
|
||||
import static org.thoughtcrime.securesms.util.RelayUtil.isRelayingMessageContent;
|
||||
import static org.thoughtcrime.securesms.util.RelayUtil.resetRelayingMessageContent;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
@@ -29,6 +41,7 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.appcompat.widget.TooltipCompat;
|
||||
|
||||
@@ -55,23 +68,13 @@ import org.thoughtcrime.securesms.util.DynamicTheme;
|
||||
import org.thoughtcrime.securesms.util.Prefs;
|
||||
import org.thoughtcrime.securesms.util.SendRelayedMessageUtil;
|
||||
|
||||
import static org.thoughtcrime.securesms.ConversationActivity.CHAT_ID_EXTRA;
|
||||
import static org.thoughtcrime.securesms.ConversationActivity.STARTING_POSITION_EXTRA;
|
||||
import static org.thoughtcrime.securesms.map.MapDataManager.ALL_CHATS_GLOBAL_MAP;
|
||||
import static org.thoughtcrime.securesms.util.RelayUtil.REQUEST_RELAY;
|
||||
import static org.thoughtcrime.securesms.util.RelayUtil.acquireRelayMessageContent;
|
||||
import static org.thoughtcrime.securesms.util.RelayUtil.getDirectSharingChatId;
|
||||
import static org.thoughtcrime.securesms.util.RelayUtil.isDirectSharing;
|
||||
import static org.thoughtcrime.securesms.util.RelayUtil.isForwarding;
|
||||
import static org.thoughtcrime.securesms.util.RelayUtil.isRelayingMessageContent;
|
||||
import static org.thoughtcrime.securesms.util.RelayUtil.resetRelayingMessageContent;
|
||||
|
||||
public class ConversationListActivity extends PassphraseRequiredActionBarActivity
|
||||
implements ConversationListFragment.ConversationSelectedListener
|
||||
{
|
||||
@SuppressWarnings("unused")
|
||||
private static final String TAG = ConversationListActivity.class.getSimpleName();
|
||||
private static final String OPENPGP4FPR = "openpgp4fpr";
|
||||
private static final String NDK_ARCH_WARNED = "ndk_arch_warned";
|
||||
public static final String CLEAR_NOTIFICATIONS = "clear_notifications";
|
||||
|
||||
private final DynamicTheme dynamicTheme = new DynamicNoActionBarTheme();
|
||||
@@ -109,7 +112,6 @@ public class ConversationListActivity extends PassphraseRequiredActionBarActivit
|
||||
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
selfAvatar = findViewById(R.id.self_avatar);
|
||||
title = findViewById(R.id.toolbar_title);
|
||||
searchToolbar = findViewById(R.id.search_toolbar);
|
||||
@@ -128,6 +130,63 @@ public class ConversationListActivity extends PassphraseRequiredActionBarActivit
|
||||
selfAvatar.setOnClickListener(v -> AccountManager.getInstance().showSwitchAccountMenu(this));
|
||||
|
||||
refresh();
|
||||
|
||||
if (BuildConfig.DEBUG) checkNdkArchitecture();
|
||||
}
|
||||
|
||||
/**
|
||||
* If the build script is invoked with a specific architecture (e.g.`./ndk-make.sh arm64-v8a`), it
|
||||
* will compile the core only for this arch. This method checks if the arch was correct.
|
||||
*
|
||||
* In order to do this, `ndk-make.sh` writes its argument into the file `ndkArch`.
|
||||
* `getNdkArch()` in `build.gradle` then reads this file and its content is assigned to
|
||||
* `BuildConfig.NDK_ARCH`.
|
||||
*/
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
private void checkNdkArchitecture() {
|
||||
boolean wrongArch = false;
|
||||
|
||||
if (!TextUtils.isEmpty(BuildConfig.NDK_ARCH)) {
|
||||
String archProperty = System.getProperty("os.arch");
|
||||
String arch;
|
||||
|
||||
if (archProperty.startsWith("armv7")) arch = "armeabi-v7a";
|
||||
else if (archProperty.equals("aarch64")) arch = "arm64-v8a";
|
||||
else if (archProperty.equals("i686")) arch = "x86";
|
||||
else if (archProperty.equals("x86_64")) arch = "x86_64";
|
||||
else {
|
||||
Log.e(TAG, "Unknown os.arch: " + archProperty);
|
||||
arch = "";
|
||||
}
|
||||
|
||||
if (!arch.equals(BuildConfig.NDK_ARCH)) {
|
||||
wrongArch = true;
|
||||
|
||||
String message;
|
||||
if (arch.equals("")) {
|
||||
message = "This phone has the unknown architecture " + archProperty + ".\n\n"+
|
||||
"Please open an issue at https://github.com/deltachat/deltachat-android/issues.";
|
||||
} else {
|
||||
message = "Apparently you used `ndk-make.sh " + BuildConfig.NDK_ARCH + "`, but this device is " + arch + ".\n\n" +
|
||||
"You can use the app, but changes you made to the Rust code were not applied.\n\n" +
|
||||
"To compile in your changes, you can:\n" +
|
||||
"- Either run `ndk-make.sh " + arch + "` to build only for " + arch + " in debug mode\n" +
|
||||
"- Or run `ndk-make.sh` without argument to build for all architectures in release mode\n\n" +
|
||||
"If something doesn't work, please open an issue at https://github.com/deltachat/deltachat-android/issues!!";
|
||||
}
|
||||
Log.e(TAG, message);
|
||||
|
||||
if (!Prefs.getBooleanPreference(this, NDK_ARCH_WARNED, false)) {
|
||||
new AlertDialog.Builder(this)
|
||||
.setMessage(message)
|
||||
.setPositiveButton(android.R.string.ok, null)
|
||||
.show();
|
||||
Prefs.setBooleanPreference(this, NDK_ARCH_WARNED, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!wrongArch) Prefs.setBooleanPreference(this, NDK_ARCH_WARNED, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user