### Install Wayland Backend Libraries (Debian/Ubuntu) Source: https://github.com/sony/flutter-embedded-linux/wiki/Installing-dependent-libraries Installs libwayland and wayland-protocols, necessary when using the Wayland backend for Flutter applications. ```Shell sudo apt install libwayland-dev wayland-protocols ``` -------------------------------- ### Build X11 Client Example Source: https://github.com/sony/flutter-embedded-linux/blob/master/examples/flutter-x11-client/README.md Steps to build the X11 client example using CMake. Ensure you are in the build directory and specify the user project path. ```Shell $ mkdir build $ cd build $ cmake -DUSER_PROJECT_PATH=examples/flutter-x11-client .. $ cmake --build . ``` -------------------------------- ### Install x11 Backend Library (Debian/Ubuntu) Source: https://github.com/sony/flutter-embedded-linux/wiki/Installing-dependent-libraries Installs the x11 library, which is required when using the x11 backend for Flutter applications. ```Shell sudo apt install libx11-dev ``` -------------------------------- ### Install Build Tools and Clone Depot Tools Source: https://github.com/sony/flutter-embedded-linux/wiki/Building-Flutter-Engine-from-source Installs essential build tools like g++, git, and python3, then clones the depot_tools repository and adds it to the PATH. ```bash $ sudo apt install g++-multilib git python3 curl $ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git $ export PATH=$PATH:$(pwd)/depot_tools ``` -------------------------------- ### Install DRM Backend Libraries with libuv (Debian/Ubuntu) Source: https://github.com/sony/flutter-embedded-linux/wiki/Installing-dependent-libraries Installs libdrm, libgbm, libinput, and libudev, required for the DRM backend. This command specifically installs libuv. ```Shell sudo apt install libdrm-dev libgbm-dev libinput-dev libudev-dev libuv-dev ``` -------------------------------- ### Install GStreamer Libraries Source: https://github.com/sony/flutter-embedded-linux/blob/master/examples/flutter-video-player-plugin/README.md Install the necessary GStreamer development and runtime libraries required by the video player plugin on Debian-based systems. ```Shell $ sudo apt install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer1.0-0 \ gstreamer1.0-plugins-base gstreamer1.0-plugins-good \ gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav ``` -------------------------------- ### Install Mandatory Libraries (Debian/Ubuntu) Source: https://github.com/sony/flutter-embedded-linux/wiki/Installing-dependent-libraries Installs essential libraries like clang, cmake, build-essential, pkg-config, EGL, xkbcommon, and OpenGL ES required for building. ```Shell sudo apt install clang cmake build-essential pkg-config libegl1-mesa-dev libxkbcommon-dev libgles2-mesa-dev ``` -------------------------------- ### Build the DRM EGLStream Backend Source: https://github.com/sony/flutter-embedded-linux/blob/master/examples/flutter-drm-eglstream-backend/README.md Builds the example project using CMake. Ensure you set the correct user project path. ```Shell mkdir build cd build cmake -DUSER_PROJECT_PATH=examples/flutter-drm-eglstream-backend .. cmake --build . ``` -------------------------------- ### Clone and Install flutter-elinux Source: https://github.com/sony/flutter-embedded-linux/wiki/Installing-flutter-elinux Clone the flutter-elinux repository, move it to /opt, and add its bin directory to your PATH. Run 'flutter-elinux doctor' to verify the installation. ```Shell git clone https://github.com/sony/flutter-elinux sudo mv flutter-elinux /opt/ export PATH=$PATH:/opt/flutter-elinux/bin flutter-elinux doctor ``` -------------------------------- ### Install DRM Backend Libraries (Debian/Ubuntu) Source: https://github.com/sony/flutter-embedded-linux/wiki/Installing-dependent-libraries Installs libdrm, libgbm, libinput, and libudev, required for the DRM backend. This command assumes libsystemd is preferred if both libsystemd and libuv are available. ```Shell sudo apt install libdrm-dev libgbm-dev libinput-dev libudev-dev libsystemd-dev ``` -------------------------------- ### Install Flutter SDK and Configure for Linux Desktop Source: https://github.com/sony/flutter-embedded-linux/wiki/How-to-use-Flutter-for-Embedded-Linux Clone the Flutter SDK, move it to the desired location, add it to the PATH, and enable Linux desktop support. Ensure your SDK channel matches the Flutter Engine embedder. ```Shell git clone https://github.com/flutter/flutter sudo mv flutter /opt/ export PATH=$PATH:/opt/flutter/bin flutter config --enable-linux-desktop flutter doctor ``` -------------------------------- ### Install embedder library Source: https://github.com/sony/flutter-embedded-linux/wiki/Building-Flutter-Engine-from-source Copies the compiled `libflutter_engine.so` to your CMake build directory. Ensure the path to your selected target and mode is correct. ```Shell cp ./out/${path to your selected target and mode}/libflutter_engine.so ``` -------------------------------- ### Set up Python 2 Virtual Environment Source: https://github.com/sony/flutter-embedded-linux/wiki/Building-Flutter-Engine-from-source Creates and activates a virtual environment using Python 2, which is required for building the Flutter Engine if your default Python installation is Python 3. ```shell $ virtualenv .env -p python2 $ source .env/bin/activate ``` -------------------------------- ### Install Flutter Engine Library Source: https://github.com/sony/flutter-embedded-linux/wiki/Installing-dependent-libraries Unzips the downloaded embedder library and copies libflutter_engine.so to the CMake build directory. This is for debug mode and x64 targets. ```Shell unzip ./linux-x64-embedder cp ./libflutter_engine.so ``` -------------------------------- ### Install Specific Flutter Version for Linux Source: https://github.com/sony/flutter-embedded-linux/wiki/Installing-flutter-elinux Clone a specific version of the flutter-elinux repository using the -b flag, move it to /opt, and add its bin directory to your PATH. Verify the installation with 'flutter-elinux doctor'. ```Shell git clone https://github.com/sony/flutter-elinux -b 3.13.1 sudo mv flutter-elinux /opt/ export PATH=$PATH:/opt/flutter-elinux/bin flutter-elinux doctor ``` -------------------------------- ### Basic DOM Parsing, Modification, and Stringification in C++ Source: https://github.com/sony/flutter-embedded-linux/blob/master/src/third_party/rapidjson/readme.md This example demonstrates the fundamental workflow of parsing a JSON string into a DOM, modifying a value within the DOM, and then stringifying the modified DOM back into a JSON string. It does not include error handling. ```cpp #include "rapidjson/document.h" #include "rapidjson/writer.h" #include "rapidjson/stringbuffer.h" #include using namespace rapidjson; int main() { // 1. Parse a JSON string into DOM. const char* json = "{\"project\":\"rapidjson\",\"stars\":10}"; Document d; d.Parse(json); // 2. Modify it by DOM. Value& s = d["stars"]; s.SetInt(s.GetInt() + 1); // 3. Stringify the DOM StringBuffer buffer; Writer writer(buffer); d.Accept(writer); // Output {"project":"rapidjson","stars":11} std::cout << buffer.GetString() << std::endl; return 0; } ``` -------------------------------- ### Build Flutter Wayland Client Source: https://github.com/sony/flutter-embedded-linux/blob/master/examples/flutter-wayland-client/README.md Standard CMake build process for the Flutter Wayland client example. Ensure you are in the build directory and specify the user project path. ```Shell mkdir build cd build cmake -DUSER_PROJECT_PATH=examples/flutter-wayland-client .. cmake --build . ``` -------------------------------- ### Run Flutter App with Wayland and Window Decorations Source: https://github.com/sony/flutter-embedded-linux/wiki/How-to-run-Flutter-apps Debug Flutter applications on Linux desktop hosts by enabling window decorations. This feature is primarily for debugging and may not be necessary on embedded systems. ```Shell ./flutter-client -b ./sample/build/linux/x64/release/bundle -d ``` -------------------------------- ### Build for Wayland Backend Source: https://github.com/sony/flutter-embedded-linux/wiki/Building-Embedded-Linux-embedding-for-Flutter Use this command to build a standalone Wayland application. Ensure you are in the build directory and specify the user project path. ```Shell $ mkdir build $ cd build $ cmake -DUSER_PROJECT_PATH=examples/flutter-wayland-client -DCMAKE_BUILD_TYPE=Release .. $ cmake --build . ``` -------------------------------- ### Build Stand-alone Application (Shell) Source: https://github.com/sony/flutter-embedded-linux/blob/master/examples/flutter-external-texture-plugin/README.md Use these shell commands to build the Wayland backend stand-alone application. Ensure you are in the project's root directory. ```shell mkdir build cd build cmake -DUSER_PROJECT_PATH=examples/flutter-external-texture-plugin .. cmake --build . ``` -------------------------------- ### Build for X11 Backend Source: https://github.com/sony/flutter-embedded-linux/wiki/Building-Embedded-Linux-embedding-for-Flutter Build a standalone X11 application. This backend is primarily for debugging and development on desktop environments and is still under active implementation. ```Shell $ mkdir build $ cd build $ cmake -DUSER_PROJECT_PATH=examples/flutter-x11-client -DCMAKE_BUILD_TYPE=Release .. $ cmake --build . ``` -------------------------------- ### Sync Flutter Engine Source Files Source: https://github.com/sony/flutter-embedded-linux/wiki/Building-Flutter-Engine-from-source Use this command to download the Flutter engine source code and its dependencies. ```Shell $ gclient sync ``` -------------------------------- ### Build Flutter App Bundle Source: https://github.com/sony/flutter-embedded-linux/blob/master/examples/flutter-video-player-plugin/README.md Build the Flutter application bundle and copy the necessary engine artifact (icudtl.dat) for running on Linux. ```Shell $ git clone https://github.com/flutter/plugins.git $ cd plugins/packages/video_player/video_player $ flutter build bundle --asset-dir=./bundle/data/flutter_assets $ cp /bin/cache/artifacts/engine/linux-*/icudtl.dat ./bundle/data ``` -------------------------------- ### Build Flutter App in Release Mode (Self-Build) Source: https://github.com/sony/flutter-embedded-linux/wiki/Building-Flutter-apps Use this command to create and build a Flutter app in release mode when the build and target machines are the same. The output is located in `build/elinux/{cpu-arch}/release/bundle/`. ```Shell $ flutter-elinux create sample $ cd sample $ flutter-elinux build elinux ``` -------------------------------- ### Build Flutter App for Wayland Backend (Weston Desktop-Shell) Source: https://github.com/sony/flutter-embedded-linux/wiki/How-to-use-Flutter-for-Embedded-Linux Build a Flutter application to run as a Weston desktop-shell. This requires configuring weston.ini. Specify the path to your user project. ```Shell mkdir build cd build cmake -DUSER_PROJECT_PATH=examples/flutter-weston-desktop-shell .. cmake --build . ``` -------------------------------- ### Build x64 Target (Release Mode) Source: https://github.com/sony/flutter-embedded-linux/wiki/Building-Flutter-Engine-from-source Configure and build the Flutter embedder for an x64 host target in release mode. Fontconfig is enabled. ```Shell ./flutter/tools/gn --runtime-mode release \ --embedder-for-target --disable-desktop-embeddings --no-build-embedder-examples \ --enable-fontconfig $ ninja -C out/host_release ``` -------------------------------- ### Build Flutter App in Release Mode Source: https://github.com/sony/flutter-embedded-linux/wiki/How-to-use-Flutter-for-Embedded-Linux Create a new Flutter sample app and build it for Linux in release mode. This should match the build mode of your Flutter Engine embedder. ```Shell flutter create sample cd sample/$ cd sample/ flutter build linux cd .. ``` -------------------------------- ### Navigate to Source Directory Source: https://github.com/sony/flutter-embedded-linux/wiki/Building-Flutter-Engine-from-source Change the current directory to the 'src' folder where the Flutter engine source code is located. ```Shell $ cd src ``` -------------------------------- ### Download Flutter Engine Embedder Library Source: https://github.com/sony/flutter-embedded-linux/wiki/Installing-dependent-libraries Downloads a pre-built Flutter Engine embedder library (libflutter_engine.so) from a specified URL. Replace FLUTTER_ENGINE with the desired SHA. ```Shell curl -O https://storage.googleapis.com/flutter_infra/flutter/FLUTTER_ENGINE/linux-x64/linux-x64-embedder ``` -------------------------------- ### Cross-Build Flutter App in Release Mode (Arm64 on x64) Source: https://github.com/sony/flutter-embedded-linux/wiki/Building-Flutter-apps This comprehensive set of commands is for cross-building a Flutter app in release mode for Arm64 targets on x64 hosts. It involves setting environment variables, copying necessary engine artifacts like `gen_snapshot`, building Flutter assets, compiling the Dart kernel snapshot, and finally generating the AOT shared library. ```Shell $ flutter-elinux create sample $ cd sample # Path to Flutter SDK $ export FLUTTER_SDK=/opt/flutter-elinux/flutter # Package name of the build target Flutter app $ export APP_PACKAGE_NAME=sample # The build data. $ export RESULT_DIR=build/linux-embedded-arm64 $ export BUILD_MODE=release $ mkdir -p .dart_tool/flutter_build/flutter-embedded-linux $ mkdir -p ${RESULT_DIR}/${BUILD_MODE}/bundle/lib/ $ mkdir -p ${RESULT_DIR}/${BUILD_MODE}/bundle/data/ # You need to use `gen_snapshot` for cross-building $ mkdir -p ${FLUTTER_SDK}/bin/cache/artifacts/engine/linux-arm64-release/clang_x64 $ cp /src/out/linux_release_arm64/clang_x64/gen_snapshot \ ${FLUTTER_SDK}/bin/cache/artifacts/engine/linux-arm64-release/clang_x64/gen_snapshot # Build Flutter assets. $ flutter build bundle --asset-dir=${RESULT_DIR}/${BUILD_MODE}/bundle/data/flutter_assets $ cp ${FLUTTER_SDK}/bin/cache/artifacts/engine/linux-x64/icudtl.dat \ ${RESULT_DIR}/${BUILD_MODE}/bundle/data/ # Build kernel_snapshot. $ ${FLUTTER_SDK}/bin/cache/dart-sdk/bin/dart \ --verbose \ --disable-dart-dev ${FLUTTER_SDK}/bin/cache/artifacts/engine/linux-x64/frontend_server.dart.snapshot \ --sdk-root ${FLUTTER_SDK}/bin/cache/artifacts/engine/common/flutter_patched_sdk_product/ \ --target=flutter \ --no-print-incremental-dependencies \ -Ddart.vm.profile=false \ -Ddart.vm.product=true \ --aot \ --tfa \ --packages .dart_tool/package_config.json \ --output-dill .dart_tool/flutter_build/flutter-embedded-linux/app.dill \ --depfile .dart_tool/flutter_build/flutter-embedded-linux/kernel_snapshot.d \ package:${APP_PACKAGE_NAME}/main.dart # Build AOT image. $ ${FLUTTER_SDK}/bin/cache/artifacts/engine/linux-arm64-release/clang_x64/gen_snapshot \ --deterministic \ --snapshot_kind=app-aot-elf \ --elf=.dart_tool/flutter_build/flutter-embedded-linux/libapp.so \ --strip \ .dart_tool/flutter_build/flutter-embedded-linux/app.dill $ cp .dart_tool/flutter_build/flutter-embedded-linux/libapp.so ${RESULT_DIR}/${BUILD_MODE}/bundle/lib/ ``` -------------------------------- ### Configure .gclient for Latest Flutter Engine Source: https://github.com/sony/flutter-embedded-linux/wiki/Building-Flutter-Engine-from-source Specifies the source URL for the latest Flutter Engine and configures dependency downloads. Use this when building the most recent version. ```yaml solutions = [ { "managed": False, "name": "src/flutter", "url": "https://github.com/flutter/engine.git", "custom_deps": {}, "deps_file": "DEPS", "safesync_url": "", "custom_vars" : { "download_android_deps" : False, "download_windows_deps" : False, }, }, ] ``` -------------------------------- ### Build Shared Library for flutter-elinux (Release Mode) Source: https://github.com/sony/flutter-embedded-linux/wiki/Building-Embedded-Linux-embedding-for-Flutter Build the flutter-elinux shared library in release mode with Wayland backend and embedder logging disabled. Set FLUTTER_RELEASE to ON. ```Shell $ cmake -DBUILD_ELINUX_SO=ON -DBACKEND_TYPE=WAYLAND -DCMAKE_BUILD_TYPE=Release \ -DENABLE_ELINUX_EMBEDDER_LOG=OFF -DFLUTTER_RELEASE=ON .. ``` -------------------------------- ### Build x64 Target (Profile Mode) Source: https://github.com/sony/flutter-embedded-linux/wiki/Building-Flutter-Engine-from-source Configure and build the Flutter embedder for an x64 host target in profile mode without Link-Time Optimization (LTO). Fontconfig is enabled. ```Shell ./flutter/tools/gn --runtime-mode profile --no-lto \ --embedder-for-target --disable-desktop-embeddings --no-build-embedder-examples \ --enable-fontconfig $ ninja -C out/host_profile ``` -------------------------------- ### Run Flutter App with Wayland Backend Source: https://github.com/sony/flutter-embedded-linux/wiki/How-to-run-Flutter-apps Execute a Flutter client application using the Wayland backend. Ensure a Wayland compositor is running beforehand. Specify the path to the Flutter app bundle. ```Shell ./flutter-client -b ./sample/build/linux/x64/release/bundle ``` -------------------------------- ### Flutter App Integration (Dart) Source: https://github.com/sony/flutter-embedded-linux/blob/master/examples/flutter-external-texture-plugin/README.md This Dart code demonstrates how to initialize the external texture and display it within a Flutter application. Requires Flutter SDK version 1.20 or above. ```dart import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'dart:async'; void main() { runApp(MyApp()); } class MyApp extends StatefulWidget { @override _MyAppState createState() => _MyAppState(); } class _MyAppState extends State { int _textureId = 0; @override void initState() { super.initState(); initialize().then((value) => setState(() {})); } Future initialize() async { late Completer creatingCompleter; try { creatingCompleter = Completer(); var channel = const MethodChannel('external_texture_test'); final reply = await channel.invokeMapMethod('initialize'); if (reply != null) { _textureId = reply['textureId']; } } on PlatformException catch (e) {} creatingCompleter.complete(); return creatingCompleter.future; } @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( backgroundColor: Colors.blue, appBar: AppBar( title: const Text('External Texture Plugin sample'), ), body: Center( child: AspectRatio( aspectRatio: 16 / 9, child: Texture(textureId: _textureId)), ), ), ); } } ``` -------------------------------- ### Run Flutter App with Wayland Backend Source: https://github.com/sony/flutter-embedded-linux/wiki/How-to-use-Flutter-for-Embedded-Linux Execute a Flutter application using the Wayland backend. Ensure a Wayland compositor like Weston is running beforehand. ```Shell ./flutter-client --bundle=./sample/build/linux/x64/release/bundle ``` -------------------------------- ### Build for DRM Backend with GBM Source: https://github.com/sony/flutter-embedded-linux/wiki/Building-Embedded-Linux-embedding-for-Flutter Build a Flutter application for the DRM backend using the GBM (Generic Buffer Management) interface. Navigate to the build directory before executing. ```Shell $ mkdir build $ cd build $ cmake -DUSER_PROJECT_PATH=examples/flutter-drm-gbm-backend -DCMAKE_BUILD_TYPE=Release .. $ cmake --build . ``` -------------------------------- ### Build Shared Library for flutter-elinux (Debug Mode) Source: https://github.com/sony/flutter-embedded-linux/wiki/Building-Embedded-Linux-embedding-for-Flutter Build the flutter-elinux shared library in debug mode with Wayland backend and embedder logging enabled. Set FLUTTER_RELEASE to OFF. ```Shell $ cmake -DBUILD_ELINUX_SO=ON -DBACKEND_TYPE=WAYLAND -DCMAKE_BUILD_TYPE=Release \ -DENABLE_ELINUX_EMBEDDER_LOG=ON -DFLUTTER_RELEASE=OFF .. ``` -------------------------------- ### Build Flutter App in Debug Mode (Self-Build) Source: https://github.com/sony/flutter-embedded-linux/wiki/Building-Flutter-apps Use this command to create and build a Flutter app in debug mode when the build and target machines are the same. The output is located in `build/elinux/{cpu-arch}/debug/bundle/`. ```Shell $ flutter-elinux create sample $ cd sample $ flutter-elinux build elinux --debug ``` -------------------------------- ### Build Flutter Bundle Artifacts (Common) Source: https://github.com/sony/flutter-embedded-linux/wiki/Building-Flutter-apps These commands can be used on both x64 and arm64 hosts for building Flutter bundle artifacts in debug mode. Flutter bundle artifacts are not architecturally different between x64 and arm64 in debug mode. ```Shell $ flutter-elinux build bundle --asset-dir=./bundle/data/flutter_assets $ cp /bin/cache/artifacts/engine/elinux-common/icu/icudtl.dat ./bundle/data ``` -------------------------------- ### Build Flutter DRM GBM Backend Source: https://github.com/sony/flutter-embedded-linux/blob/master/examples/flutter-drm-gbm-backend/README.md Build the Flutter DRM GBM backend project. Ensure you are in the root directory of the project and have created a build directory. ```Shell mkdir build cd build cmake -DUSER_PROJECT_PATH=examples/flutter-drm-gbm-backend .. cmake --build . ``` -------------------------------- ### Run Flutter App with DRM EGLStream Backend Source: https://github.com/sony/flutter-embedded-linux/blob/master/examples/flutter-drm-eglstream-backend/README.md Launches the Flutter application using the DRM EGLStream backend. Requires switching to CUI and setting the FLUTTER_DRM_DEVICE environment variable. ```Shell Ctrl + Alt + F3 # Switching to CUI FLUTTER_DRM_DEVICE="/dev/dri/card1" ./flutter-drm-eglstream-backend --bundle=FLUTTER_BUNDLE_PATH ``` -------------------------------- ### Build Flutter App for X11 Backend (Stand-alone) Source: https://github.com/sony/flutter-embedded-linux/wiki/How-to-use-Flutter-for-Embedded-Linux Build a stand-alone Flutter application for the X11 backend. This is primarily for debugging and development on desktop environments. Specify the path to your user project. ```Shell mkdir build cd build cmake -DUSER_PROJECT_PATH=examples/flutter-x11-client .. cmake --build . ``` -------------------------------- ### Build arm64 Target (Release Mode) Source: https://github.com/sony/flutter-embedded-linux/wiki/Building-Flutter-Engine-from-source Configure and build the Flutter embedder for an arm64 target in release mode. Fontconfig is enabled. ```Shell ./flutter/tools/gn --target-os linux --linux-cpu arm64 --runtime-mode release \ --embedder-for-target --disable-desktop-embeddings --no-build-embedder-examples \ --enable-fontconfig $ ninja -C out/linux_release_arm64 ``` -------------------------------- ### Build for DRM Backend with EGLStream Source: https://github.com/sony/flutter-embedded-linux/wiki/Building-Embedded-Linux-embedding-for-Flutter Build a Flutter application for the DRM backend using the EGLStream interface. This is an alternative to GBM for DRM. ```Shell $ mkdir build $ cd build $ cmake -DUSER_PROJECT_PATH=examples/flutter-drm-eglstream-backend -DCMAKE_BUILD_TYPE=Release .. $ cmake --build . ``` -------------------------------- ### Build x64 Target (Debug Mode) Source: https://github.com/sony/flutter-embedded-linux/wiki/Building-Flutter-Engine-from-source Configure and build the Flutter embedder for an x64 host target in debug mode with unoptimized builds. Fontconfig is enabled. ```Shell ./flutter/tools/gn --runtime-mode debug --unoptimized \ --embedder-for-target --disable-desktop-embeddings --no-build-embedder-examples \ --enable-fontconfig $ ninja -C out/host_debug_unopt ``` -------------------------------- ### Build arm64 Target (Profile Mode) Source: https://github.com/sony/flutter-embedded-linux/wiki/Building-Flutter-Engine-from-source Configure and build the Flutter embedder for an arm64 target in profile mode without Link-Time Optimization (LTO). Fontconfig is enabled. ```Shell ./flutter/tools/gn --target-os linux --linux-cpu arm64 --runtime-mode profile --no-lto \ --embedder-for-target --disable-desktop-embeddings --no-build-embedder-examples \ --enable-fontconfig $ ninja -C out/linux_profile_arm64 ``` -------------------------------- ### Configure .gclient for Specific Flutter Engine Version Source: https://github.com/sony/flutter-embedded-linux/wiki/Building-Flutter-Engine-from-source Specifies the source URL for a specific version of the Flutter Engine, identified by a commit-id or SHA. Replace FLUTTER_ENGINE with the desired version. ```yaml solutions = [ { "managed": False, "name": "src/flutter", "url": "https://github.com/flutter/engine.git@FLUTTER_ENGINE", "custom_deps": {}, "deps_file": "DEPS", "safesync_url": "", "custom_vars" : { "download_android_deps" : False, "download_windows_deps" : False, }, }, ] ``` -------------------------------- ### Run Flutter App with DRM Backend Source: https://github.com/sony/flutter-embedded-linux/wiki/How-to-run-Flutter-apps Execute a Flutter client application using the DRM backend. This requires switching to a Character User Interface (CUI) and setting the FLUTTER_DRM_DEVICE environment variable. ```Shell sudo FLUTTER_DRM_DEVICE="/dev/dri/card1" --bundle=./sample/build/linux/x64/release/bundle ``` ```Shell sudo FLUTTER_DRM_DEVICE="/dev/dri/card0:/dev/dri/card1" --bundle=./sample/build/linux/x64/release/bundle ``` -------------------------------- ### Run Flutter App on Embedded Linux Source: https://github.com/sony/flutter-embedded-linux/blob/master/examples/flutter-video-player-plugin/README.md Execute the Flutter application using the built embedder, setting the library path and specifying the bundle directory. ```Shell $ cd $ LD_LIBRARY_PATH=./plugins/video_player/ ./flutter-client -b ./bundle/ ``` -------------------------------- ### Run Flutter App with DRM Device Source: https://github.com/sony/flutter-embedded-linux/blob/master/examples/flutter-drm-gbm-backend/README.md Launch the Flutter application using the DRM GBM backend. Switch to a CUI and set the FLUTTER_DRM_DEVICE environment variable if not using the default /dev/dri/card0. Replace FLUTTER_BUNDLE_PATH with the actual path to your Flutter app's bundle. ```Shell Ctrl + Alt + F3 # Switching to CUI FLUTTER_DRM_DEVICE="/dev/dri/card1" ./flutter-drm-gbm-backend --bundle=FLUTTER_BUNDLE_PATH ``` -------------------------------- ### Cross-compile using Yocto SDK Source: https://github.com/sony/flutter-embedded-linux/wiki/Building-Embedded-Linux-embedding-for-Flutter Cross-compile a Flutter application using a Yocto SDK for aarch64 on x64 hosts. Requires a toolchain file and modification of the sysroot path. ```Shell $ cmake -DUSER_PROJECT_PATH= -DCMAKE_TOOLCHAIN_FILE= .. ``` -------------------------------- ### Prepare Flutter Bundle Artifacts for Debug Mode Source: https://github.com/sony/flutter-embedded-linux/wiki/How-to-use-Flutter-for-Embedded-Linux In debug mode, bundle Flutter assets and copy the ICU data file. This process is architecturally agnostic for x64 and arm64 hosts. ```Shell flutter build bundle --asset-dir=./bundle/data/flutter_assets cp /bin/cache/artifacts/engine/linux-*/icudtl.dat ./bundle/data ``` -------------------------------- ### Build the Embedder Source: https://github.com/sony/flutter-embedded-linux/blob/master/examples/flutter-video-player-plugin/README.md Compile the Embedded Linux embedder for Flutter, specifying the path to your user project. ```Shell $ mkdir build $ cd build $ cmake -DUSER_PROJECT_PATH=examples/flutter-video-player-plugin .. $ cmake --build . ``` -------------------------------- ### Build Flutter App in Debug Mode Source: https://github.com/sony/flutter-embedded-linux/wiki/How-to-use-Flutter-for-Embedded-Linux Build the Flutter application for Linux in debug mode. This command is used regardless of the host or target architecture. ```Shell flutter build linux --debug ``` -------------------------------- ### Switch Flutter Engine Build Modes Source: https://github.com/sony/flutter-embedded-linux/wiki/How-to-run-Flutter-apps Dynamically switch between debug, profile, and release modes of a Flutter app without replacing the engine library. Use LD_LIBRARY_PATH to point to the desired engine build. ```Shell LD_LIBRARY_PATH= ./flutter-client --bundle= ``` ```Shell LD_LIBRARY_PATH=/usr/lib/flutter_engine/debug/ ./flutter-client --bundle=./sample/build/linux/x64/debug/bundle ``` ```Shell LD_LIBRARY_PATH=/usr/lib/flutter_engine/profile/ ./flutter-client --bundle=./sample/build/linux/x64/profile/bundle ``` ```Shell LD_LIBRARY_PATH=/usr/lib/flutter_engine/release/ ./flutter-client --bundle=./sample/build/linux/x64/release/bundle ``` -------------------------------- ### VS Code Debugger Configuration for Flutter Embedded Linux Source: https://github.com/sony/flutter-embedded-linux/wiki/How-to-debug-Flutter-apps Configure VS Code's `launch.json` file to attach to a Flutter application running on embedded Linux. Specify the device ID and the Observatory URI. ```Json { "version": "0.2.0" "configurations": [ { "type": "dart", "name": "Flutter Embedded Linux Attach", "request": "attach", "deviceId": "flutter-tester", "observatoryUri": "http://127.0.0.1:40409/k8IUol2dnPI=/" } ] } ``` -------------------------------- ### Attach Flutter Debugger via Command Line Source: https://github.com/sony/flutter-embedded-linux/wiki/How-to-debug-Flutter-apps Use the `flutter attach` command with the `--device-id` and `--debug-uri` flags to connect to a running Flutter application for debugging. ```Shell $ cd / $ flutter attach --device-id=flutter-tester --debug-uri http://127.0.0.1:40409/k8IUol2dnPI=/ ``` -------------------------------- ### Switch Flutter Build Modes with LD_LIBRARY_PATH Source: https://github.com/sony/flutter-embedded-linux/wiki/How-to-use-Flutter-for-Embedded-Linux Use the LD_LIBRARY_PATH environment variable to dynamically load different Flutter engine libraries (debug, profile, release) without replacing libflutter_engine.so. ```Shell LD_LIBRARY_PATH= ./flutter-client --bundle= ``` ```Shell # e.g. Run in debug mode LD_LIBRARY_PATH=/usr/lib/flutter_engine/debug/ ./flutter-client --bundle=./sample/build/linux/x64/debug/bundle ``` ```Shell # e.g. Run in profile mode LD_LIBRARY_PATH=/usr/lib/flutter_engine/profile/ ./flutter-client --bundle=./sample/build/linux/x64/profile/bundle ``` ```Shell # e.g. Run in release mode LD_LIBRARY_PATH=/usr/lib/flutter_engine/release/ ./flutter-client --bundle=./sample/build/linux/x64/release/bundle ``` -------------------------------- ### Set Fixed Observatory Port via Environment Variables Source: https://github.com/sony/flutter-embedded-linux/wiki/How-to-debug-Flutter-apps Configure a fixed Observatory port and disable service authentication codes by setting environment variables before launching the Flutter client. This option is only available in debug mode. ```Shell $ FLUTTER_ENGINE_SWITCHES=2 \ FLUTTER_ENGINE_SWITCH_1="observatory-port=12345" \ FLUTTER_ENGINE_SWITCH_2="disable-service-auth-codes" \ ./flutter-x11-clinet --bundle=sample/build/linux/x64/debug/bundle flutter: Observatory listening on http://127.0.0.1:12345/ ``` -------------------------------- ### Run Flutter app with LD_LIBRARY_PATH Source: https://github.com/sony/flutter-embedded-linux/wiki/Building-Flutter-Engine-from-source Use `LD_LIBRARY_PATH` to specify the directory containing `libflutter_engine.so` when running your Flutter app. This allows switching between build modes without replacing the library. ```Shell LD_LIBRARY_PATH= ./flutter-client ``` ```Shell # e.g. Run in debug mode LD_LIBRARY_PATH=/usr/lib/flutter_engine/debug/ ./flutter-client ./sample/build/linux/x64/debug/bundle ``` ```Shell # e.g. Run in profile mode LD_LIBRARY_PATH=/usr/lib/flutter_engine/profile/ ./flutter-client ./sample/build/linux/x64/profile/bundle ``` ```Shell # e.g. Run in release mode LD_LIBRARY_PATH=/usr/lib/flutter_engine/release/ ./flutter-client ./sample/build/linux/x64/release/bundle ``` -------------------------------- ### Build arm64 Target (Debug Mode) Source: https://github.com/sony/flutter-embedded-linux/wiki/Building-Flutter-Engine-from-source Configure and build the Flutter embedder for an arm64 target in debug mode with unoptimized builds. Fontconfig is enabled. ```Shell ./flutter/tools/gn --target-os linux --linux-cpu arm64 --runtime-mode debug --unoptimized \ --embedder-for-target --disable-desktop-embeddings --no-build-embedder-examples \ --enable-fontconfig $ ninja -C out/linux_debug_unopt_arm64 ``` -------------------------------- ### Debug Embedder Build Source: https://github.com/sony/flutter-embedded-linux/wiki/Building-Embedded-Linux-embedding-for-Flutter Build the embedder with CMAKE_BUILD_TYPE=Debug to enable logging and facilitate debugging with tools like gdb or lldb. ```Shell $ cmake -DUSER_PROJECT_PATH= -DCMAKE_BUILD_TYPE=Debug .. ``` -------------------------------- ### Obtain Observatory Port Source: https://github.com/sony/flutter-embedded-linux/wiki/How-to-debug-Flutter-apps The Observatory port is printed to the console when a Flutter app launches. This URI is needed to attach a debugger and changes with each launch. ```Shell flutter: Observatory listening on http://127.0.0.1:40409/k8IUol2dnPI=/ ``` -------------------------------- ### Cross-compile Flutter App with Yocto SDK Source: https://github.com/sony/flutter-embedded-linux/wiki/How-to-use-Flutter-for-Embedded-Linux Cross-compile your Flutter application using a Yocto SDK for aarch64 on x64 hosts. You need to provide a toolchain file and update the user target sysroot path. ```Shell cmake -DUSER_PROJECT_PATH= -DCMAKE_TOOLCHAIN_FILE= .. ``` -------------------------------- ### Set Flutter Embedder Logging Levels Source: https://github.com/sony/flutter-embedded-linux/wiki/How-to-run-Flutter-apps Control the logging verbosity of the Flutter embedder by setting the FLUTTER_LOG_LEVELS environment variable. Available levels include TRACE, INFO, WARNING, ERROR, and FATAL. ```Shell FLUTTER_LOG_LEVELS=TRACE ./flutter-client --bundle= ``` ```Shell FLUTTER_LOG_LEVELS=INFO ./flutter-client --bundle= ``` ```Shell FLUTTER_LOG_LEVELS=WARNING ./flutter-client --bundle= ``` ```Shell FLUTTER_LOG_LEVELS=ERROR ./flutter-client --bundle= ``` ```Shell FLUTTER_LOG_LEVELS=FATAL ./flutter-client --bundle= ``` -------------------------------- ### Debug Flutter Embedder Build Source: https://github.com/sony/flutter-embedded-linux/wiki/How-to-use-Flutter-for-Embedded-Linux Build the Flutter embedder with debugging symbols enabled using `CMAKE_BUILD_TYPE=Debug`. This allows for gathering logs and using debuggers like gdb or lldb. ```Shell cmake -DUSER_PROJECT_PATH= -DCMAKE_BUILD_TYPE=Debug .. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.