Simplify Installation of Flutter Engine Library & Cross Compilation
I've already used flutter pi cross compilation was very straight forward and simple while also providing steps for both Windows and Linux.
Going through the documentation for this project the installation of the flutter engine library is a lot more complex since it requires building it yourself. Compared to how the flutter pi dev has provided pre compiled libraries for arm and arm64 platforms while providing reasonable explanations for each step.
Is there someway we can streamline the cross compilation process for Windows and Linux since that's going to be the case for a majority of embedded systems development use cases.
If you are OK to use a pre-built image, use flutter-elinux. However, if you develop your real product, it would be better to build Flutter Engine and this embedder yourself using your target toolchain/sysroot and use it. See also: Use pre-build image
Does it make sense?
Yes it does make sense, I was going through setting up a Yocto build for the first time but since I'm very new to all of this and it seems very very complicated. I would like to help out by making a PR to maybe improve the documentation to make it more approachable for beginners, once I figure out how to make a build myself.
In a very basic way the flutter-pi repository breaks down the entire process in a very simple and approachable way and I hope maybe we can break down the step for this project. I think focusing more on cross compilation is important since that's what any developer will be focusing on and keeping the Raspberry Pi 4 as a reference board is important since it runs ARM 64 bit and is the most accessible to beginners.
Here's a reference to the flutter-pi build + deploy process documentation.
- Find out the path to your flutter SDK. For me it's
C:\flutter. (I'm on Windows) - Open terminal or commandline and
cdinto your app directory.
- Build the asset bundle.
flutter build bundle - Build the kernel snapshot. (Replace
my_app_namewith the name of your app)C:\flutter\bin\cache\dart-sdk\bin\dart.exe ^ C:\flutter\bin\cache\dart-sdk\bin\snapshots\frontend_server.dart.snapshot ^ --sdk-root C:\flutter\bin\cache\artifacts\engine\common\flutter_patched_sdk_product ^ --target=flutter ^ --aot ^ --tfa ^ -Ddart.vm.product=true ^ --packages .packages ^ --output-dill build\kernel_snapshot.dill ^ --verbose ^ --depfile build\kernel_snapshot.d ^ package:my_app_name/main.dart - Fetch the latest
gen_snapshot_linux_x64_releaseI provide in the engine binaries repo. - The following steps must be executed on a linux x64 machine. If you're on windows, you can use WSL. If you're on macOS, you can use a linux VM.
- Build the
app.so. If you're building for arm64, you need to omit the--sim-use-hardfpflag.gen_snapshot_linux_x64_release \ --deterministic \ --snapshot_kind=app-aot-elf \ --elf=build/flutter_assets/app.so \ --strip \ --sim-use-hardfp \ build/kernel_snapshot.dill - Now you can switch to your normal OS again.
- Upload the asset bundle and the
app.soto your Raspberry Pi.
orrsync -a --info=progress2 ./build/flutter_assets/ pi@raspberrypi:/home/pi/my_appscp -r ./build/flutter_assets/ pi@raspberrypi:/home/pi/my_app - You can now launch the app in release mode using
flutter-pi --release /home/pi/my_app
Your project goes into great depth of the entire build process, what components are needed, how those components are built etc. But due to the cross compilation process being much more involved and complicated it can make the entire process unapproachable. Even with the flutter-elinux the quick start or documentation makes cross build seem like an unreasonable decision however it's one of the most important steps for anyone trying to get a build running on any ARM board.
I'll close this issue as there has been no updates for a long time. Thanks.