mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-05 20:45:43 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
97ab26cb31 | ||
|
|
69d303873c |
No files matched your search
+3
-1
@@ -303,7 +303,9 @@ tasks.named('preBuild').configure { dependsOn(stageGogNotices) }
|
|||||||
def verifyRuntimeInputs = tasks.register('verifyRuntimeInputs', Exec) {
|
def verifyRuntimeInputs = tasks.register('verifyRuntimeInputs', Exec) {
|
||||||
mustRunAfter(stageSessionScripts, stageRuntimeAssets)
|
mustRunAfter(stageSessionScripts, stageRuntimeAssets)
|
||||||
workingDir rootProject.projectDir
|
workingDir rootProject.projectDir
|
||||||
commandLine pythonExecutable, 'tools/release/runtime_inputs.py', 'verify'
|
def allowStale = (project.findProperty('allowStaleRuntime')
|
||||||
|
?: localBuildOptions.getProperty('droiddeck.allowStaleRuntime', 'false')).toString().toBoolean()
|
||||||
|
commandLine([pythonExecutable, 'tools/release/runtime_inputs.py', 'verify'] + (allowStale ? ['--allow-stale-sources'] : []))
|
||||||
}
|
}
|
||||||
tasks.configureEach { task ->
|
tasks.configureEach { task ->
|
||||||
if (task.name in ['packageDebug', 'packageRelease']) task.dependsOn(verifyRuntimeInputs)
|
if (task.name in ['packageDebug', 'packageRelease']) task.dependsOn(verifyRuntimeInputs)
|
||||||
|
|||||||
@@ -23,7 +23,8 @@ while IFS= read -r dir; do
|
|||||||
done < <(ls -d "${sdk_dir}"/build-tools/* 2>/dev/null | sort -rV)
|
done < <(ls -d "${sdk_dir}"/build-tools/* 2>/dev/null | sort -rV)
|
||||||
[[ -n "${build_tools}" ]] || { echo "No build-tools with aapt, zipalign and apksigner under ${sdk_dir}." >&2; exit 1; }
|
[[ -n "${build_tools}" ]] || { echo "No build-tools with aapt, zipalign and apksigner under ${sdk_dir}." >&2; exit 1; }
|
||||||
|
|
||||||
./gradlew -q :app:assembleRelease
|
# Runtime assets from another branch are fine for a Kotlin/UI loop; CI and releases stay strict.
|
||||||
|
./gradlew -q -PallowStaleRuntime=true :app:assembleRelease
|
||||||
(
|
(
|
||||||
cd "$(dirname "${signing_env}")"
|
cd "$(dirname "${signing_env}")"
|
||||||
set -a; . "${signing_env}"; set +a
|
set -a; . "${signing_env}"; set +a
|
||||||
|
|||||||
@@ -31,6 +31,16 @@ SOURCE_PATHS = ['app/build.gradle', 'app/src/main/cpp/fakeinput_steam.cpp', 'app
|
|||||||
'app/src/main/cpp/waylandcomp/src/spatialpose_shm.h',
|
'app/src/main/cpp/waylandcomp/src/spatialpose_shm.h',
|
||||||
'app/src/main/cpp/adrenotools/src/hook/kgsl.h',
|
'app/src/main/cpp/adrenotools/src/hook/kgsl.h',
|
||||||
'app/src/main/assets/graphics_driver/adrenotools-turnip25.1.0.tzst']
|
'app/src/main/assets/graphics_driver/adrenotools-turnip25.1.0.tzst']
|
||||||
|
# Gradle reads these pins directly, so prepared assets built from other pins cannot be reused.
|
||||||
|
STRICT_SOURCE_PREFIXES = ('tools/packs/tracking/',)
|
||||||
|
|
||||||
|
|
||||||
|
def staged_scripts(root):
|
||||||
|
"""Outputs Gradle's stageSessionScripts copies from source on every build."""
|
||||||
|
overlay = root / 'tools/linuxfs/overlay'
|
||||||
|
patterns = ['usr/local/bin/droiddeck-*', 'usr/local/bin/steam-compatibility', 'usr/bin/**/*']
|
||||||
|
return {'assets/linuxfs/' + path.relative_to(overlay).as_posix()
|
||||||
|
for pattern in patterns for path in overlay.glob(pattern) if path.is_file()}
|
||||||
|
|
||||||
|
|
||||||
def digest(path):
|
def digest(path):
|
||||||
@@ -149,19 +159,31 @@ def record(root=ROOT):
|
|||||||
(root / MANIFEST).write_text(json.dumps(data, sort_keys=True, indent=2) + '\n')
|
(root / MANIFEST).write_text(json.dumps(data, sort_keys=True, indent=2) + '\n')
|
||||||
|
|
||||||
|
|
||||||
def verify(root=ROOT):
|
def verify(root=ROOT, stale_sources_ok=False):
|
||||||
try:
|
try:
|
||||||
data = json.loads((root / MANIFEST).read_text())
|
data = json.loads((root / MANIFEST).read_text())
|
||||||
except (OSError, ValueError):
|
except (OSError, ValueError):
|
||||||
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 or data.get('sources') != sources(root):
|
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.')
|
||||||
|
current = sources(root)
|
||||||
|
if data.get('sources') != current:
|
||||||
|
if not stale_sources_ok:
|
||||||
|
raise ValueError('Runtime sources changed since preparation. Run tools/build_local.sh.')
|
||||||
|
recorded = data.get('sources') or {}
|
||||||
|
changed = sorted(name for name in recorded.keys() | current.keys() if recorded.get(name) != current.get(name))
|
||||||
|
pinned = [name for name in changed if name.startswith(STRICT_SOURCE_PREFIXES)]
|
||||||
|
if pinned:
|
||||||
|
raise ValueError('Runtime pins changed since preparation (' + ', '.join(pinned) + '). Run tools/build_local.sh.')
|
||||||
|
print('Warning: reusing runtime assets prepared from other sources (run tools/build_local.sh if these matter):\n '
|
||||||
|
+ '\n '.join(changed[:20]) + ('\n ...' if len(changed) > 20 else ''), file=sys.stderr)
|
||||||
for name in required():
|
for name in required():
|
||||||
if name not in data['outputs']:
|
if name not in data['outputs']:
|
||||||
raise ValueError('Runtime manifest missing ' + name)
|
raise ValueError('Runtime manifest missing ' + name)
|
||||||
|
restaged = staged_scripts(root) if stale_sources_ok else set()
|
||||||
for name, output in data['outputs'].items():
|
for name, output in data['outputs'].items():
|
||||||
path = root / output['path']
|
path = root / output['path']
|
||||||
if not path.is_file() or digest(path) != output['sha256']:
|
if not path.is_file() or (digest(path) != output['sha256'] and name not in restaged):
|
||||||
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.')
|
||||||
@@ -224,7 +246,7 @@ if __name__ == '__main__':
|
|||||||
if sys.argv[1] == 'record':
|
if sys.argv[1] == 'record':
|
||||||
record()
|
record()
|
||||||
elif sys.argv[1] == 'verify':
|
elif sys.argv[1] == 'verify':
|
||||||
verify()
|
verify(stale_sources_ok='--allow-stale-sources' in sys.argv[2:])
|
||||||
elif sys.argv[1] == 'apk':
|
elif sys.argv[1] == 'apk':
|
||||||
check_apk(sys.argv[2])
|
check_apk(sys.argv[2])
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -88,6 +88,42 @@ class RuntimeInputsTest(unittest.TestCase):
|
|||||||
with self.assertRaisesRegex(ValueError, 'sources changed'):
|
with self.assertRaisesRegex(ValueError, 'sources changed'):
|
||||||
runtime.verify(self.root)
|
runtime.verify(self.root)
|
||||||
|
|
||||||
|
def test_dev_loop_can_reuse_assets_from_other_sources(self):
|
||||||
|
runtime.record(self.root)
|
||||||
|
self.source.write_text('new implementation')
|
||||||
|
with mock.patch('sys.stderr', new_callable=io.StringIO) as stderr:
|
||||||
|
runtime.verify(self.root, stale_sources_ok=True)
|
||||||
|
self.assertIn('tools/linuxfs/preload/test.c', stderr.getvalue())
|
||||||
|
|
||||||
|
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')
|
||||||
|
with self.assertRaisesRegex(ValueError, 'changed runtime input'):
|
||||||
|
runtime.verify(self.root, stale_sources_ok=True)
|
||||||
|
|
||||||
|
def test_dev_loop_accepts_restaged_session_scripts(self):
|
||||||
|
script = self.root / 'tools/linuxfs/overlay/usr/local/bin/droiddeck-test'
|
||||||
|
staged = self.root / 'app/src/main/assets/linuxfs/usr/local/bin/droiddeck-test'
|
||||||
|
for path in (script, staged):
|
||||||
|
path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
path.write_text('old script')
|
||||||
|
runtime.record(self.root)
|
||||||
|
script.write_text('new script')
|
||||||
|
staged.write_text('new script')
|
||||||
|
with mock.patch('sys.stderr', new_callable=io.StringIO):
|
||||||
|
runtime.verify(self.root, stale_sources_ok=True)
|
||||||
|
with self.assertRaisesRegex(ValueError, 'sources changed'):
|
||||||
|
runtime.verify(self.root)
|
||||||
|
|
||||||
|
def test_dev_loop_rejects_changed_tracking_pins(self):
|
||||||
|
pins = self.root / 'tools/packs/tracking/release.env'
|
||||||
|
pins.parent.mkdir(parents=True)
|
||||||
|
pins.write_text('OPENCV_VERSION=4.10.0')
|
||||||
|
runtime.record(self.root)
|
||||||
|
pins.write_text('OPENCV_VERSION=4.11.0')
|
||||||
|
with self.assertRaisesRegex(ValueError, 'pins changed'):
|
||||||
|
runtime.verify(self.root, stale_sources_ok=True)
|
||||||
|
|
||||||
def test_changed_quest_source_rejects_old_outputs(self):
|
def test_changed_quest_source_rejects_old_outputs(self):
|
||||||
source = self.root / 'tools/quest/kgsl_compat.c'
|
source = self.root / 'tools/quest/kgsl_compat.c'
|
||||||
source.parent.mkdir(parents=True)
|
source.parent.mkdir(parents=True)
|
||||||
|
|||||||
Reference in new issue
Block a user