Skip to content

Instantly share code, notes, and snippets.

@swift-kim
Last active July 29, 2020 08:04
Show Gist options
  • Save swift-kim/f2eb9d59695188ea5ee5ea391ce38a0a to your computer and use it in GitHub Desktop.
Save swift-kim/f2eb9d59695188ea5ee5ea391ce38a0a to your computer and use it in GitHub Desktop.
Flutter on Tizen from scratch

Building the Flutter engine for Tizen devices

Prerequisites

  • Linux host machine
  • Tizen (armv7l) device
  • Build dependencies (Ubuntu 20.04)
    • sudo apt install texinfo bison flex python libncurses5
  • Visual Studio Code (optional)
    • This is a recommended IDE for browsing the source code.

Download the engine source code

  • The engine has dependencies on various third party modules. Building the engine requires all their source code to be synced.

  • Follow the instructions in Setting up the Engine development environment.

  • The directory structure after running gclient sync should look like this.

    src (flutter/buildroot)
    ├── build
    ├── flutter (<user>/engine)
    ├── third_party
    │   ├── dart (https://dart.googlesource.com/sdk.git)
    │   ├── skia (https://skia.googlesource.com/skia.git)
    │   ├── icu (https://chromium.googlesource.com/chromium/deps/icu.git)
    │   └── ...
    └── ...
    

Set up the build environment

  • We'll use a clang cross compiler to build the engine binary. The GBS build is not supported at the moment.

  • Build clang from source.

    $ git clone https://github.com/llvm/llvm-project.git --depth 1
    $ cd llvm-project
    $ mkdir build && cd build
    $ cmake ../llvm -DLLVM_ENABLE_PROJECTS=clang -G "Unix Makefiles" \
      -DCMAKE_BUILD_TYPE=Release \
      -DCMAKE_INSTALL_PREFIX=<target path>/toolchain \
      -DLLVM_DEFAULT_TARGET_TRIPLE=armv7l-tizen-linux-gnueabi \
      -DLLVM_TARGETS_TO_BUILD=ARM
    $ make -j4
    $ make install
  • Build binutils from source.

    $ git clone git://sourceware.org/git/binutils-gdb.git --depth 1
    $ cd binutils-gdb
    $ ./configure --prefix=<target path>/toolchain \
      --enable-gold \
      --enable-ld \
      --target=armv7l-tizen-linux-gnueabi
    $ make -j4
    $ make install

    Clean the entire repo and try again if anything goes wrong.

  • Build the sysroot.

Build libflutter_engine.so

  • (Temporary patch) Add Tizen-specific fonts to Linux default font families.

    ./flutter/third_party/txt/src/txt/platform_linux.cc

     std::vector<std::string> GetDefaultFontFamilies() {
    -  return {"Ubuntu", "Cantarell", "DejaVu Sans", "Liberation Sans", "Arial"};
    +  return {"SamsungOneUI", "BreezeSans", "Ubuntu", "Cantarell", "DejaVu Sans", "Liberation Sans", "Arial"};
     }
  • Set up the build with gn. (Use --runtime-mode debug for debug build.)

    ./flutter/tools/gn \
    --target-os linux \
    --linux-cpu arm \
    --target-toolchain <toolchain path> \
    --target-sysroot <sysroot path> \
    --target-triple armv7l-tizen-linux-gnueabi \
    --runtime-mode release \
    --embedder-for-target \
    --disable-desktop-embeddings
  • Run the ninja build.

    ninja -C out/linux_release_arm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment