Compare commits

...
2 changed files with 50 additions and 1 deletions

No files matched your search

+2 -1
View File
@@ -14,7 +14,8 @@ after restarting. If no complete copy exists, the pack uses the checkout's pin.
- `tools/agent/dd-lab-build` builds the checkout with Gradle on the device (`processReleaseResources`
and `mergeDexRelease`), packs the linked resources and dex files into `overlay.apk`, writes
`overlay.json`, and stages both in the app's `files/lab/next`. It then recompiles the app without
an app image and restarts DroidDeck.
an app image and restarts DroidDeck. The resource linker uses IDs from the installed APK so
base and overlay code resolve the same resource names.
- Run by the app's own agent (`DD_AGENT` set), it writes `files/agent/lab-request` instead, and the
app runs the build in a process of its own, logging to `~/.cache/dd-lab-build.log`; the agent's
copy follows that log and exits with the build. A turn's processes end with the turn, so a build
+48
View File
@@ -134,6 +134,54 @@ fi
gradle=(./gradlew :app:processReleaseResources :app:mergeDexRelease --max-workers=2 -PskipRust=true -x buildVkBridgeServer
-Pandroid.aapt2FromMavenOverride=$HOME/aapt2/aapt2 -Pkotlin.compiler.execution.strategy=daemon
-Pkotlin.daemon.jvmargs=-Xmx${kotlin_heap}m -Dorg.gradle.jvmargs=-Xmx${gradle_heap}m --console=plain)
# Release package aliases rewrite the manifest but keep the resource table under the linker package.
resource_package=com.droiddeck.launcher
resource_cache=$cache/dd-lab-resource-ids
mkdir -p "$resource_cache"
resource_key=$(printf '%s\n' "$pkg" "$base" "$apk" | sha256sum | cut -d ' ' -f1)
stable_ids=$resource_cache/$resource_key.txt
if [ ! -s "$stable_ids" ]; then
progress checking 0 "reading the installed APK resource IDs"
if ! (
resource_work=$(mktemp -d "$resource_cache/.extract.XXXXXX") || exit 1
trap 'rm -rf "$resource_work"' EXIT
adb -s "$serial" pull "$apk" "$resource_work/base.apk" >/dev/null &&
"$HOME/aapt2/aapt2" dump resources "$resource_work/base.apk" > "$resource_work/resources.txt" &&
awk -v package="$resource_package" '
$1 == "Package" { in_package = ($2 == "name=" package) }
in_package && $1 == "resource" && $2 ~ /^0x[[:xdigit:]]+$/ {
print package ":" $3 " = " $2
count++
}
END { if (!count) exit 1 }
' "$resource_work/resources.txt" > "$resource_work/ids.txt" &&
mv "$resource_work/ids.txt" "$stable_ids"
); then
fail "could not read resource IDs from the installed APK"
fi
fi
resource_init=$resource_cache/link.gradle
cat > "$resource_init.part.$$" <<'EOF'
gradle.beforeProject { project ->
if (project.path == ':app') {
project.pluginManager.withPlugin('com.android.application') {
project.androidComponents.finalizeDsl { android ->
android.androidResources.additionalParameters.addAll([
'--stable-ids', project.providers.gradleProperty('droiddeckLabStableIds').get()
])
}
}
}
}
EOF
if cmp -s "$resource_init.part.$$" "$resource_init"; then
rm "$resource_init.part.$$"
else
mv "$resource_init.part.$$" "$resource_init"
fi
gradle+=(--init-script "$resource_init" "-PdroiddeckLabStableIds=$stable_ids")
progress planning
plan_file=$cache/dd-lab-build-plan
plan_key=$(