Fix Task 2 resource and native contracts
Sync changed files to Google Drive / sync (push) Successful in 33s
Sync changed files to Google Drive / sync (push) Successful in 33s
This commit is contained in:
1 parent
b52921e171
commit
3c16d9485a
3 files changed
+14
-3
No files matched your search
@@ -2,6 +2,7 @@
|
||||
"schema": "kam-runtime-resources/1",
|
||||
"entries": [
|
||||
{"kind": "directory", "path": "data"},
|
||||
{"kind": "directory", "path": "SpriteResource"},
|
||||
{"kind": "directory", "path": "Maps"},
|
||||
{"kind": "directory", "path": "MapsMP"},
|
||||
{"kind": "directory", "path": "Campaigns"},
|
||||
|
||||
@@ -46,6 +46,7 @@ def current_package() -> tuple[dict, str]:
|
||||
apk=package.get('apk')
|
||||
if not isinstance(apk,dict) or set(apk)!={'file','sha256','size','native_library_path_in_apk'} or apk.get('file')!='out/current/kam-mobile.apk': fail('Package APK locator mismatch')
|
||||
if package['cpu'] not in CPUS or package['abi']!=CPUS[package['cpu']][0]: fail('Invalid package ABI')
|
||||
if apk.get('native_library_path_in_apk')!=f"lib/{package['abi']}/libkam_mobile.so": fail('Package native library path does not match selected ABI')
|
||||
if not CURRENT_APK.is_file() or apk.get('sha256')!=sha256(CURRENT_APK): fail('Current APK missing or changed')
|
||||
return package, identity['package']
|
||||
|
||||
|
||||
+12
-3
@@ -92,6 +92,16 @@ def _error(log:Path)->str:
|
||||
text=log.read_text(errors='replace') if log.exists() else ''
|
||||
return (first_errors(text) or [text[-1500:] or 'Build command failed'])[0]
|
||||
|
||||
def _native_library_path(cpu:str)->str:
|
||||
return f'lib/{CPUS[cpu][0]}/libkam_mobile.so'
|
||||
|
||||
def _select_native_library(project:Path, name:str, cpu:str)->Path:
|
||||
candidates=sorted(project.rglob(f'lib{name}_android_{cpu}.so'),key=lambda path:str(path))
|
||||
if not candidates:raise ProbeError('Compiler exited 0 but expected native library is missing')
|
||||
hashes={sha256(path) for path in candidates}
|
||||
if len(hashes)!=1:raise ProbeError('Ambiguous native library outputs for '+CPUS[cpu][0]+': '+', '.join(str(path) for path in candidates))
|
||||
return candidates[0]
|
||||
|
||||
def _prepare(build_id:str, diagnostics:bool=True)->tuple[Path,Path]:
|
||||
work=ROOT/'build'/build_id; logs=work/'logs'
|
||||
logs.mkdir(parents=True,exist_ok=True)
|
||||
@@ -118,9 +128,7 @@ def build_local(a:argparse.Namespace,build_id:str)->int:
|
||||
if compile['status']!='PASS':
|
||||
return _finish(_record(build_id,a.cpu,compile['status'],app,len(resources),compile,package,error=_error(logs/'compile.log')))
|
||||
try:
|
||||
candidates=list(project.rglob(f"lib{descriptor['name']}_android_{a.cpu}.so"))
|
||||
if len(candidates)!=1:raise ProbeError('Compiler exited 0 but expected exactly one native library')
|
||||
library=candidates[0]; inspect_elf(library.read_bytes(),a.cpu)
|
||||
library=_select_native_library(project,descriptor['name'],a.cpu); inspect_elf(library.read_bytes(),a.cpu)
|
||||
except (ProbeError,OSError,ValueError) as error:
|
||||
compile['status']='FAIL'
|
||||
return _finish(_record(build_id,a.cpu,'FAIL',app,len(resources),compile,package,error=str(error)))
|
||||
@@ -133,6 +141,7 @@ def build_local(a:argparse.Namespace,build_id:str)->int:
|
||||
if not candidates:raise ProbeError('Packaging exited 0 but no APK')
|
||||
if len({sha256(path) for path in candidates})!=1:raise ProbeError('Multiple different APK outputs')
|
||||
apk=candidates[0]; apk_info=inspect_apk(apk,a.cpu,library.name,sha256(library),library.read_bytes())
|
||||
if apk_info['main_library_path']!=_native_library_path(a.cpu):raise ProbeError('APK native library path does not match selected ABI and libkam_mobile.so')
|
||||
signer=signature_tool()
|
||||
if signer:
|
||||
signed=run_command([signer,'verify','--verbose',str(apk)],project,logs/'signature.log',a.timeout)
|
||||
|
||||
Reference in new issue
Block a user