官方教程:
https://chromium.googlesource.com/chromium/src/+/master/docs/mac_build_instructions.md
在根据提示走的时候遇到了些错误:
gn gen out/Default
********************************************************************************
WARNING: The NaCL SDK is 32-bit only. macOS 10.15+ removed support for 32-bit
executables. To fix, set enable_nacl=false in args.gn, or downgrade to
macOS 10.14. For more information, see https://crbug.com/1049832.
********************************************************************************
ERROR at //components/nacl/features.gni:40:3: Assertion failed.
assert(false, "NaCL SDK is incompatible with host macOS version")
^-----
NaCL SDK is incompatible with host macOS version
See //BUILD.gn:18:1: whence it was imported.
import("//components/nacl/features.gni")
意思是 NaCL只支持32位,启用nacl需设置为false
args.gn 是一个文件,目录在当前src目录下的 ./out/Default/args.gn
中
可以使用文本编辑器编辑之后再运行。不过我没这么做。我在网上找的方法。
直接在命令后加的参数。
gn gen out/Default --args="enable_nacl=false"
之后,我在args.gn文件中还添加了是否是debug模式,是否编译组件
enable_nacl = false
is_debug = true
is_component_build = true
在执行autoninja -C out/Default chrome
进行首次编译的时候,真的是耗费了好几个小时。真是漫长的等待。不过最终终于编译过了。
根据提示,为了增加git status的效率,做了一下处理:
echo kern.maxvnodes=$((512*1024)) | sudo tee -a /etc/sysctl.conf
git update-index --test-untracked-cache
git config core.untrackedCache true
本来想着不使用xcode IDE,但是想到平时是使用xcode开发对,对xcode要比其他IDE熟悉一些,还是用xcode吧。
于是需要生成xcode可以识别的项目工程。
gn gen out/gn --ide=xcode --args="enable_nacl=false"
然后在out/gn/ninja/all.xcworkspace
找到all.xcworkspace打开。
首次启动时,xcode会告诉我们,有太多的scheme,问是手动还是自动。我选择了手动。
添加的scheme有chrome_app, all, source 三个。我头一次做,也不知道添加上,我可能是觉得这三个比较有用,所以就使用创建了这三个吧。
然而,编译巨慢无比。。。
我可能是放弃了,还是改用命令行编译。
但是,可以用xcode管理项目,默认的,Xcode会对项目进行index,对于chromium这种史诗级巨大对项目而言,index实在是等不了,所以,把xcode的index功能关掉还能用用,若不然,真是心力憔悴。
关闭xcode index功能
defaults write com.apple.dt.XCode IDEIndexDisable 1
恢复xcode index功能
defaults write com.apple.dt.XCode IDEIndexDisable 0
安装ccache以加快编译速度
brew install --HEAD ccache
Error: The following directories are not writable by your user:
/usr/local/share/man/man8
You should change the ownership of these directories to your user.
sudo chown -R $(whoami) /usr/local/share/man/man8
And make sure that your user has write permission.
chmod u+w /usr/local/share/man/man8
根据提示执行
sudo chown -R $(whoami) /usr/local/share/man/man8
chmod u+w /usr/local/share/man/man8
然后再执行安装命令即可。
在src目录使用
gn gen out-gn --args='cc_wrapper="ccache"'
报错如下:
********************************************************************************
WARNING: The NaCL SDK is 32-bit only. macOS 10.15+ removed support for 32-bit
executables. To fix, set enable_nacl=false in args.gn, or downgrade to
macOS 10.14. For more information, see https://crbug.com/1049832.
********************************************************************************
ERROR at //components/nacl/features.gni:40:3: Assertion failed.
assert(false, "NaCL SDK is incompatible with host macOS version")
改用如下命令通过:
gn gen out-gn --args='cc_wrapper="ccache" enable_nacl=false'
网友评论