Support empty resources and project Android services
Sync changed files to Google Drive / sync (push) Successful in 1m2s

This commit is contained in:
admin_d committed 2026-09-14 23:49:46 +05:00
1 parent c6b5725c35
commit 19ee837986
5 files changed
+77 -6

No files matched your search

+27 -2
View File
@@ -9,7 +9,7 @@ from common import (ROOT, COMMIT, CPUS, ProbeError, stamp, sha256, write_json, r
from source_fetch import fetch, verify
from source_audit import inventory
from source_resolution import load_source_contract, validate_source_contract, build_source_resolution
from generate import materialize_application_project
from generate import android_service_roots, materialize_application_project
from artifacts import inspect_elf, inspect_apk
from resource_staging import stage_runtime_resources
@@ -108,6 +108,30 @@ def _prepare(build_id:str, diagnostics:bool=True)->tuple[Path,Path]:
if diagnostics:tool_versions(logs)
return work,logs
def stage_android_services(project:Path, logs:Path)->None:
services=android_service_roots(project/'android_services')
if not services:return
if os.environ.get('KAM_CONTAINER_BUILD')!='1':
raise ProbeError('Project-owned Android services require the normal disposable-container build: ./build-android.sh')
castle_path=os.environ.get('CASTLE_ENGINE_PATH')
if not castle_path:
raise ProbeError('Cannot stage project-owned Android services: CASTLE_ENGINE_PATH is not set')
service_root=Path(castle_path)/'tools/build-tool/data/android/services'
if not service_root.is_dir():
raise ProbeError('Cannot stage project-owned Android services: Castle service root is missing: '+str(service_root))
try:
with (logs/'android-services.log').open('w',encoding='utf-8') as log:
for service in services:
destination=service_root/service.name
if destination.exists() or destination.is_symlink():
raise ProbeError('Project-owned Android service collides with Castle built-in service: '+service.name)
shutil.copytree(service,destination)
log.write(f'project service: {service.name}\nsource: {service}\ncastle destination: {destination}\nstatus: staged\n')
except ProbeError:
raise
except OSError as error:
raise ProbeError(f'Cannot stage project-owned Android services: {error}') from error
def build_local(a:argparse.Namespace,build_id:str)->int:
work,logs=_prepare(build_id, not bool(os.environ.get('KAM_BUILD_ID')))
app=None; resources=None; compile={'status':'NOT_RUN','exit_code':None}; package={'status':'NOT_RUN','exit_code':None}
@@ -119,6 +143,7 @@ def build_local(a:argparse.Namespace,build_id:str)->int:
resolution=build_source_resolution(validated,vendor_root,ROOT/'code')
descriptor=materialize_application_project(work/'application',resolution);app=_application(descriptor)
resources=stage_runtime_resources(descriptor['data_root'])
stage_android_services(descriptor['project_dir'],logs)
except (ProbeError,OSError,ValueError,KeyError) as error:
return _finish(_record(build_id,a.cpu,'BLOCKED',app,None,compile,package,error=str(error)))
if not shutil.which('castle-engine'):
@@ -183,7 +208,7 @@ def docker_build(a:argparse.Namespace,build_id:str)->int:
if image is None:raise ProbeError('Image has no immutable RepoDigest')
write_json(lock,{'image':image,'image_id':info['Id'],'resolved_from':IMAGE_TAG,'locked_at':stamp(),'note':'Subsequent runs use this digest, never silently advance the tag.'})
cmd=['docker','run','--rm','--platform=linux/amd64','--user','0:0','-e','HOME=/work/.cache/home',
'-e','KAM_BUILD_ID='+build_id,'-v',str(ROOT)+':/work','-w','/work']
'-e','KAM_BUILD_ID='+build_id,'-e','KAM_CONTAINER_BUILD=1','-v',str(ROOT)+':/work','-w','/work']
if os.environ.get('GITHUB_TOKEN'):cmd+=['-e','GITHUB_TOKEN']
cmd+=['--entrypoint','python3',image,'tools/runner.py','--local','--cpu',a.cpu,'--timeout',str(a.timeout)]
if a.no_fetch:cmd+=['--no-fetch']