Flutter -- 17.渲染引擎准备工作

2021-12-03  本文已影响0人  MissStitch丶

一.下载渲染引擎

1.下载引擎时需注意的点

2.查看当前Engine版本flutter doctor -v

mac@zhangtao ~ % flutter doctor -v  
[✓] Flutter (Channel stable, 2.5.3, on macOS 11.6 20G165 darwin-x64, locale
    zh-Hans-CN)
    • Flutter version 2.5.3 at /Users/mac/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 18116933e7 (7 weeks ago), 2021-10-15 10:46:35 -0700
    • Engine revision d3ea636dc5
    • Dart version 2.14.4

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/mac/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 13.1, Build version 13A1030d
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2020.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)

[✓] Connected device (1 available)
    • Chrome (web) • chrome • web-javascript • Google Chrome 96.0.4664.55

• No issues found!

3.查看channel版本flutter channel

mac@zhangtao ~ % flutter channel                  
Flutter channels:
  master
  dev
  beta
* stable

4.Github上查看Engine

5.查看当前Engine详细的CommitId(d3ea636dc5)

mac@zhangtao internal % cat $FLUTTER_ENGINE                     
d3ea636dc5d16b56819f3266241e1f708979c233

.zshrc中配置的环境变量(老版本使用.base_profile)
#Flutetr
export FLUTTER=~/flutter
export FLUTTER_ENGINE=${FLUTTER}/bin/internal/engine.version

6.工具准备(使用到depot_tools)

#depot_tools
export DEPOT_TOOLS=~/depot_tools

//写入环境变量
export PATH=$FLUTTER/bin:DEPOT_TOOLS:$PATH

7.安装ant

brew install ant

8.开始下载

mkdir engine
touch .gclient
solutions = [
    {
        "managed": False,
        "name": "src/flutter",
        "url":
"git@github.com:flutter/engine.git@d3ea636dc5d16b56819f3266241e1f708979c233
2",
        "custom_deps": {},
        "deps_file": "DEPS",
        "safesync_url": "",
}, ]
gclient sync

二.更新渲染引擎

git pull
git reset --hard commitID //告诉Git下次下载就下载这个CommitId
gclient sync --with_branch_heads --with_tags --verbose

三.编译引擎代码(GN构建、Ninja编译)

1.首先使用GN(是一个生成Ninja)构建文件的元构建系统

# 构建iOS设备使用的引擎
# 真机debug版本 -构建后的-> ios_debug_unopt
./gn --ios --unoptimized
# 真机release版本(日常开发使用,如果我们要自定义引擎)-构建后的-> ios_release_unopt
./gn --ios --unoptimized --runtime-mode=release 
#模拟器版本 -构建后的-> ios_debug_sim_unopt
./gn --ios --simulator --unoptimized
# 主机端(Mac) -构建后的->  host_debug_unopt
./gn --unoptimized

2.使用Ninja编译工程

ninja -C host_debug_unopt && ninja -C ios_debug_sim_unopt && ninja -C
ios_debug_unopt && ninja -C ios_release_unopt
engine_out.png

四.安装Ninja(Mac big Sur)

1.首先要先安装re2c并进入re2c目录

//进入家目录执行
git clone https://github.com/skvadrik/re2c.git && cd re2c

2.执行./autogen.sh

brew install automake
brew install libtool

3.执行./configure&&make&&make install

sudo chown -R $(whoami) $(brew --prefix)/*

4.此时rec2就安装完成了,安装ninja

git clone git://github.com/ninja-build/ninja.git && cd ninja
./configure.py --bootstrap

5.安装cmake

brew install cmake
cmake -Bbuild-cmake -H.
cmake --build build-cmake

6.配置Ninja

cp ninja /usr/bin/
#Flutetr
export FLUTTER=~/flutterSDK
export NINJA=~/re2c/ninja
export PATH=$FLUTTER/bin:$PATH
FLUTTER_ENGINE="${FLUTTER}/bin/internal/engine.version"
export PATH="/Users/mac/re2c/ninja":"$PATH"
ninja --version  
mac@user ninja % ninja --version
1.10.2.git
上一篇 下一篇

猜你喜欢

热点阅读