柚子快報(bào)激活碼778899分享:Cronet iOS 編譯
柚子快報(bào)激活碼778899分享:Cronet iOS 編譯
本文主要記錄一下本人cronet ios 編譯的過(guò)程,遇到的一些問(wèn)題以及解決辦法,持續(xù)更新。
你要準(zhǔn)備的
?mac電腦,存儲(chǔ)空間要富余,100G左右,剩余空間只有幾十G,就先清一清存儲(chǔ)。梯子,很重要,我用的是clash。節(jié)點(diǎn)最好要穩(wěn)定且速度不差。你要做的
代理設(shè)置:?梯子注意不要設(shè)置為tun模式,不好使,至少我最初下載代碼時(shí)最后老是失敗。代理模式設(shè)置為規(guī)則模式即可,不用全局模式,terminal中,打開(kāi)? ~/.zshrc 文件編輯 添加下列內(nèi)容: alias proxy='export https_proxy=http://127.0.0.1:7897;export http_proxy=http://127.0.0.1:7897'
alias unproxy='unset http_proxy;unset https_proxy' 方便開(kāi)啟和關(guān)閉,設(shè)置完了source ~/.zshrc一下,或者退出terminal,重新進(jìn)入,然后開(kāi)啟proxy。下面的內(nèi)容可能會(huì)涉及到google的一些網(wǎng)址,所以直接打開(kāi)就好。安裝 depot_tools 工具,引自GET CODE 下載 depot_tools 源碼,并將該項(xiàng)目根目錄添加到 PATH,從而可以使用其工具比如 fetch。 Install depot_tools
Clone the depot_tools repository:
$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
Add depot_tools to the end of your PATH (you will probably want to put this in your ~/.bashrc or ~/.zshrc). Assuming you cloned depot_tools to /path/to/depot_tools:
$ export PATH="$PATH:/path/to/depot_tools" 獲取源碼,這沒(méi)什么好說(shuō)的,就是創(chuàng)建一個(gè)目錄,然后開(kāi)始fetch $ mkdir chromium && cd chromium
$ fetch --nohistory ios 加nohistory也是為了加快速度,減少拉取的內(nèi)容 下載指定tag的代碼,因?yàn)樯厦娌襟E下載下來(lái)的代碼肯定對(duì)應(yīng)主分支最新代碼,下載完成后,用心的朋友肯定會(huì)發(fā)現(xiàn)沒(méi)有我們iOS的頭文件,也就是src/compoments/cronet/下沒(méi)有iOS文件夾,因?yàn)槟壳耙呀?jīng)不再維護(hù)cronet ios了。所以我們只能找以前的tag下載我們要的代碼,從這個(gè)鏈接搜索?sourceCode?,打開(kāi)后如圖在小箭頭出下面查看各tag,也發(fā)現(xiàn)120****的tag都不包含cronet ios 了。所以我們找一個(gè)tag,進(jìn)行使用,這里我用的是108.0.5359.112,下面下載代碼 $ git fetch origin 108.0.5359.112
$ get checkout -b chromium-ios-108.0.5359.112 FETCH_HEAD 同步 $ gclient sync 如果成功會(huì)顯示如下 Syncing projects: 100% (136/136), done.
Running hooks: 100% (134/134), done. 編譯,首先進(jìn)入src文件下,不要去其他目錄
生成.gn文件 $ ./components/cronet/tools/cr_cronet.py gn -i --release --out_dir=out/Cronet-iphoneos-release 這里后面跟隨的參數(shù),也就是gn -i --release 這些的。都跟cr_cronet.py 文件中的一些內(nèi)容對(duì)應(yīng),感興趣的朋友可以去查看該文件中的main方法 編譯 $ ninja -C out/Cronet-iphoneos-release cronet_package 不出意外的話,也就是順利編譯的話,你應(yīng)該可以在out文件夾下得到這些 你可能遇到的,不出意外的話,肯定是要出意外了。下面羅列一些我遇到的坑以及對(duì)應(yīng)解決辦法
第一條還是重申一下,梯子的設(shè)置,不要直接設(shè)置allproxy,而是使用http_proxy和httpsproxy 分別設(shè)置,然后也不要用tun模式。git 全局代理取消掉,我之前是設(shè)置了的,但是總感覺(jué)下載會(huì)失敗,于是取消了。。boto文件,你可能會(huì)遇到如下錯(cuò)誤 You have PROXY values set in your environment, but gsutil in depot_tools does not (yet) obey them. Also, --no_auth prevents the normal BOTO_CONFIG environment variable from being used. To use a proxy in this situation, please supply those settings in a .boto file pointed to by the NO_AUTH_BOTO_CONFIG environment var 解決辦法:創(chuàng)建一個(gè)~/.boto 文件? 編輯內(nèi)容如下 [Boto]
proxy = 127.0.0.1
proxy_port = your port 然后設(shè)置環(huán)境變量 export NO_AUTH_BOTO_CONFIG=~/.boto 既然提到了boto文件,提一下你可能遇到的這個(gè)錯(cuò)誤
Failed to fetch file gs://chromium-clang-format/a1b33be85faf2578f3101d7806e443e1c0949498 for src/buildtools/mac/clang-format. [Err: Traceback (most recent call last):
File "/Users/xx/Desktop/Cronet_iOS/chromium/src/third_party/depot_tools/external_bin/gsutil/gsutil_4.68/gsutil/gsutil", line 21, in
gsutil.RunMain()
File "/Users/xx/Desktop/Cronet_iOS/chromium/src/third_party/depot_tools/external_bin/gsutil/gsutil_4.68/gsutil/gsutil.py", line 121, in RunMain
import gslib.__main__
File "/Users/xx/Desktop/Cronet_iOS/chromium/src/third_party/depot_tools/external_bin/gsutil/gsutil_4.68/gsutil/gslib/__main__.py", line 53, in
import boto
File "/Users/xx/Desktop/Cronet_iOS/chromium/src/third_party/depot_tools/external_bin/gsutil/gsutil_4.68/gsutil/gslib/vendored/boto/boto/__init__.py", line 53, in
config = Config()
File "/Users/xx/Desktop/Cronet_iOS/chromium/src/third_party/depot_tools/external_bin/gsutil/gsutil_4.68/gsutil/gslib/vendored/boto/boto/pyami/config.py", line 67, in __init__
self.load_credential_file(full_path)
File "/Users/xx/Desktop/Cronet_iOS/chromium/src/third_party/depot_tools/external_bin/gsutil/gsutil_4.68/gsutil/gslib/vendored/boto/boto/pyami/config.py", line 93, in load_credential_file
self.readfp(c_data)
File "/Users/xx/Library/Caches/.vpython-root/store/cpython+4iq7om6oam69t4sf0sj3324hp8/contents/lib/python3.8/configparser.py", line 763, in readfp
self.read_file(fp, source=filename)
File "/Users/xx/Library/Caches/.vpython-root/store/cpython+4iq7om6oam69t4sf0sj3324hp8/contents/lib/python3.8/configparser.py", line 718, in read_file
self._read(f, source)
File "/Users/xx/Library/Caches/.vpython-root/store/cpython+4iq7om6oam69t4sf0sj3324hp8/contents/lib/python3.8/configparser.py", line 1067, in _read
raise DuplicateSectionError(sectname, fpname,
configparser.DuplicateSectionError: While reading from '??>' [line 14]: section 'Credentials' already exists
]
我之前boto文件好像是哪個(gè)命令生成的,所以里面配置項(xiàng)都是全的,包含了[Credentials],出現(xiàn)這個(gè)報(bào)錯(cuò)后,檢查boto文件中是否包含這個(gè)配置項(xiàng),直接刪除即可。 depot工具無(wú)法連接谷歌,出現(xiàn)如下報(bào)錯(cuò) gclient sync
depot_tools update failed. Couldn't fetch main branch.
Retry later or reclone depot_tools
fatal: unable to access 'https://chromium.googlesource.com/chromium/tools/depot_tools.git/': LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to chromium.googlesource.com:443 解決辦法:檢查你的梯子已經(jīng)是否能夠正常訪問(wèn)以上url。這種情況一般因?yàn)榫W(wǎng)絡(luò)環(huán)境還沒(méi)配置好。 gclient sync 過(guò)程可能會(huì)出現(xiàn)如下錯(cuò)誤
xx@bogon chromium % gclient sync
Syncing projects: 100% (136/136), done.
Running hooks: 11% (16/134) clang
________ running 'python3 src/tools/clang/scripts/update.py' in '/Users/xx/Desktop/Cronet_iOS/chromium'
Downloading https://commondatastorage.googleapis.com/chromium-browser-clang/Mac/clang-llvmorg-16-init-6578-g0d30e92f-2.tar.xz
Retrying in 5 s ...
Downloading https://commondatastorage.googleapis.com/chromium-browser-clang/Mac/clang-llvmorg-16-init-6578-g0d30e92f-2.tar.xz
Retrying in 10 s ...
Downloading https://commondatastorage.googleapis.com/chromium-browser-clang/Mac/clang-llvmorg-16-init-6578-g0d30e92f-2.tar.xz
Retrying in 20 s ...
Downloading https://commondatastorage.googleapis.com/chromium-browser-clang/Mac/clang-llvmorg-16-init-6578-g0d30e92f-2.tar.xz
Failed to download prebuilt clang package clang-llvmorg-16-init-6578-g0d30e92f-2.tar.xz
Use build.py if you want to build locally.
Exiting.
Hook 'python3 src/tools/clang/scripts/update.py' took 40.11 secs 解決辦法:代碼編輯器打開(kāi)?src/tools/clang/scripts/update.py ,按如下圖,做一些新增和修改,在import部分導(dǎo)入ssl庫(kù),然后搜索request,做如下修改,貼圖 sync過(guò)程中,可能會(huì)遇到nacltools下載一直失敗的問(wèn)題。錯(cuò)誤如下 Running hooks: 4% ( 6/134) nacltools
________ running 'python3 src/build/download_nacl_toolchains.py --mode nacl_core_sdk sync --extract' in '/Users/xx/Desktop/Cronet_iOS/chromium'
INFO: --Syncing nacl_arm_glibc to revision 053185d68ed3b96640f15c4ae457b1ff373c6cac--
INFO: Downloading package archive: binutils_arm_x86_64_apple_darwin.tgz (1/6)
WARNING: Failed mid stream.
WARNING: Download failed on https://storage.googleapis.com/nativeclient-once/object/binutils_arm_x86_64_apple_darwin_b33eac0121acfb07112b84a130824382abab91e2.tgz, retrying... (1)
WARNING: Failed mid stream.
WARNING: Download failed on https://storage.googleapis.com/nativeclient-once/object/binutils_arm_x86_64_apple_darwin_b33eac0121acfb07112b84a130824382abab91e2.tgz, retrying... (2)
WARNING: Failed mid stream.
WARNING: Download failed on https://storage.googleapis.com/nativeclient-once/object/binutils_arm_x86_64_apple_darwin_b33eac0121acfb07112b84a130824382abab91e2.tgz, retrying... (3)
WARNING: Failed mid stream.
WARNING: Download failed on https://storage.googleapis.com/nativeclient-once/object/binutils_arm_x86_64_apple_darwin_b33eac0121acfb07112b84a130824382abab91e2.tgz, giving up.
package_version: Could not download URL (https://storage.googleapis.com/nativeclient-once/object/binutils_arm_x86_64_apple_darwin_b33eac0121acfb07112b84a130824382abab91e2.tgz): No active exception to reraise
Hook 'python3 src/build/download_nacl_toolchains.py --mode nacl_core_sdk sync --extract' took 116.15 secs 解決辦法:在src的上一級(jí)目錄中,編輯 生成的 .gclient 文件,做如下新增,關(guān)閉該依賴(lài)的下載,?依據(jù)URL solutions = [
{
"name": "src",
"url": "https://chromium.googlesource.com/chromium/src.git",
"managed": False,
"custom_deps": {},
"custom_vars": {
"checkout_nacl":False, //新增此項(xiàng)
},
},
]
target_os = ["ios"]
target_os_only = "True"
編譯過(guò)程中,可能會(huì)遇到ios_deployment_target不匹配的問(wèn)題,報(bào)錯(cuò)如下 [62/4960] CXX obj/buildtools/third_party/libc++/libc++/barrier.o
FAILED: obj/buildtools/third_party/libc++/libc++/barrier.o
../../third_party/llvm-build/Release+Asserts/bin/clang++ -MMD -MF obj/buildtools/third_party/libc++/libc++/barrier.o.d -DLIBCXX_BUILDING_LIBCXXABI -DDCHECK_ALWAYS_ON=1 -DCR_XCODE_VERSION=1431 -DCR_CLANG_REVISION=\"llvmorg-16-init-6578-g0d30e92f-2\" -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS -DCR_LIBCXX_REVISION=64d36e572d3f9719c5d75011a718f33f11126851 -D_DEBUG -DDYNAMIC_ANNOTATIONS_ENABLED=1 -D_LIBCPP_BUILDING_LIBRARY -I../../buildtools/third_party/libc++/trunk/src -I../.. -Igen -I../../buildtools/third_party/libc++ -fvisibility-global-new-delete-hidden -fno-delete-null-pointer-checks -fno-ident -fno-strict-aliasing -fstack-protector-strong -femit-dwarf-unwind=no-compact-unwind -fcolor-diagnostics -fmerge-all-constants -fcrash-diagnostics-dir=../../tools/clang/crashreports -mllvm -instcombine-lower-dbg-declare=0 -ffp-contract=off -fcomplete-member-pointers -target x86_64-apple-ios10.0-simulator -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -no-canonical-prefixes -ftrivial-auto-var-init=pattern -O0 -fno-omit-frame-pointer -g2 -gdwarf-aranges -Xclang -debug-info-kind=limited -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator16.4.sdk -fvisibility=hidden -Xclang -add-plugin -Xclang find-bad-constructs -Xclang -plugin-arg-find-bad-constructs -Xclang raw-ref-template-as-trivial-member -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -fstrict-aliasing -fPIC -Werror -Wall -Wno-unused-variable -Wno-c++11-narrowing -Wno-unused-but-set-variable -Wno-misleading-indentation -Wunguarded-availability -Wundeclared-selector -Wno-missing-field-initializers -Wno-unused-parameter -Wno-psabi -Wloop-analysis -Wno-unneeded-internal-declaration -Wenum-compare-conditional -Wno-ignored-pragma-optimize -Wno-deprecated-builtins -Wno-bitfield-constant-conversion -Wno-undefined-bool-conversion -Wno-tautological-undefined-compare -std=c++17 -Wno-trigraphs -nostdinc++ -isystem../../buildtools/third_party/libc++/trunk/include -isystem../../buildtools/third_party/libc++abi/trunk/include -fvisibility-inlines-hidden -std=c++20 -fexceptions -frtti -c ../../buildtools/third_party/libc++/trunk/src/barrier.cpp -o obj/buildtools/third_party/libc++/libc++/barrier.o
../../buildtools/third_party/libc++/trunk/src/barrier.cpp:37:43: error: aligned allocation function of type 'void *(std::size_t, std::align_val_t)' is only available on iOS 11 or newer
__state = unique_ptr<__state_t[]>(new __state_t[__count]);
^
../../buildtools/third_party/libc++/trunk/src/barrier.cpp:37:43: note: if you supply your own aligned allocation functions, use -faligned-allocation to silence this diagnostic
../../buildtools/third_party/libc++/trunk/src/barrier.cpp:37:43: error: aligned deallocation function of type 'void (void *, std::align_val_t) noexcept' is only available on iOS 11 or newer
__state = unique_ptr<__state_t[]>(new __state_t[__count]);
^
../../buildtools/third_party/libc++/trunk/src/barrier.cpp:37:43: note: if you supply your own aligned allocation functions, use -faligned-allocation to silence this diagnostic
In file included from ../../buildtools/third_party/libc++/trunk/src/barrier.cpp:13:
In file included from ../../buildtools/third_party/libc++/trunk/include/barrier:51:
../../buildtools/third_party/libc++/trunk/include/__memory/unique_ptr.h:75:5: error: aligned deallocation function of type 'void (void *, std::align_val_t) noexcept' is only available on iOS 11 or newer
delete[] __ptr;
^
../../buildtools/third_party/libc++/trunk/include/__memory/unique_ptr.h:488:7: note: in instantiation of function template specialization 'std::default_delete
__ptr_.second()(__tmp);
^
../../buildtools/third_party/libc++/trunk/include/__memory/unique_ptr.h:444:75: note: in instantiation of member function 'std::unique_ptr
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 ~unique_ptr() { reset(); }
^
../../buildtools/third_party/libc++/trunk/src/barrier.cpp:33:5: note: in instantiation of member function 'std::unique_ptr
__barrier_algorithm_base(ptrdiff_t& __expected)
^
../../buildtools/third_party/libc++/trunk/include/__memory/unique_ptr.h:75:5: note: if you supply your own aligned allocation functions, use -faligned-allocation to silence this diagnostic
delete[] __ptr;
^
解決辦法:按下圖做修改target為11以上 編譯過(guò)程中,可能會(huì)遇到簽名相關(guān)的錯(cuò)誤,報(bào)錯(cuò)如下:
['gn', 'gen', 'out/Cronet-iphoneos-release', '--args=target_os="ios" enable_websockets=false disable_file_support=true disable_brotli_filter=false is_component_build=false use_crash_key_stubs=true use_partition_alloc=false include_transport_security_state_preload_list=false is_debug=false is_official_build=true use_platform_icu_alternatives=true is_cronet_build=true enable_remoting=false ios_app_bundle_id_prefix="org.chromium" ios_deployment_target="11.0" enable_dsyms=true ios_stack_profiler_enabled=false target_cpu="arm64" ', '--ide=xcode', '--filters=//components/cronet/*'] {}
ERROR at //build/config/ios/ios_sdk.gni:185:33: Script returned non-zero exit code.
ios_code_signing_identity = exec_script("find_signing_identity.py",
^----------
Current dir: /Users/xx/Desktop/Cronet_iOS/chromium/src/out/Cronet-iphoneos-release/
Command: python3 /Users/xx/Desktop/Cronet_iOS/chromium/src/build/config/ios/find_signing_identity.py --matching-pattern Apple Development
Returned 1 and printed out:
Automatic code signing identity selection was enabled but could not
find exactly one codesigning identity matching "Apple Development".
Check that the keychain is accessible and that there is exactly one
valid codesigning identity matching the pattern. Here is the parsed
output of `xcrun security find-identity -v -p codesigning`:
1) 25820***********************************: "Apple Development: xxxxxxxx"
2) FD910***********************************: "Apple Development: xxxxxxxx"
2 valid identities found
See //build/config/sysroot.gni:72:5: whence it was imported.
import("http://build/config/ios/ios_sdk.gni")
^--------------------------------------
See //third_party/rust/autocxx/chromium_integration/rust_autocxx.gni:8:1: whence it was imported.
import("http://build/config/sysroot.gni")
^----------------------------------
See //build/rust/rust_target.gni:12:3: whence it was imported.
import("http://third_party/rust/autocxx/chromium_integration/rust_autocxx.gni")
^------------------------------------------------------------------------
See //build/rust/rust_static_library.gni:5:1: whence it was imported. 解決辦法:關(guān)閉codesign,如下圖,注意單引號(hào)里面最后有一個(gè)空格 編譯過(guò)程中,可能會(huì)遇到如下報(bào)錯(cuò)
xx@bogon src % ./components/cronet/tools/cr_cronet.py gn --out_dir=out/Cronet
Namespace(asan=False, bundle_id_prefix='org.chromium', command='gn', iphoneos=False, out_dir='out/Cronet', release=False, x86=False)
[]
False org.chromium x64
['goma_ctl', 'ensure_start'] {}
Need to login. Run `goma_auth login` to login.
Temporary error, or need to logout->login again
['gn', 'gen', 'out/Cronet', '--args=target_os="ios" enable_websockets=false disable_file_support=true disable_brotli_filter=false is_component_build=false use_crash_key_stubs=true use_partition_alloc=false include_transport_security_state_preload_list=false use_platform_icu_alternatives=true is_cronet_build=true enable_remoting=false ios_app_bundle_id_prefix="org.chromium" ios_deployment_target="10.0" enable_dsyms=true ios_stack_profiler_enabled=false target_cpu="x64" ', '--ide=xcode', '--filters=//components/cronet/*'] {}
Traceback (most recent call last):
File "/Users/xx/Desktop/Cronet_iOS/depot_tools/gn.py", line 14, in
import gclient_paths
File "/Users/xx/Desktop/Cronet_iOS/depot_tools/gclient_paths.py", line 24, in
def FindGclientRoot(from_dir, filename='.gclient'):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/functools.py", line 490, in lru_cache
raise TypeError('Expected maxsize to be an integer or None')
TypeError: Expected maxsize to be an integer or None
解決辦法:代碼編輯器打開(kāi)depot_tools/gclient_paths.py文件,將每個(gè)方法上面的@functools.lru_cache 修改為@functools.lru_cache(maxsize=None) 你會(huì)得到的
out/Cronet-iphoneos-release 目錄下,你會(huì)得到一個(gè)xcode可以打開(kāi)的工程和打好包的庫(kù),如圖恭喜你,完成編譯。
柚子快報(bào)激活碼778899分享:Cronet iOS 編譯
推薦鏈接
本文內(nèi)容根據(jù)網(wǎng)絡(luò)資料整理,出于傳遞更多信息之目的,不代表金鑰匙跨境贊同其觀點(diǎn)和立場(chǎng)。
轉(zhuǎn)載請(qǐng)注明,如有侵權(quán),聯(lián)系刪除。