1 Star 0 Fork 100

wcedla / flutter_engine

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
BSD-3-Clause

Flutter Engine

原始仓来源:https://github.com/flutter/engine

仓库说明:

本仓库是基于flutter官方engine仓库拓展,可构建支持在OpenHarmony设备上运行的flutter engine程序。

构建说明:

  • 构建环境:
  1. 目前支持在Linux与Mac中构建,Window环境中支持构建gen_snapshot;
  2. 请确保当前构建环境可以访问DEPS文件中配置的字段allowed_hosts列表。
  • 构建步骤:
  1. 构建基础环境:可参照官网

    需要安装的基础库:

    sudo apt install python3
    sudo apt install pkg-config
    sudo apt install ninja-build

    配置node:下载 node 并解压,且配置到环境变量中:

    # nodejs
    export NODE_HOME=/home/<user>/env/node-v14.19.1-linux-x64
    export PATH=$NODE_HOME/bin:$PATH

    Windows构建环境: 可参考官网 "Compiling for Windows" 章节搭建Windows构建环境

  2. 配置文件:创建空文件夹engine,engine内新建.gclient文件,编辑文件:

    solutions = [
      {
        "managed": False,
        "name": "src/flutter",
        "url": "git@gitee.com:openharmony-sig/flutter_engine.git",
        "custom_deps": {},
        "deps_file": "DEPS",
        "safesync_url": "",
      },
    ]
  3. 同步代码:在engine目录,执行gclient sync;这里会同步engine源码、官方packages仓,还有执行ohos_setup任务;

  4. 下载sdk: 从鸿蒙套件列表下载配套开发工具,暂不支持非该渠道下载的套件

# HarmonyOS SDK,解压开发套件包中 sdk/xxSDK.zip 之后的目录
export HOS_SDK_HOME=/home/<user>/ohos/sdk

# 解压开发套件包中 commandline/commandline-tools-xxxx.zip 之后 bin 子目录
export PATH=$PATH:/home/<user>/ohos/command-line-tools/bin
  1. 开始构建:在engine目录,执行./ohos,即可开始构建支持ohos设备的flutter engine。

  2. 更新代码:在engine目录,执行./ohos -b master

Engine构建产物

构建产物

FAQ

  1. 运行项目工程报Member notfound:'isOhos'的错误:请确保src/third_party/dart目录下应用了所有的dart patch(补丁位于src/flutter/attachment/repos目录,可使用git apply应用patch)应用patch后重新编译engine

  2. 提示Permission denied: 执行chmod +x <脚本文件> 添加执行权限

  3. 单独编译debug/release/profile模式的engine:./ohos -t debug|release|profile

  4. 查看帮助:./ohos -h

  5. 由于windows和mac、linux对换行符处理方式不同,在应用dart补丁时会造成dart vm snapshot hash结果不同,可通过以下方法获取当前snapshot hash值

    python xxx/src/third_party/dart/tools/make_version.py --format='{{SNAPSHOT_HASH}}'

    其中xxx为创建的engine路径

    如果获取到的值不是“8af474944053df1f0a3be6e6165fa7cf”那么就需要检查xxx/src/third_party/dart/runtime/vm/dart.cc文件和xxx/src/third_party/dart/runtime/vm/image_snapshot.cc文件中全部行的结尾是不是以LF结尾的,windows可以使用notepad++查看,其它系统具体方法请自行查询

embedding层代码构建指导

  1. 编辑shell/platform/ohos/flutter_embedding/local.properties:

    sdk.dir=<OpenHarmony的sdk目录>
    nodejs.dir=<nodejs的sdk目录>
  2. 你需要复制文件 libflutter.soshell/platform/ohos/flutter_embedding/libs/arm64-v8a/

  3. 在shell/platform/ohos/flutter_embedding目录下,执行

    # buildMode可选值为: debug release profile
    ./hvigorw --mode module -p module=flutter@default -p product=default -p buildMode=debug assembleHar --no-daemon
  4. har文件输出路径为:shell/platform/ohos/flutter_embedding/flutter/build/default/outputs/default/flutter.har

ps:如果你使用的是DevEco Studio的Beta版本,编译工程时遇到“must have required property 'compatibleSdkVersion', location: build-profile.json5:17:11"错误,请参考《DevEco Studio环境配置指导.docx》中的‘6 创建工程和运行Hello World’【配置插件】章节修改 shell/platform/ohos/flutter_embedding/hvigor/hvigor-config.json5文件。

Copyright 2013 The Flutter Authors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Google Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

简介

暂无描述 展开 收起
BSD-3-Clause
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/wcedla/flutter_engine.git
git@gitee.com:wcedla/flutter_engine.git
wcedla
flutter_engine
flutter_engine
dev

搜索帮助