@tokamakdev/platform-android-arm64 0.1.1-beta.54 → 0.1.1-beta.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -45,6 +45,50 @@ kotlin=$app/src/main/kotlin/com/tokamak/runtime
45
45
  plugin_api=$project/tokamak-plugin
46
46
  plugin_modules=$project/plugins
47
47
  icons=$input/icons/$platform
48
+ # The oldest Android API level the app supports.
49
+ min_sdk=31
50
+
51
+ # The Android NDK's compiler, which links the runtime into the app.
52
+ android_linker() {
53
+ local ndk=${ANDROID_NDK_HOME:-}
54
+ local sdk_root=${ANDROID_HOME:-${ANDROID_SDK_ROOT:-}}
55
+ if [[ ! -d "$ndk" && -n "$sdk_root" && -d "$sdk_root/ndk" ]]; then
56
+ ndk=$(find "$sdk_root/ndk" -mindepth 1 -maxdepth 1 -type d -print | sort | tail -n 1)
57
+ fi
58
+ local compiler
59
+ for compiler in "$ndk"/toolchains/llvm/prebuilt/*/bin/aarch64-linux-android"$min_sdk"-clang; do
60
+ if [[ -x "$compiler" ]]; then
61
+ printf '%s' "$compiler"
62
+ return
63
+ fi
64
+ done
65
+ echo "Android builds link the tokamak runtime with the Android NDK, which is not installed." >&2
66
+ echo "Install it with Android Studio's SDK Manager (SDK Tools > NDK) or \`sdkmanager \"ndk;29.0.14206865\"\`, or set ANDROID_NDK_HOME." >&2
67
+ exit 1
68
+ }
69
+
70
+ # Link the runtime into libtokamak.so, exporting the JNI functions and the
71
+ # entry points of the runtime parts the app links.
72
+ link_runtime() {
73
+ local runtime=$input/runtime/TokamakRuntime
74
+ local exports=$project/tokamak-exports.map
75
+ local compiler libraries
76
+ compiler=$(android_linker)
77
+ {
78
+ printf '{\n global:\n Java_*;\n'
79
+ sed 's/.*/ &;/' "$metadata/exported-symbols"
80
+ printf ' local:\n *;\n};\n'
81
+ } > "$exports"
82
+ read -r -a libraries <<< "$(< "$runtime/link-libraries")"
83
+ "$compiler" -shared -o "$native/libtokamak.so" \
84
+ -Wl,-soname,libtokamak.so \
85
+ -Wl,--whole-archive "$runtime/libtokamak.a" -Wl,--no-whole-archive \
86
+ -Wl,--version-script="$exports" \
87
+ -Wl,--gc-sections -Wl,--as-needed -Wl,--eh-frame-hdr \
88
+ -Wl,-z,noexecstack -Wl,-z,relro,-z,now -Wl,-z,max-page-size=16384 \
89
+ -Wl,--strip-all \
90
+ "${libraries[@]}"
91
+ }
48
92
 
49
93
  xml_escape() {
50
94
  printf '%s' "$1" |
@@ -58,7 +102,7 @@ xml_escape() {
58
102
  rm -rf "$app/src/main/assets" "$app/src/main/jniLibs" "$app/src/main/kotlin" "$app/src/main/res" "$app/user" "$plugin_api" "$plugin_modules" "$output"
59
103
  mkdir -p "$native" "$assets" "$kotlin" "$app/src/main/res" "$plugin_api/src/main/kotlin"
60
104
  cp -R "$input/app/." "$assets/"
61
- cp "$input/runtime/libtokamak.so" "$native/libtokamak.so"
105
+ link_runtime
62
106
  cp -R "$input/native-shell/app/." "$kotlin/"
63
107
  cp -R "$input/native-shell/plugin/." "$plugin_api/src/main/kotlin/"
64
108
  cat > "$plugin_api/build.gradle" <<'EOF'
@@ -146,7 +190,7 @@ for plugin in "$input/plugins"/*/; do
146
190
  printf "include ':plugins:%s'\n" "$(basename "$plugin")" >> "$project/settings.gradle"
147
191
  done
148
192
 
149
- cat > "$project/build.gradle" <<'EOF'
193
+ cat > "$project/build.gradle" <<EOF
150
194
  plugins {
151
195
  id 'com.android.application' version '8.7.3' apply false
152
196
  id 'com.android.library' version '8.7.3' apply false
@@ -158,7 +202,7 @@ subprojects {
158
202
  android {
159
203
  compileSdk 35
160
204
  defaultConfig {
161
- minSdk 31
205
+ minSdk $min_sdk
162
206
  }
163
207
  sourceSets {
164
208
  main {
@@ -192,7 +236,7 @@ android {
192
236
 
193
237
  defaultConfig {
194
238
  applicationId '$identifier'
195
- minSdk 31
239
+ minSdk $min_sdk
196
240
  targetSdk 35
197
241
  versionCode 1
198
242
  versionName '$version'
@@ -0,0 +1,4 @@
1
+ [diffend] Oversized file quarantined before diffing.
2
+ name: package/android-arm64/lib/TokamakRuntime/libtokamak.a
3
+ size: 39086104 bytes
4
+ sha256: 642a7fcdb133ba4e0d8f465e45e36027b187e39fd95b3a6b1166273885f55e44
@@ -0,0 +1 @@
1
+ -ldl -llog -lunwind -ldl -lm -lc -llog
@@ -4,7 +4,7 @@
4
4
  "artifacts": [
5
5
  {
6
6
  "kind": "runtimeLibrary",
7
- "path": "bin/libtokamak.so"
7
+ "path": "lib/TokamakRuntime"
8
8
  },
9
9
  {
10
10
  "kind": "nativeShellDirectory",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tokamakdev/platform-android-arm64",
3
- "version": "0.1.1-beta.54",
3
+ "version": "0.1.1-beta.55",
4
4
  "description": "The tokamak platform pack for android-arm64",
5
5
  "repository": {
6
6
  "type": "git",
Binary file