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

+2 -2
View File
@@ -5,8 +5,8 @@
# Building and testing # Building and testing
- For an install-and-look iteration, use `tools/quick_deploy.sh` (build without lint, sign, install, about 30 s). Run `tools/build_local.sh` once to prepare the runtime and again only before a PR. It is not a per-change step. - For an install-and-look iteration, use `tools/quick_deploy.sh` (build without lint, sign, install, about 30 s). Run `tools/build_local.sh` once to prepare the runtime and again only before a PR. It is not a per-change step.
- `verifyRuntimeInputs` fails the fast build with "Missing or changed runtime input" or "Runtime sources changed since preparation" after you pull main or edit `tools/linuxfs` (overlay scripts, preloads). Run `tools/build_local.sh` once. Do not revert scripts or copy `app/build` from another checkout to get past it. - Helper scripts (`tools/linuxfs/overlay`, `tools/linuxfs/desktop`) are staged on every Gradle build, so editing them needs no `build_local.sh`. After preloads or other runtime components change, the fast loop warns and reuses the old binaries; run `tools/build_local.sh` when those matter. "Missing or changed runtime input" means the prepared files themselves changed: run `tools/build_local.sh` once. Do not revert scripts or copy `app/build` between checkouts; `tools/seed_worktree.sh` seeds a new worktree from the main checkout.
- CI builds with the NDK in `tools/ci/toolchains.env` and runs `testReleaseUnitTest`. Local builds default to `gradle.properties`' NDK and `testDebugUnitTest`. Pass `-PndkVersion=` and run the release variant when a failure only shows up in CI. - Every build defaults to the NDK in `tools/ci/toolchains.env`, as CI does. CI runs `testReleaseUnitTest`; when a test fails only in CI, run the release variant locally.
- Run the tests that cover what you changed, including unchanged tests of code you edited: `./gradlew -PskipRust=true :app:testDebugUnitTest --tests '<class>'` and `python3 -m unittest discover -s tools/tests -p 'test_<area>*.py'`. The full Python suite takes about 9 minutes, and some preload tests fail on any host without zram/ntsync. Leave full runs to CI. - Run the tests that cover what you changed, including unchanged tests of code you edited: `./gradlew -PskipRust=true :app:testDebugUnitTest --tests '<class>'` and `python3 -m unittest discover -s tools/tests -p 'test_<area>*.py'`. The full Python suite takes about 9 minutes, and some preload tests fail on any host without zram/ntsync. Leave full runs to CI.
- For UI screenshots without a device, run `./gradlew -PskipRust=true :app:testDebugUnitTest --tests '*PreviewRenderTest'` and read `app/build/preview-renders/{handheld,portrait}/`. Add cases per `docs/compose-previews.md`. Check portrait, not just landscape. - For UI screenshots without a device, run `./gradlew -PskipRust=true :app:testDebugUnitTest --tests '*PreviewRenderTest'` and read `app/build/preview-renders/{handheld,portrait}/`. Add cases per `docs/compose-previews.md`. Check portrait, not just landscape.
- After changing `SettingsIndex`, regenerate the doc: `UPDATE_SETTINGS_MAP=1 ./gradlew -PskipRust=true :app:testDebugUnitTest --tests '*SettingsMapTest*'`. - After changing `SettingsIndex`, regenerate the doc: `UPDATE_SETTINGS_MAP=1 ./gradlew -PskipRust=true :app:testDebugUnitTest --tests '*SettingsMapTest*'`.
+5 -6
View File
@@ -125,7 +125,8 @@ def variantSuffixes = rootProject.file('tools/release/variants.txt').readLines()
android { android {
namespace 'com.droiddeck.launcher' namespace 'com.droiddeck.launcher'
compileSdk 34 compileSdk 34
ndkVersion project.findProperty('ndkVersion') ?: '27.3.13750724' ndkVersion project.findProperty('ndkVersion') ?: providers.fileContents(rootProject.layout.projectDirectory.file('tools/ci/toolchains.env'))
.asText.get().readLines().find { it.startsWith('CI_ANDROID_NDK_VERSION=') }.split('=', 2)[1].trim()
defaultConfig { defaultConfig {
applicationId "com.droiddeck.launcher" applicationId "com.droiddeck.launcher"
@@ -264,11 +265,9 @@ if (vitureSdkDir) {
tasks.named('preBuild').configure { dependsOn(stageVitureNotices) } tasks.named('preBuild').configure { dependsOn(stageVitureNotices) }
} }
def stageSessionScripts = tasks.register('stageSessionScripts', Copy) { def stageSessionScripts = tasks.register('stageSessionScripts', Exec) {
from(rootProject.file('tools/linuxfs/overlay')) { workingDir rootProject.projectDir
include 'usr/local/bin/droiddeck-*', 'usr/local/bin/steam-compatibility', 'usr/bin/**' commandLine pythonExecutable, 'tools/release/check_session_assets.py', '--stage'
}
into(layout.projectDirectory.dir('src/main/assets/linuxfs'))
} }
tasks.named('preBuild').configure { dependsOn(stageSessionScripts) } tasks.named('preBuild').configure { dependsOn(stageSessionScripts) }
-1
View File
@@ -4,6 +4,5 @@ org.gradle.configuration-cache=true
org.gradle.parallel=true org.gradle.parallel=true
android.useAndroidX=true android.useAndroidX=true
android.nonTransitiveRClass=true android.nonTransitiveRClass=true
ndkVersion=27.3.13750724
org.gradle.tooling.parallel=true org.gradle.tooling.parallel=true
+5
View File
@@ -63,6 +63,11 @@ fi
ndk_version=${DROIDDECK_NDK_VERSION:-} ndk_version=${DROIDDECK_NDK_VERSION:-}
if [[ -z "${ndk_version}" ]]; then 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_path=$(find "${sdk_dir}/ndk" -mindepth 2 -maxdepth 2 -name source.properties -print | xargs -n1 dirname | sort -V | tail -1)
ndk_version=${ndk_path##*/} ndk_version=${ndk_path##*/}
fi fi
+12
View File
@@ -1,6 +1,7 @@
from pathlib import Path from pathlib import Path
import importlib.util import importlib.util
import re import re
import shutil
import sys import sys
from zipfile import ZipFile from zipfile import ZipFile
@@ -34,6 +35,14 @@ def source_assets(overlay=OVERLAY):
return result 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): def check(apk, overlay=OVERLAY):
errors = check_extraction(overlay, SESSION_FILES.read_text()) if overlay == OVERLAY else [] errors = check_extraction(overlay, SESSION_FILES.read_text()) if overlay == OVERLAY else []
with ZipFile(apk) as package: with ZipFile(apk) as package:
@@ -60,6 +69,9 @@ def check(apk, overlay=OVERLAY):
if __name__ == '__main__': if __name__ == '__main__':
if sys.argv[1:] == ['--stage']:
stage()
sys.exit()
errors = check(sys.argv[1]) errors = check(sys.argv[1])
if errors: if errors:
sys.exit('\n'.join(errors)) sys.exit('\n'.join(errors))
+24 -1
View File
@@ -48,8 +48,19 @@ def digest(path):
return result.hexdigest() 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): def sources(root):
files, builds = [], set() files, builds = [], set()
skipped = set(copied(root))
for name in SOURCE_PATHS: for name in SOURCE_PATHS:
path = root / name path = root / name
files.extend(path.rglob('*') if path.is_dir() else [path]) 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')) 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)) 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' 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)} and not any(build in path.parents for build in builds)}
def outputs(root): def outputs(root):
result = {} result = {}
skipped = set(copied(root).values())
for tree in ['linuxfs', 'directaudio', 'droiddeck-esync', 'desktop-removal', 'hybris']: for tree in ['linuxfs', 'directaudio', 'droiddeck-esync', 'desktop-removal', 'hybris']:
base = root / 'app/src/main/assets' / tree base = root / 'app/src/main/assets' / tree
for path in base.rglob('*'): 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): 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() 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']: 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']] for name in ['turnip26.3.0-a6xx', 'turnip26.3.0-quest2']]
paths += ['assets/linuxfs/' + name for name in ['libfakeinput.so', 'libddsession.so', paths += ['assets/linuxfs/' + name for name in ['libfakeinput.so', 'libddsession.so',
'libddfastpath.so', 'libddnatv-hook.so', 'libssbs.so', 'usr/local/bin/droiddeck-clipboard', '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/bin/gamescope', 'usr/local/lib/droiddeck/uruntime',
'usr/local/lib/droiddeck-pipewire.tzst']] 'usr/local/lib/droiddeck-pipewire.tzst']]
for arch in ['x86_64', 'i386']: 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.') raise ValueError('Runtime inputs have not been prepared. Run tools/build_local.sh.')
if data.get('version') != 1: if data.get('version') != 1:
raise ValueError('Runtime sources changed since preparation. Run tools/build_local.sh.') 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) current = sources(root)
if data.get('sources') != current: if data.get('sources') != current:
if not stale_sources_ok: 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.') 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()}: if outputs(root) != {name: output['path'] for name, output in data['outputs'].items()}:
raise ValueError('Runtime file set changed. Run tools/build_local.sh.') 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 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/packs app/build/localPackAssets app/build/packs-local-aside app/build/quest-inputs
app/build/rustJniLibs app/build/vkbridgeJniLibs 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/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/jniLibs/arm64-v8a
app/src/main/rust/stores/target app/src/main/rust/stores/target
) )
for path in "${paths[@]}"; do for path in "${paths[@]}"; do
[[ -e "${main_root}/${path}" ]] || continue [[ -e "${main_root}/${path}" ]] || continue
if [[ -d "${main_root}/${path}" ]]; then 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}")" mkdir -p "$(dirname "${repo_root}/${path}")"
staged=$(mktemp -d "${repo_root}/${path}.seed.XXXXXX") staged=$(mktemp -d "${repo_root}/${path}.seed.XXXXXX")
trap 'rm -rf "${staged}"' EXIT trap 'rm -rf "${staged}"' EXIT
+35
View File
@@ -1,6 +1,7 @@
import importlib.util import importlib.util
import gzip import gzip
import io import io
import json
from pathlib import Path, PureWindowsPath from pathlib import Path, PureWindowsPath
import subprocess import subprocess
import tarfile import tarfile
@@ -122,6 +123,40 @@ class RuntimeInputsTest(unittest.TestCase):
runtime.verify(self.root, stale_sources_ok=True) runtime.verify(self.root, stale_sources_ok=True)
self.assertIn('tools/linuxfs/preload/test.c', stderr.getvalue()) 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): def test_dev_loop_still_rejects_changed_outputs(self):
runtime.record(self.root) runtime.record(self.root)
(self.root / 'app/src/main/jniLibs/arm64-v8a/libproot.so').write_bytes(b'old APK binary') (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"' mapping = '"usr/local/bin/droiddeck-login1" to "usr/local/bin/sub/login1"'
self.assertEqual(['not extracted at session start: usr/local/bin/droiddeck-login1'], self.assertEqual(['not extracted at session start: usr/local/bin/droiddeck-login1'],
assets.check_extraction(self.overlay, mapping)) 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())