Skip to content

Commit 38b7d63

Browse files
committed
release: Flutter 3.41.5 for Termux ARM64
- Upgrade Flutter 3.35.0 → 3.41.5 (Dart 3.11.3) - Add Linux release/profile engine builds (build_all now builds all 3 modes) - Fix utils.py __MODE__ ordering bug (debug must be first) - Full build matrix verified: 6/6 (Linux debug/release/profile + APK debug/release/profile) - Update all documentation, README, CHANGELOG, workflow - Add version-specific patches for 3.41.5
1 parent 08a545f commit 38b7d63

13 files changed

Lines changed: 604 additions & 58 deletions

.agent/workflows/build-termux-flutter.md

Lines changed: 61 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ description: 為 Termux 交叉編譯 Flutter Engine 並打包成 .deb 安裝包
1313
## 快速構建 (一鍵)
1414
// turbo-all
1515
```bash
16-
cd /mnt/d/OtherProject/mine/flutter_termux/termux-flutter
17-
./build_termux_flutter.sh
16+
cd /home/iml1s/projects/termux-flutter
17+
python3 build.py build_all --arch=arm64
1818
```
1919

2020
## 分步驟構建
@@ -24,41 +24,79 @@ cd /mnt/d/OtherProject/mine/flutter_termux/termux-flutter
2424
python3 build.py sysroot --arch=arm64
2525
```
2626

27-
### 2. 配置 GN
27+
### 2. Linux Debug Engine (主要)
2828
```bash
29-
python3 build.py configure arch=arm64 mode=debug
29+
python3 build.py configure --arch=arm64 --mode=debug
30+
python3 build.py build --arch=arm64 --mode=debug
31+
python3 build.py build_dart --arch=arm64 --mode=debug
32+
python3 build.py build_impellerc --arch=arm64 --mode=debug
33+
python3 build.py build_const_finder --arch=arm64 --mode=debug
3034
```
3135

32-
### 3. 編譯
36+
### 3. Linux Release Engine
3337
```bash
34-
python3 build.py build arch=arm64 mode=debug
38+
python3 build.py configure --arch=arm64 --mode=release
39+
python3 build.py build --arch=arm64 --mode=release
3540
```
3641

37-
### 4. 打包
42+
### 4. Linux Profile Engine
3843
```bash
39-
python3 build.py debuild --arch=arm64
44+
python3 build.py configure --arch=arm64 --mode=profile
45+
python3 build.py build --arch=arm64 --mode=profile
4046
```
4147

42-
## 升級到新版本
48+
### 5. Android gen_snapshot
49+
```bash
50+
python3 build.py configure_android --arch=arm64 --mode=release
51+
python3 build.py build_android_gen_snapshot --arch=arm64 --mode=release
52+
```
4353

44-
1. 修改 `build.toml` 中的 `tag = '新版本號'`
45-
2. 執行 `python3 build.py clone`
46-
3. 執行 `python3 build.py sync`
47-
4. 如果補丁失敗,需手動更新 `patches/*.patch`
48-
5. 執行完整構建流程
54+
### 6. 打包 .deb
55+
```bash
56+
python3 build.py debuild --arch=arm64
57+
```
4958

50-
## 在 Termux 上安裝
59+
## 在 Termux 上安裝與驗證
5160

52-
```bash
53-
# 推送到手機
54-
adb push flutter_*.deb /sdcard/Download/
61+
```powershell
62+
# 推送到手機 (PowerShell, 不要用 Git Bash)
63+
adb push flutter_3.41.5_aarch64.deb /data/local/tmp/
64+
```
5565

66+
```bash
5667
# 在 Termux 中執行
57-
pkg update && pkg install x11-repo
58-
cp /sdcard/Download/flutter_*.deb ~/
59-
dpkg -i ~/flutter_*.deb
68+
dpkg -i /data/local/tmp/flutter_3.41.5_aarch64.deb
69+
apt-get install -f
70+
bash $PREFIX/share/flutter/post_install.sh
71+
source $PREFIX/etc/profile.d/flutter.sh
72+
73+
# 驗證
6074
flutter --version
75+
flutter create test_app && cd test_app
76+
77+
# Build Matrix 驗證 (6/6)
78+
flutter build linux --debug
79+
flutter build linux --release
80+
flutter build linux --profile
81+
flutter build apk --debug --target-platform android-arm64
82+
flutter build apk --release --target-platform android-arm64
83+
flutter build apk --profile --target-platform android-arm64
6184
```
6285

63-
## 關鍵補丁說明
64-
我們在 `build/config/termux/BUILD.gn` 中加入了 `-llog`, `-lm` 以解決 Android 日誌符號缺失問題。
86+
## ⚠️ 關鍵注意事項
87+
88+
1. `utils.py __MODE__` 必須是 `('debug', 'release', 'profile')` — debug 在前!
89+
- `Output.any` 取第一個存在的目錄
90+
- 如果 release 在前,dart-sdk snapshots 會用 product mode → 整個 flutter CLI 壞掉
91+
92+
2. `ninja flutter` **不會** build dart binary — 必須另外跑 `build_dart()`
93+
94+
3. 只支援 ARM64 APK — android-arm/android-x64 gen_snapshot 無法交叉編譯
95+
96+
## 升級到新版本
97+
98+
1. 修改 `build.toml` 中的 `tag = '新版本號'`
99+
2. 執行 `python3 build.py clone`
100+
3. 執行 `python3 build.py sync`
101+
4. 如果補丁失敗,需手動更新 `patches/*.patch`
102+
5. 執行完整構建流程

AGENTS.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Cross-compile Flutter SDK for Termux (Android/Bionic ARM64). Produces a `.deb` p
1313
python3 build.py build_all --arch=arm64
1414

1515
# Individual steps
16-
python3 build.py clone # Clone Flutter 3.35.0
16+
python3 build.py clone # Clone Flutter 3.41.5
1717
python3 build.py sync # gclient sync (~30GB)
1818
python3 build.py patch_engine && python3 build.py patch_dart && python3 build.py patch_skia
1919
python3 build.py sysroot --arch=arm64 # Assemble Termux sysroot from apt
@@ -22,6 +22,10 @@ python3 build.py build --arch=arm64 --mode=debug # ninja build
2222
python3 build.py build_dart --arch=arm64 --mode=debug # dart binary (separate!)
2323
python3 build.py build_impellerc --arch=arm64 --mode=debug
2424
python3 build.py build_const_finder --arch=arm64 --mode=debug
25+
python3 build.py configure --arch=arm64 --mode=release # Linux release engine
26+
python3 build.py build --arch=arm64 --mode=release
27+
python3 build.py configure --arch=arm64 --mode=profile # Linux profile engine
28+
python3 build.py build --arch=arm64 --mode=profile
2529
python3 build.py configure_android --arch=arm64 --mode=release
2630
python3 build.py build_android_gen_snapshot --arch=arm64 --mode=release
2731
python3 build.py debuild --arch=arm64 # Package .deb
@@ -47,6 +51,7 @@ python3 build.py debuild --arch=arm64 # Package .deb
4751
4. **`package.yaml` uses `eval()`** for variable resolution — be careful with template strings.
4852
5. **`debuild()` auto-syncs** from Windows to WSL via `[sync]` config before packaging.
4953
6. **GN flag `is_termux=true`** activates custom BUILD.gn rules that add `-llog -lm` for Android logging symbols.
54+
7. **`utils.py __MODE__` must be `('debug', 'release', 'profile')`** — debug first! `Output.any` picks the first existing directory. If release comes first, `output.any` points to release (product mode) dart-sdk snapshots, breaking the entire Flutter CLI.
5055

5156
## Termux Runtime: post_install.sh Auto-Fixes
5257

@@ -79,6 +84,8 @@ android {
7984
```
8085
flutter/engine/src/out/
8186
├── linux_debug_arm64/ # Main: dart-sdk, gen_snapshot, libflutter_linux_gtk.so
87+
├── linux_release_arm64/ # Release: gen_snapshot, libflutter_linux_gtk.so
88+
├── linux_profile_arm64/ # Profile: gen_snapshot, libflutter_linux_gtk.so
8289
├── android_release_arm64/ # Android gen_snapshot (release APK)
8390
└── android_profile_arm64/ # Android gen_snapshot (profile APK)
8491
```
@@ -87,6 +94,6 @@ flutter/engine/src/out/
8794

8895
- Build: WSL2 Ubuntu on Windows, NDK r27d at `/opt/android-ndk-r27d`
8996
- WSL path: `/home/iml1s/projects/termux-flutter/`
90-
- Target: aarch64, Flutter 3.35.0
97+
- Target: aarch64, Flutter 3.41.5
9198
- Test device: `RFCNC0WNT9H`
9299
- Use PowerShell (not Git Bash) for `adb push` to avoid path mangling

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,24 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [3.41.5-termux] - 2026-03-25
9+
10+
### Added
11+
- Flutter version upgrade: 3.35.0 → 3.41.5 (Dart 3.11.3)
12+
- **Linux release/profile engine builds**: `build_all()` now compiles all three Linux modes (debug, release, profile)
13+
- Full build matrix verified on device (6/6): Linux debug/release/profile + APK debug/release/profile
14+
15+
### Fixed
16+
- **`flutter build linux` (release/profile) failure**: `build_all()` was only building debug mode engine for Linux, leaving `linux_release_arm64/` and `linux_profile_arm64/` empty in the deb package
17+
- **`utils.py __MODE__` ordering bug**: Original order `('release', 'debug', 'profile')` caused `Output.any` to select release (product mode) dart-sdk snapshots when release directory exists, breaking the entire Flutter CLI. Fixed to `('debug', 'release', 'profile')`
18+
19+
### Technical Details
20+
- Build output now includes 5 directories: `linux_debug_arm64/`, `linux_release_arm64/`, `linux_profile_arm64/`, `android_release_arm64/`, `android_profile_arm64/`
21+
- `build_all()` expanded from 8 to 12 steps to include Linux release/profile configure+build
22+
- Deb package size increased from ~541MB to ~662MB due to additional engine artifacts
23+
24+
---
25+
826
## [3.35.0-termux] - 2026-01-07
927

1028
### Added

CLAUDE.md

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ python3 build.py sysroot --arch=arm64 # Build sysroot
2323
python3 build.py configure --arch=arm64 --mode=debug
2424
python3 build.py build --arch=arm64 --mode=debug
2525
python3 build.py build_dart --arch=arm64 --mode=debug
26+
python3 build.py build_impellerc --arch=arm64 --mode=debug
27+
python3 build.py build_const_finder --arch=arm64 --mode=debug
28+
python3 build.py configure --arch=arm64 --mode=release # Linux release engine
29+
python3 build.py build --arch=arm64 --mode=release
30+
python3 build.py configure --arch=arm64 --mode=profile # Linux profile engine
31+
python3 build.py build --arch=arm64 --mode=profile
2632

2733
# Android gen_snapshot (for flutter build apk)
2834
python3 build.py configure_android --arch=arm64 --mode=release
@@ -44,6 +50,9 @@ python3 build.py debuild --arch=arm64
4450
| `utils.py` | Build utilities and path helpers |
4551
| `patches/{version}/*.patch` | Version-specific Engine/Dart/Skia patches |
4652
| `scripts/install/post_install.sh` | Post-installation setup for APK builds |
53+
| `scripts/build/` | Build helper scripts (profile, gen_snapshot, etc.) |
54+
| `scripts/setup/` | WSL/NDK/Gradle environment setup scripts |
55+
| `scripts/fix/` | Workaround scripts (aapt2, gradle, SSH) |
4756
| `install_flutter_complete.sh` | One-command Termux installation script |
4857
| `CHANGELOG.md` | Version history and release notes |
4958
| `BUILD_GUIDE.md` | Detailed build guide and troubleshooting |
@@ -56,7 +65,7 @@ flutter_termux/
5665
├── build.toml # Build configuration
5766
├── install_flutter_complete.sh # Termux installation script
5867
├── patches/
59-
│ └── 3.35.0/ # Version-specific patches
68+
│ └── 3.41.5/ # Version-specific patches
6069
│ ├── engine.patch
6170
│ ├── dart.patch
6271
│ └── skia.patch
@@ -103,8 +112,14 @@ flutter_termux/
103112
flutter/engine/src/out/
104113
├── linux_debug_arm64/
105114
│ ├── dart-sdk/bin/dart # Dart binary
106-
│ ├── gen_snapshot # Linux gen_snapshot
115+
│ ├── gen_snapshot # Linux gen_snapshot (release mode VM)
107116
│ └── libflutter_linux_gtk.so # Linux GTK library (~106MB)
117+
├── linux_release_arm64/
118+
│ ├── gen_snapshot # Release gen_snapshot
119+
│ └── libflutter_linux_gtk.so # Release GTK library
120+
├── linux_profile_arm64/
121+
│ ├── gen_snapshot # Profile gen_snapshot
122+
│ └── libflutter_linux_gtk.so # Profile GTK library
108123
├── android_release_arm64/
109124
│ └── clang_arm64/gen_snapshot # Android release gen_snapshot
110125
└── android_profile_arm64/
@@ -119,10 +134,17 @@ In `build.py` `build()` method:
119134

120135
**Important**: `flutter_gtk` target must be enabled, otherwise `flutter build linux` fails.
121136

137+
## Internal Patterns
138+
139+
- **`@utils.record` / `@utils.recordm`**: Decorators that auto-log all method calls with args. Set `NO_RECORD=1` to disable.
140+
- **`Build.sync()`**: Detects Windows vs WSL via `platform.system()`. On Windows, wraps `cp` in `wsl -e bash -c`; on WSL, runs directly.
141+
- **`Package.__format__()`**: Uses `string.Template.safe_substitute()` for `$variable` expansion in `package.yaml`.
142+
- **`package.yaml` `define` blocks**: Use `eval()` with globals (`root`, `arch`, `output`, `version`) — never put untrusted strings here.
143+
122144
## Known Limitations
123145

124146
1. **APK only supports ARM64**: android-arm and android-x64 gen_snapshot cannot be cross-compiled (BoringSSL 32-bit issues, sysroot incompatibility)
125-
2. Uses debug mode binaries due to sysroot conflicts (glibc vs bionic headers)
147+
2. **`utils.py __MODE__` must be `('debug', 'release', 'profile')`**: debug first! `Output.any` picks the first existing directory. If release comes first, product mode dart-sdk snapshots break the entire Flutter CLI.
126148
3. See `BUILD_GUIDE.md` for detailed troubleshooting
127149

128150
## Common Issues
@@ -181,11 +203,11 @@ chmod +x depot_tools/vpython3
181203

182204
```powershell
183205
# Transfer deb to device
184-
powershell -Command "adb push 'flutter_3.35.0_aarch64.deb' '/data/local/tmp/'"
206+
powershell -Command "adb push 'flutter_3.41.5_aarch64.deb' '/data/local/tmp/'"
185207
186208
# Install in Termux
187209
pkg install x11-repo
188-
dpkg -i /data/local/tmp/flutter_3.35.0_aarch64.deb
210+
dpkg -i /data/local/tmp/flutter_3.41.5_aarch64.deb
189211
apt-get install -f
190212
bash $PREFIX/share/flutter/post_install.sh # Required for APK builds!
191213
@@ -202,16 +224,19 @@ flutter doctor -v
202224

203225
## Version Info
204226

205-
- Flutter: 3.35.0
227+
- Flutter: 3.41.5
228+
- Dart SDK: 3.11.3
206229
- Target: aarch64 (ARM64)
207230

208-
## Verified Feature Status (2026-01-07)
231+
## Verified Feature Status (2026-03-25)
209232

210233
| Feature | Status | Requirements |
211234
|---------|--------|--------------|
212235
| `flutter doctor` || deb install only |
213236
| `flutter create` || deb install only |
214-
| `flutter build linux` || gtk3, x11-repo |
237+
| `flutter build linux --debug` || gtk3, x11-repo |
238+
| `flutter build linux --release` || gtk3, x11-repo |
239+
| `flutter build linux --profile` || gtk3, x11-repo |
215240
| `flutter build apk --debug` || post_install.sh + project config |
216241
| `flutter build apk --profile` || post_install.sh + project config |
217242
| `flutter build apk --release` || post_install.sh + project config |

GEMINI.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Windows (edit files)
4444
├── package.py ← Reads package.yaml, builds data.tar.xz + control.tar.xz → .deb
4545
├── package.yaml ← Declarative: maps build artifacts → deb install paths
4646
├── utils.py ← Arch mapping, output paths, Termux detection
47-
└── patches/3.35.0/ ← Engine/Dart/Skia patches (version-specific)
47+
└── patches/3.41.5/ ← Engine/Dart/Skia patches (version-specific)
4848
4949
▼ (sync to WSL via [sync] config in build.toml)
5050
WSL Ubuntu (build)
@@ -53,8 +53,10 @@ WSL Ubuntu (build)
5353
│ └── engine/src/ ← Engine source (gclient managed)
5454
│ └── out/
5555
│ ├── linux_debug_arm64/ ← Main output (dart, gen_snapshot, libflutter_linux_gtk.so)
56-
│ ├── android_release_arm64/ ← Android gen_snapshot (release)
57-
│ └── android_profile_arm64/ ← Android gen_snapshot (profile)
56+
├── linux_release_arm64/ ← Release engine (gen_snapshot, libflutter_linux_gtk.so)
57+
├── linux_profile_arm64/ ← Profile engine (gen_snapshot, libflutter_linux_gtk.so)
58+
├── android_release_arm64/ ← Android gen_snapshot (release)
59+
└── android_profile_arm64/ ← Android gen_snapshot (profile)
5860
5961
▼ (adb push .deb → dpkg -i on device)
6062
Termux (runtime)
@@ -75,6 +77,8 @@ Termux (runtime)
7577

7678
6. **Windows↔WSL sync**: `build.toml [sync]` section defines paths to copy from Windows mount to WSL native fs before `debuild`, preventing stale-file issues.
7779

80+
7. **`utils.py __MODE__` must be `('debug', 'release', 'profile')`**: `Output.any` picks the first existing build directory. If `release` is first and `linux_release_arm64/` exists, `output.any` selects it — its `product` mode dart-sdk snapshots will break the entire Flutter CLI. Debug must always be first.
81+
7882
## Termux Runtime: post_install.sh Auto-Fixes
7983

8084
`post_install.sh` automatically handles these ARM64 compatibility issues:
@@ -115,18 +119,18 @@ android {
115119
- Host: Windows + WSL2 Ubuntu, Ryzen 9950X3D (24 threads allocated)
116120
- NDK: r27d at `/opt/android-ndk-r27d`
117121
- WSL build dir: `/home/iml1s/projects/termux-flutter/`
118-
- Flutter: 3.35.0
122+
- Flutter: 3.41.5
119123
- Target: aarch64 (ARM64)
120124
- Test device: `RFCNC0WNT9H`
121125

122126
## Deployment
123127

124128
```powershell
125129
# From Windows (use PowerShell, NOT Git Bash — path mangling)
126-
adb push flutter_3.35.0_aarch64.deb /data/local/tmp/
130+
adb push flutter_3.41.5_aarch64.deb /data/local/tmp/
127131
128132
# In Termux
129-
dpkg -i /data/local/tmp/flutter_3.35.0_aarch64.deb
133+
dpkg -i /data/local/tmp/flutter_3.41.5_aarch64.deb
130134
apt-get install -f
131135
bash $PREFIX/share/flutter/post_install.sh # Required for APK builds
132136
source $PREFIX/etc/profile.d/flutter.sh

0 commit comments

Comments
 (0)