Put the native executable in the lib directory, to appease recent R^X requirements, and bump the Android target version back up to 34.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4572 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2023-10-22 18:52:20 +00:00
parent 0550aa4e98
commit 566d00f0df
4 changed files with 20 additions and 56 deletions

View File

@ -39,7 +39,7 @@ ANDROID_BUILD_TOOLS := $(ANDROID_SDK)/build-tools/34.0.0
ANDROID_PLATFORM := $(ANDROID_SDK)/platforms/android-33 ANDROID_PLATFORM := $(ANDROID_SDK)/platforms/android-33
ANDROID_NDK ?= $(ANDROID_SDK)/ndk/26.0.10792818 ANDROID_NDK ?= $(ANDROID_SDK)/ndk/26.0.10792818
ANDROID_MIN_SDK_VERSION := 24 ANDROID_MIN_SDK_VERSION := 24
ANDROID_TARGET_SDK_VERSION := 28 ANDROID_TARGET_SDK_VERSION := 34
ANDROID_ARMV7A_TARGETS := \ ANDROID_ARMV7A_TARGETS := \
out/androiddebug-armv7a/tildefriends \ out/androiddebug-armv7a/tildefriends \
@ -662,24 +662,24 @@ out/apk/TildeFriends-x86-debug.unsigned.apk: out/apk/classes.dex out/androiddebu
out/apk/TildeFriends-x86-release.unsigned.apk: out/apk/classes.dex out/androidrelease-x86_64/tildefriends out/androidrelease-x86/tildefriends $(RAW_FILES) out/apk/res.apk out/apk/TildeFriends-x86-release.unsigned.apk: out/apk/classes.dex out/androidrelease-x86_64/tildefriends out/androidrelease-x86/tildefriends $(RAW_FILES) out/apk/res.apk
out/apk/TildeFriends-arm-%.unsigned.apk: out/apk/TildeFriends-arm-%.unsigned.apk:
@mkdir -p $(dir $@) out/apk-arm-$(BUILD_TYPE)/bin/arm64-v8a/ out/apk-arm-$(BUILD_TYPE)/bin/armeabi-v7a/ @mkdir -p $(dir $@) out/apk-arm-$(BUILD_TYPE)/lib/arm64-v8a/ out/apk-arm-$(BUILD_TYPE)/lib/armeabi-v7a/
@echo [aapt] $@ @echo [aapt] $@
@cp out/android$(BUILD_TYPE)/tildefriends out/apk-arm-$(BUILD_TYPE)/bin/arm64-v8a/ @cp out/android$(BUILD_TYPE)/tildefriends out/apk-arm-$(BUILD_TYPE)/lib/arm64-v8a/tildefriends.so
@cp out/android$(BUILD_TYPE)-armv7a/tildefriends out/apk-arm-$(BUILD_TYPE)/bin/armeabi-v7a/ @cp out/android$(BUILD_TYPE)-armv7a/tildefriends out/apk-arm-$(BUILD_TYPE)/lib/armeabi-v7a/tildefriends.so
@$(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk-arm-$(BUILD_TYPE)/bin/arm64-v8a/tildefriends @$(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk-arm-$(BUILD_TYPE)/lib/arm64-v8a/tildefriends.so
@$(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk-arm-$(BUILD_TYPE)/bin/armeabi-v7a/tildefriends @$(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk-arm-$(BUILD_TYPE)/lib/armeabi-v7a/tildefriends.so
@cp out/apk/res.apk $@ @cp out/apk/res.apk $@
@cp out/apk/classes.dex out/apk-arm-$(BUILD_TYPE)/ @cp out/apk/classes.dex out/apk-arm-$(BUILD_TYPE)/
@cd out/apk-arm-$(BUILD_TYPE) && zip -u ../../$@ -q -9 -r . && cd ../../ @cd out/apk-arm-$(BUILD_TYPE) && zip -u ../../$@ -q -9 -r . && cd ../../
@zip -u $@ -q -9 -x '*.map' --exclude=apps/gg* --exclude=apps/welcome* -r $(PACKAGE_DIRS) $(RAW_FILES) @zip -u $@ -q -9 -x '*.map' --exclude=apps/gg* --exclude=apps/welcome* -r $(PACKAGE_DIRS) $(RAW_FILES)
out/apk/TildeFriends-x86-%.unsigned.apk: out/apk/TildeFriends-x86-%.unsigned.apk:
@mkdir -p $(dir $@) out/apk-x86-$(BUILD_TYPE)/bin/x86_64/ out/apk-x86-$(BUILD_TYPE)/bin/x86/ @mkdir -p $(dir $@) out/apk-x86-$(BUILD_TYPE)/lib/x86_64/ out/apk-x86-$(BUILD_TYPE)/lib/x86/
@echo [aapt] $@ @echo [aapt] $@
@cp out/android$(BUILD_TYPE)-x86_64/tildefriends out/apk-x86-$(BUILD_TYPE)/bin/x86_64/ @cp out/android$(BUILD_TYPE)-x86_64/tildefriends out/apk-x86-$(BUILD_TYPE)/lib/x86_64/
@cp out/android$(BUILD_TYPE)-x86/tildefriends out/apk-x86-$(BUILD_TYPE)/bin/x86/ @cp out/android$(BUILD_TYPE)-x86/tildefriends out/apk-x86-$(BUILD_TYPE)/lib/x86/
@$(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk-x86-$(BUILD_TYPE)/bin/x86_64/tildefriends @$(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk-x86-$(BUILD_TYPE)/lib/x86_64/tildefriends
@$(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk-x86-$(BUILD_TYPE)/bin/x86/tildefriends @$(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk-x86-$(BUILD_TYPE)/lib/x86/tildefriends
@cp out/apk/res.apk $@ @cp out/apk/res.apk $@
@cp out/apk/classes.dex out/apk-x86-$(BUILD_TYPE)/ @cp out/apk/classes.dex out/apk-x86-$(BUILD_TYPE)/
@cd out/apk-x86-$(BUILD_TYPE) && zip -u ../../$@ -q -9 -r . && cd ../../ @cd out/apk-x86-$(BUILD_TYPE) && zip -u ../../$@ -q -9 -r . && cd ../../

View File

@ -473,7 +473,7 @@ function guessMode(name) {
function loadFile(name, id) { function loadFile(name, id) {
return fetch('/' + id + '/view').then(function(response) { return fetch('/' + id + '/view').then(function(response) {
if (!response.ok) { if (!response.ok) {
alert('Request failed: ' + response.status + ' ' + response.statusText); alert(`Request failed for ${name}: ${response.status} ${response.statusText}`);
return 'missing file!'; return 'missing file!';
} }
return response.text(); return response.text();

View File

@ -3,9 +3,13 @@
package="com.unprompted.tildefriends" package="com.unprompted.tildefriends"
android:versionCode="12" android:versionCode="12"
android:versionName="0.0.12-wip"> android:versionName="0.0.12-wip">
<uses-sdk android:minSdkVersion="24" android:targetSdkVersion="28"/> <uses-sdk android:minSdkVersion="24" android:targetSdkVersion="34"/>
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.INTERNET"/>
<application android:label="Tilde Friends" android:usesCleartextTraffic="true" android:debuggable="true"> <application
android:label="Tilde Friends"
android:usesCleartextTraffic="true"
android:debuggable="true"
android:extractNativeLibs="true">
<meta-data android:name="android.max_aspect" android:value="2.1"/> <meta-data android:name="android.max_aspect" android:value="2.1"/>
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"

View File

@ -37,8 +37,6 @@ import java.nio.file.WatchEvent;
import java.nio.file.WatchKey; import java.nio.file.WatchKey;
import java.nio.file.WatchService; import java.nio.file.WatchService;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
public class MainActivity extends Activity { public class MainActivity extends Activity {
WebView web_view; WebView web_view;
@ -60,12 +58,7 @@ public class MainActivity extends Activity {
set_status("Extracting executable..."); set_status("Extracting executable...");
Log.w("tildefriends", String.format("getFilesDir() is %s", getFilesDir().toString())); Log.w("tildefriends", String.format("getFilesDir() is %s", getFilesDir().toString()));
Log.w("tildefriends", String.format("getPackageResourcePath() is %s", getPackageResourcePath().toString())); Log.w("tildefriends", String.format("getPackageResourcePath() is %s", getPackageResourcePath().toString()));
Log.w("tildefriends", String.format("nativeLibraryDir is %s", getApplicationInfo().nativeLibraryDir));
if (!extract_executable()) {
Log.w("tildefriends", "Failed to extract a compatible executable.");
set_status("No compatible ABI found.");
return;
}
String port_file_path = getFilesDir().toString() + "/port.txt"; String port_file_path = getFilesDir().toString() + "/port.txt";
new File(port_file_path).delete(); new File(port_file_path).delete();
@ -125,7 +118,7 @@ public class MainActivity extends Activity {
thread.start(); thread.start();
set_status("Starting server..."); set_status("Starting server...");
String exe = getFilesDir().toString() + "/tildefriends"; String exe = getApplicationInfo().nativeLibraryDir + "/tildefriends.so";
ProcessBuilder builder = new ProcessBuilder(exe, "run", "-z", getPackageResourcePath().toString(), "-a", "out_http_port_file=" + port_file_path, "-p", "0"); ProcessBuilder builder = new ProcessBuilder(exe, "run", "-z", getPackageResourcePath().toString(), "-a", "out_http_port_file=" + port_file_path, "-p", "0");
Log.w("tildefriends", "files = " + getFilesDir().toString()); Log.w("tildefriends", "files = " + getFilesDir().toString());
Log.w("tildefriends", "exe = " + exe); Log.w("tildefriends", "exe = " + exe);
@ -194,39 +187,6 @@ public class MainActivity extends Activity {
}); });
} }
private boolean extract_executable()
{
try (ZipFile zip = new ZipFile(new File(getPackageResourcePath()))) {
for (String abi : android.os.Build.SUPPORTED_ABIS)
{
String lookup = String.format("bin/%s/tildefriends", abi);
Log.w("tildefriends", "Looking for " + lookup);
ZipEntry entry = zip.getEntry(lookup);
if (entry != null) {
Log.w("tildefriends", "Extracting " + entry.getName());
try (FileOutputStream out = new FileOutputStream(getFilesDir().toString() + "/tildefriends")) {
try (InputStream in = zip.getInputStream(entry)) {
byte[] buffer = new byte[32768];
int count;
while ((count = in.read(buffer)) != -1) {
out.write(buffer, 0, count);
}
new File(getFilesDir().toString() + "/tildefriends").setExecutable(true);
return true;
}
}
}
}
} catch (java.io.FileNotFoundException e) {
Log.w("tildefriends", "FileNotFoundException extracting executable");
Log.w("tildefriends", e.toString());
} catch (java.io.IOException e) {
Log.w("tildefriends", "IOException extracting executable");
Log.w("tildefriends", e.toString());
}
return false;
}
@Override @Override
protected void onDestroy() protected void onDestroy()
{ {