fix(build): restore customize.sh and build.gradle.kts with all native libs

PR 157 wholesale replacement dropped libsupervisor.so and
libcertgen.so from both the ZIP include filter and the
customize.sh extraction. service.sh calls ./supervisor and
App.kt loads libcertgen.so, so the module would fail on install.

Restores our versions with the Rust build task, 4-lib include
filter, and supervisor/certgen extraction. Adopts PR 157's
nativeLibsDir simplification (always use stripped libs).
This commit is contained in:
Enginex0
2026-03-20 06:58:10 +01:00
parent 2b31d4ef47
commit 21a3cb1ec0
2 changed files with 40 additions and 8 deletions
+34 -5
View File
@@ -71,6 +71,35 @@ dependencies {
implementation(libs.bcpkix) implementation(libs.bcpkix)
} }
// --- Rust native cert gen build task ---
val buildRustCertgen by tasks.registering(Exec::class) {
group = "TEESimulator-RS Native Build"
description = "Builds libcertgen.so via cargo-ndk for arm64-v8a."
workingDir = rootProject.projectDir.resolve("native-certgen")
commandLine(
"cargo", "ndk",
"-t", "arm64-v8a",
"-o", rootProject.projectDir.resolve("app/src/main/jniLibs").absolutePath,
"build", "--release"
)
inputs.dir(rootProject.projectDir.resolve("native-certgen/src"))
inputs.file(rootProject.projectDir.resolve("native-certgen/Cargo.toml"))
inputs.file(rootProject.projectDir.resolve("native-certgen/Cargo.lock"))
outputs.dir(rootProject.projectDir.resolve("app/src/main/jniLibs"))
environment("ANDROID_NDK_HOME", android.ndkDirectory.absolutePath)
}
// AGP auto-detects jniLibs/ as an input to mergeJniLibFolders — wire the dependency
tasks.configureEach {
if (name.endsWith("JniLibFolders") && name.startsWith("merge")) {
dependsOn(buildRustCertgen)
}
}
androidComponents { androidComponents {
onVariants(selector().all()) { variant -> onVariants(selector().all()) { variant ->
val capitalized = variant.name.replaceFirstChar { it.uppercase() } val capitalized = variant.name.replaceFirstChar { it.uppercase() }
@@ -79,7 +108,7 @@ androidComponents {
// --- Define output locations and file names --- // --- Define output locations and file names ---
// Stage all files in a temporary directory inside 'build' before zipping // Stage all files in a temporary directory inside 'build' before zipping
val tempModuleDir = project.layout.buildDirectory.dir("module/${variant.name}") val tempModuleDir = project.layout.buildDirectory.dir("module/${variant.name}")
val zipFileName = "TEESimulator-RS-$verName-$gitCommitCount-$gitCommitHash-$capitalized.zip" val zipFileName = "TEESimulator-RS-$verName-$gitCommitCount-$capitalized.zip"
// Task 1: Prepare all module files in the temporary build directory. // Task 1: Prepare all module files in the temporary build directory.
// Using Sync ensures that stale files from previous runs are removed. // Using Sync ensures that stale files from previous runs are removed.
@@ -94,6 +123,7 @@ androidComponents {
dependsOn("minify${capitalized}WithR8") dependsOn("minify${capitalized}WithR8")
} }
dependsOn("strip${capitalized}DebugSymbols") dependsOn("strip${capitalized}DebugSymbols")
dependsOn(buildRustCertgen)
if (isDebug) { if (isDebug) {
from(variant.artifacts.get(SingleArtifact.APK)) { from(variant.artifacts.get(SingleArtifact.APK)) {
@@ -115,8 +145,8 @@ androidComponents {
"intermediates/stripped_native_libs/${variant.name}/strip${capitalized}DebugSymbols/out/lib" "intermediates/stripped_native_libs/${variant.name}/strip${capitalized}DebugSymbols/out/lib"
) )
) { ) {
into("lib") // Place them in the 'lib' subfolder of the staging directory. into("lib")
include("**/libinject.so", "**/libTEESimulator.so") include("**/libinject.so", "**/libTEESimulator.so", "**/libsupervisor.so", "**/libcertgen.so")
} }
// Now, copy and process the files from 'module' directory. // Now, copy and process the files from 'module' directory.
@@ -131,8 +161,7 @@ androidComponents {
// Use expand() for simple key-value replacement. // Use expand() for simple key-value replacement.
expand( expand(
"REPLACEMEVERCODE" to gitCommitCount.toString(), "REPLACEMEVERCODE" to gitCommitCount.toString(),
"REPLACEMEVER" to "REPLACEMEVER" to "$verName-$gitCommitCount",
"$verName ($gitCommitCount-$gitCommitHash-${variant.name})",
) )
} }
+6 -3
View File
@@ -15,7 +15,7 @@ fi
# --- Version Info --- # --- Version Info ---
VERSION=$(grep_prop version "${TMPDIR}/module.prop") VERSION=$(grep_prop version "${TMPDIR}/module.prop")
ui_print "- Installing TEESimulator $VERSION" ui_print "- Installing TEESimulator-RS $VERSION"
ui_print "" ui_print ""
# --- Architecture Handling --- # --- Architecture Handling ---
@@ -48,7 +48,7 @@ install_file() {
# --- Installation --- # --- Installation ---
ui_print "- Extracting module files" ui_print "- Extracting module files"
for file in customize.sh module.prop service.sh sepolicy.rule daemon; do for file in customize.sh module.prop service.sh sepolicy.rule daemon action.sh uninstall.sh; do
install_file "$file" "$MODPATH" install_file "$file" "$MODPATH"
done done
@@ -67,10 +67,14 @@ ui_print ""
ui_print "- Extracting $ARCH libraries" ui_print "- Extracting $ARCH libraries"
install_file "lib/$ABI_DIR/libTEESimulator.so" "$MODPATH" install_file "lib/$ABI_DIR/libTEESimulator.so" "$MODPATH"
install_file "lib/$ABI_DIR/libinject.so" "$MODPATH" install_file "lib/$ABI_DIR/libinject.so" "$MODPATH"
install_file "lib/$ABI_DIR/libsupervisor.so" "$MODPATH"
install_file "lib/$ABI_DIR/libcertgen.so" "$MODPATH"
ui_print "" ui_print ""
mv "$MODPATH/libinject.so" "$MODPATH/inject" mv "$MODPATH/libinject.so" "$MODPATH/inject"
mv "$MODPATH/libsupervisor.so" "$MODPATH/supervisor"
chmod 755 "$MODPATH/inject" chmod 755 "$MODPATH/inject"
chmod 755 "$MODPATH/supervisor"
# --- Configuration Files --- # --- Configuration Files ---
if [ ! -d "$CONFIG_DIR" ]; then if [ ! -d "$CONFIG_DIR" ]; then
@@ -88,7 +92,6 @@ if [ ! -f "$CONFIG_DIR/target.txt" ]; then
install_file "target.txt" "$CONFIG_DIR" install_file "target.txt" "$CONFIG_DIR"
fi fi
# Remove legacy TEE status file; TEE status is now determined at runtime.
rm -f "$CONFIG_DIR/tee_status.txt" rm -f "$CONFIG_DIR/tee_status.txt"
if [ ! -f "$CONFIG_DIR/hbk" ]; then if [ ! -f "$CONFIG_DIR/hbk" ]; then