Skip to content

Instantly share code, notes, and snippets.

@zcweng
Last active December 22, 2023 08:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zcweng/26951517ad87fabead1dc1b92434059d to your computer and use it in GitHub Desktop.
Save zcweng/26951517ad87fabead1dc1b92434059d to your computer and use it in GitHub Desktop.
1、安装gclient环境、git、python2.7以上
2、使用翻GFW代理并导出配置代理环境变量:
suke-2:engine suke$ export http_proxy="http://127.0.0.1:8001"; export HTTP_PROXY="http://127.0.0.1:8001"; export https_proxy="http://127.0.0.1:8001"; export HTTPS_PROXY="http://127.0.0.1:8001"
3、配置git代理:
suke-2:engine suke$ git config --global http.proxy $HTTP_PROXY
suke-2:engine suke$ git config --global https.proxy $HTTPS_PROXY
PS.>>>git拉取完成后记得关闭:
suke-2:engine suke$ git config --global --unset http.proxy
suke-2:engine suke$ git config --global --unset https.proxy
>>>查看git代理设置:
suke-2:engine suke$ git config --get http.proxy
suke-2:engine suke$ git config --get https.proxy
4、github上fork Flutter Engine项目,github拉取代码太慢,可以使用国内码云(https://gitee.com)fork。例如我的https://gitee.com/xuangyang/engine
5、在本地创建文件夹engine.
6、在engine里面创建文件.gclient,并填写内容(gclient是谷歌搞的一个基于python脚本编写项目依赖管理的工具,类似git,但是更复杂):
solutions = [
{
"managed": False,
"name": "src/flutter",
"url": "https://gitee.com/xuangyang/engine.git",
"custom_deps": {},
"deps_file": "DEPS",
"safesync_url": "",
},
]
7、在终端cd到engine目录下,执行gclient sync。等待依赖拉取完成,时间比较长,依赖各种项目太多,skia、dart等等,在engine的git下面有个DEPS文件中查看具体依赖项目,以及拉取地址等。
8、经过漫长的等待,报错了:
>> .....
[0:38:09] Still working on:
[0:38:09] src/third_party/dart
Syncing projects: 100% (94/94), done.
________ running 'cipd ensure -log-level error -root /Users/suke/development/flutter_build/engine -ensure-file /var/folders/jd/8wrnwyf53kj3tq8wdyqd_xg40000gn/T/tmp2ARsaR.ensure' in '.'
curl: (6) Could not resolve host: chrome-infra-packages.appspot.com
Error: Command 'cipd ensure -log-level error -root /Users/suke/development/flutter_build/engine -ensure-file /var/folders/jd/8wrnwyf53kj3tq8wdyqd_xg40000gn/T/tmp2ARsaR.ensure' returned non-zero exit status 6
目测是国内无法访问https://chrome-infra-packages.appspot.com造成的,先不管,继续尝试编译
编译ios framework:
suke-2:engine suke$ ./src/flutter/tools/gn --ios
>> gn gen --check in out/ios_debug
Traceback (most recent call last):
File "./src/flutter/tools/gn", line 361, in <module>
sys.exit(main(sys.argv))
File "./src/flutter/tools/gn", line 336, in main
gn_call_result = subprocess.call(command, cwd=SRC_ROOT)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 522, in call
return Popen(*popenargs, **kwargs).wait()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
是gn脚本报错,查看代码336行:
gn_call_result = subprocess.call(command, cwd=SRC_ROOT)
是python调用gn命令,打印command数组内容为:['/Users/suke/development/flutter_build/engine/src/buildtools/mac-x64/gn', 'gen', '--check', '--ide=xcode', 'out/ios_debug', '--args=skia_enable_pdf=false enable_lto=true full_dart_sdk=false use_clang_static_analyzer=false use_ios_simulator=false dart_runtime_mode="develop" skia_use_fontconfig=false skia_use_dng_sdk=false skia_enable_flutter_defines=true use_goma=false dart_custom_version_for_pub="flutter" embedder_for_target=false is_official_build=true android_full_debug=false is_clang=true skia_use_sfntly=false dart_target_arch="dbc" dart_component_kind="static_library" flutter_runtime_mode="debug" goma_dir="None" target_os="ios" mac_sdk_path="" skia_use_x11=false enable_coverage=false target_cpu="arm64" skia_use_expat=false dart_lib_export_symbols=false is_debug=false']
对比发现buildtools/目录下没有mac-x64/文件夹,刚刚gclient sync最后报错应该是buildtool里面配置失败了。
接着查看update.sh脚本,发现其执行cipd脚本,里面调用curl https://chrome-infra-packages.appspot.com
应该就是这的问题,之前配置了代理并没有对curl有效,于是利用alias 重命名curl。
执行 vim ~/.bash_profile
增加一行内容: alias curl='curl -I -x "http://127.0.0.1:8001"'
保存并source ~/.bash_profile
测试是否生效 curl https://www.google.com
ok
继续回到buildtool目录下,执行./update.sh
>> Bootstrapping cipd client for mac-amd64...
>> ######################################################################## 100.0%
发现buildtool下多了mac-64/目录,下面相应的构建工具都有了,ok,回到engine目录,重新尝试编译。
执行
>> ERROR at //third_party/dart/build/dart/dart_action.gni:101:3: Assertion failed.
assert(_is_fuchsia || prebuilt_dart_exe_works,
^-----
A pre built dart executable needs to be present
See //third_party/dart/build/dart/dart_action.gni:180:3: whence it was called.
_prebuilt_tool_action(target_name) {
^-----------------------------------
See //third_party/dart/utils/compile_platform.gni:42:3: whence it was called.
prebuilt_dart_action(target_name) {
^----------------------------------
See //flutter/lib/snapshot/BUILD.gn:235:1: whence it was called.
compile_platform("non_strong_platform") {
^----------------------------------------
See //flutter/BUILD.gn:21:5: which caused the file to be included.
"$flutter_root/lib/snapshot:generate_snapshot_bin",
^-------------------------------------------------
@evanwsu
Copy link

evanwsu commented Dec 22, 2023

mac 上 运行
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
输入gclient version报错,
fatal error: failed to build venv: failed to build package : cipkg.Derivation{Name:"virtualenv", Platform:"", Builder:"builtin:cipdExport", Args:[]string{"infra/3pp/tools/virtualenv version:2@16.7.12.chromium.7\n"}, Env:[]string(nil), Inputs:[]string(nil)}: failed to build derivation: failed to export packages: exec: "cipd": cannot run executable found relative to current directory
请问这是什么问题?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment