fix(build): helper script edits no longer invalidate the prepared runtime, and every build uses CI's NDK (#3116)

* fix(build): helper script edits no longer invalidate the prepared runtime, and every build uses CI's NDK

* docs(agents): helper script edits no longer need build_local.sh
This commit is contained in:
Kurt Himebauch authored and GitHub committed 2026-11-23 21:55:27 -05:00
1 parent fcaaf4dde0
commit 95aab3703f
9 files changed
+97 -12

No files matched your search

+5
View File
@@ -63,6 +63,11 @@ fi
ndk_version=${DROIDDECK_NDK_VERSION:-}
if [[ -z "${ndk_version}" ]]; then
. "${repo_root}/tools/ci/toolchains.env"
[[ -d "${sdk_dir}/ndk/${CI_ANDROID_NDK_VERSION}" ]] && ndk_version=${CI_ANDROID_NDK_VERSION}
fi
if [[ -z "${ndk_version}" ]]; then
echo "NDK ${CI_ANDROID_NDK_VERSION} (tools/ci/toolchains.env) is not installed; using the newest NDK instead, so native caches will not match CI." >&2
ndk_path=$(find "${sdk_dir}/ndk" -mindepth 2 -maxdepth 2 -name source.properties -print | xargs -n1 dirname | sort -V | tail -1)
ndk_version=${ndk_path##*/}
fi
+12
View File
@@ -1,6 +1,7 @@
from pathlib import Path
import importlib.util
import re
import shutil
import sys
from zipfile import ZipFile
@@ -34,6 +35,14 @@ def source_assets(overlay=OVERLAY):
return result
def stage(target=OVERLAY.parents[2] / 'app/src/main', overlay=OVERLAY):
for source, asset in source_assets(overlay).items():
path = target / asset
if not path.is_file() or path.read_bytes() != source.read_bytes():
path.parent.mkdir(parents=True, exist_ok=True)
shutil.copyfile(source, path)
def check(apk, overlay=OVERLAY):
errors = check_extraction(overlay, SESSION_FILES.read_text()) if overlay == OVERLAY else []
with ZipFile(apk) as package:
@@ -60,6 +69,9 @@ def check(apk, overlay=OVERLAY):
if __name__ == '__main__':
if sys.argv[1:] == ['--stage']:
stage()
sys.exit()
errors = check(sys.argv[1])
if errors:
sys.exit('\n'.join(errors))
+24 -1
View File
@@ -48,8 +48,19 @@ def digest(path):
return result.hexdigest()
def copied(root):
# Helper scripts are staged verbatim on every Gradle build and checked against the APK by
# check_session_assets.py, so they are neither preparation inputs nor prepared outputs.
if str(Path(__file__).resolve().parent) not in sys.path:
sys.path.insert(0, str(Path(__file__).resolve().parent))
from check_session_assets import OVERLAY, source_assets
found = source_assets() if root == ROOT else source_assets(root / OVERLAY.relative_to(ROOT))
return {source.relative_to(root).as_posix(): 'app/src/main/' + asset for source, asset in found.items()}
def sources(root):
files, builds = [], set()
skipped = set(copied(root))
for name in SOURCE_PATHS:
path = root / name
files.extend(path.rglob('*') if path.is_dir() else [path])
@@ -57,14 +68,18 @@ def sources(root):
builds.update(manifest.parent / 'target' for manifest in path.rglob('Cargo.toml'))
return {path.relative_to(root).as_posix(): digest(path) for path in sorted(set(files))
if path.is_file() and '__pycache__' not in path.parts and path.suffix != '.pyc'
and path.relative_to(root).as_posix() not in skipped
and not any(build in path.parents for build in builds)}
def outputs(root):
result = {}
skipped = set(copied(root).values())
for tree in ['linuxfs', 'directaudio', 'droiddeck-esync', 'desktop-removal', 'hybris']:
base = root / 'app/src/main/assets' / tree
for path in base.rglob('*'):
if path.relative_to(root).as_posix() in skipped:
continue
if path.is_file() and not any(part.startswith('.') for part in path.relative_to(base).parts):
result['assets/' + tree + '/' + path.relative_to(base).as_posix()] = path.relative_to(root).as_posix()
for library in ['libproot.so', 'libproot-loader.so', 'libdirectaudiorelay.so']:
@@ -84,7 +99,6 @@ def required():
for name in ['turnip26.3.0-a6xx', 'turnip26.3.0-quest2']]
paths += ['assets/linuxfs/' + name for name in ['libfakeinput.so', 'libddsession.so',
'libddfastpath.so', 'libddnatv-hook.so', 'libssbs.so', 'usr/local/bin/droiddeck-clipboard',
'usr/local/bin/droiddeck-gog-maintenance',
'usr/local/bin/gamescope', 'usr/local/lib/droiddeck/uruntime',
'usr/local/lib/droiddeck-pipewire.tzst']]
for arch in ['x86_64', 'i386']:
@@ -178,6 +192,10 @@ def verify(root=ROOT, stale_sources_ok=False):
raise ValueError('Runtime inputs have not been prepared. Run tools/build_local.sh.')
if data.get('version') != 1:
raise ValueError('Runtime sources changed since preparation. Run tools/build_local.sh.')
copies = copied(root)
data['sources'] = {name: value for name, value in (data.get('sources') or {}).items() if name not in copies}
data['outputs'] = {name: output for name, output in (data.get('outputs') or {}).items()
if output.get('path') not in copies.values()}
current = sources(root)
if data.get('sources') != current:
if not stale_sources_ok:
@@ -195,6 +213,11 @@ def verify(root=ROOT, stale_sources_ok=False):
raise ValueError('Missing or changed runtime input: ' + name + '. Run tools/build_local.sh.')
if outputs(root) != {name: output['path'] for name, output in data['outputs'].items()}:
raise ValueError('Runtime file set changed. Run tools/build_local.sh.')
for source, asset in copies.items():
path = root / asset
if not path.is_file() or path.read_bytes() != (root / source).read_bytes():
raise ValueError(asset + ' is not a current copy of ' + source
+ '. Run python3 tools/release/check_session_assets.py --stage.')
return data
+7 -2
View File
@@ -10,14 +10,19 @@ paths=(
app/build/packs app/build/localPackAssets app/build/packs-local-aside app/build/quest-inputs
app/build/rustJniLibs app/build/vkbridgeJniLibs
app/src/main/assets/directaudio app/src/main/assets/droiddeck-esync app/src/main/assets/linuxfs
app/src/main/assets/desktop-removal
app/src/main/assets/desktop-removal app/src/main/assets/hybris
app/src/main/jniLibs/arm64-v8a
app/src/main/rust/stores/target
)
for path in "${paths[@]}"; do
[[ -e "${main_root}/${path}" ]] || continue
if [[ -d "${main_root}/${path}" ]]; then
[[ -z "$(ls -A "${repo_root}/${path}" 2>/dev/null)" ]] || continue
if [[ -n "$(ls -A "${repo_root}/${path}" 2>/dev/null)" ]]; then
# A directory holding only tracked files (jniLibs) still lacks every built library.
[[ -z "$(git -C "${repo_root}" ls-files --others -- "${path}")" ]] || continue
cp -Rn "${main_root}/${path}/." "${repo_root}/${path}/"
continue
fi
mkdir -p "$(dirname "${repo_root}/${path}")"
staged=$(mktemp -d "${repo_root}/${path}.seed.XXXXXX")
trap 'rm -rf "${staged}"' EXIT
+35
View File
@@ -1,6 +1,7 @@
import importlib.util
import gzip
import io
import json
from pathlib import Path, PureWindowsPath
import subprocess
import tarfile
@@ -122,6 +123,40 @@ class RuntimeInputsTest(unittest.TestCase):
runtime.verify(self.root, stale_sources_ok=True)
self.assertIn('tools/linuxfs/preload/test.c', stderr.getvalue())
def helper(self, content):
source = self.root / 'tools/linuxfs/overlay/usr/local/bin/droiddeck-test-helper'
source.parent.mkdir(parents=True, exist_ok=True)
source.write_text(content)
staged = self.root / 'app/src/main/assets/linuxfs/usr/local/bin/droiddeck-test-helper'
staged.parent.mkdir(parents=True, exist_ok=True)
staged.write_text(content)
return source, staged
def test_an_edited_helper_script_needs_no_new_preparation(self):
self.helper('old helper')
runtime.record(self.root)
self.helper('new helper')
runtime.verify(self.root)
def test_a_staged_helper_that_lags_its_source_is_rejected(self):
source, _ = self.helper('old helper')
runtime.record(self.root)
source.write_text('new helper')
with self.assertRaisesRegex(ValueError, 'not a current copy'):
runtime.verify(self.root, stale_sources_ok=True)
def test_a_manifest_that_hashed_helper_scripts_still_verifies(self):
source, staged = self.helper('old helper')
runtime.record(self.root)
manifest = self.root / runtime.MANIFEST
data = json.loads(manifest.read_text())
data['sources']['tools/linuxfs/overlay/usr/local/bin/droiddeck-test-helper'] = 'old'
data['outputs']['assets/linuxfs/usr/local/bin/droiddeck-test-helper'] = {
'path': 'app/src/main/assets/linuxfs/usr/local/bin/droiddeck-test-helper', 'sha256': 'old'}
manifest.write_text(json.dumps(data))
self.helper('new helper')
runtime.verify(self.root)
def test_dev_loop_still_rejects_changed_outputs(self):
runtime.record(self.root)
(self.root / 'app/src/main/jniLibs/arm64-v8a/libproot.so').write_bytes(b'old APK binary')
+7
View File
@@ -50,3 +50,10 @@ class SessionAssetsTest(unittest.TestCase):
mapping = '"usr/local/bin/droiddeck-login1" to "usr/local/bin/sub/login1"'
self.assertEqual(['not extracted at session start: usr/local/bin/droiddeck-login1'],
assets.check_extraction(self.overlay, mapping))
def test_stage_refreshes_a_changed_helper(self):
target = self.root / 'main'
assets.stage(target, self.overlay)
self.helper.write_bytes(b'new helper')
assets.stage(target, self.overlay)
self.assertEqual(b'new helper', (target / self.name).read_bytes())