blog

Flutterエンジンのコンパイルとデバッグ

--android--デバイス側 --android ----android-cpu=arm64 ......

Sep 13, 2020 · 3 min. read
シェア

I. 環境設定

GitHubアカウント SSHキーの追加

忍者の設定

  1. ダウンロードとコンパイル
git clone git://github.com/ninja.git && cd ninja
git checkout release
./configure.py --bootstrap
  1. 環境変数の設定
$ vi ~/.bashrc
export PATH=$PATH:/home/wangzhen/WorkSpace/ninja
$ source ~/.bashrc

デポの設定_tools

リポジトリをクローンします。

git clone https://..///_.it

depot_toolsのパスを~/.bashrcに追加します:

export PATH=/path/to/depot_tools:$PATH

エンジン環境の設定

  1. エンジンコードのダウンロードsolutions = [ { "managed": False, "name": "src/flutter", "url": "git@github.com:<your_name_here>/engine.git", "custom_deps": {}, "deps_file": "DEPS", "safesync_url": "", }, ]

  2. engineディレクトリに.gclientファイルを作成し、そのファイルに以下の内容を入力します。

    solutions = [
     {
     "managed": False,
     "name": "src/flutter",
     "url": "git@github.com:<your_name_here>/engine.git",
     "custom_deps": {},
     "deps_file": "DEPS",
     "safesync_url": "",
     },
    ]
    
  3. engineディレクトリでgclient syncコマンドを実行すると、すべての依存関係がダウンロードされ、最新のコードが同期されます。

  4. 以下のコマンドを実行してください:

    sudo ./build/install-build-deps-android.sh
    sudo ./build/install-build-deps.sh
    sudo ./flutter/build/install-build-deps-linux-desktop.sh
    

エンジンのコンパイル

  1. engineディレクトリにcompile.shスクリプトを作成し、次のように記述します:

    set -ex
    cd ~/dev/engine/src/flutter #これをコードパスに置き換える
    git fetch upstream
    git rebase upstream/master
    gclient sync
    cd ..
    flutter/tools/gn --unoptimized --runtime-mode=debug
    flutter/tools/gn --android --unoptimized --android-cpu=arm64
    flutter/tools/gn --android --unoptimized --runtime-mode=debug
    flutter/tools/gn --android --runtime-mode=profile
    flutter/tools/gn --android --runtime-mode=release
    cd out
    find . -mindepth 1 -maxdepth 1 -type d | xargs -n 1 NY -c 'ninja -C $0 || exit 255'
    
  2. 実行権限を付与します:

    chmod a+x compile.sh
    
  3. compile.shを実行してコンパイルします。

指定された実行可能ファイルを個別にコンパイルする方法。

  1. コンパイル用ファイルの準備
    • ./flutter/tools/gn --android --unoptimized デバイス側の実行ファイル
    • ./flutter/tools/gn --android --unoptimized --android-cpu=arm64 for newer 64-bit Android devices.
    • ./flutter/tools/gn --android --android-cpu x86 --unoptimized x86エミュレータ用
    • ./flutter/tools/gn --android --android-cpu x64 --unoptimized x64エミュレータ用
    • ./flutter/tools/gn --unoptimized for host-side executables, needed to compile the code.
  2. ninjaでのコンパイル
    • ninja -C out/android_debug_unopt for device-side executables.
    • ninja -C out/android_debug_unopt_arm64 for newer 64-bit Android devices.
    • ninja -C out/android_debug_unopt_x86 for x86 emulators.
    • ninja -C out/android_debug_unopt_x64 for x64 emulators.
    • ninja -C out/host_debug_unopt for host-side executables.

実行とデバッグ

エンジンコードを修正したら、flutter appディレクトリで実行する必要があります:

flutter run --local-engine-src-path <your_path>/engine/src/ --local-engine=android_debug_unopt_arm64

--local-engine-src-pathエンジン・パスを指定し、-local-engine で実行するデバイスを指定します。

Read next

フロントエンドの質問 - 知識 - まとめ

パートIにはいくつの「データ型」がありますか?それらは何ですか?答え:nullとundefinedの違いは何ですか?答え:コールバック関数とは何ですか?

Sep 13, 2020 · 3 min read