栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

flutter源码下载(最新)

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

flutter源码下载(最新)

前言

flutter源码下载其实很简单,但是官网上少了切换depot_tools分支的操作,导致无法下载成功,会报各种错误。
其次flutter源码下载用到git,cipd(下载二进制大文件速度极快, 芜湖起飞飞飞飞~) 以及 python的openurl三种方式下载源码,由于是国内下载这三者都需要设置代理。其中python的openurl需要修改下代码。
博主凭记忆编写,不一定全,但是大体正确,其中细节就靠你们自己了。

1. 代理设置 1.1 git
git config --global http.proxy http://127.0.0.1:1234
git config --global https.proxy https://127.0.0.1:1234
1.2 cipd

虽然我们还没拿到cipd_client,但是可以先设置环境变量。
cipd设置代理的原理可以参考下:https://blog.csdn.net/guillotine007/article/details/81152585Z

export HTTP_PROXY=http://127.0.0.1:1234
export HTTPS_PROXY=https://127.0.0.1:1234
1.3 openurl

需要下载flutter源码以后,才能进行修改,后面写。
需要下载flutter源码以后,才能进行修改,后面写。
需要下载flutter源码以后,才能进行修改,后面写。

2. 下载google的工具箱 depot_tools 2.1 介绍

depot_tools包含下载flutter源码的gclient shell脚本,以及下载cipd的cipd_client 二进制工具。

2.2 下载
	git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
2.3 切换分支

depot_tools刚下载过来是在master分支的,master分支的gclient不能正常工作,和flutter中DEPS是冲突的,因此需要切换到origin master分支.

	# 查看本地是否存在main分支
	git branch
	# 查看远程分支是否存在main分支
	git branch -a
	# 分支同步
	git fetch
	# 切换分支
	git checkout origin/main
2.4 环境设置

depot_tools运行默认会自动更新,我们下载的最新的,就不需要更新了

export DEPOT_TOOLS_UPDATe=0

depot_tools使用cipd_client下载时,需要设置代理服务器,通过环境变量设置即可,其中cipd_client的代理设置原理查看:https://blog.csdn.net/guillotine007/article/details/81152585Z

export HTTP_PROXY=http://127.0.0.1:1234
export HTTPS_PROXY=https://127.0.0.1:1234

这样gclient就能开始正常工作了

3. 下载flutter完整源码

flutter核心是flutter_engine。
flutter_engine依赖的库以及编译工具和编译环境,通过gclient管理的体系进行管理。
也就是我们先拿到flutter_engine的源码,然后再通过gclient将所有的依赖,然后用google提供的编译工具,参照sony官网的提示https://github.com/sony/flutter-embedded-linux/wiki/Building-Flutter-Engine-from-source,就可以直接编译通过。

3.2 创建.gclient

depot_tools中的gclient脚本会根据.gclient内容下载源码,大伙直接复制粘贴以下内容,保存到.gclient中即可。至于在什么目录下你们随意。

solutions = [
  {
    "managed": False,
    // 将flutter_engine的源码至当前路径下的src/flutter中
    "name": "src/flutter",
    "url": "https://github.com/flutter/engine.git",
    "custom_deps": {},
    "deps_file": "DEPS",
    "safesync_url": "",
    "custom_vars" : {
    	# 博主好像为了解决某些依赖库中不知道platform变量的问题,加了这个
		"platform":"linux"
    },
  },
]
target_os = ["linux"]
3.3 glient下载源码

先将flutter切换到稳定的main

	cd src/flutter
	git fetch
	git checkout origin/main

执行gclient下载源码:

gclient sync
3.4 可能遇到的问题

可能1:

DEPS中不仅指定了依赖的库的本地保存路径,下载链接还有下载的版本号。
有的版本号已经不存在了,导致gclient下载失败

解决1:

这种情况下可以使用git clone直接下载不带版本号的链接并保存到对应的本地路劲

可能2:

python使用urlopen下载失败。
出现问题位置:
	src/third_party/dart/build/linux/sysroot_scripts/install-sysroot.py

解决2:

openurl(url, proxies={'http':'127.0.0.1:1234', 'https':'127.0.0.1:1234'})

可能3:

dart源码中的DEPS找不到变量platform

解决3:

通过“.gclient”文件中的custom_vars添加
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/915955.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号