|
| 1 | +# embedder |
| 2 | + |
| 3 | +[](https://github.com/flutter-tizen/embedder/actions) |
| 4 | + |
| 5 | +The Flutter embedder for Tizen. |
| 6 | + |
| 7 | +## Build |
| 8 | + |
| 9 | +### Prerequisites |
| 10 | + |
| 11 | +- Linux (x64) |
| 12 | +- [depot_tools](https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html#_setting_up) |
| 13 | +- [LLVM](https://apt.llvm.org) (10 or later) |
| 14 | + - `sudo apt install clang-12` |
| 15 | +- Additional dependencies |
| 16 | + - `sudo apt install git python3 python3-pip rpm2cpio cpio` |
| 17 | + - `sudo apt install binutils-arm-linux-gnueabi binutils-aarch64-linux-gnu binutils-i686-linux-gnu` |
| 18 | + - `pip3 install requests` |
| 19 | + |
| 20 | +### Environment setup |
| 21 | + |
| 22 | +1. Create an empty directory called `embedder` and `cd` into it. |
| 23 | + |
| 24 | +1. Create a `.gclient` file by running: |
| 25 | + |
| 26 | + ```sh |
| 27 | + gclient config --name=src --unmanaged https://github.com/flutter-tizen/embedder |
| 28 | + ``` |
| 29 | + |
| 30 | +1. Run `gclient sync` to fetch all the source code and dependencies. |
| 31 | + |
| 32 | + Note: `gclient sync` must be run every time the `DEPS` file (or the `generate_sysroot.py` script) is updated. |
| 33 | + |
| 34 | +### Compile |
| 35 | + |
| 36 | +`cd` into the generated `src` directory and run the following commands. |
| 37 | + |
| 38 | +Note: The toolchain path (`/usr/lib/llvm-12`) can be replaced as you want. For example, you can use `~/tizen-studio/tools/llvm-10` if you have [Tizen Studio](https://developer.tizen.org/development/tizen-studio/download) and the `NativeToolchain-Gcc-9.2` package installed. |
| 39 | + |
| 40 | +- **For arm** |
| 41 | + |
| 42 | + ```sh |
| 43 | + tools/gn --target-cpu arm --target-toolchain /usr/lib/llvm-12 |
| 44 | + ninja -C out/tizen_arm |
| 45 | + ``` |
| 46 | + |
| 47 | +- **For arm64** |
| 48 | + |
| 49 | + ```sh |
| 50 | + tools/gn --target-cpu arm64 --target-toolchain /usr/lib/llvm-12 |
| 51 | + ninja -C out/tizen_arm64 |
| 52 | + ``` |
| 53 | + |
| 54 | +- **For x86** |
| 55 | + |
| 56 | + ```sh |
| 57 | + tools/gn --target-cpu x86 --target-toolchain /usr/lib/llvm-12 |
| 58 | + ninja -C out/tizen_x86 |
| 59 | + ``` |
| 60 | + |
| 61 | +### Notes |
| 62 | + |
| 63 | +- To build an app (TPK) with the embedder generated in the above, copy the output artifacts (`libflutter_tizen*.so`) into the [flutter-tizen](https://github.com/flutter-tizen/flutter-tizen) tool's cached artifacts directory (`flutter/bin/cache/artifacts/engine`) and run `flutter-tizen run` or `flutter-tizen build tpk`. |
| 64 | +- To use the target device's `libstdc++.so` instead of the embedder's built-in libc++ (`third_party/libcxx`), provide the `--system-cxx` option to `tools/gn`. Tizen 5.5's `libstdc++.so` is not compatible with C++17 so you must use a sysroot for Tizen 6.0 or above. |
| 65 | +- Building NUI-related code requires a sysroot for Tizen 6.5 or above and the `--api-version 6.5` option. |
| 66 | + |
| 67 | +## Repository structure |
| 68 | + |
| 69 | +This repository contains the following files and directories. |
| 70 | + |
| 71 | +- `//build` |
| 72 | + - `config`: Contains GN configs for setting up the build environment for the toolchain. |
| 73 | + - `secondary`: The secondary source tree to find input files for build. See the `.gn` file for details. |
| 74 | +- `//flutter` |
| 75 | + - `fml`: A subset of the Flutter engine's [fml](https://github.com/flutter/engine/tree/main/fml) library. |
| 76 | + - `shell/platform/common`: Contains C++ client wrapper and other common code used by the embedder implementation. Copied from [flutter/engine](https://github.com/flutter/engine/tree/main/shell/platform/common). |
| 77 | + - `shell/platform/embedder`: Contains `embedder.h` which defines a low-level API for interacting with the Flutter engine. Copied from [flutter/engine](https://github.com/flutter/engine/tree/main/shell/platform/embedder). |
| 78 | + - `shell/platform/tizen`: The Tizen embedder implementation. |
| 79 | + - `channels`: Internal plugins based on platform channels. |
| 80 | + - `public`: The public API of the embedder. |
| 81 | + - `third_party/accessibility`: A fork of the chromium accessibility library. Copied from [flutter/engine](https://github.com/flutter/engine/tree/main/third_party/accessibility). |
| 82 | +- `//tools` |
| 83 | + - `check_symbols.py`: A script to check whether the build artifacts contain symbols not defined in the allowlist. Used by continuous integration. |
| 84 | + - `download_engine.py`: A script to download engine artifacts required for linking. Executed as a hook by `gclient sync`. The downloaded artifacts can be found in `//engine`. |
| 85 | + - `generate_sysroot.py`: A script to generate Tizen sysroots for arm/arm64/x86. Executed as a hook by `gclient sync`. The sysroots are by default generated in `//sysroot`. |
| 86 | + - `gn`: A script to automate running `gn gen`. |
| 87 | +- `.gn`: The top-level `.gn` file referenced by `gn`. |
| 88 | +- `DEPS`: The DEPS file used by `gclient sync` to install dependencies and execute hooks. |
0 commit comments