refactor(build): unify SDK configuration and release tooling
Pin Flutter with FVM and share local environment loading across IDE, Python, and Dart entrypoints. Keep CI on the verified preinstalled SDK and skip local overrides. Extract common build presets, process execution, and file hashing. Propagate project roots through SDK selection and release commands, and migrate macOS release, signing, and DMG orchestration to Python. Reuse local check suites in CI, support Android source overrides, and update documentation and regression tests.
This commit is contained in:
1 parent
a13a54d5ec
commit
0343e2f723
57 files changed
+1858
-375
No files matched your search
@@ -0,0 +1 @@
|
||||
"""Shared infrastructure for repository command-line tools."""
|
||||
@@ -0,0 +1,23 @@
|
||||
"""Application build presets shared by CLI and platform release workflows."""
|
||||
from common.process import ROOT
|
||||
from project_tools import run_tool
|
||||
|
||||
|
||||
def build_arguments(platform, *, flavor='production', mode='release', split_per_abi=False):
|
||||
target = 'apk' if platform == 'android' else platform
|
||||
arguments = ['build', target, f'--{mode}', '--flavor', flavor]
|
||||
if platform == 'android':
|
||||
arguments += ['--target-platform', 'android-arm64,android-x64']
|
||||
if split_per_abi:
|
||||
arguments.append('--split-per-abi')
|
||||
if platform == 'macos':
|
||||
arguments.append('--split-debug-info=build/symbols/macos')
|
||||
return arguments
|
||||
|
||||
|
||||
def build_application(platform, *, flavor='production', mode='release',
|
||||
split_per_abi=False, extra=(), environment=None, root=ROOT, cwd=None):
|
||||
"""Use root's SDK/configuration; an isolated build may override cwd."""
|
||||
return run_tool('flutter', build_arguments(
|
||||
platform, flavor=flavor, mode=mode, split_per_abi=split_per_abi) + list(extra),
|
||||
root=root, cwd=cwd, env=environment, check=True)
|
||||
@@ -0,0 +1,7 @@
|
||||
"""Streaming hashes for platform package files."""
|
||||
import hashlib
|
||||
|
||||
|
||||
def file_sha256(path):
|
||||
with path.open('rb') as stream:
|
||||
return hashlib.file_digest(stream, 'sha256').hexdigest()
|
||||
@@ -0,0 +1,31 @@
|
||||
"""Run argument vectors and report failures without logging credentials."""
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
|
||||
|
||||
def run(command, *, cwd=ROOT, env=None, check=True, timeout=None, **kwargs):
|
||||
return subprocess.run(list(map(str, command)), cwd=cwd, env=env,
|
||||
check=check, timeout=timeout, **kwargs)
|
||||
|
||||
|
||||
def cli(main):
|
||||
"""Shared exit contract; argparse continues to own help and usage errors."""
|
||||
try:
|
||||
return main() or 0
|
||||
except subprocess.CalledProcessError as error:
|
||||
print(f'Command failed (exit {error.returncode}).', file=sys.stderr)
|
||||
return error.returncode
|
||||
except subprocess.TimeoutExpired:
|
||||
print('Command timed out.', file=sys.stderr)
|
||||
return 1
|
||||
except (RuntimeError, ValueError) as error:
|
||||
print(error, file=sys.stderr)
|
||||
return 1
|
||||
except OSError:
|
||||
print('Required tool or file is unavailable; check paths and permissions.', file=sys.stderr)
|
||||
return 1
|
||||
except KeyboardInterrupt:
|
||||
return 130
|
||||
Reference in new issue
Block a user