Reuse Android compiler outputs and remove old build artifacts
Sync changed files to Google Drive / sync (push) Successful in 2m27s
Sync changed files to Google Drive / sync (push) Successful in 2m27s
This commit is contained in:
1 parent
29df541ea1
commit
d6676896d4
70 files changed
+225
-2828
No files matched your search
+17
-8
@@ -1,11 +1,11 @@
|
||||
"""Generate isolated Android CGE targets. No KaM stubs or rewritten game loaders."""
|
||||
from __future__ import annotations
|
||||
import hashlib, os, re, shutil, xml.etree.ElementTree as ET
|
||||
import hashlib, io, os, re, shutil, xml.etree.ElementTree as ET
|
||||
from pathlib import Path
|
||||
from common import ROOT, ProbeError
|
||||
|
||||
UPSTREAM_DEFINES=['DBG_SKIP_SECURE_AUTH'] # Existing upstream switch; private multiplayer authentication is out of scope.
|
||||
COMPILER_OPTIONS=['-B','-CX-','-XX-','-k--no-undefined','-k--no-gc-sections']
|
||||
COMPILER_OPTIONS=['-CX-','-XX-','-k--no-undefined','-k--no-gc-sections']
|
||||
_ANDROID_SERVICE_NAME=re.compile(r'[A-Za-z][A-Za-z0-9_]*\Z')
|
||||
|
||||
_PROJECT_ATTRIBUTES={
|
||||
@@ -89,27 +89,36 @@ def android_service_roots(root: Path) -> tuple[Path,...]:
|
||||
raise ProbeError(f'Cannot inspect Android services: {error}') from error
|
||||
|
||||
def materialize_application_project(project: Path, source_resolution: dict) -> dict:
|
||||
"""Create one fresh Castle project from the permanent manifest and RP01 paths."""
|
||||
if project.exists():raise ProbeError('Target directory must be fresh: '+str(project))
|
||||
"""Refresh project inputs while preserving compatible compiler outputs."""
|
||||
if project.is_symlink():raise ProbeError('Target directory must not be a symlink: '+str(project))
|
||||
try:
|
||||
compiler_paths=tuple(source_resolution['compiler_source_paths'])
|
||||
library_paths=tuple(source_resolution['library_paths'])
|
||||
except (KeyError, TypeError) as error:
|
||||
raise ProbeError(f'Invalid source resolution: {error}') from error
|
||||
tree,root=_permanent_manifest()
|
||||
project.mkdir(parents=True)
|
||||
data_root=project/'data';data_root.mkdir()
|
||||
project.mkdir(parents=True,exist_ok=True)
|
||||
data_root=project/'data'
|
||||
if data_root.is_symlink():raise ProbeError('Project data must not be a symlink')
|
||||
data_root.mkdir(exist_ok=True)
|
||||
options=_one_child(root,'compiler_options')
|
||||
for tag,paths,kind in (('search_paths',compiler_paths,'Source'),('library_paths',library_paths,'Native library')):
|
||||
slot=_one_child(options,tag)
|
||||
for child in list(slot):slot.remove(child)
|
||||
for path in paths:ET.SubElement(slot,'path',value=_manifest_path(path,project,kind))
|
||||
ET.indent(tree)
|
||||
tree.write(project/'CastleEngineManifest.xml',encoding='utf-8',xml_declaration=True)
|
||||
rendered=io.BytesIO()
|
||||
tree.write(rendered,encoding='utf-8',xml_declaration=True)
|
||||
manifest=project/'CastleEngineManifest.xml'
|
||||
if manifest.is_symlink():raise ProbeError('Generated manifest must not be a symlink')
|
||||
if not manifest.exists() or manifest.read_bytes()!=rendered.getvalue():
|
||||
manifest.write_bytes(rendered.getvalue())
|
||||
source_services=ROOT/'app/android_services'
|
||||
services=android_service_roots(source_services)
|
||||
destination_root=project/'android_services'
|
||||
android_service_roots(destination_root)
|
||||
if destination_root.exists():shutil.rmtree(destination_root)
|
||||
if services:
|
||||
destination_root=project/'android_services'
|
||||
destination_root.mkdir()
|
||||
for service in services:
|
||||
destination=destination_root/service.name
|
||||
|
||||
Reference in new issue
Block a user