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:
lingjhf committed 2026-10-06 23:34:15 +08:00
1 parent a13a54d5ec
commit 0343e2f723
57 files changed
+1858 -375

No files matched your search

+15 -10
View File
@@ -2,19 +2,23 @@
The JSON config supplies WHISPER_SOURCE, M2M100_SOURCE, MELBAND_SOURCE and
CUTDEX_ASR_FIXTURE. Models are copied into the app-managed resource layout.
Run build_macos_release.sh afterwards to produce the normal application.
Run build_macos_release.py afterwards to produce the normal application.
"""
import argparse
import json
import os
import shutil
from pathlib import Path
import subprocess
import tempfile
import sys
from functools import partial
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
from project_tools import project_environment, tool_command
from common.process import cli, run as run_command
from release import sign_app
def run(command, **kwargs):
subprocess.run(list(map(str, command)), check=True, timeout=900, **kwargs)
run = partial(run_command, timeout=900)
def main():
@@ -24,14 +28,15 @@ def main():
parser.add_argument('--report', type=Path, required=True)
args = parser.parse_args()
repo = Path(__file__).resolve().parents[2]
config = json.loads(args.config.read_text())
config = json.loads(args.config.read_text(encoding='utf-8'))
model_keys = ['WHISPER_SOURCE', 'M2M100_SOURCE', 'MELBAND_SOURCE']
for key in model_keys + ['CUTDEX_ASR_FIXTURE']:
if not Path(config[key]).is_absolute() or not Path(config[key]).exists():
raise ValueError(f'Missing absolute input path: {key}')
runtime = args.runtime.resolve()
run([os.environ.get('FLUTTER', 'flutter'), 'build', 'macos', '--release',
'--flavor=production', '--target=tool/testing/release_smoke.dart'], cwd=repo)
environment = project_environment()
run(tool_command('flutter', ['build', 'macos', '--release',
'--flavor=production', '--target=tool/testing/release_smoke.dart']), cwd=repo, env=environment)
with tempfile.TemporaryDirectory(prefix='cutdex relocated release ') as temporary:
root = Path(temporary)
app = root / 'cutdex.app'
@@ -41,8 +46,8 @@ def main():
if embedded.exists():
shutil.rmtree(embedded)
run(['/usr/bin/ditto', runtime, embedded])
run(['/bin/bash', repo / 'tool/macos/sign_macos_app.sh', app])
run([os.environ.get('PYTHON', 'python3'), repo / 'tool/macos/check_macos_release.py', '--app', app])
sign_app(app, environment=environment)
run([sys.executable, repo / 'tool/macos/check_macos_release.py', '--app', app], env=environment)
results = []
for configured in [False, True]:
home = root / ('with-models' if configured else 'without-models')
@@ -79,4 +84,4 @@ def main():
if __name__ == '__main__':
main()
sys.exit(cli(main))